#define Use_LinkedList #define Use_TagList #include #include #include #include #include #include "proboard.hpp" static char *valid="ABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890#$"; static void near getfname(char *s,char *fn); static bool near displayline(char *line,FileArea& fa); const int MAX_TAGS = 52; LinkedList taglist; FilesIdx local_tags[MAX_TAGS]; int num_local_tags; static int remember_area = 0; static long remember_pos = -1; static int last_tag = 0; char tag_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890*#$!@%+=&?|>= 26) continue; for(i=0; tag_chars[i] ; i++) { if(c == tag_chars[i]) break; } if(tag_chars[i] && i < num_local_tags) { io << c << "\7,"; io.fullcolor(tagcharcol); tagged << c; } } for(i=0;i num_local_tags) continue; if(!is_tagged(local_tags[j].name , local_tags[j].area)) taglist.add(local_tags[j]); } io << '\r' << S_X_FILES_TAGGED(form("%d",taglist.count())); io.wait('\r'); io << "\7\r" << String(' ',language_string_length(S_X_FILES_TAGGED(form("%d",taglist.count())))) << '\r'; //io << "\7\r \r"; //if(rip_mode) io.show_remote = FALSE; } if(rep == (eol ? 2:4)) { io.show_remote = TRUE; edit_taglist(); io << "\f\7"; rep = 0; //if(rip_mode) io.show_remote = FALSE; } if(eol) { if(rep == 0) break; } else { if(rep >= 0 && rep <= 2) break; } } io.show_remote = TRUE; io.fullcolor(oldcolor); /* if(rip_mode) { rip_clear_status(); rip_show_enter(); } */ return rep; } void clear_tags() { last_tag = 0; num_local_tags = 0; } static bool is_whitespace(char c) { return (c==' ' || c=='\t'); } static char first_nonblank( char *line ) { char f =*line; if(is_whitespace(*line)) { for(int i=0 ; line[i] != '\0' && is_whitespace(line[i]) ; i++) {} f = line[i]; } return f; } static int display_areaname(int areanum, char *areaname , int prevsize) { io << form("\7%3d - %*s\r\xFF",areanum,-prevsize,areaname); return strlen(areaname); } void list_files(char *data) { FileArea fa; int areanum; io << "\f\n" << S_FILELIST_PRESS_S_TO_STOP << "\n\n\xFF"; linecounter(2); io.enablestop(); if(toupper(data[0])=='X') areanum = user.fileArea; else areanum = atoi(data); if(!fa.read(areanum)) return; LOG(2,"Files listed (%s)",fa.name); File tf; if(!tf.open(fa.listpath,fmode_read | fmode_text)) { LOG("Can't open file list %s",fa.listpath); return; } eol = FALSE; io.more_func = filelist_more; clear_tags(); char *line = new char[500]; bool interrupted = FALSE; remember_area = fa.areaNum; remember_pos = 0; while(tf.readLine(line,499)) { strip_linefeed(line); if(!displayline(line,fa)) { interrupted = TRUE; break; } remember_pos = tf.pos(); } io.more_func = NULLFUNC; delete [] line; if(!interrupted) { if(num_local_tags) { eol = TRUE; filelist_more(); } //io << '\n' << S_END_OF_FILE_LISTING << ' ' << S_PRESS_ENTER_TO_CONTINUE; } } void keyword_search(char *data) { FileArea fa; char item[41]; io << "\f\n" << S_KEYWORD_SEARCH_TITLE_AND_PROMPT; io.read(item,40,READMODE_UPALL); if(!*item) return; String buffer[10]; int pointer = 0, found = 0, group = 0; String param[40]; BitArray arealist(MAX_FILE_AREAS,1); int npara=parse_data(data,param); LOG(2,"Keyword search (%s)",item); io << "\n\f\n" << S_SEARCHING_FOR_KEYWORD(item) << "\n\n"; create_arealist(param,npara,arealist); for(int i = 0;i= cmpdate ) { strcpy( newf[ num_new++ ].name, find.name() ); } } if ( ! num_new ) { continue; } File tf; if ( ! tf.open( fa.listpath, fmode_read | fmode_text ) ) { LOG( "Can't open file list %s", fa.listpath ); continue; } for ( bool found = FALSE; tf.readLine( line, 499 ); ) { strip_linefeed( line ); if ( strchr( valid, toupper( *line ) ) && *line ) { char file[ 13 ]; found = FALSE; getfname( line, file ); strupr( file ); for ( int i = 0; i < num_new; i++ ) { if ( ! strcmp( newf[ i ].name, file )) { break; } } if ( i < num_new ) { found = TRUE; if ( linefeed ) { io << '\n'; if ( linecounter() ) { interrupted = TRUE; break; } } linefeed = FALSE; if ( ! displayline( line, fa ) ) { interrupted = TRUE; break; } } } else { char fnb = first_nonblank( line ); if ( fnb && found && strchr( "+|!;", fnb ) ) { if ( linefeed ) { io << '\n'; if ( linecounter() ) { interrupted = TRUE; break; } } linefeed = FALSE; if ( ! displayline( line, fa ) ) { interrupted = TRUE; break; } } } } } delete [] line; delete [] newf; io.more_func = NULLFUNC; if ( ! interrupted ) { if ( num_local_tags ) { eol = TRUE; filelist_more(); } // io << '\n' // << S_END_OF_FILE_SEARCH // << ' ' // << S_PRESS_ENTER_TO_CONTINUE; } } void filename_search(char *data) { int group = 0; char search[13]; io << "\f\n" << S_FILENAME_SEARCH_TITLE_AND_PROMPT; io.read(search,12,READMODE_UPALL); if(!*search) return; FileArea fa; String param[40]; BitArray arealist(MAX_FILE_AREAS,1); int npara = parse_data(data,param); for(int i = 0;i= 0) s.del(i,1); while((i = s.find("\x18")) >= 0) s.del(i,1); while((i = s.find("\x19")) >= 0) s.del(i,1); } } static bool near displayline( char *line, FileArea &fa ) { String str; String wrap; String wrapcolor; int left_margin; if ( ( strchr( valid, toupper( *line ) ) || ( *line=='!' && strchr( valid, toupper( line[ 1 ] ) ) ) ) && *line ) { Date date; long size; int counter; String fname; String desc; split_line( line, fname, date, size, counter, desc, fa ); RemoveDangerousChars( desc ); str = fullcolor_string( cfg.listColorTag ); local_tags[ last_tag ].area = fa.areaNum; strcpy( local_tags[ last_tag ].name, fname ); strupr( local_tags[ last_tag ].name ); if ( size ) { str << tag_chars[ last_tag ] << ' '; if ( last_tag >= num_local_tags ) { num_local_tags = last_tag + 1; } last_tag = ( ++last_tag ) % min( MAX_TAGS, ( /* rip_mode ? rip_screenlines : */ user.screenLength ) ); } else { str << " "; } str << fullcolor_string( cfg.listColorFileName ); str << form( "%-12s ", (char *) fname ); if ( size ) { str << fullcolor_string( cfg.listColorDate ); str << date.format( date_formats_long[ user.dateFormat ] ); // form( "%02d/%02d/%02d", // date[ ( cfg.europe ? 0 : 1 ) ], // date[ ( cfg.europe ? 1 : 0 ) ], // date[ 2 ] % 100 ); // Y2K FIXED! // date[ 2 ] ); // Y2K BUG! str << fullcolor_string( cfg.listColorSize ); if ( ( size + 512L ) / 1024L > 1000L ) { str << form( "%2ld.%1ldM ", ( size + 512L ) / 1024L / 1024L, ( ( size + 512L ) % ( 1024L * 1024L ) ) / 1024L * 10L / 1024L ); } else { if ( size >= 1000L ) { str << form( "%4ldk ", ( size + 512L ) / 1024L ); } else { str << form( "%4ldb ", size ); } } } else { str << fullcolor_string( cfg.listColorMissing ); str << " "; } if ( ! cfg.hideFileCounter ) { str << fullcolor_string( cfg.listColorCounter ); str << form( "[%02d]", counter ); if ( counter < 100 ) { str << ' '; } } wrapcolor = fullcolor_string( cfg.listColorDesc ); str << wrapcolor; io << str; if ( stopped ) { return FALSE; } left_margin = 34 - 5 * cfg.hideFileCounter; str = desc; } else { char fnb = first_nonblank( line ); if ( fnb && strchr( "+|", fnb ) ) { line = strchr( line, fnb ); } switch ( *line ) { case '|': case '+': line++; while ( is_whitespace( *line ) && *line != '\0' ) { line++; } left_margin = 34 - 5 * cfg.hideFileCounter; wrapcolor = fullcolor_string( cfg.listColorDesc ); io.fullcolor( cfg.listColorDesc ); io << String( ' ', left_margin ); break; case '!': left_margin = 0; io.fullcolor( cfg.listColorDesc ); wrapcolor = fullcolor_string( cfg.listColorDesc ); line++; break; case ';': left_margin = 0; io.fullcolor( cfg.listColorDesc ); wrapcolor = fullcolor_string( cfg.listColorDesc ); line++; break; default : left_margin = 0; io.fullcolor( cfg.listColorSeperator ); wrapcolor = fullcolor_string( cfg.listColorSeperator ); break; } str = line; RemoveDangerousChars( str ); } str.replace( "\t", " " ); if ( stopped ) { return FALSE; } for ( ; ; ) { int l = wordwrap( str, wrap, 79 - left_margin ); str << '\n'; io << str; if ( linecounter() || stopped ) { return FALSE; } if ( ! l ) { break; } io << wrapcolor << String( ' ', left_margin ); if ( stopped ) { return FALSE; } str = wrap; } io.flush(); return TRUE; }