Thread View: news.software.readers
4 messages
4 total messages
Started by Sylvain Robitaille
Fri, 15 Aug 1997 00:00
slrn0.9.4.3 patch adds new feature to scoring
Author: Sylvain Robitaille
Date: Fri, 15 Aug 1997 00:00
Date: Fri, 15 Aug 1997 00:00
133 lines
5042 bytes
5042 bytes
It was recently suggested to me that a feature our users might benefit
from, in a newsreader, is the ability to "include" external scoring files
from within the user's own score file.
I really liked this idea and put together the patch which follows.
To use the feature, place scoring rules in a file, (ideally world
readable, so that others may use that file too), which you wish to include
into your "regular" score file.
In the regular score file, place the rule "Include: <path/to/file>" on a
line by itself. I suggest keeping includes near the top of the file, so
they're easy to find. <path/to/file> is relative to your home directory, or
you can use an absolute path if you wish.
If for any reason, the program cannot read the included file, it will
generate an error message, similar to when there's a syntax error in a
score file.
Included files, can include yet more files, but be careful if you do this
that an included file does not include the file which included it.
Hope you enjoy. I'd appreciate comments.
--
----------------------------------------------------------------------
Sylvain Robitaille sp_robi@alcor.concordia.ca
Assistant to the System Managers Concordia University
Computing Services Department Montreal, Quebec, Canada
----------------------------------------------------------------------
*** src/score.c.original Sat Jul 12 16:29:01 1997
--- src/score.c Fri Aug 15 16:38:57 1997
***************
*** 793,802 ****
unsigned long today;
int start_new_score = 0, score_has_expired = 0;
unsigned int pscore_flags = 0;
today = get_today ();
!
! if (Group_Score_Root != NULL)
{
free_group_scores ();
}
--- 793,812 ----
unsigned long today;
int start_new_score = 0, score_has_expired = 0;
unsigned int pscore_flags = 0;
+ static int numfiles = 0;
today = get_today ();
!
! /***
! *** 1997/08/15 Sylvain Robitaille (sp_robi@alcor.concordia.ca)
! *** ------------------------------------------------------------
! ***
! *** Added keyword "Include" causes this function to re-call itself,
! *** but we only want it to call free_group_scores() the first time
! *** through, or else we lose what was set previously. numfiles
! *** counts the number of times the function has recursed.
! ***/
! if (Group_Score_Root != NULL && !numfiles)
{
free_group_scores ();
}
***************
*** 852,857 ****
--- 862,904 ----
continue;
}
+ /***
+ *** 1997/08/15 Sylvain Robitaille (sp_robi@alcor.concordia.ca)
+ *** ------------------------------------------------------------
+ ***
+ *** What we want is a way to permit users to include a "machine wide"
+ *** score file, where we can maintain a list of usenet spammers for
+ *** instance, and we can kill those out of local newsgroups. This will of
+ *** course permit other flexibility, but in my mind, this is the main
+ *** objective.
+ ***/
+ if (!slrn_case_strncmp (lp, (unsigned char *)"Include:", 8))
+ {
+ int success;
+ char include_file[SLRN_MAX_PATH_LEN];
+ unsigned char *filename = lp + 8;
+
+ filename = (unsigned char *) slrn_skip_whitespace ((char *) filename);
+ slrn_make_home_filename (filename, include_file);
+ numfiles++;
+ slrn_trim_string(include_file);
+
+ success = slrn_read_score_file(include_file);
+ if (success)
+ {
+ continue;
+ }
+ else if (!success)
+ {
+ score_error ("Can't include file.", line, linenum, file);
+ }
+ else
+ {
+ score_error ("Error in include file.", line, linenum, file);
+ }
+ goto error_return;
+ }
+
if (!slrn_case_strncmp (lp, (unsigned char *)"Score:", 6))
{
unsigned char *lpp = lp + 6;
***************
*** 871,877 ****
start_new_score = 1;
continue;
}
!
if (start_new_score)
{
if (!slrn_case_strncmp (lp, (unsigned char *) "Expires:", 8))
--- 918,924 ----
start_new_score = 1;
continue;
}
!
if (start_new_score)
{
if (!slrn_case_strncmp (lp, (unsigned char *) "Expires:", 8))
Re: slrn0.9.4.3 patch adds new feature to scoring
Author: Sylvain Robitaille
Date: Sun, 17 Aug 1997 00:00
Date: Sun, 17 Aug 1997 00:00
124 lines
4507 bytes
4507 bytes
On 15 Aug 1997 22:59:44 GMT, I wrote:
>
>I really liked this idea and put together the patch which follows.
>
>Hope you enjoy. I'd appreciate comments.
Don't-cha just *love* it when you overlook a simple logic bug in code???
Byrial Jensen and Russell Schulz, (I'm purposely not posting their email
addresses in case they're not exactly fond of spam), both pointed out an error
in my if statement which checks to see if the included file was correctly
included. A corrected patch is appended to this post.
Thanks to both of them for finding this.
--
----------------------------------------------------------------------
Sylvain Robitaille sp_robi@alcor.concordia.ca
Assistant to the System Managers Concordia University
Computing Services Department Montreal, Quebec, Canada
----------------------------------------------------------------------
*** src/score.c.original Sat Jul 12 16:29:01 1997
--- src/score.c Fri Aug 15 16:38:57 1997
***************
*** 793,802 ****
unsigned long today;
int start_new_score = 0, score_has_expired = 0;
unsigned int pscore_flags = 0;
today = get_today ();
!
! if (Group_Score_Root != NULL)
{
free_group_scores ();
}
--- 793,812 ----
unsigned long today;
int start_new_score = 0, score_has_expired = 0;
unsigned int pscore_flags = 0;
+ static int numfiles = 0;
today = get_today ();
!
! /***
! *** 1997/08/15 Sylvain Robitaille (sp_robi@alcor.concordia.ca)
! *** ------------------------------------------------------------
! ***
! *** Added keyword "Include" causes this function to re-call itself,
! *** but we only want it to call free_group_scores() the first time
! *** through, or else we lose what was set previously. numfiles
! *** counts the number of times the function has recursed.
! ***/
! if (Group_Score_Root != NULL && !numfiles)
{
free_group_scores ();
}
***************
*** 852,857 ****
--- 862,904 ----
continue;
}
+ /***
+ *** 1997/08/15 Sylvain Robitaille (sp_robi@alcor.concordia.ca)
+ *** ------------------------------------------------------------
+ ***
+ *** What we want is a way to permit users to include a "machine wide"
+ *** score file, where we can maintain a list of usenet spammers for
+ *** instance, and we can kill those out of local newsgroups. This will of
+ *** course permit other flexibility, but in my mind, this is the main
+ *** objective.
+ ***/
+ if (!slrn_case_strncmp (lp, (unsigned char *)"Include:", 8))
+ {
+ int success;
+ char include_file[SLRN_MAX_PATH_LEN];
+ unsigned char *filename = lp + 8;
+
+ filename = (unsigned char *) slrn_skip_whitespace ((char *) filename);
+ slrn_make_home_filename (filename, include_file);
+ numfiles++;
+ slrn_trim_string(include_file);
+
+ success = slrn_read_score_file(include_file);
+ if (success > 0)
+ {
+ continue;
+ }
+ else if (!success)
+ {
+ score_error ("Can't include file.", line, linenum, file);
+ }
+ else
+ {
+ score_error ("Error in include file.", line, linenum, file);
+ }
+ goto error_return;
+ }
+
if (!slrn_case_strncmp (lp, (unsigned char *)"Score:", 6))
{
unsigned char *lpp = lp + 6;
***************
*** 871,877 ****
start_new_score = 1;
continue;
}
!
if (start_new_score)
{
if (!slrn_case_strncmp (lp, (unsigned char *) "Expires:", 8))
--- 918,924 ----
start_new_score = 1;
continue;
}
!
if (start_new_score)
{
if (!slrn_case_strncmp (lp, (unsigned char *) "Expires:", 8))
Re: slrn0.9.4.3 patch adds new feature to scoring
Author: Sylvain Robitaille
Date: Mon, 18 Aug 1997 00:00
Date: Mon, 18 Aug 1997 00:00
123 lines
4518 bytes
4518 bytes
On 17 Aug 1997 04:04:33 GMT, I wrote:
>Don't-cha just *love* it when you overlook a simple logic bug in code???
I enjoy it so much that I did it yet again!!! <arrgh!>
Byrial Jensen points out that I've completely ignored the fact that score
files are re-read after being edited with the 'K' command. I'm embarrassed.
The patch-du-jour is attached, and now I believe it's complete... <sigh!>
Apologies to any who've already applied this patch. :-(
--
----------------------------------------------------------------------
Sylvain Robitaille sp_robi@alcor.concordia.ca
Assistant to the System Managers Concordia University
Computing Services Department Montreal, Quebec, Canada
----------------------------------------------------------------------
*** src/score.c.orig Sat Jul 12 16:29:01 1997
--- src/score.c Mon Aug 18 01:17:44 1997
***************
*** 793,802 ****
unsigned long today;
int start_new_score = 0, score_has_expired = 0;
unsigned int pscore_flags = 0;
today = get_today ();
!
! if (Group_Score_Root != NULL)
{
free_group_scores ();
}
--- 793,812 ----
unsigned long today;
int start_new_score = 0, score_has_expired = 0;
unsigned int pscore_flags = 0;
+ static int numfiles = 0;
today = get_today ();
!
! /***
! *** 1997/08/15 Sylvain Robitaille (sp_robi@alcor.concordia.ca)
! *** ------------------------------------------------------------
! ***
! *** Added keyword "Include" causes this function to re-call itself,
! *** but we only want it to call free_group_scores() the first time
! *** through, or else we lose what was set previously. numfiles
! *** counts the number of times the function has recursed.
! ***/
! if (Group_Score_Root != NULL && !numfiles)
{
free_group_scores ();
}
***************
*** 852,857 ****
--- 862,905 ----
continue;
}
+ /***
+ *** 1997/08/17 Sylvain Robitaille (sp_robi@alcor.concordia.ca)
+ *** ------------------------------------------------------------
+ ***
+ *** What we want is a way to permit users to include a "machine wide"
+ *** score file, where we can maintain a list of usenet spammers for
+ *** instance, and we can kill those out of local newsgroups. This will of
+ *** course permit other flexibility, but in my mind, this is the main
+ *** objective.
+ ***/
+ if (!slrn_case_strncmp (lp, (unsigned char *)"Include:", 8))
+ {
+ int success;
+ char include_file[SLRN_MAX_PATH_LEN];
+ unsigned char *filename = lp + 8;
+
+ filename = (unsigned char *) slrn_skip_whitespace ((char *) filename);
+ slrn_make_home_filename (filename, include_file);
+ numfiles++; /* ensure included files won't clear previous work done. */
+ slrn_trim_string(include_file);
+ numfiles--;
+
+ success = slrn_read_score_file(include_file);
+ if (success)
+ {
+ continue;
+ }
+ else if (!success)
+ {
+ score_error ("Can't include file.", line, linenum, file);
+ }
+ else
+ {
+ score_error ("Error in include file.", line, linenum, file);
+ }
+ goto error_return;
+ }
+
if (!slrn_case_strncmp (lp, (unsigned char *)"Score:", 6))
{
unsigned char *lpp = lp + 6;
***************
*** 871,877 ****
start_new_score = 1;
continue;
}
!
if (start_new_score)
{
if (!slrn_case_strncmp (lp, (unsigned char *) "Expires:", 8))
--- 919,925 ----
start_new_score = 1;
continue;
}
!
if (start_new_score)
{
if (!slrn_case_strncmp (lp, (unsigned char *) "Expires:", 8))
Re: slrn0.9.4.3 patch adds new feature to scoring
Author: Sylvain Robitaille
Date: Tue, 19 Aug 1997 00:00
Date: Tue, 19 Aug 1997 00:00
103 lines
4080 bytes
4080 bytes
This is the last one, I promise! :-(
This ensures that included score files do not undo the work already done,
and that when the main score file is re-read, it correctly starts over
from scratch.
It also makes sure that it correctly handles the return value from having
included the score file.
--
----------------------------------------------------------------------
Sylvain Robitaille syl@alcor.concordia.ca
Assistant to the System Managers Concordia University
Computing Services Department Montreal, Quebec, Canada
----------------------------------------------------------------------
*** src/score.c.original Sat Jul 12 16:29:01 1997
--- src/score.c Mon Aug 18 20:42:51 1997
***************
*** 793,802 ****
unsigned long today;
int start_new_score = 0, score_has_expired = 0;
unsigned int pscore_flags = 0;
today = get_today ();
!
! if (Group_Score_Root != NULL)
{
free_group_scores ();
}
--- 793,812 ----
unsigned long today;
int start_new_score = 0, score_has_expired = 0;
unsigned int pscore_flags = 0;
+ static int numfiles = 0;
today = get_today ();
!
! /***
! *** 1997/08/15 Sylvain Robitaille (sp_robi@alcor.concordia.ca)
! *** ------------------------------------------------------------
! ***
! *** Added keyword "Include" causes this function to re-call itself,
! *** but we only want it to call free_group_scores() the first time
! *** through, or else we lose what was set previously. numfiles
! *** counts the number of times the function has recursed.
! ***/
! if ((Group_Score_Root != NULL) && (numfiles == 0))
{
free_group_scores ();
}
***************
*** 852,857 ****
--- 862,905 ----
continue;
}
+ /***
+ *** 1997/08/17 Sylvain Robitaille (sp_robi@alcor.concordia.ca)
+ *** ------------------------------------------------------------
+ ***
+ *** What we want is a way to permit users to include a "machine wide"
+ *** score file, where we can maintain a list of usenet spammers for
+ *** instance, and we can kill those out of local newsgroups. This will of
+ *** course permit other flexibility, but in my mind, this is the main
+ *** objective.
+ ***/
+ if (!slrn_case_strncmp (lp, (unsigned char *)"Include:", 8))
+ {
+ int success;
+ char include_file[SLRN_MAX_PATH_LEN];
+ unsigned char *filename = lp + 8;
+
+ filename = (unsigned char *) slrn_skip_whitespace ((char *) filename);
+ slrn_make_home_filename (filename, include_file);
+ numfiles++; /* ensure included files won't clear previous work done. */
+ slrn_trim_string(include_file);
+
+ success = slrn_read_score_file(include_file);
+ numfiles--;
+ if (success > 0)
+ {
+ continue;
+ }
+ else if (success == 0)
+ {
+ score_error ("Can't include file.", line, linenum, file);
+ }
+ else /* success < 0 */
+ {
+ score_error ("Error in include file.", line, linenum, file);
+ }
+ goto error_return;
+ }
+
if (!slrn_case_strncmp (lp, (unsigned char *)"Score:", 6))
{
unsigned char *lpp = lp + 6;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads