Thread View: news.software.readers
1 messages
1 total messages
Started by Chang Byung-kyu
Sat, 24 Sep 1994 08:49
TIN: [1.22 PATCH] for alt.binaries.*
Author: Chang Byung-kyu
Date: Sat, 24 Sep 1994 08:49
Date: Sat, 24 Sep 1994 08:49
351 lines
12301 bytes
12301 bytes
I patched tin-1.22 to support auto-decoding of articles posted in
alt.binaries.* groups.
You can automatically decode the articles in alt.binaries.* group
by pressing 'V' in the a.b.* group.
for example, two articles, "em-pn-12.jpg (1/2)", "em-pn-12.jpg (2/2)"
will be uudecoded to file "em-pn-12.jpg" automatically and store to
default save directory.
cut the following section and store to 'tin-1.22.patch' and patch
tin-1.22.
NOTE : please send any comments to chitos@baram.kaist.ac.kr via
e-mail, cause I don't subscribe this group... ;)
-------------------------- CUT HERE -----------------------------------
diff -urN tin-1.22/Makefile tin-1.22.new/Makefile
--- tin-1.22/Makefile Sat Sep 25 23:29:52 1993
+++ tin-1.22.new/Makefile Sat Sep 24 15:41:02 1994
@@ -2,10 +2,11 @@
#
# Options that may need changing. For advanced options read the INSTALL file.
#
-CC = cc
-COPTS = -c -O
-#CC = gcc
-#COPTS = -c -g
+#CC = cc
+#COPTS = -c -O
+CC = gcc
+COPTS = -c -g
+COPTS += -DCHITOS
# LD has to be changed to ln for AmigaDOS
LD = $(CC)
YACC = yacc
diff -urN tin-1.22/extern.h tin-1.22.new/extern.h
--- tin-1.22/extern.h Sat Sep 25 23:30:04 1993
+++ tin-1.22.new/extern.h Sat Sep 24 14:26:05 1994
@@ -720,3 +720,7 @@
extern struct sigaction thread_act;
#endif
+#ifdef CHITOS
+extern int auto_decoding_flag;
+extern int uudecode_success;
+#endif
diff -urN tin-1.22/group.c tin-1.22.new/group.c
--- tin-1.22/group.c Sat Sep 25 23:30:12 1993
+++ tin-1.22.new/group.c Sat Sep 24 17:19:12 1994
@@ -815,7 +815,21 @@
(int) base[index_point], group_p
}
break;
-
+
+#ifdef CHITOS
+ case 'V':
+ auto_decoding( group_path );
+ /*
+ add_to_save_list(25, &arts[28], FALSE, TRUE, "/temp/chitos/b");
+ add_to_save_list(26, &arts[23], FALSE, TRUE, "/temp/chitos/b");
+ save_regex_arts(FALSE, "alt/binaries/pictures/supermodels");
+ post_process_files( 'u' );
+ free_save_array();
+ show_group_page();
+ */
+ break;
+#endif
+
case 't': /* tag/untag art for mailing/piping/prin
if (index_point >= 0) {
int tagged = TRUE;
@@ -1601,3 +1615,235 @@
#endif /* INDEX_DAEMON */
}
+
+#ifdef CHITOS
+
+#include <ctype.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define PN_NOT 0
+#define PN_ONE 1 /* cc238.gif */
+#define PN_MANY_ONE 2 /* em-pn.gif (1/3) */
+#define PN_MANY_TWO 3 /* maria.mpg (03/12) */
+
+#define DEFAULT_SAVE_FILE "chitos"
+
+int decode_arts[100]; /* maximum number of devided file is 100 */
+int auto_decoding_flag = FALSE;
+ /* used for making 'deleted' var. TRUE */
+int uudecode_success; /* used for uudecode is successful or not
+ * in case of PN_ONE.
+ */
+
+init_decode_arts()
+{
+ register int i;
+ for( i=0; i<100; i++ )
+ decode_arts[i] = -1;
+}
+/* temporary file name : default_savedir/default_save_file
+ */
+auto_decoding( group_path )
+ char* group_path;
+{
+ int i, j;
+ int nth, kind, curNo, ret1 = TRUE;
+ char fn[PATH_LEN+PATH_LEN];
+ struct passwd * ppwd;
+
+ ppwd = getpwuid( getuid() );
+
+ if( strlen(default_save_file) == 0 )
+ strcpy( default_save_file, DEFAULT_SAVE_FILE );
+
+ /*
+ * in Linux or SunOS (not tested), fopen("~/News/aaa","a+") returns
+ * NULL in any case. So we must replace the first '~' to his/her home
+ * directory.
+ */
+
+ if( default_savedir[0] == '~' )
+ sprintf(fn, "%s%s/%s", ppwd->pw_dir, default_savedir+1,
+ default_save_file);
+ else
+ sprintf(fn, "%s/%s", default_savedir, default_save_file);
+
+ auto_decoding_flag = TRUE;
+ init_decode_arts();
+
+ for( i=0; i<top; i++ ) {
+ if( arts[i].inthread == FALSE && arts[i].unread == TRUE) {
+ nth = 1;
+ switch( kind = kind_pic_name( arts[i].subject, &nth ) ) {
+ case PN_NOT :
+ ;
+ break;
+ case PN_ONE :
+ add_to_save_list( i, &arts[i],FALSE,TRUE,fn);
+ uudecode_success = FALSE;
+ save_regex_arts(FALSE, group_path);
+ post_process_files( 'u' );
+ free_save_array();
+ if( uudecode_success == TRUE ) arts[i].unread = FALSE;
+ show_group_page();
+ init_decode_arts();
+ ;
+ break;
+ case PN_MANY_ONE :
+ case PN_MANY_TWO :
+ decode_arts[1] = i;
+ for( j=0; j < top; j++ ) {
+ if( j != i && arts[j].inthread == FALSE &&
+ arts[j].unread == TRUE ) {
+ if( subjcmp( arts[i].subject, arts[j].subject,
+ kind, &curNo) == TRUE ) {
+ decode_arts[curNo] = j;
+ }
+ }
+ }
+ for( j = 1; j<=nth; j++ ) {
+ if( decode_arts[j] == -1 )
+ ret1 = FALSE;
+ }
+ if( ret1 ) {
+ for( j = 1; j<=nth; j++ ) {
+ add_to_save_list( decode_arts[j],
+ &arts[decode_arts[j]],FALSE,TRUE,fn);
+ }
+ save_regex_arts(FALSE, group_path);
+ post_process_files( 'u' );
+ free_save_array();
+ show_group_page();
+
+ for( j = 1; j<=nth; j++ ) {
+ arts[decode_arts[j]].unread = FALSE;
+ }
+ }
+ init_decode_arts();
+ ret1 = TRUE;
+ break;
+ default :
+ break;
+ }
+ }
+ }
+ auto_decoding_flag = FALSE;
+}
+
+/* only called when PN_MANY_ONE, PN_MANY_TWO.
+ *
+ * compare two subject and return TRUE if two subject represent that
+ * the two file is related one.
+ * CAUTION : only compare the front part. ( ^^^ is compared part )
+ *
+ * ex) "em-pn (1/3) blah", "em-pn (2/3) huh", PN_MANY_ONE, nth
+ * ^^^^^^^ ^^^^^^^
+ * -> TRUE, and nth will be set to 2. ( by s2's (2/3) )
+ *
+ */
+subjcmp( s1, s2, kind, nth )
+ char* s1;
+ char* s2;
+ int kind;
+ int* nth;
+{
+ register int i;
+ for( i=0; i<strlen(s1)-1; i++ ) {
+ if( s1[i] == '/' && isdigit(s1[i-1]) && isdigit(s1[i+1]) ) {
+
+ /* ex) (1/3) case
+ */
+ if( kind == PN_MANY_ONE ) {
+ if( isdigit(s2[i-1]) ) {
+ if( !strncmp( s1, s2, i-1) ) {
+ *nth = s2[i-1] - '0';
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ else
+ return FALSE;
+ }
+ else if( kind == PN_MANY_TWO ) {
+ if( isdigit(s2[i-1]) && isdigit(s2[i-2]) ) {
+ if( !strncmp( s1, s2, i-2 ) ) {
+ *nth = (s2[i-2]-'0') * 10 + (s2[i-1]-'0');
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ else
+ return FALSE;
+ }
+ }
+ }
+}
+
+/* check the subject, and if it is an uudecoded file (by seeing the subject)
+ * then return the kind (PN_*). otherwise return PN_NOT.
+ *
+ * return value :
+ * PN_*
+ * total : return the second number when thie subject include "NUMBER/NUMBER"
+ * format.
+ * ex) em-pn-38.jpg (2/3) -> total will be 3.
+ * maria.gif (1/7) -> 7.
+ *
+ */
+kind_pic_name( s, total )
+ char* s; /* subject */
+ int* total; /* useful when return value is PN_MANY_ONE or PN_MANY_TWO *
+{
+ register int i, sl;
+ sl = strlen(s);
+
+ /* check the subject including "NUMBER/NUMBER" format
+ * ex) em-pn-38.jpg (1/2) blah blah blah
+ */
+ for( i=0; i < sl-1; i++ ) {
+
+ if( s[i] == '/' && isdigit(s[i-1]) && isdigit(s[i+1]) ) {
+
+ /* ex) (1/2) case
+ */
+ if( !isdigit(s[i-2]) && ( i+2 >= sl || !isdigit(s[i+2])) ) {
+ *total = s[i+1] - '0';
+ if( s[i+1] == '1' )
+ return PN_ONE;
+ else if( s[i+1] > '1' )
+ return PN_MANY_ONE;
+ else
+ return PN_NOT;
+ }
+
+ /* ex) [00/03] case
+ */
+ else if( i < sl-2 && isdigit(s[i+2]) ) {
+ *total = (s[i+1]-'0') * 10 + (s[i+2]-'0');
+ return PN_MANY_TWO;
+
+ }
+ else
+ return PN_NOT;
+ }
+ }
+ /* check whether '.gif', '.jpg', '.GIF', '.JPG'
+ * ex) cc238.gif
+ */
+ for( i=0; i < sl-1; i++ ) {
+ if( i < sl-3 ) {
+ if( !strncmp(s+i, ".gif", 4) ||
+ !strncmp(s+i, ".GIF", 4) ||
+ !strncmp(s+i, ".jpg", 4) ||
+ !strncmp(s+i, ".JPG", 4) )
+ return PN_ONE;
+ }
+ }
+ return PN_NOT;
+}
+#endif
+
diff -urN tin-1.22/save.c tin-1.22.new/save.c
--- tin-1.22/save.c Sat Sep 25 23:30:28 1993
+++ tin-1.22.new/save.c Sat Sep 24 14:25:32 1994
@@ -992,6 +992,9 @@
switch (state) {
case INITIAL:
if (! strncmp ("begin", s, 5)) {
+#ifdef CHITOS
+ uudecode_success = TRUE;
+#endif
state = MIDDLE;
fprintf (fp_out, "%s", s
}
@@ -1294,11 +1297,19 @@
int delete = FALSE;
int i;
+#ifdef CHITOS
+ if( auto_decoding_flag == TRUE )
+ delete = TRUE;
+ else {
+#endif
if (active[my_group[cur_groupnum]].attribute.delete_tmp_files) {
delete = TRUE;
} else if (prompt_yn (cLINES, txt_delete_processed_files, 'y')) {
delete = TRUE;
}
+#ifdef CHITOS
+ }
+#endif
if (delete) {
wait_message ("\r\n");
Binary files tin-1.22/tin and tin-1.22.new/tin differ
-------------------------- CUT HERE -----------------------------------
--
--== %%%%%%__ Chang, Byoung-Gyu
-== _+----|| Dept. of CS, Korea Advanced Institute of Science
= \_ |---. and Technology, Taejon, Korea, 305-701
chitos .----"" Dorm. : +82 42-868-6677
CHITOS .----"""' URL : http://ara.kaist.ac.kr/members/chitos.html
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