--- url.c.orig Fri Dec 20 23:46:42 2002 +++ url.c Fri Dec 20 23:46:42 2002 @@ -11,6 +11,7 @@ #include #include +#include #ifdef __EMX__ #include /* ?? */ #endif /* __EMX__ */ @@ -1218,12 +1219,49 @@ otherinfo(ParsedURL *target, ParsedURL *current, char *referer) { Str s = Strnew(); + char buf[2]; + char* p = NULL; + struct utsname hostinfo; + buf[0] = buf[1] = '\0'; Strcat_charp(s, "User-Agent: "); if (UserAgent == NULL || *UserAgent == '\0') Strcat_charp(s, w3m_version); - else - Strcat_charp(s, UserAgent); + else { + p = UserAgent; + while (*p != '\0') { + if (*p == '%') { + switch (*(p + 1)) { + case 'v': /* w3m version */ + Strcat_charp(s, w3m_version); + p++; + break; + case 'V': /* OS version */ + if (uname(&hostinfo) == 0) { + Strcat_charp(s, hostinfo.sysname); + buf[0] = ' '; + Strcat_charp(s, buf); + Strcat_charp(s, hostinfo.release); + Strcat_charp(s, buf); + Strcat_charp(s, hostinfo.machine); + p++; + } else { + buf[0] = *p; + Strcat_charp(s, buf); + } + break; + default: /* thru */ + buf[0] = *p; + Strcat_charp(s, buf); + break; + } + } else { + buf[0] = *p; + Strcat_charp(s, buf); + } + p++; + } + } Strcat_charp(s, "\r\n"); Strcat_m_charp(s, "Accept: ", AcceptMedia, "\r\n", NULL);