Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux Pacman Development (http://www.linux-archive.org/archlinux-pacman-development/)
-   -   pacman: use alpm method to set useragent (http://www.linux-archive.org/archlinux-pacman-development/506730-pacman-use-alpm-method-set-useragent.html)

Dave Reisner 03-28-2011 07:15 PM

pacman: use alpm method to set useragent
 
The call for this needs to be done a little later now since it requires
that the handle be initialized.

Signed-off-by: Dave Reisner <d@falconindy.com>
---
src/pacman/pacman.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index eac9c9c..381d2bc 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -253,13 +253,13 @@ static void localize(void)
*/
static void setuseragent(void)
{
- char agent[101];
+ char *agent;
struct utsname un;

uname(&un);
- snprintf(agent, 100, "pacman/%s (%s %s) libalpm/%s",
+ pm_asprintf(&agent, "pacman/%s (%s %s) libalpm/%s",
PACKAGE_VERSION, un.sysname, un.machine, alpm_version());
- setenv("HTTP_USER_AGENT", agent, 0);
+ alpm_option_set_useragent(agent);
}

static void setarch(const char *arch)
@@ -1360,9 +1360,6 @@ int main(int argc, char *argv[])
localize();
#endif

- /* set user agent for downloading */
- setuseragent();
-
/* init config data */
config = config_new();

@@ -1387,6 +1384,9 @@ int main(int argc, char *argv[])
alpm_option_set_signaturedir(GPGDIR);
alpm_option_set_logfile(LOGFILE);

+ /* set user agent for downloading */
+ setuseragent();
+
/* Priority of options:
* 1. command line
* 2. config file
--
1.7.4.2


All times are GMT. The time now is 10:16 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.