🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #117270

Re: SLRN - how can you change user agent? [patch] (the right one this time)

#117270
From: David Beverly
Date: Sat, 04 Jan 2003 13:10
164 lines
6426 bytes
On Wed, 01 Jan 2003 at 15:21 GMT, I posted a patch for slrn...

but the wrong one.

Oops.

Anyway, here's the correct one. Short and simple, allows you to set your
User-Agent header to any arbitrary string (255 chars or less) via the
useragent variable:

(in ~/.slrnrc or your local moral equivalent)

set useragent "this here is slrn, is it not nifty?  worship slrn"

use -p1 while in the slrn source root, if you have no clue what that means,
you probably shouldn't be applying patches anyway (hint: man patch - don't
ask me or anyone else here how to apply a patch, patch ain't a newsreader)

HAND,

David Beverly

Index: slrn/src/post.c
diff -u slrn/src/post.c:1.1 slrn/src/post.c:1.2
--- slrn/src/post.c:1.1	Sat Jan  4 03:48:33 2003
+++ slrn/src/post.c	Sat Jan  4 03:53:28 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,35 @@
 
 static int postpone_file (char *);
 
+void slrn_add_user_agent_header (FILE *fp) /* rain 2003-01-01 */
+{
+   char buf[256];
+   char *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
+	 {
+		system_os_name = slrn_get_os_name ();
+		slrn_snprintf (buf, sizeof (buf), "User-Agent: slrn/%s (%s)\n",
+					   Slrn_Version, system_os_name);
+	 }
+#else
+   system_os_name = slrn_get_os_name ();
+   slrn_snprintf (buf, sizeof (buf), "User-Agent: slrn/%s (%s)\n",
+				  Slrn_Version, system_os_name);
+#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)
 {
@@ -693,7 +723,7 @@
    time_t now;
    char save_post_file[SLRN_MAX_PATH_LEN];
    char line [MAX_LINE_BUFLEN];
-   char *system_os_name;
+   /* char *system_os_name; */
    int has_from = 0, has_messageid = 0, header = 1;
 
    if ((save_file == NULL) || (*save_file == 0))
@@ -755,9 +785,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);                /* rain - eoheaders */
 		  header = 0;
 	       }
 	     else if (is_empty_header (line))
@@ -1193,8 +1222,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");     /* rain - eoheaders */
 		  header = 0;
 #if SLRN_HAS_MIME
 		  if (Slrn_Use_Mime & MIME_DISPLAY) fp = slrn_mime_encode (fp);
Index: slrn/src/post.h
diff -u slrn/src/post.h:1.1 slrn/src/post.h:1.2
--- slrn/src/post.h:1.1	Sat Jan  4 03:48:34 2003
+++ slrn/src/post.h	Sat Jan  4 03:53:28 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 */
Index: slrn/src/slrnfeat.h
diff -u slrn/src/slrnfeat.h:1.1 slrn/src/slrnfeat.h:1.2
--- slrn/src/slrnfeat.h:1.1	Sat Jan  4 03:48:34 2003
+++ slrn/src/slrnfeat.h	Sat Jan  4 03:53:28 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.
  */
Index: slrn/src/startup.c
diff -u slrn/src/startup.c:1.1 slrn/src/startup.c:1.2
--- slrn/src/startup.c:1.1	Sat Jan  4 03:48:33 2003
+++ slrn/src/startup.c	Sat Jan  4 03:53:28 2003
@@ -605,6 +605,9 @@
 
 Slrn_Str_Var_Type Slrn_Str_Variables [] = /*{{{*/
 {
+#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},
Index: slrn/src/version.h
diff -u slrn/src/version.h:1.1 slrn/src/version.h:1.2
--- slrn/src/version.h:1.1	Sat Jan  4 03:48:34 2003
+++ slrn/src/version.h	Sat Jan  4 03:53:28 2003
@@ -22,7 +22,7 @@
 /* Keep this separate from autoconf's settings for now */
 #define MY_VERSION "0.9.7.4"
 #define SLRN_VERSION_NUMBER 90704
-/* #define PATCH_LEVEL "1" */
+#define PATCH_LEVEL "1.2 (local)"
 #define SLRN_RELEASE_DATE "2002-03-13"
 
 #ifdef PATCH_LEVEL
Technical Details
Message-ID: <v1dnaimno2964@corp.supernews.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!cyclone.bc.net!HSNX.atgi.net!cyclone-sf.pbi.net!151.164.30.35!cyclone.swbell.net!newsfeed1.easynews.com!easynews.com!easynews!sn-xit-02!sn-xit-03!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail
References: <4giM9.1271678$6N5.164384@post-03.news.easynews.com> <slrnb16u08.2jp.rain@192.168.135.3>

Show Full Headers
Complete Article Headers
Message-ID: <v1dnaimno2964@corp.supernews.com>
Subject: Re: SLRN - how can you change user agent? [patch] (the right one this time)
Date: Sat, 04 Jan 2003 13:10:42 -0000
From: David Beverly <rain@synaesthetic.net>
References: <4giM9.1271678$6N5.164384@post-03.news.easynews.com> <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!cyclone.bc.net!HSNX.atgi.net!cyclone-sf.pbi.net!151.164.30.35!cyclone.swbell.net!newsfeed1.easynews.com!easynews.com!easynews!sn-xit-02!sn-xit-03!sn-xit-01!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.4pl1.2 (local) [YellowDog Linux 2.2]
X-Complaints-To: abuse@supernews.com
Lines: 163