Article View: news.software.readers
Article #117082Re: SLRN - how can you change user agent? [patch]
From: David Beverly
Date: Wed, 01 Jan 2003 23:21
Date: Wed, 01 Jan 2003 23:21
137 lines
5555 bytes
5555 bytes
On Thu, 19 Dec 2002 at 03:41 GMT, P Bergsson <pberg@my-deja.com> wrote:
> Just putting a User-Agent header means you end up with two :(
Here's a patch that will allow you to set the useragent with a line
like:
set useragent "arbitrary string here"
in your .slrnrc
Thsi seems a little more spiffy than recompiling any/everytime you
might want to change the User-Agent header.
The patch is against a clean source distro of 0.9.7.4, you're on your
own if you have other patches already applied.
HTH, and Happy New Year,
David Beverly
diff -Naur slrn-0.9.7.4.orig/src/post.c slrn-0.9.7.4/src/post.c
--- slrn-0.9.7.4.orig/src/post.c Wed Mar 13 05:02:38 2002
+++ slrn-0.9.7.4/src/post.c Wed Jan 1 14:47:37 2003
@@ -63,6 +63,7 @@
#define MAX_LINE_BUFLEN 2048
+char *Slrn_Custom_User_Agent; /* rain 2003-01-01 */
char *Slrn_CC_Followup_Message = NULL;
char *Slrn_CC_Post_Message = NULL;
char *Slrn_Save_Posts_File;
@@ -80,6 +81,34 @@
static int postpone_file (char *);
+void slrn_add_user_agent_header (FILE *fp) /* rain 2003-01-01 */
+{
+ char buf[256];
+ char *default_user_agent_str;
+ char *system_os_name = slrn_get_os_name ();
+ sprintf (default_user_agent_str, "slrn/%s (%s)",
+ Slrn_Version, system_os_name);
+#if SLRN_HAS_CUSTOM_USER_AGENT
+ if ((NULL != Slrn_Custom_User_Agent) &&
+ (*Slrn_Custom_User_Agent != 0))
+ {
+ /* should add support for % escapes here */
+ slrn_snprintf (buf, sizeof (buf), "User-Agent: %s\n",
+ Slrn_Custom_User_Agent);
+ }
+ else
+ slrn_snprintf (buf, sizeof (buf), "User-Agent: %s\n",
+ default_user_agent_str);
+#else
+ slrn_snprintf (buf, sizeof (buf), "User-Agent: %s\n",
+ default_user_agent_str);
+#endif
+ if (fp != NULL)
+ fputs (buf, fp);
+ else
+ Slrn_Post_Obj->po_puts (buf);
+}
+
#if SLRN_HAS_GEN_MSGID
static char *slrn_create_message_id (void)
{
@@ -755,9 +784,8 @@
if (Slrn_Use_Mime & MIME_ARCHIVE)
slrn_mime_add_headers (outfp);
#endif
- system_os_name = slrn_get_os_name ();
- fprintf (outfp, "User-Agent: slrn/%s (%s)\n", Slrn_Version,
- system_os_name);
+ slrn_add_user_agent_header (outfp); /* rain 2003-01-01 */
+ fputs ("\n", outfp); /* eoheaders */
header = 0;
}
else if (is_empty_header (line))
@@ -1193,8 +1221,8 @@
if (Slrn_Use_Mime & MIME_DISPLAY)
slrn_mime_add_headers (0); /* 0 --> Slrn_Post_Obj->po_puts */
#endif
- Slrn_Post_Obj->po_printf ("User-Agent: slrn/%s (%s)\n\n",
- Slrn_Version, system_os_name);
+ slrn_add_user_agent_header (NULL); /* rain 2003-01-01 */
+ Slrn_Post_Obj->po_puts ("\n"); /* eoheaders */
header = 0;
#if SLRN_HAS_MIME
if (Slrn_Use_Mime & MIME_DISPLAY) fp = slrn_mime_encode (fp);
diff -Naur slrn-0.9.7.4.orig/src/post.h slrn-0.9.7.4/src/post.h
--- slrn-0.9.7.4.orig/src/post.h Sat Nov 3 07:15:57 2001
+++ slrn-0.9.7.4/src/post.h Wed Jan 1 13:13:57 2003
@@ -20,6 +20,7 @@
*/
extern void slrn_add_signature (FILE *);
extern void slrn_add_date_header (FILE *);
+extern void slrn_add_user_agent_header (FILE *); /* rain 2003-01-01 */
extern int slrn_add_custom_headers (FILE *, char *, int (*)(char *, FILE *));
extern int slrn_post (char *, char *, char *);
extern int slrn_post_file (char *, char *, int);
@@ -37,3 +38,5 @@
extern int Slrn_Generate_Date_Header;
extern char *Slrn_Signoff_String;
extern int Slrn_Netiquette_Warnings;
+
+extern char *Slrn_Custom_User_Agent; /* rain 2003-01-01 */
diff -Naur slrn-0.9.7.4.orig/src/slrnfeat.h slrn-0.9.7.4/src/slrnfeat.h
--- slrn-0.9.7.4.orig/src/slrnfeat.h Sat Mar 2 04:03:32 2002
+++ slrn-0.9.7.4/src/slrnfeat.h Wed Jan 1 04:47:12 2003
@@ -7,6 +7,11 @@
* the feature will be turned off.
*/
+/* If non-zero, the User-Agent header can be set in slrnrc
+ * set useragent "whatever"
+ */
+#define SLRN_HAS_CUSTOM_USER_AGENT 1
+
/* If non-zero, a special message will be displayed when article is the last
* one in a thread.
*/
diff -Naur slrn-0.9.7.4.orig/src/startup.c slrn-0.9.7.4/src/startup.c
--- slrn-0.9.7.4.orig/src/startup.c Mon Mar 11 07:19:27 2002
+++ slrn-0.9.7.4/src/startup.c Wed Jan 1 04:47:12 2003
@@ -605,7 +605,10 @@
Slrn_Str_Var_Type Slrn_Str_Variables [] = /*{{{*/
{
- {"failed_posts_file", &Slrn_Failed_Post_Filename},
+#if SLRN_HAS_CUSTOM_USER_AGENT
+ {"useragent", &Slrn_Custom_User_Agent},
+#endif
+ {"failed_posts_file", &Slrn_Failed_Post_Filename},
#if ! SLRN_HAS_STRICT_FROM
{"hostname", &Slrn_User_Info.hostname},
{"realname", &Slrn_User_Info.realname},
Technical Details
Message-ID:
<slrnb16u08.2jp.rain@192.168.135.3>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mailReferences:
<4giM9.1271678$6N5.164384@post-03.news.easynews.com>Show Full Headers
Complete Article Headers
Message-ID: <slrnb16u08.2jp.rain@192.168.135.3> Subject: Re: SLRN - how can you change user agent? [patch] Date: Wed, 01 Jan 2003 23:21:54 -0000 From: David Beverly <rain@synaesthetic.net> References: <4giM9.1271678$6N5.164384@post-03.news.easynews.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail Newsgroups: news.software.readers Organization: Literate Rage X-Edited-With-Muttmode: muttmail.sl - 2002_12_30 User-Agent: slrn/0.9.7.4 (Linux) X-Complaints-To: abuse@supernews.com Lines: 136