home *** CD-ROM | disk | FTP | other *** search
/ The Arcade BBS / arcadebbs.zip / arcadebbs / bbstools / MODS / LISTF40.ZIP / LISTPLUS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-03  |  79.7 KB  |  3,507 lines

  1. #include "vars.h"
  2. #pragma hdrstop
  3.  
  4. #include <conio.h>
  5. #include <ctype.h>
  6. #include <dir.h>
  7. #include <signal.h>
  8. #include <time.h>
  9. #include <stdarg.h>
  10. #include <errno.h>
  11.  
  12. #include "listplus.h"
  13.  
  14.  
  15. // Few global variables
  16.  
  17. asylum_config config_listing;
  18. int list_loaded;  // 1 through ? or -1 through ? for sysop defined choices
  19.  
  20.  
  21. int extended_desc_used, lc_lines_used;
  22. int ext_is_on;
  23.  
  24. struct listplus_config lp_config;
  25.  
  26. static char far _on_[]="ON!";
  27. static char far _off_[] ="OFF";
  28.  
  29. int lp_config_loaded;
  30.  
  31. #ifdef FILE_POINTS
  32. long fpts;
  33. #endif
  34.  
  35.  
  36. char *lp_color_list[] = { "Black   ",
  37.                       "Blue    ",
  38.                       "Green   ",
  39.                       "Cyan    ",
  40.                       "Red     ",
  41.                       "Purple  ",
  42.                       "Brown   ",
  43.                       "L-Gray  ",
  44.                       "D-Gray  ",
  45.                       "L-Blue  ",
  46.                       "L-Green ",
  47.                       "L-Cyan  ",
  48.                       "L-Red   ",
  49.                       "L-Purple",
  50.                       "Yellow  ",
  51.                       "White   " };
  52.  
  53.  
  54.  
  55. void colorize_foundtext(char *text, struct search_record *search_rec, int color)
  56. {
  57.   int size, x;
  58.   char *temp, found_color[10], normal_color[10], *tok;
  59.   char find[101], word[101];
  60.  
  61.   sprintf(found_color, "|%02d|%02d", lp_config.found_fore_color, lp_config.found_back_color);
  62.   sprintf(normal_color, "|16|%02d", color);
  63.  
  64.  
  65.  
  66.   if(lp_config.colorize_found_text)
  67.   {
  68.     strcpy(find, search_rec->search);
  69.     tok = strtok(find, "&|!()");
  70.  
  71.  
  72.     while(tok)
  73.     {
  74.       temp=text;
  75.       strcpy(word, tok);
  76.       strip_string(word);
  77.  
  78.  
  79.       while(temp && word[0])
  80.       {
  81.         if((temp=strstr_nocase(temp, word))!=NULL)
  82.         {
  83.           // First move text over 6 places and insert 'found color'
  84.           size=strlen(temp)+1;
  85.           memmove(&temp[6], &temp[0], size);
  86.           strncpy(temp, found_color, 6);
  87.  
  88.           // Now move to the end of the found text
  89.           temp+=strlen(word)+6;
  90.           size=strlen(temp)+1;
  91.  
  92.           // And move text over 6 places to make room for normal color
  93.           memmove(&temp[6], &temp[0], size);
  94.           strncpy(temp, normal_color, 6);
  95.  
  96.           temp+=6;    /* go past the color codes we just added */
  97.  
  98.           // Get off of this find so we can find the next match
  99.           ++temp;
  100.         }
  101.       }
  102.       tok = strtok(NULL, "&|!()");
  103.     }
  104.   }
  105. }
  106.  
  107.  
  108.  
  109. void printtitle_plus(void)
  110. {
  111.   char s[81], *head;
  112.  
  113.   if(WhereY() != 0 || WhereX() != 0)
  114.     CLS();
  115.  
  116.   npr_color("|16|15%s", charstr(79,'▄'));
  117.   nl();
  118.  
  119.   sprintf(s, " ∙ [%-26.26s dir:%3d] (%d files) Space to tag - ?=Help ∙ ",
  120.                    stripcolors(directories[udir[curdir].subnum].name),
  121.                    atoi(udir[curdir].keys), numf);
  122.   justify_string(s, 79, ' ', JUSTIFY_LEFT);
  123.   npr_color("|23|01%s", s);
  124.   nl();
  125.  
  126.   if(config_listing.lp_options & cfl_header)
  127.     build_header();
  128.  
  129.   npr_color("|16|08%s\r\n",charstr(79,'▀'));
  130.   ansic(0);
  131. }
  132.  
  133.  
  134.  
  135.  
  136. void build_header(void)
  137. {
  138.   char header[100];
  139.   int desc_pos=30;
  140.  
  141.   strcpy(header, " Tag # ");
  142.  
  143.   if(config_listing.lp_options & cfl_fname)
  144.     strcat(header, "Filename");
  145.  
  146.   if(config_listing.lp_options & cfl_extension)
  147.     strcat(header, ".EXT ");
  148.  
  149.   if(config_listing.lp_options & cfl_dloads)
  150.     strcat(header, " DL ");
  151.  
  152.   if(config_listing.lp_options & cfl_kbytes)
  153.     strcat(header, "Bytes ");
  154.  
  155. #ifdef FILE_POINTS
  156.   if(config_listing.lp_options & cfl_file_points)
  157.     strcat(header, "Fpts ");
  158. #endif
  159.  
  160.   if(config_listing.lp_options & cfl_days_old)
  161.     strcat(header, "Old ");
  162.  
  163.   if(config_listing.lp_options & cfl_times_a_day_dloaded)
  164.     strcat(header, "DL'PD ");
  165.  
  166.   if(config_listing.lp_options & cfl_days_between_dloads)
  167.     strcat(header, "DBDLS ");
  168.  
  169.  
  170.   if(config_listing.lp_options & cfl_description)
  171.   {
  172.     desc_pos = strlen(header);
  173.     strcat(header, "Description");
  174.   }
  175.  
  176.   justify_string(header, 79, ' ', JUSTIFY_LEFT);
  177.   npr_color("|23|01%s",header);
  178.   nl();
  179.  
  180.   header[0]=0;
  181.  
  182.   if(config_listing.lp_options & cfl_date_uploaded)
  183.     strcat(header, "Date Uploaded      ");
  184.   if(config_listing.lp_options & cfl_upby)
  185.     strcat(header, "Who uploaded");
  186.  
  187.   if(header[0])
  188.   {
  189.     justify_string(header, desc_pos+strlen(header), ' ', JUSTIFY_RIGHT);
  190.     justify_string(header, 79, ' ', JUSTIFY_LEFT);
  191.     npr_color("|23|01%s",header);
  192.     nl();
  193.   }
  194.  
  195.  
  196. }
  197.  
  198.  
  199. int first_file_pos(void)
  200. {
  201.   int x;
  202.  
  203.   x = FIRST_FILE_POS;
  204.  
  205.   if(config_listing.lp_options & cfl_header)
  206.     x += lp_configured_lines();
  207.  
  208.   return(x);
  209. }
  210.  
  211. int lp_configured_lines(void)
  212. {
  213.   if(config_listing.lp_options & cfl_date_uploaded || config_listing.lp_options & cfl_upby)
  214.     return 2;
  215.  
  216.   return 1;
  217. }
  218.   
  219.  
  220. void print_searching(void)
  221. {
  222.   static int pos=0;
  223.   int amount = 4;
  224.   char *searching="|/-\\";
  225.  
  226.   if(WhereY() !=0 || WhereX() !=0)
  227.     CLS();
  228.  
  229.   ansic(2);
  230.  
  231.   outchr(searching[pos]);
  232.   ++pos;
  233.   if(pos >= amount)
  234.     pos = 0;
  235. }
  236.  
  237. void catch_divide_by_zero(int x)
  238. {
  239.   if(x!=x)  /* this is just to shut warnings up */
  240.     x=x;
  241.   sysoplog("Caught divide by 0");
  242. }
  243.  
  244.  
  245. int listfiles_plus(int type)
  246. {
  247.   int x;
  248.   int save_topdata=topdata;
  249.   int save_dir=curdir;
  250.   long save_status=thisuser.sysstatus;
  251.   extern int numlock;
  252.   int save_numlock = NOTNUMBERS;
  253.  
  254.  
  255.   helpl=800;
  256.   tagging=0;
  257.  
  258.   ext_is_on = 1;            /* turn extended descriptions on */
  259.   signal(SIGFPE, catch_divide_by_zero);
  260.  
  261.  
  262.   // Turn off topscreen info for this mod
  263.   topdata=0;
  264.   topscreen();
  265.  
  266.   CLS();
  267.  
  268.  
  269.   x = listfiles_plus_function(type);
  270.  
  271. #ifdef FAST_EXTENDED_DESCRIPTION
  272.   lp_zap_ed_info();
  273. #endif
  274.  
  275.   ansic(0);
  276.   GOTO_XY(1, thisuser.screenlines-3);
  277.   nln(3);
  278.  
  279.  
  280.   lines_listed=0;
  281.  
  282.   tmp_disable_conf(0);
  283.   thisuser.sysstatus = save_status;
  284.  
  285.  
  286.   if(type == NSCAN_NSCAN || type == NSCAN_DIR)
  287.     curdir = save_dir;
  288.   dliscan();
  289.  
  290.   topdata=save_topdata;
  291.   topscreen();
  292.  
  293.   numlock = save_numlock;
  294.   return x;
  295. }
  296.  
  297. int listfiles_plus_function(int type)
  298. {
  299.   uploadsrec (*file_recs)[1];
  300.   int file_handle[51], lines, max_lines, lines_left;
  301.   int save_first_file=0;
  302.   char vert_pos[51];
  303.  
  304.   int first_file, amount;
  305.   int file_pos=0, save_file_pos=0, menu_pos=0;
  306.   int done=0, all_done=0, force_menu, needed;
  307.   unsigned command;
  308.   int redraw;
  309.  
  310.   int matches=0; // when a file passes the compare_criteria inc
  311.   int had;
  312.  
  313.   int this_dir, also_this_dir;
  314.   int scan_dir, save_dir = curdir;
  315.   int changedir=0;
  316.  
  317.   int file=-1, sysop_mode=0;
  318.   char **menu_items;
  319.   
  320.   struct side_menu_colors smc;
  321.   struct search_record search_rec;
  322.  
  323.  
  324.  
  325.  
  326.   load_lp_config();
  327.  
  328.   smc.normal_highlight  = lp_config.normal_highlight;
  329.   smc.normal_menu_item  = lp_config.normal_menu_item;
  330.   smc.current_highlight = lp_config.current_highlight;
  331.   smc.current_menu_item = lp_config.current_menu_item;
  332.  
  333.  
  334.   load_listing();        /* load configurable listing up */
  335.  
  336.  
  337.   menu_items=(char **)alloc_2d(20, 15, sizeof(char));
  338.   if(!menu_items)
  339.     return 0;
  340.  
  341.  
  342.   prep_menu_items(menu_items);
  343.  
  344.  
  345.   (char *)file_recs=(char *)malloca((thisuser.screenlines+20)*sizeof(uploadsrec));
  346.   if(!file_recs)
  347.   {
  348.     free_2d(menu_items);
  349.     return 0;
  350.   }
  351.  
  352.  
  353.   if(!prep_search_rec(&search_rec, type))
  354.   {
  355.     bbsfree(file_recs);
  356.     free_2d(menu_items);
  357.     return 0;
  358.   }
  359.  
  360.  
  361.   max_lines = calc_max_lines();
  362.  
  363.  
  364.  
  365.   num_listed=0;
  366.   for (this_dir=0; (this_dir<num_dirs) && (!hangup) && (udir[this_dir].subnum!=-1) && !all_done; this_dir++)
  367.   {
  368.     also_this_dir=udir[this_dir].subnum;
  369.     scan_dir=0;
  370.  
  371.     checka(&all_done,&all_done);
  372.  
  373.     if(search_rec.alldirs==THIS_DIR)
  374.     {
  375.       if(this_dir==save_dir)
  376.         scan_dir=1;
  377.     }
  378.     else // Either for NSCAN or all dirs
  379.     {
  380.       // This part checks to see if it is in the nscan
  381.       if (qsc_n[also_this_dir/32]&(1L<<(also_this_dir%32)))
  382.         scan_dir=1;
  383.  
  384.       // If we are searching all dirs, scan it..
  385.       if(search_rec.alldirs==ALL_DIRS)
  386.         scan_dir=1;
  387.  
  388.  
  389.       // If we have a nscan date specified, lets check the file dates first...
  390.       // and not even open it if it hasn't been changed
  391.       if(search_rec.nscandate)
  392.       {
  393.  
  394.         if ((dir_dates[udir[this_dir].subnum]) && (dir_dates[udir[this_dir].subnum]<nscandate))
  395.         {
  396.           scan_dir=0;
  397.  
  398.           curdir=this_dir;
  399.           print_searching();
  400.         }
  401.       }
  402.     }
  403.  
  404.  
  405.  
  406.     if(scan_dir)
  407.     {
  408.       curdir=this_dir;
  409.       dliscan();
  410.  
  411.  
  412.       num_listed=0;
  413.  
  414.  
  415.       first_file=save_first_file=1;
  416.       amount=0;
  417.       done=0;
  418.       matches=0;
  419.       lines=0;
  420.  
  421.  
  422.       while(!done && !hangup && !all_done)
  423.       {
  424.         if(!amount)
  425.         {
  426.           // Open files to read only while reading dir
  427.           file=sh_open1(dlfn,O_RDONLY | O_BINARY);
  428.  
  429.           if(file < 1)
  430.           {
  431.             done=1;
  432.             continue;
  433.           }
  434.  
  435.  
  436.           print_searching();
  437.         }
  438.  
  439.         if(numf)
  440.         {
  441.           changedir=0;
  442.           force_menu = 0;
  443.  
  444.           SETREC(file, first_file+amount);
  445.           sh_read(file,(void *)file_recs[matches],sizeof(uploadsrec));
  446.  
  447.  
  448.  
  449.           if(compare_criteria(&search_rec, file_recs[matches]))
  450.           {
  451.  
  452.             lines_left=max_lines-lines;
  453.  
  454.             /* Check to make sure we have enough room to print full description */
  455.             needed = check_lines_needed(file_recs[matches]);
  456.  
  457.             if(needed <= lines_left)
  458.             {
  459.               int lines_used;
  460.  
  461.               if(!matches)
  462.                 printtitle_plus();
  463.  
  464.               file_handle[matches]=first_file+amount;
  465.  
  466.  
  467.               vert_pos[matches]=lines;
  468.  
  469.               lines_used = printinfo_plus(file_recs[matches], file_handle[matches], check_batch_queue(file_recs[matches]->filename), lines_left, &search_rec);
  470.  
  471. #ifdef EXTRA_SPACE
  472.               if(lines_used > 1 && lines_used < lines_left)
  473.               {
  474.                 nl();
  475.                 ++lines_used;
  476.               }
  477. #endif
  478.  
  479.               lines+= lines_used;
  480.  
  481.  
  482.               ++matches;  // Amount of files on screen
  483.             }
  484.             else
  485.               force_menu=1;   /* Won't fit, force menu to show */
  486.           }
  487.           if(!force_menu)  /* only increment if we are not forcing the menu */
  488.             ++amount;
  489.  
  490.  
  491.           if((lines >=max_lines) || (numf < first_file+amount) || force_menu)
  492.           {
  493.             // Close it now, since we don't need it right now
  494.             file=sh_close(file);
  495.  
  496.             if(matches)
  497.             {
  498.               int menu_done=0;
  499.  
  500.               file_pos=save_file_pos;
  501.               drawfile(vert_pos[file_pos], file_handle[file_pos]);
  502.  
  503.               redraw=1;
  504.               save_file_pos=0;
  505.  
  506.               while(!menu_done && !hangup)
  507.               {
  508.                 command = side_menu(&menu_pos, redraw, menu_items, 2, max_lines+first_file_pos()+1, &smc);
  509.  
  510.                 redraw=1;
  511.                 ansic(0);
  512.  
  513.                 if(do_sysop_command(command))
  514.                 {
  515.                   menu_done=1;
  516.                   amount=lines=matches=0;
  517.                   save_file_pos=file_pos;
  518.                 }
  519.  
  520.  
  521.  
  522.                 if(command==COMMAND_PAGEUP)
  523.                 {
  524.                   command=EXECUTE;
  525.                   menu_pos=1;
  526.                 }
  527.                 if(command==COMMAND_PAGEDN)
  528.                 {
  529.                   command=EXECUTE;
  530.                   menu_pos=0;
  531.                 }
  532.  
  533.                 switch(command)
  534.                 {
  535.                   case CX:
  536.                   case AX:
  537.                     goto TOGGLE_EXTENDED;
  538.  
  539.                   case '?':
  540.                   case CO:
  541.                     CLS();
  542.                     printfile("LISTPLUS.HLP");
  543.                     pausescr();
  544.  
  545.                     menu_done=1;
  546.                     amount=lines=matches=0;
  547.                     save_file_pos=file_pos;
  548.                     break;
  549.  
  550.                   case COMMAND_DOWN:
  551.                     undrawfile(vert_pos[file_pos], file_handle[file_pos]);
  552.                     ++file_pos;
  553.                     if(file_pos>=matches)
  554.                       file_pos=0;
  555.                     drawfile(vert_pos[file_pos], file_handle[file_pos]);
  556.                     redraw=0;
  557.                     break;
  558.  
  559.                   case COMMAND_UP:
  560.                     undrawfile(vert_pos[file_pos], file_handle[file_pos]);
  561.                     if(!file_pos)
  562.                       file_pos=matches-1;
  563.                     else
  564.                       --file_pos;
  565.                     drawfile(vert_pos[file_pos], file_handle[file_pos]);
  566.                     redraw=0;
  567.                     break;
  568.  
  569.  
  570.                   case SPACE: // Add or remove batch queue
  571.                     goto ADD_OR_REMOVE_BATCH;
  572.  
  573.                   case EXECUTE:
  574.                     switch(menu_pos)
  575.                     {
  576.                       case 0: // Next
  577.                         save_first_file=first_file;
  578.                         first_file+=amount;
  579.  
  580.                         if(first_file>numf)
  581.                           done=1;
  582.  
  583.                         menu_done=1;
  584.                         amount=lines=matches=0;
  585.                         break;
  586.  
  587.                       case 1: // Prev
  588.                         if(save_first_file>=first_file)
  589.                         {
  590.                           if(first_file>5)
  591.                             first_file-=5;
  592.                           else
  593.                             first_file=1;
  594.                         }
  595.                         else
  596.                           first_file=save_first_file;
  597.  
  598.                         menu_done=1;
  599.                         amount=lines=matches=0;
  600.                         break;
  601.  
  602.                       case 2: // TAG file
  603.                         if(sysop_mode)
  604.                         {
  605.                           do_batch_sysop_command(SYSOP_DELETE, file_recs[file_pos]->filename);
  606.  
  607.                           menu_done=1;
  608.                           save_file_pos=file_pos=0;
  609.                           amount=lines=matches=0;
  610.                         }
  611.                         else
  612.                         {
  613.  
  614. ADD_OR_REMOVE_BATCH:
  615. #ifdef KBPERDAY
  616.                           kbbatch+=bytes_to_k(file_recs[file_pos]->numbytes);
  617. #endif
  618.                           if(find_batch_queue(file_recs[file_pos]->filename) > -1)
  619.                           {
  620.                             remove_batch(file_recs[file_pos]->filename);
  621.                             redraw=0;
  622.                           }
  623. #ifdef FILE_POINTS
  624.                           else if(((!(file_recs[file_pos]->mask & mask_validated)) || ((file_recs[file_pos]->filepoints>thisuser.filepoints)) &&
  625.                            (!(thisuser.exempt & exempt_ratio))) && !sysop_mode)
  626.                           {
  627.  
  628.                             CLS();
  629.                             pl("You don't have enough file points to download this file");
  630.                             pl("Or this file is not validated yet.");
  631. #else
  632.                           else if(!ratio_ok() && !sysop_mode)
  633.                           {
  634. #endif
  635.                             menu_done=1;
  636.                             amount=lines=matches=0;
  637.                             save_file_pos=file_pos;
  638.                             pausescr();
  639.                           }
  640.                           else
  641.                           {
  642.                             char file[130];
  643.                             redraw=0;
  644.  
  645.                             // If it is in the dir, check to make sure it exists
  646.                             // before adding it, if it is on CD ROM, just add it
  647.                             if (!(directories[udir[curdir].subnum].mask & mask_cdrom) && !sysop_mode)
  648.                             {
  649.                               strcpy(file, directories[udir[curdir].subnum].path);
  650.                               strcat(file, file_recs[file_pos]->filename);
  651.                               if(sysop_mode || !using_modem || exist(file))
  652.                               {
  653. #ifdef FILE_POINTS
  654.                                 fpts=0;
  655.                                 fpts=(file_recs[file_pos]->filepoints);
  656. #endif
  657.                                 add_batch(file_recs[file_pos]->filename, udir[curdir].subnum, file_recs[file_pos]->numbytes);
  658.                               }
  659.                               else if(lp_config.request_file)
  660.                               {
  661.                                 menu_done=1;
  662.                                 amount=lines=matches=0;
  663.                                 request_file(file_recs[file_pos]->filename);
  664.                               }
  665.                             }
  666.                             else {
  667. #ifdef FILE_POINTS
  668.                               fpts=0;
  669.                               fpts=(file_recs[file_pos]->filepoints);
  670. #endif
  671.                               add_batch(file_recs[file_pos]->filename, udir[curdir].subnum, file_recs[file_pos]->numbytes);
  672.                             }
  673.                           }
  674.  
  675.  
  676. #ifdef KBPERDAY
  677.                           kbbatch-=bytes_to_k(file_recs[file_pos]->numbytes);
  678. #endif
  679.                           GOTO_XY(1, first_file_pos()+vert_pos[file_pos]);
  680.                           npr_color("|%2d %c ", lp_config.tagged_color, check_batch_queue(file_recs[file_pos]->filename) ? '■':' ');
  681.                         }
  682.                         break;
  683.  
  684.                       case 3: // Info
  685.                         if(!sysop_mode)
  686.                         {
  687.                           show_fileinfo(file_recs[file_pos]);
  688.                           menu_done=1;
  689.                           save_file_pos=file_pos;
  690.                           amount=lines=matches=0;
  691.                         }
  692.                         else
  693.                         {
  694.                           do_batch_sysop_command(SYSOP_RENAME, file_recs[file_pos]->filename);
  695.  
  696.                           menu_done=1;
  697.                           save_file_pos=file_pos;
  698.                           amount=lines=matches=0;
  699.                         }
  700.                         menu_pos = 0;      // jump up to the 'next' option
  701.                         break;
  702.  
  703.  
  704.                       case 4: // View
  705.                         if(!sysop_mode)
  706.                         {
  707.                           view_file(file_recs[file_pos]->filename);
  708.                           menu_done=1;
  709.                           save_file_pos=file_pos;
  710.                           amount=lines=matches=0;
  711.                         }
  712.                         else
  713.                         {
  714.                           do_batch_sysop_command(SYSOP_MOVE, file_recs[file_pos]->filename);
  715.  
  716.                           menu_done=1;
  717.                           save_file_pos=file_pos=0;
  718.                           amount=lines=matches=0;
  719.                         }
  720.                         menu_pos = 0;      // jump up to the 'next' option
  721.                         break;
  722.  
  723.                       case 5: // Download or move batch files
  724.                         if(!sysop_mode && using_modem)
  725.                         {
  726.                           CLS();
  727.  
  728.                           menu_done=1;
  729.                           save_file_pos=file_pos;
  730.                           amount=lines=matches=0;
  731.  
  732. #ifdef FILE_POINTS
  733.                         if(((!(file_recs[file_pos]->mask & mask_validated)) || ((file_recs[file_pos]->filepoints>thisuser.filepoints)) &&
  734.                            (!(thisuser.exempt & exempt_ratio))) && !sysop_mode)
  735.                         {
  736.                           CLS();
  737.                           pl("You don't have enough file points to download this file");
  738.                           pl("Or this file is not validated yet.");
  739. #else
  740.                           if(!ratio_ok())
  741.                           {
  742. #endif
  743.                             pausescr();
  744.                           }
  745.                           else
  746.                             download_plus(file_recs[file_pos]->filename);
  747.                           dliscan();
  748.                         }
  749.                         else if(!sysop_mode)
  750.                         {
  751.                           do_batch_sysop_command(SYSOP_MOVE, file_recs[file_pos]->filename);
  752.  
  753.                           menu_done=1;
  754.                           save_file_pos=file_pos=0;
  755.                           amount=lines=matches=0;
  756.                         }
  757.                         else
  758.                         {
  759.                           sysop_configure();
  760.  
  761.                           smc.normal_highlight  = lp_config.normal_highlight;
  762.                           smc.normal_menu_item  = lp_config.normal_menu_item;
  763.                           smc.current_highlight = lp_config.current_highlight;
  764.                           smc.current_menu_item = lp_config.current_menu_item;
  765.  
  766.  
  767.  
  768.                           menu_done=1;
  769.                           save_file_pos=file_pos;
  770.                           amount=lines=matches=0;
  771.                         }
  772.                         menu_pos = 0;      // jump up to the 'next' option
  773.                         break;
  774.  
  775.                       case 6: // +dir
  776.                         menu_done=1;
  777.                         amount=lines=matches=0;
  778.                         first_file=1;
  779.  
  780.                         changedir=1;
  781.  
  782.                         if ((curdir<num_dirs-1) && (udir[curdir+1].subnum>=0))
  783.                         {
  784.                           ++curdir;
  785.                           ++this_dir;
  786.                         }
  787.                         else
  788.                         {
  789.                           curdir=0;
  790.                           this_dir=0;
  791.                         }
  792.                         if(!type)
  793.                           save_dir=curdir;
  794.                         dliscan();
  795.  
  796.                         menu_pos = 0;      // jump up to the 'next' option
  797.                         break;
  798.  
  799.                       case 7: // -dir
  800.                         menu_done=1;
  801.                         amount=lines=matches=0;
  802.                         first_file=1;
  803.  
  804.                         changedir=-1;
  805.  
  806.                         if (curdir>0)
  807.                         {
  808.                           --curdir;
  809.                           --this_dir;
  810.                         }
  811.                         else
  812.                         {
  813.                           while ((udir[curdir+1].subnum>=0) && (curdir<num_dirs-1))
  814.                             ++curdir;
  815.                           this_dir=curdir;
  816.                         }
  817.                         if(!type)
  818.                           save_dir=curdir;
  819.                         dliscan();
  820.  
  821.                         menu_pos = 0;      // jump up to the 'next' option
  822.                         break;
  823.  
  824.                       case 8:  // toggle extended
  825. TOGGLE_EXTENDED:        ext_is_on = !ext_is_on;  /* descriptions on and off */
  826.                         menu_done=1;
  827.                         amount=lines=matches=0;
  828.                         file_pos=0;
  829.                         save_file_pos=file_pos;
  830.                         menu_pos = 0;      // jump up to the 'next' option
  831.                         break;
  832.  
  833.                       case 9: // Quit
  834.                         menu_done=1;
  835.                         done=1;
  836.                         amount=lines=matches=0;
  837.                         all_done=1;
  838.                         lines_listed = 0;
  839.                         break;
  840.  
  841.  
  842.                       case 10: // ? Help
  843.                         CLS();
  844.                         printfile("LISTPLUS.HLP");
  845.                         pausescr();
  846.  
  847.  
  848.                         menu_done=1;
  849.                         amount=lines=matches=0;
  850.                         save_file_pos=file_pos;
  851.                         break;
  852.  
  853.                       case 11: // Sysop
  854.  
  855.                         if(so() && !sysop_mode)
  856.                         {
  857.                           sysop_mode=1;
  858.  
  859.                           strcpy(menu_items[2], "Delete");
  860.                           strcpy(menu_items[3], "Rename");
  861.                           strcpy(menu_items[4], "Move");
  862.                           strcpy(menu_items[5], "Config");
  863.                           strcpy(menu_items[11], "Back");
  864.                         }
  865.                         else
  866.                         {
  867.                           sysop_mode=0;
  868.                           prep_menu_items(menu_items);
  869.                         }
  870.                         outchr('\r');
  871.                         EOL();
  872.  
  873.                         break;
  874.  
  875.  
  876.                     }
  877.  
  878.                     break;
  879.  
  880.                   case GET_OUT:
  881.                     menu_done=1;
  882.                     done=1;
  883.                     all_done=1;
  884.                     amount=lines=matches=0;
  885.                     break;
  886.  
  887.                 }
  888.               }
  889.             }
  890.             else
  891.             {
  892.               if(!changedir)
  893.                 done=1;  // If !matches
  894.               else if(changedir==1)
  895.               {
  896.                 if ((curdir<num_dirs-1) && (udir[curdir+1].subnum>=0))
  897.                   ++curdir;
  898.                 else
  899.                   curdir=0;
  900.                 dliscan();
  901.  
  902.               }
  903.               else
  904.               {
  905.                 if (curdir>0)
  906.                   --curdir;
  907.                 else
  908.                 {
  909.                   while ((udir[curdir+1].subnum>=0) && (curdir<num_dirs-1))
  910.                     ++curdir;
  911.                 }
  912.                 dliscan();
  913.  
  914.               }
  915.             }
  916.           }
  917.         }
  918.         else
  919.         {
  920.           file=sh_close(file);
  921.  
  922.           if(!changedir)
  923.             done=1;  // If !matches
  924.           else if(changedir==1)
  925.           {
  926.             if ((curdir<num_dirs-1) && (udir[curdir+1].subnum>=0))
  927.               ++curdir;
  928.             else
  929.               curdir=0;
  930.             dliscan();
  931.  
  932.           }
  933.           else
  934.           {
  935.             if (curdir>0)
  936.               --curdir;
  937.             else
  938.             {
  939.               while ((udir[curdir+1].subnum>=0) && (curdir<num_dirs-1))
  940.                 ++curdir;
  941.             }
  942.             dliscan();
  943.           }
  944.         }
  945.       }
  946.     }
  947.   }
  948.  
  949.   if(file!=-1)
  950.     file=sh_close(file);
  951.  
  952.  
  953.   bbsfree(file_recs);
  954.   free_2d(menu_items);
  955.  
  956.   return(all_done);
  957. }
  958.  
  959. void drawfile(int filepos, int filenum)
  960. {
  961.   lines_listed = 0;
  962.  
  963.   GOTO_XY(4, filepos+first_file_pos());
  964.   setc(lp_config.current_file_color);
  965.   npr_color("%3d0", filenum);
  966.   GOTO_XY(4, filepos+first_file_pos());
  967.   
  968. }
  969.  
  970. void undrawfile(int filepos, int filenum)
  971. {
  972.   lines_listed = 0;
  973.   GOTO_XY(4, filepos+first_file_pos());
  974.   npr_color("|%2d%3d0", lp_config.file_num_color, filenum);
  975. }
  976.  
  977.  
  978. int add_batch(char *filename, int dn, long fs)
  979. {
  980.   double t;
  981.   
  982.   if(find_batch_queue(filename) > -1)
  983.     return 0;
  984.   
  985.   if (numbatch>=sysinfo.max_batch)
  986.   {
  987.     GOTO_XY(1, thisuser.screenlines-1);
  988.     pl(get_string(900));
  989.     pausescr();
  990.   }
  991.   else if(!ratio_ok())
  992.   {
  993.     pausescr();
  994.   }
  995.   else 
  996.   {
  997.     if (modem_speed && fs)
  998.       // t=(12.656) / ((double) (modem_speed)) * ((double)(fs));
  999.       t=(9.0) / ((double) (modem_speed)) * ((double)(fs));
  1000.     else
  1001.       t=0.0;
  1002. #ifdef FILE_POINTS
  1003.     if ((thisuser.filepoints<(batchfpts+fpts))
  1004.         && (!(thisuser.exempt & exempt_ratio))) {
  1005.       GOTO_XY(1, thisuser.screenlines-1);
  1006.       pl("Not enough file points to download this file");
  1007.       pausescr();
  1008.     }
  1009.     else
  1010. #endif
  1011.     if (nsl()<=(batchtime + t)) 
  1012.     {
  1013.       GOTO_XY(1, thisuser.screenlines-1);
  1014.       pl(get_string(901));
  1015.       pausescr();
  1016.     }
  1017.     else 
  1018.     {
  1019.       if (dn==-1) 
  1020.       {
  1021.         GOTO_XY(1, thisuser.screenlines-1);
  1022.         pl(get_string(902));
  1023.         pausescr();
  1024.       } 
  1025.       else 
  1026.       {
  1027.         batchtime += t;
  1028. #ifdef FILE_POINTS
  1029.         batchfpts += fpts;
  1030. #endif
  1031.         strcpy(batch[numbatch].filename,filename);
  1032.         batch[numbatch].dir=dn;
  1033.         batch[numbatch].time=t;
  1034.         batch[numbatch].sending=1;
  1035.         batch[numbatch].len=fs;
  1036. #ifdef FILE_POINTS
  1037.         batch[numbatch].filepoints=fpts;
  1038. #endif
  1039.   
  1040.         numbatch++;
  1041. #ifdef KBPERDAY
  1042.         kbbatch+=bytes_to_k(fs);
  1043. #endif
  1044.         ++numbatchdl;
  1045.         
  1046.         return 1;
  1047.       }
  1048.     }
  1049.   }
  1050.   return 0;
  1051. }
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058. // Return the amount of lines that were printed
  1059. int printinfo_plus(uploadsrec *u, int filenum, int marked, int LinesLeft, struct search_record *search_rec)
  1060. {
  1061.   char temp[150], filename[13], ext[4];
  1062.   char finfo[1024], element[150], *str;
  1063.   int width=0;
  1064.  
  1065.   int ch=0, chars_this_line=0, numl=0, cpos=0, will_fit=78;
  1066.   int char_printed=0, extdesc_pos;
  1067.   unsigned int_cmd;
  1068.  
  1069.   int daysold;
  1070.   long TimeNow, DiffTime;
  1071.  
  1072.  
  1073.  
  1074.   // Extract out filename and extention
  1075.   strcpy(filename, u->filename);
  1076.   str=strchr(filename, '.');
  1077.   str[0]=0;
  1078.   ++str;
  1079.   strcpy(ext, str);
  1080.  
  1081.   TimeNow=time(NULL);
  1082.   DiffTime=difftime(TimeNow, u->daten);
  1083.   daysold=DiffTime/SECONDS_PER_DAY;
  1084.  
  1085.  
  1086.  
  1087.   sprintf(finfo, "|%2d %c |%2d%3d ", lp_config.tagged_color, marked ? '■' : ' ', lp_config.file_num_color, filenum);
  1088.   width = 7;
  1089.  
  1090.   lines_listed=0;             /* kill any pauses that might happen */
  1091.  
  1092.  
  1093.  
  1094.  
  1095.   if(config_listing.lp_options & cfl_fname)
  1096.   {
  1097.     strcpy(temp, filename);
  1098.     justify_string(temp, 8, ' ', JUSTIFY_LEFT);
  1099.  
  1100.     if(search_rec)
  1101.       colorize_foundtext(temp, search_rec, config_listing.lp_colors[0]);
  1102.  
  1103.     sprintf(element, "|%02d%s", config_listing.lp_colors[0], temp);
  1104.     strcat(finfo, element);
  1105.     width+=8;
  1106.   }
  1107.  
  1108.  
  1109.   if(config_listing.lp_options & cfl_extension)
  1110.   {
  1111.     strcpy(temp, ext);
  1112.     justify_string(temp, 3, ' ', JUSTIFY_LEFT);
  1113.  
  1114.     if(search_rec)
  1115.       colorize_foundtext(temp, search_rec, config_listing.lp_colors[1]);
  1116.  
  1117.     sprintf(element, "|%02d.%s", config_listing.lp_colors[1], temp);
  1118.     strcat(finfo, element);
  1119.     width+=4;
  1120.   }
  1121.  
  1122.   if(config_listing.lp_options & cfl_dloads)
  1123.   {
  1124.     sprintf(temp, "%3d", u->numdloads);
  1125.     temp[3]=0;
  1126.  
  1127.     sprintf(element, " |%02d%s", config_listing.lp_colors[2], temp);
  1128.     strcat(finfo, element);
  1129.     width+=4;
  1130.   }
  1131.  
  1132.  
  1133.   if(config_listing.lp_options & cfl_kbytes)
  1134.   {
  1135.     sprintf(temp, "%4ldk", (long)bytes_to_k(u->numbytes));
  1136.     temp[5]=0;
  1137.  
  1138.     if (!(directories[udir[curdir].subnum].mask & mask_cdrom))
  1139.     {
  1140.       char file[101];
  1141.       strcpy(file, directories[udir[curdir].subnum].path);
  1142.       strcat(file, u->filename);
  1143.  
  1144.       if(lp_config.check_exist)
  1145.       {
  1146.         if (!exist(file))
  1147.           strcpy(temp,"OFFLN");
  1148.       }
  1149.     }
  1150.  
  1151.     sprintf(element, " |%02d%s", config_listing.lp_colors[3], temp);
  1152.     strcat(finfo, element);
  1153.     width+=6;
  1154.   }
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161. #ifdef FILE_POINTS
  1162.   if(config_listing.lp_options & cfl_file_points)
  1163.   {
  1164.     if (u->mask & mask_validated)
  1165.     {
  1166.       if (u->filepoints)
  1167.         { sprintf(temp,"%4u",u->filepoints); temp[4]=0; }
  1168.       else
  1169.         sprintf(temp,"Free");
  1170.     }
  1171.     else
  1172.       sprintf(temp, "9e99");
  1173.  
  1174.     sprintf(element, " |%02d%s", config_listing.lp_colors[5], temp);
  1175.     strcat(finfo, element);
  1176.     width+=5;
  1177.   }
  1178. #endif
  1179.  
  1180.  
  1181.   if(config_listing.lp_options & cfl_days_old)
  1182.   {
  1183.     sprintf(temp, "%3d", daysold);
  1184.     temp[3]=0;
  1185.  
  1186.     sprintf(element, " |%02d%s", config_listing.lp_colors[6], temp);
  1187.     strcat(finfo, element);
  1188.     width+=4;
  1189.   }
  1190.  
  1191.  
  1192.  
  1193.   if(config_listing.lp_options & cfl_times_a_day_dloaded)
  1194.   {
  1195.     float t;
  1196.  
  1197.     t=daysold ? (float)u->numdloads/(float)daysold : 0.0;
  1198.  
  1199.     sprintf(temp, "%2.2f", t);
  1200.     temp[5]=0;
  1201.  
  1202.     sprintf(element, " |%02d%s", config_listing.lp_colors[8], temp);
  1203.     strcat(finfo, element);
  1204.     width+=6;
  1205.   }
  1206.  
  1207.  
  1208.   if(config_listing.lp_options & cfl_days_between_dloads)
  1209.   {
  1210.     float t;
  1211.  
  1212.     t = daysold ? (float)u->numdloads/(float)daysold : 0.0;
  1213.     t = t ? (float)1/(float)t : 0.0;
  1214.  
  1215.     sprintf(temp, "%3.1f", t);
  1216.     temp[5]=0;
  1217.  
  1218.     sprintf(element, " |%02d%s", config_listing.lp_colors[9], temp);
  1219.     strcat(finfo, element);
  1220.     width+=6;
  1221.   }
  1222.  
  1223.  
  1224.   if(config_listing.lp_options & cfl_description)
  1225.   {
  1226.     char *desc;
  1227.  
  1228.  
  1229.     ++width;          /* add 1 for the pre-space added before the desc */
  1230.  
  1231.     strcpy(temp, u->description);
  1232.  
  1233.     if(search_rec)
  1234.       colorize_foundtext(temp, search_rec, config_listing.lp_colors[10]);
  1235.  
  1236.     sprintf(element, " |%02d%s", config_listing.lp_colors[10], temp);
  1237.     strcat(finfo, element);
  1238.  
  1239.     extdesc_pos = width;
  1240.   }
  1241.   else
  1242.     extdesc_pos = -1;
  1243.  
  1244.   strcat(finfo, "\r\n");
  1245.  
  1246.  
  1247.  
  1248.  
  1249.   cpos=0;
  1250.  
  1251.   while(finfo[cpos] && numl < LinesLeft)
  1252.   {
  1253.     do
  1254.     {
  1255.       ch=finfo[cpos];
  1256.  
  1257.       if(!ch)
  1258.         continue;
  1259.  
  1260.       ++cpos;
  1261.  
  1262.     }while(ch=='\r' && ch);
  1263.  
  1264.     if(!ch)
  1265.       break;
  1266.  
  1267.     if (ch==10)
  1268.     {
  1269.       nl();
  1270.       chars_this_line=0;
  1271.       char_printed=0;
  1272.       ++numl;
  1273.     }
  1274.     else if (chars_this_line > will_fit && ch)
  1275.     {
  1276.       do{
  1277.         ch=finfo[cpos++];
  1278.       }while(ch!='\n' && ch!=0);
  1279.       --cpos;
  1280.     }
  1281.     else if(ch)
  1282.       chars_this_line += outchr_color(ch);
  1283.   }
  1284.  
  1285.   if(extdesc_pos > 0)
  1286.   {
  1287.     int num_extended, lines_left;
  1288.     int lines_printed;
  1289.  
  1290.     lines_left=LinesLeft-numl;
  1291.     num_extended=thisuser.num_extended;
  1292.  
  1293.     if(num_extended<lp_config.show_at_least_extended)
  1294.       num_extended=lp_config.show_at_least_extended;
  1295.  
  1296.     if(num_extended > lines_left)
  1297.       num_extended=lines_left;
  1298.  
  1299.     if(ext_is_on && mask_extended & u->mask)                                    /* description color */
  1300.       lines_printed=print_extended_plus(u->filename, num_extended, -extdesc_pos, config_listing.lp_colors[10], search_rec);
  1301.     else
  1302.       lines_printed=0;
  1303.  
  1304.  
  1305.     if(lines_printed)
  1306.     {
  1307.       numl+=lines_printed;
  1308.  
  1309.       chars_this_line=0;
  1310.       char_printed=0;
  1311.     }
  1312.   }
  1313.  
  1314.  
  1315.   if(WhereX())
  1316.   {
  1317.     if(char_printed)
  1318.     {
  1319.       nl();
  1320.       ++numl;
  1321.     }
  1322.     else
  1323.       outchr('\r');
  1324.   }
  1325.  
  1326.  
  1327.   temp[0]=0;
  1328.   finfo[0]=0;
  1329.  
  1330.   if(config_listing.lp_options & cfl_date_uploaded)
  1331.   {
  1332.     strcpy(temp,  u->date);
  1333.     justify_string(temp, 8, ' ', JUSTIFY_LEFT);
  1334.     sprintf(element, "|%02dUL Date: %s  ", config_listing.lp_colors[4], temp);
  1335.     strcat(finfo, element);
  1336.   }
  1337.   if(config_listing.lp_options & cfl_upby)
  1338.   {
  1339.     strcpy(temp, u->upby);
  1340.     properize(temp);
  1341.     temp[15]=0;
  1342.  
  1343.     sprintf(element, "|%02dUpby: %s", config_listing.lp_colors[7], temp);
  1344.     strcat(finfo, element);
  1345.   }
  1346.  
  1347.  
  1348.   if(temp[0])
  1349.   {
  1350.     justify_string(finfo, strlen(finfo) + width, ' ', JUSTIFY_RIGHT);
  1351.     outstr_color(finfo);
  1352.     nl();
  1353.     ++numl;
  1354.   }
  1355.  
  1356.   return(numl);
  1357. }
  1358.  
  1359.  
  1360.  
  1361.   
  1362. int load_config_listing(int config)
  1363. {
  1364.   int fh, len;
  1365.   char fname[201];
  1366.   userrec u;
  1367.  
  1368.  
  1369.   unload_config_listing();
  1370.  
  1371.  
  1372.   memset((void *)&config_listing, 0, sizeof(asylum_config));
  1373.  
  1374.   for(fh=0;fh<32;fh++)         /* set default colors to grey */
  1375.     config_listing.lp_colors[fh]=7;
  1376.  
  1377.   /* setup a default set of items already turned on */
  1378.   config_listing.lp_options = cfl_fname | cfl_extension | cfl_dloads | cfl_kbytes | cfl_description;
  1379.  
  1380.  
  1381.   if(!config)
  1382.     return 0;
  1383.  
  1384.  
  1385.   sprintf(fname, "%sASYLUM.USR", syscfg.datadir, config);
  1386.  
  1387.   if(exist(fname))
  1388.   {
  1389.     read_user(config, &u);
  1390.     fh=sh_open1(fname, O_RDONLY | O_BINARY);
  1391.  
  1392.     if(fh > 0)
  1393.     {
  1394.       lseek(fh, (long) config * sizeof(asylum_config), SEEK_SET);
  1395.  
  1396.       len = sh_read(fh, (void *) &config_listing, sizeof(asylum_config));
  1397.       fh=sh_close(fh);
  1398.  
  1399.       if(len != sizeof(asylum_config) || strcmpi(config_listing.name, u.name) != 0)
  1400.       {
  1401.         memset(&config_listing, 0, sizeof(config_listing));
  1402.         strcpy(config_listing.name, u.name);
  1403.         return 0;
  1404.       }
  1405.  
  1406.       list_loaded=config;
  1407.       extended_desc_used = config_listing.lp_options & cfl_description;
  1408.  
  1409.       /* force filename to be shown */
  1410.       config_listing.lp_options |= cfl_fname;
  1411.       /* force description to be turned on too */
  1412.       config_listing.lp_options |= cfl_description;
  1413.  
  1414.       return 1;
  1415.     }
  1416.   }
  1417.   return 0;
  1418. }
  1419.  
  1420. void write_config_listing(int config)
  1421. {
  1422.   int fh;
  1423.   char fname[201];
  1424.   userrec u;
  1425.  
  1426.   if(!config)
  1427.     return;
  1428.  
  1429.   read_user(config, &u);
  1430.   strcpy(config_listing.name, u.name);
  1431.  
  1432.   sprintf(fname, "%sASYLUM.USR", syscfg.datadir);
  1433.  
  1434.   fh=sh_open1(fname, O_RDWR | O_BINARY | O_CREAT);
  1435.   if(!fh)
  1436.     return;
  1437.  
  1438.  
  1439.   /* force filename to be shown */
  1440.   config_listing.lp_options |= cfl_fname;
  1441.   /* force description to be turned on too */
  1442.   config_listing.lp_options |= cfl_description;
  1443.  
  1444.  
  1445.   lseek(fh, (long)config * (long) sizeof(asylum_config), SEEK_SET);
  1446.   sh_write(fh, (void *) &config_listing, sizeof(asylum_config));
  1447.   fh=sh_close(fh);
  1448. }
  1449.  
  1450.  
  1451. void unload_config_listing(void)
  1452. {
  1453.   list_loaded=0;
  1454.   memset(&config_listing, 0, sizeof(asylum_config));
  1455. }
  1456.  
  1457.  
  1458. int print_extended_plus(char *fn, int numlist, int indent, int color, struct search_record *search_rec)
  1459. {
  1460.   char *ss, *new_ss;
  1461.   unsigned char numl=0;
  1462.   int cpos=0;
  1463.   char ch,s[81];
  1464.   int i;
  1465.   int chars_this_line=0, will_fit;
  1466.   int strip_pos, temp_char;
  1467.  
  1468.   will_fit=80-abs(indent)-2;
  1469.  
  1470.   ss=READ_EXTENDED_DESCRIPTION(fn);
  1471.  
  1472.   if(!ss)
  1473.     return 0;
  1474.  
  1475.  
  1476.   strip_pos=strlen(ss);
  1477.   --strip_pos;
  1478.  
  1479.   while(ss[strip_pos] && strip_pos)
  1480.   {
  1481.     temp_char=ss[strip_pos];
  1482.  
  1483.     if(isspace(temp_char))
  1484.       ss[strip_pos]=0;
  1485.     else
  1486.       break;
  1487.  
  1488.     --strip_pos;
  1489.   }
  1490.  
  1491.  
  1492.   if(ss)
  1493.   {
  1494.     i=strlen(ss);
  1495.  
  1496.     if(i>MAX_EXTENDED_SIZE)
  1497.     {
  1498.       i=MAX_EXTENDED_SIZE;
  1499.       ss[i]=0;
  1500.     }
  1501.  
  1502.     new_ss=(char *)malloca((i*4)+30);
  1503.  
  1504.     if (new_ss)
  1505.     {
  1506.       strcpy(new_ss, ss);
  1507.  
  1508.       if(search_rec)
  1509.         colorize_foundtext(new_ss, search_rec, color);
  1510.  
  1511.       if(indent > -1)
  1512.         npr_color("  1Extended Description:\n\r");
  1513.  
  1514.       ch=10;
  1515.  
  1516.       while ((new_ss[cpos]) && (numl<numlist) && !hangup)
  1517.       {
  1518.  
  1519.         if ((ch==10) && (indent))
  1520.         {
  1521.           sprintf(s,"\x1b[%dC", abs(indent));
  1522.  
  1523.           setc(color);
  1524.           outchr('\r');
  1525.           outstr(s);
  1526.         }
  1527.  
  1528.         do{
  1529.           ch=new_ss[cpos++];
  1530.         }while(ch=='\r' && !hangup);
  1531.  
  1532.         if (ch==10)
  1533.         {
  1534.           nl();
  1535.           chars_this_line=0;
  1536.           ++numl;
  1537.         }
  1538.         else if (chars_this_line > will_fit)
  1539.         {
  1540.           do
  1541.           {
  1542.             ch=new_ss[cpos++];
  1543.           }while(ch!='\n' && ch!=0);
  1544.           --cpos;
  1545.         }
  1546.         else
  1547.           chars_this_line += outchr_color(ch);
  1548.       }
  1549.  
  1550.       if(WhereX())
  1551.       {
  1552.         nl();
  1553.         ++numl;
  1554.       }
  1555.  
  1556.       bbsfree(new_ss);
  1557.       bbsfree(ss);
  1558.     }
  1559.   }
  1560.   ansic(0);
  1561.   return(numl);
  1562. }
  1563.  
  1564.  
  1565. void show_fileinfo(uploadsrec *u)
  1566. {
  1567.   
  1568.   CLS();
  1569.   
  1570.   ansic(7);
  1571.   repeat_char('═', 78);
  1572.   nl();
  1573.  
  1574.   npr("  1File info  : 5%s", u->filename);
  1575.   nl();
  1576.  
  1577.   npr("  1Description: 5%s", u->description);
  1578.   nl();
  1579.   npr("  1Uploaded on: 5%s", u->date);
  1580.   nl();
  1581.   npr("  1Uploaded by: 5%s", u->upby);
  1582.   nl();
  1583.   npr("  1Size       : 5%ld", u->numbytes);
  1584.   npr("  1Downloaded : 5%d", u->numdloads);
  1585.   nl();
  1586.   nl();
  1587.   print_extended_plus(u->filename,255, 27, LIGHTCYAN, NULL);
  1588.  
  1589.   ansic(7);
  1590.   repeat_char('═', 78);
  1591.   nl();
  1592.   
  1593.   pausescr();
  1594. }
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600. int check_lines_needed(uploadsrec *u)
  1601. {
  1602.   char *ss, *tmp;
  1603.   int elines = 0;
  1604.   int max_extended, max_lines, num_extended;
  1605.  
  1606.  
  1607.   lc_lines_used = lp_configured_lines();
  1608.  
  1609.  
  1610.   max_lines = calc_max_lines();
  1611.   num_extended=thisuser.num_extended;
  1612.  
  1613.   if(num_extended<lp_config.show_at_least_extended)
  1614.     num_extended=lp_config.show_at_least_extended;
  1615.  
  1616.   if(max_lines > num_extended)
  1617.     max_lines = num_extended;
  1618.  
  1619.   if(extended_desc_used)    /* if extended description is used */
  1620.   {
  1621.     max_extended=thisuser.num_extended;
  1622.  
  1623.     if(max_extended<lp_config.show_at_least_extended)
  1624.       max_extended=lp_config.show_at_least_extended;
  1625.  
  1626.     if(ext_is_on && mask_extended & u->mask)    /* only try to read an extended */
  1627.       ss=READ_EXTENDED_DESCRIPTION(u->filename);/* description if it claims to  */
  1628.     else                                        /* have on in the first place   */
  1629.       ss=NULL;
  1630.  
  1631.     if(ss)
  1632.     {
  1633.       tmp = ss;
  1634.  
  1635.       while((elines < max_extended) && ((tmp = strchr(tmp, '\r')) != NULL))
  1636.       {
  1637.         ++elines;
  1638.         ++tmp;
  1639.       }
  1640.       bbsfree(ss);
  1641.     }
  1642.   }
  1643.  
  1644.   if(lc_lines_used + elines > max_lines)
  1645.     return(max_lines-1);
  1646.  
  1647.   return(lc_lines_used + elines);
  1648. }
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655. typedef struct {
  1656.   char name[13];
  1657.   long offset;           /* of ext_desc_type */
  1658. } ext_desc_rec;
  1659.  
  1660.  
  1661.  
  1662. static int ed_num;
  1663. static ext_desc_rec *ed_info;
  1664.  
  1665.  
  1666. static char last_edlfn[131];
  1667. static int ext_file;
  1668.  
  1669. char *lp_read_extended_description(char *fn)
  1670. {
  1671.   ext_desc_type ed;
  1672.   long l,l1;
  1673.   char *ss=NULL;
  1674.   int i;
  1675.  
  1676.   lp_get_ed_info();
  1677.  
  1678.   if(ed_info && ext_file > 0)
  1679.   {
  1680.     for (i=0; i<ed_num; i++)
  1681.     {
  1682.       if (strcmp(fn, ed_info[i].name)==0)
  1683.       {
  1684.         sh_lseek(ext_file, ed_info[i].offset, SEEK_SET);
  1685.         l=sh_read(ext_file, &ed, sizeof(ext_desc_type));
  1686.  
  1687.         if ((l==sizeof(ext_desc_type)) && (strcmp(fn, ed.name)==0))
  1688.         {
  1689.           ss=malloca((long) ed.len+10);
  1690.           if (ss) {
  1691.             sh_read(ext_file,ss,ed.len);
  1692.             ss[ed.len]=0;
  1693.           }
  1694.           return(ss);
  1695.         }
  1696.         else
  1697.           break;
  1698.       }
  1699.     }
  1700.   }
  1701.  
  1702.   return(NULL);
  1703. }
  1704.  
  1705. void lp_zap_ed_info(void)
  1706. {
  1707.   if (ed_info) {
  1708.     bbsfree(ed_info);
  1709.     ed_info = NULL;
  1710.   }
  1711.  
  1712.   if(ext_file > 0)
  1713.     ext_file = sh_close(ext_file);
  1714.  
  1715.   ext_file = -1;
  1716.  
  1717.   last_edlfn[0] = 0;
  1718.  
  1719.   ed_num=0;
  1720. }
  1721.  
  1722. void lp_get_ed_info(void)
  1723. {
  1724.   long l,l1;
  1725.   ext_desc_type ed;
  1726.  
  1727.  
  1728.   if(strcmp(last_edlfn, edlfn) != 0)
  1729.   {
  1730.     lp_zap_ed_info();
  1731.  
  1732.     strcpy(last_edlfn, edlfn);
  1733.  
  1734.     if (!numf)
  1735.       return;
  1736.  
  1737.     l=0;
  1738.  
  1739.     ext_file=sh_open1(edlfn,O_RDONLY | O_BINARY);
  1740.  
  1741.     if (ext_file>0)
  1742.     {
  1743.       l1=filelength(ext_file);
  1744.       if (l1>0)
  1745.       {
  1746.         ed_info=malloca((long)numf*sizeof(ext_desc_rec));
  1747.         if (ed_info==NULL)
  1748.         {
  1749.           ext_file = sh_close(ext_file);
  1750.           return;
  1751.         }
  1752.         ed_num=0;
  1753.         while ((l<l1) && (ed_num<numf))
  1754.         {
  1755.           sh_lseek(ext_file,l,SEEK_SET);
  1756.           if (sh_read(ext_file,&ed,sizeof(ext_desc_type)) == sizeof(ext_desc_type)) {
  1757.             strcpy(ed_info[ed_num].name,ed.name);
  1758.             ed_info[ed_num].offset=l;
  1759.             l += (long) ed.len + sizeof(ext_desc_type);
  1760.             ed_num++;
  1761.           }
  1762.         } /* while l < l1 */
  1763.       }   /* if l1 > 0    */
  1764.     }  /* if ext_file > 0 */
  1765.   }    /* if the strings do not match */
  1766. }
  1767.  
  1768.  
  1769.  
  1770.  
  1771. void prep_menu_items(char **menu_items)
  1772. {
  1773.   strcpy(menu_items[0], "Next");
  1774.   strcpy(menu_items[1], "Prev");
  1775.   strcpy(menu_items[2], "Tag");
  1776.   strcpy(menu_items[3], "Info");
  1777.   strcpy(menu_items[4], "View");
  1778.  
  1779.   if(using_modem!=0)
  1780.     strcpy(menu_items[5], "Download");
  1781.   else
  1782.     strcpy(menu_items[5], "Move");
  1783.  
  1784.   strcpy(menu_items[6], "+Dir");
  1785.   strcpy(menu_items[7], "-Dir");
  1786.   strcpy(menu_items[8], "FDIZ");
  1787.   strcpy(menu_items[9], "Quit");
  1788.   strcpy(menu_items[10], "?");
  1789.   if(so())
  1790.   {
  1791.     strcpy(menu_items[11], "Sysop");
  1792.     menu_items[13][0]=0;
  1793.   }
  1794.   else
  1795.     menu_items[12][0]=0;
  1796. }
  1797.  
  1798. int prep_search_rec(struct search_record *search_rec, int type)
  1799. {
  1800.   memset(search_rec, 0, sizeof(struct search_record));
  1801.   search_rec->search_extended=lp_config.search_extended_on;
  1802.  
  1803.   if(type==LIST_DIR)  // Regular listfile
  1804.   {
  1805.     file_mask(search_rec->filemask);
  1806.     search_rec->alldirs=THIS_DIR;
  1807.   }
  1808.   else if(type==SEARCH_ALL) // Search file
  1809.   {
  1810.     search_rec->alldirs=ALL_DIRS;
  1811.     if(!search_criteria(search_rec))
  1812.       return 0;
  1813.   }
  1814.   else if(type==NSCAN_DIR) // new files
  1815.   {
  1816.     search_rec->alldirs=THIS_DIR;
  1817.     search_rec->nscandate=nscandate;
  1818.   }
  1819.   else if(type==NSCAN_NSCAN) // New scan of dirs in NSCAN
  1820.   {
  1821. #ifdef JAFO22
  1822.     newfscan=1;
  1823. #endif
  1824.     search_rec->nscandate=nscandate;
  1825.     search_rec->alldirs=ALL_DIRS;
  1826.   }
  1827.   else
  1828.   {
  1829.     sysoplog("Undef LP type");
  1830.     return 0;
  1831.   }
  1832.  
  1833.  
  1834.   if(!search_rec->filemask[0] && !search_rec->nscandate && !search_rec->search[0])
  1835.     return 0;
  1836.  
  1837.  
  1838.   if(search_rec->filemask[0])
  1839.   {
  1840.     if (strchr(search_rec->filemask,'.')==NULL)
  1841.       strcat(search_rec->filemask,".*");
  1842.   }
  1843.   align(search_rec->filemask);
  1844.  
  1845.   return 1;
  1846. }
  1847.  
  1848.  
  1849. int calc_max_lines(void)
  1850. {
  1851.   int max_lines;
  1852.  
  1853.  
  1854.   if(lp_config.max_screen_lines_to_show)
  1855.   {
  1856.     max_lines = thisuser.screenlines-(first_file_pos()+1+STOP_LIST)
  1857.                       >
  1858.             lp_config.max_screen_lines_to_show-(first_file_pos()+1+STOP_LIST)
  1859.                       ?
  1860.             lp_config.max_screen_lines_to_show-(first_file_pos()+1+STOP_LIST)
  1861.                       :
  1862.             thisuser.screenlines-(first_file_pos()+1+STOP_LIST);
  1863.   }
  1864.   else
  1865.     max_lines = thisuser.screenlines-(first_file_pos()+1+STOP_LIST);
  1866.  
  1867.   return max_lines;
  1868. }
  1869.  
  1870.  
  1871.  
  1872. void sysop_configure(void)
  1873. {
  1874.   int key, done=0, color;
  1875.   char s[201];
  1876.  
  1877.   if(!so())
  1878.     return;
  1879.  
  1880.   load_lp_config();
  1881.  
  1882.  
  1883.  
  1884.   while(!done && !hangup)
  1885.   {
  1886.  
  1887.     CLS();
  1888.     printfile("LPSYSOP");
  1889.  
  1890.     GOTO_XY(38, 2);
  1891.     setc(lp_config.normal_highlight);
  1892.     npr("%3d", lp_config.normal_highlight);
  1893.  
  1894.     GOTO_XY(77, 2);
  1895.     setc(lp_config.normal_menu_item);
  1896.     npr("%3d", lp_config.normal_menu_item);
  1897.  
  1898.     GOTO_XY(38, 3);
  1899.     setc(lp_config.current_highlight);
  1900.     npr("%3d", lp_config.current_highlight);
  1901.  
  1902.     GOTO_XY(77, 3);
  1903.     setc(lp_config.current_menu_item);
  1904.     npr("%3d", lp_config.current_menu_item);
  1905.  
  1906.     ansic(0);
  1907.  
  1908.     GOTO_XY(38, 6);
  1909.     npr_color("|%2d%2d", lp_config.tagged_color, lp_config.tagged_color);
  1910.  
  1911.     GOTO_XY(77, 6);
  1912.     npr_color("|%2d%2d", lp_config.file_num_color, lp_config.file_num_color);
  1913.  
  1914.     GOTO_XY(38, 7);
  1915.     npr_color("|%2d%2d", lp_config.found_fore_color, lp_config.found_fore_color);
  1916.  
  1917.     GOTO_XY(77, 7);
  1918.     npr_color("|%2d%2d", lp_config.found_back_color, lp_config.found_back_color);
  1919.  
  1920.     GOTO_XY(38, 8);
  1921.     setc(lp_config.current_file_color);
  1922.     npr_color("%3d", lp_config.current_file_color);
  1923.  
  1924.  
  1925.     GOTO_XY(38, 11);
  1926.     ansic(4);
  1927.     npr("%2d", lp_config.max_screen_lines_to_show);
  1928.  
  1929.     GOTO_XY(77, 11);
  1930.     ansic(4);
  1931.     npr("%2d", lp_config.show_at_least_extended);
  1932.  
  1933.     GOTO_XY(29, 14);
  1934.     ansic(4);
  1935.     npr("%s", lp_config.check_exist ? _on_ : _off_);
  1936.  
  1937.     GOTO_XY(74, 14);
  1938.     ansic(4);
  1939.     npr("%s", lp_config.request_file ? _on_ : _off_);
  1940.  
  1941.     GOTO_XY(29, 15);
  1942.     ansic(4);
  1943.     npr("%s", lp_config.colorize_found_text ? _on_ : _off_);
  1944.  
  1945.     GOTO_XY(74, 15);
  1946.     ansic(4);
  1947.     npr("%s", lp_config.search_extended_on ? _on_ : _off_);
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.     ansic(0);
  1954.  
  1955.     GOTO_XY(1, 19);
  1956.  
  1957.     ansic(1);
  1958.     outstr("Q-Quit ");
  1959.     mpl(1);
  1960.     key=onek("Q\rABCDEFGHIJKMNOS");
  1961.  
  1962.     switch(key)
  1963.     {
  1964.       case 'Q':
  1965.       case '\r':
  1966.         done=1;
  1967.         break;
  1968.  
  1969.  
  1970.       case 'A':
  1971.       case 'B':
  1972.       case 'C':
  1973.       case 'D':
  1974.       case 'I':
  1975.         color=SelectColor(2);
  1976.         if(color>=0)
  1977.         {
  1978.           switch(key)
  1979.           {
  1980.             case 'A':
  1981.               lp_config.normal_highlight=color;
  1982.               break;
  1983.               
  1984.             case 'B':
  1985.               lp_config.normal_menu_item=color;
  1986.               break;
  1987.  
  1988.             case 'C':
  1989.               lp_config.current_highlight=color;
  1990.               break;
  1991.  
  1992.             case 'D':
  1993.               lp_config.current_menu_item=color;
  1994.               break;
  1995.  
  1996.             case 'I':
  1997.               lp_config.current_file_color=color;
  1998.               break;
  1999.           }
  2000.         }
  2001.         break;
  2002.  
  2003.       case 'E':
  2004.       case 'F':
  2005.       case 'G':
  2006.       case 'H':
  2007.         color=SelectColor(1);
  2008.         if(color>=0)
  2009.         {
  2010.           switch(key)
  2011.           {
  2012.             case 'E':
  2013.               lp_config.tagged_color=color;
  2014.               break;
  2015.               
  2016.             case 'F':
  2017.               lp_config.file_num_color=color;
  2018.               break;
  2019.  
  2020.             case 'G':
  2021.               lp_config.found_fore_color=color;
  2022.               break;
  2023.  
  2024.             case 'H':
  2025.               lp_config.found_back_color=color+16;
  2026.               break;
  2027.           }
  2028.         }
  2029.         break;
  2030.  
  2031.       case 'J':
  2032.         outstr("Enter max amount of lines to show (0=disabled) ");
  2033.         mpl(2);
  2034.         input(s, 2);
  2035.         lp_config.max_screen_lines_to_show=atoi(s);
  2036.         break;
  2037.  
  2038.       case 'K':
  2039.         outstr("Enter minimum extended description lines to show ");
  2040.         mpl(2);
  2041.         input(s, 2);
  2042.         lp_config.show_at_least_extended=atoi(s);
  2043.         break;
  2044.  
  2045.       case 'M':
  2046.         lp_config.request_file=!lp_config.request_file;
  2047.         break;
  2048.  
  2049.  
  2050.       case 'N':
  2051.         lp_config.colorize_found_text=!lp_config.colorize_found_text;
  2052.         break;
  2053.  
  2054.       case 'O':
  2055.         lp_config.search_extended_on=!lp_config.search_extended_on;
  2056.         break;
  2057.  
  2058.  
  2059.       case 'S':
  2060.         lp_config.check_exist=!lp_config.check_exist;
  2061.         break;
  2062.  
  2063.     }
  2064.   }
  2065.   save_lp_config();
  2066.   load_lp_config();
  2067. }
  2068.  
  2069.  
  2070. int SelectColor(int which)
  2071. {
  2072.   char ch,nc;
  2073.  
  2074.   helpl=36;
  2075.   nl();
  2076.   
  2077.   if (thisuser.sysstatus & sysstatus_color)
  2078.   {
  2079.     color_list();
  2080.     ansic(0);
  2081.     nl();
  2082.     prt(2, get_string(430));
  2083.     ch=onek("01234567");
  2084.     nc=ch-'0';
  2085.  
  2086.     if(which==2)
  2087.     {
  2088.       prt(2, get_string(431));
  2089.       ch=onek("01234567");
  2090.       nc=nc | ((ch-'0') << 4);
  2091.     }
  2092.   }
  2093.   else
  2094.   {
  2095.     nl();
  2096.     prt(5, get_string(432));
  2097.     if (yn()) {
  2098.       if ((thisuser.bwcolors[1] & 0x70) == 0)
  2099.         nc=0 | ((thisuser.bwcolors[1] & 0x07) << 4);
  2100.       else
  2101.         nc=(thisuser.bwcolors[1] & 0x70);
  2102.     }
  2103.     else
  2104.     {
  2105.       if ((thisuser.bwcolors[1] & 0x70) == 0)
  2106.         nc=0 | (thisuser.bwcolors[1] & 0x07);
  2107.       else
  2108.         nc=((thisuser.bwcolors[1] & 0x70) >> 4);
  2109.     }
  2110.   }
  2111.  
  2112.     prt(5, get_string(434));
  2113.     if (yn())
  2114.       nc |= 0x08;
  2115.  
  2116.   if(which==2)
  2117.   {
  2118.     prt(5, get_string(437));
  2119.     if (yn())
  2120.       nc |= 0x80;
  2121.   }
  2122.  
  2123.   nl();
  2124.   setc(nc);
  2125.   outstr(describe(nc));
  2126.   ansic(0);
  2127.   nl();
  2128.  
  2129.  
  2130.   prt(5, get_string(438));
  2131.   if(yn())
  2132.     return nc;
  2133.   return -1;
  2134. }
  2135. void check_listplus(void)
  2136. {
  2137.   ansic(1);
  2138.   outstr("Use listplus file tagging? ");
  2139.  
  2140.   if(ny())
  2141.   {
  2142.     if(thisuser.sysstatus & sysstatus_listplus) /* ! sysstatus_list means */
  2143.       thisuser.sysstatus -= sysstatus_listplus; /* to use it              */
  2144.   }
  2145.   else
  2146.   {
  2147.     if(!(thisuser.sysstatus & sysstatus_listplus))
  2148.       thisuser.sysstatus += sysstatus_listplus;
  2149.   }
  2150.  
  2151. }
  2152. void config_file_list(void)
  2153. {
  2154.   int key, done=0, which = -1;
  2155.   unsigned long bit;
  2156.   char action[51];
  2157.   uploadsrec u;
  2158.  
  2159.   strcpy(u.filename, "ASYLUM.ZIP");
  2160.   strcpy(u.description, "The Asylum Group at its simply Best!");
  2161.   strcpy(u.date, "01/01/94");
  2162.   strcpy(u.upby, "Zu Digital");
  2163.   u.numdloads=105;
  2164.   u.numbytes=150000L;
  2165.   u.daten = time(NULL) - 10000;
  2166.  
  2167.  
  2168.  
  2169.  
  2170.   load_lp_config();
  2171.  
  2172.   if(usernum!=list_loaded)          /* if there isn't one of this user    */
  2173.     if(!load_config_listing(usernum))  /* then load the sysops, and let them */
  2174.       load_config_listing(1);          /* edit from there                    */
  2175.  
  2176.  
  2177.   CLS();
  2178.   printfile("LPCONFIG");
  2179.  
  2180.   /* force filename to be shown */
  2181.   if(!config_listing.lp_options & cfl_fname)
  2182.     config_listing.lp_options |= cfl_fname;
  2183.  
  2184.   /* description too */
  2185.   if(!config_listing.lp_options & cfl_description)
  2186.     config_listing.lp_options |= cfl_description;
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.   action[0]=0;
  2193.   while(!done && !hangup)
  2194.   {
  2195.     update_user_config_screen(&u, which);
  2196.     
  2197.     key=onek("Q2346789H!@#$%^&*(");  /* removed '1' and '5' */
  2198.  
  2199.  
  2200.     switch(key)
  2201.     {
  2202.       /* case '1': */
  2203.       case '2':
  2204.       case '3':
  2205.       case '4':
  2206.       /* case '5': */
  2207.       case '6':
  2208.       case '7':
  2209.       case '8':
  2210.       case '9':
  2211.       case 'H':
  2212.         switch(key)
  2213.         {
  2214.           /* case '1': bit = cfl_fname;          which = 1;  break; */
  2215.           case '2': bit = cfl_extension;      which = 2;  break;
  2216.           case '3': bit = cfl_dloads;         which = 3;  break;
  2217.           case '4': bit = cfl_kbytes;         which = 4;  break;
  2218.           /* case '5': bit = cfl_description;    which = 5;  break; */
  2219.           case '6': bit = cfl_date_uploaded;  which = 6;  break;
  2220.           case '7': bit = cfl_file_points;    which = 7;  break;
  2221.           case '8': bit = cfl_days_old;       which = 8;  break;
  2222.           case '9': bit = cfl_upby;           which = 9;  break;
  2223.           case 'H': bit = cfl_header;         which = 10; break;
  2224.         }
  2225.  
  2226.         if(config_listing.lp_options & bit)
  2227.           config_listing.lp_options &= ~bit;
  2228.         else
  2229.           config_listing.lp_options |= bit;
  2230.         break;
  2231.  
  2232.       case '!':
  2233.       case '@':
  2234.       case '#':
  2235.       case '$':
  2236.       case '%':
  2237.       case '^':
  2238.       case '&':
  2239.       case '*':
  2240.       case '(':
  2241.         switch(key)
  2242.         {
  2243.           case '!': bit = 0;  which = 1; break;
  2244.           case '@': bit = 1;  which = 2; break;
  2245.           case '#': bit = 2;  which = 3; break;
  2246.           case '$': bit = 3;  which = 4; break;
  2247.           case '%': bit = 10; which = 5; break;
  2248.           case '^': bit = 4;  which = 6; break;
  2249.           case '&': bit = 5;  which = 7; break;
  2250.           case '*': bit = 6;  which = 8; break;
  2251.           case '(': bit = 7;  which = 9; break;
  2252.         }
  2253.  
  2254.         ++config_listing.lp_colors[bit];
  2255.         if(config_listing.lp_colors[bit] > 15)
  2256.           config_listing.lp_colors[bit]=1;
  2257.         break;
  2258.  
  2259.       case 'Q':
  2260.         done = 1;
  2261.         break;
  2262.     }
  2263.  
  2264.   }
  2265.   list_loaded = usernum;
  2266.   write_config_listing(usernum);
  2267.   nln(4);
  2268. }
  2269.  
  2270.  
  2271. void update_user_config_screen(uploadsrec *u, int which)
  2272. {
  2273.   int space;
  2274.   struct search_record sr;
  2275.  
  2276.   memset(&sr, 0, sizeof(struct search_record));
  2277.  
  2278.   if(which < 1 || which == 1)
  2279.   {
  2280.     GOTO_XY(37, 4);
  2281.     setc(config_listing.lp_options & cfl_fname ? RED + (BLUE <<4) : BLACK + (BLUE <<4));
  2282.     npr("■ ");
  2283.     setc(BLACK+(BLUE<<4));
  2284.     outstr(lp_color_list[config_listing.lp_colors[0]]);
  2285.   }
  2286.  
  2287.   if(which < 1 || which == 2)
  2288.   {
  2289.     GOTO_XY(37, 5);
  2290.     setc(config_listing.lp_options & cfl_extension ? RED + (BLUE <<4) : BLACK + (BLUE <<4));
  2291.     npr("■ ");
  2292.     setc(BLACK+(BLUE<<4));
  2293.     outstr(lp_color_list[config_listing.lp_colors[1]]);
  2294.   }
  2295.  
  2296.   if(which < 1 || which == 3)
  2297.   {
  2298.     GOTO_XY(37, 6);
  2299.     setc(config_listing.lp_options & cfl_dloads ? RED + (BLUE <<4) : BLACK + (BLUE <<4));
  2300.     npr("■ ");
  2301.     setc(BLACK+(BLUE<<4));
  2302.     outstr(lp_color_list[config_listing.lp_colors[2]]);
  2303.   }
  2304.  
  2305.   if(which < 1 || which == 4)
  2306.   {
  2307.     GOTO_XY(37, 7);
  2308.     setc(config_listing.lp_options & cfl_kbytes ? RED + (BLUE <<4) : BLACK + (BLUE <<4));
  2309.     npr("■ ");
  2310.     setc(BLACK+(BLUE<<4));
  2311.     outstr(lp_color_list[config_listing.lp_colors[3]]);
  2312.   }
  2313.  
  2314.   if(which < 1 || which == 5)
  2315.   {
  2316.     GOTO_XY(37, 8);
  2317.     setc(config_listing.lp_options & cfl_description ? RED + (BLUE <<4) : BLACK + (BLUE <<4));
  2318.     npr("■ ");
  2319.     setc(BLACK+(BLUE<<4));
  2320.     outstr(lp_color_list[config_listing.lp_colors[10]]);
  2321.   }
  2322.  
  2323.   if(which < 1 || which == 6)
  2324.   {
  2325.     GOTO_XY(37, 9);
  2326.     setc(config_listing.lp_options & cfl_date_uploaded ? RED + (BLUE <<4) : BLACK + (BLUE <<4));
  2327.     npr("■ ");
  2328.     setc(BLACK+(BLUE<<4));
  2329.     outstr(lp_color_list[config_listing.lp_colors[4]]);
  2330.   }
  2331.  
  2332.   if(which < 1 || which == 7)
  2333.   {
  2334.     GOTO_XY(37, 10);
  2335.     setc(config_listing.lp_options & cfl_file_points ? RED + (BLUE <<4) : BLACK + (BLUE <<4));
  2336.     npr("■ ");
  2337.     setc(BLACK+(BLUE<<4));
  2338.     outstr(lp_color_list[config_listing.lp_colors[5]]);
  2339.   }
  2340.  
  2341.   if(which < 1 || which == 8)
  2342.   {
  2343.     GOTO_XY(37, 11);
  2344.     setc(config_listing.lp_options & cfl_days_old ? RED + (BLUE <<4) : BLACK + (BLUE <<4));
  2345.     npr("■ ");
  2346.     setc(BLACK+(BLUE<<4));
  2347.     outstr(lp_color_list[config_listing.lp_colors[6]]);
  2348.   }
  2349.  
  2350.   if(which < 1 || which == 9)
  2351.   {
  2352.     GOTO_XY(37, 12);
  2353.     setc(config_listing.lp_options & cfl_upby ? RED + (BLUE <<4) : BLACK + (BLUE <<4));
  2354.     npr("■ ");
  2355.     setc(BLACK+(BLUE<<4));
  2356.     outstr(lp_color_list[config_listing.lp_colors[7]]);
  2357.   }
  2358.  
  2359.   if(which < 1 || which == 10)
  2360.   {
  2361.     GOTO_XY(37, 13);
  2362.     setc(config_listing.lp_options & cfl_header ? RED + (BLUE <<4) : BLACK + (BLUE <<4));
  2363.     npr("■ ");
  2364.     setc(BLACK+(BLUE<<4));
  2365.   }
  2366.  
  2367.  
  2368.   setc(YELLOW);
  2369.   GOTO_XY(1, 21);
  2370.   EOL();
  2371.   nl();
  2372.   EOL();
  2373.   GOTO_XY(1, 21);
  2374.   printinfo_plus(u, 1, 1, 30, &sr);
  2375.  
  2376.   GOTO_XY(30, 17);
  2377.   setc(YELLOW);
  2378.   backspace();
  2379. }
  2380.  
  2381.  
  2382. int rename_filename(char *fn, int dn)
  2383. {
  2384.   char s[81],s1[81],s2[81],*ss,s3[81],ch;
  2385.   int i,cp,f, ret=1;
  2386.   uploadsrec u;
  2387.  
  2388. #ifdef FAST_EXTENDED_DESCRIPTION
  2389.   lp_zap_ed_info();
  2390. #endif
  2391.  
  2392.  
  2393.   dliscan1(dn);
  2394.  
  2395.   strcpy(s, fn);
  2396.  
  2397.   if (s[0]==0)
  2398.     return ret;
  2399.  
  2400.   if (strchr(s,'.')==NULL)
  2401.     strcat(s,".*");
  2402.   align(s);
  2403.  
  2404.   strcpy(s3,s);
  2405.   i=recno(s);
  2406.   while (i>0)
  2407.   {
  2408.     f=sh_open1(dlfn,O_RDONLY | O_BINARY);
  2409.  
  2410.     if(f < 1)
  2411.       break;
  2412.  
  2413.  
  2414.     cp=i;
  2415.     SETREC(f,i);
  2416.     sh_read(f,(void *)&u,sizeof(uploadsrec));
  2417.     f=sh_close(f);
  2418.     nl();
  2419.     printfileinfo(&u, dn);
  2420.     nl();
  2421.     prt(5,get_string(830));
  2422.     ch=ynq();
  2423.     if (ch=='Q')
  2424.     {
  2425.       ret=0;
  2426.       break;
  2427.     }
  2428.  
  2429.     else if (ch=='N') {
  2430.       i=nrecno(s3,cp);
  2431.       continue;
  2432.     }
  2433.     nl();
  2434.     prt(2,get_string(72));
  2435.     input(s,12);
  2436.         if (!okfn(s))
  2437.       s[0]=0;
  2438.     if (s[0]) {
  2439.       align(s);
  2440.       if(strcmp(s, /* get_string(1310) */ "        .   ")) {
  2441.         strcpy(s1,directories[dn].path);
  2442.         strcpy(s2,s1);
  2443.         strcat(s1,s);
  2444.         if (exist(s1))
  2445.           pl(get_string(831));
  2446.         else {
  2447.           strcat(s2,u.filename);
  2448.           rename(s2,s1);
  2449.           if (exist(s1)) {
  2450.             /* stock read extended only */
  2451.             ss=read_extended_description(u.filename);
  2452.             if (ss) {
  2453.               delete_extended_description(u.filename);
  2454.               add_extended_description(s,ss);
  2455.               bbsfree(ss);
  2456.             }
  2457.             strcpy(u.filename,s);
  2458.           } else
  2459.             pl(get_string(832));
  2460.         }
  2461.       }
  2462.     }
  2463.     nl();
  2464.     pl(get_string(833));
  2465.     prt(2,": ");
  2466.     inputl(s,58);
  2467.     if (s[0]) {
  2468.       strcpy(u.description,s);
  2469.     }
  2470.     /* stock read extended only */
  2471.     ss=read_extended_description(u.filename);
  2472.     nl();
  2473.         nl();
  2474.     prt(5,get_string(834));
  2475.     if (yn()) {
  2476.       nl();
  2477.       if (ss) {
  2478.         prt(5,get_string(835));
  2479.         if (yn()) {
  2480.           bbsfree(ss);
  2481.           delete_extended_description(u.filename);
  2482.                     u.mask &= ~mask_extended;
  2483.         } else {
  2484.           u.mask |= mask_extended;
  2485.           modify_extended_description(&ss,
  2486.             directories[dn].name,u.filename);
  2487.           if (ss) {
  2488.             delete_extended_description(u.filename);
  2489.             add_extended_description(u.filename,ss);
  2490.             bbsfree(ss);
  2491.           }
  2492.         }
  2493.       } else {
  2494.         modify_extended_description(&ss,
  2495.             directories[dn].name,u.filename);
  2496.         if (ss) {
  2497.           add_extended_description(u.filename,ss);
  2498.           bbsfree(ss);
  2499.           u.mask |= mask_extended;
  2500.         } else
  2501.                     u.mask &= ~mask_extended;
  2502.       }
  2503.     } else
  2504.       if (ss) {
  2505.         bbsfree(ss);
  2506.         u.mask |= mask_extended;
  2507.       } else
  2508.                 u.mask &= ~mask_extended;
  2509.     f=sh_open(dlfn,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  2510.     if(f > 0)
  2511.     {
  2512.       SETREC(f,i);
  2513.       sh_write(f,(void *)&u,sizeof(uploadsrec));
  2514.       f=sh_close(f);
  2515.     }
  2516.  
  2517.     i=nrecno(s3,cp);
  2518.   }
  2519.   return ret;
  2520. }
  2521.  
  2522. int remove_filename(char *fn, int dn)
  2523. {
  2524.   int i,i1,rm,abort,rdlp,f, ret=1;
  2525.   char ch,s[81],s1[81];
  2526.   uploadsrec u;
  2527.   userrec uu;
  2528.  
  2529. #ifdef FAST_EXTENDED_DESCRIPTION
  2530.   lp_zap_ed_info();
  2531. #endif
  2532.  
  2533.  
  2534.   dliscan1(dn);
  2535.  
  2536.   strcpy(s, fn);
  2537.  
  2538.   if (s[0]==0) {
  2539.     return ret;
  2540.   }
  2541.   if (strchr(s,'.')==NULL)
  2542.     strcat(s,".*");
  2543.   align(s);
  2544.   i=recno(s);
  2545.   abort=0;
  2546.   while ((!hangup) && (i>0) && (!abort))
  2547.   {
  2548.     f=sh_open1(dlfn,O_RDONLY | O_BINARY);
  2549.     if(f > 0)
  2550.     {
  2551.       SETREC(f,i);
  2552.       sh_read(f,(void *)&u,sizeof(uploadsrec));
  2553.       f=sh_close(f);
  2554.     }
  2555.  
  2556.  
  2557.     if ((dcs()) || ((u.ownersys==0) && (u.ownerusr==usernum))) {
  2558.       nl();
  2559.  
  2560.       printfileinfo(&u, dn);
  2561.       prt(2,get_string(818));
  2562.       ch=ynq();
  2563.       if (ch=='Q')
  2564.       {
  2565.         ret=0;
  2566.         abort=1;
  2567.       }
  2568.       else if (ch=='Y') {
  2569.         rdlp=1;
  2570.         if (dcs()) {
  2571.           prt(5,get_string(819));
  2572.           rm=yn();
  2573.           if (rm && (u.ownersys==0)) {
  2574.             prt(5,get_string(820));
  2575.             rdlp=yn();
  2576.           }
  2577.  
  2578.           if (sysinfo.flags & OP_FLAGS_FAST_SEARCH)
  2579.           {
  2580.             nl();
  2581.             prt(5,get_string(1381));
  2582.             if (yn())
  2583.               modify_database(s,0);
  2584.           }
  2585.  
  2586.         } else {
  2587.           rm=1;
  2588.           modify_database(s,0);
  2589.         }
  2590.         if (rm)
  2591.         {
  2592.           sprintf(s1,"%s%s",directories[dn].path,u.filename);
  2593.           unlink(s1);
  2594.           if ((rdlp) && (u.ownersys==0)) {
  2595.             read_user(u.ownerusr,&uu);
  2596.             if ((uu.inact & inact_deleted)==0) {
  2597.               if (date_to_daten(uu.firston) < u.daten) {
  2598.                 --uu.uploaded;
  2599.                 uu.uk -= bytes_to_k(u.numbytes);
  2600. #ifdef FILE_POINTS
  2601.                 if (u.mask & mask_validated)                            
  2602.                   if ((u.filepoints * 2) > uu.filepoints)
  2603.                     uu.filepoints=0;
  2604.                   else                                             
  2605.                     uu.filepoints -= (u.filepoints * 2);           
  2606.                 npr("Removed %u file points\r\n",(u.filepoints * 2));  
  2607. #endif
  2608.                 write_user(u.ownerusr,&uu);
  2609.               }
  2610.             }
  2611.           }
  2612.         }
  2613.         if (u.mask & mask_extended)
  2614.           delete_extended_description(u.filename);
  2615.         sprintf(s1,get_stringx(1,44),u.filename,
  2616.                           directories[dn].name);
  2617.         sysoplog(s1);
  2618.         f=sh_open(dlfn,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  2619.  
  2620.         if(f > 0)
  2621.         {
  2622.           for (i1=i; i1<numf; i1++)
  2623.           {
  2624.             SETREC(f,i1+1);
  2625.             sh_read(f,(void *)&u,sizeof(uploadsrec));
  2626.             SETREC(f,i1);
  2627.             sh_write(f,(void *)&u,sizeof(uploadsrec));
  2628.           }
  2629.           --i;
  2630.           --numf;
  2631.           SETREC(f,0);
  2632.           sh_read(f, &u, sizeof(uploadsrec));
  2633.           u.numbytes=numf;
  2634.           SETREC(f,0);
  2635.           sh_write(f,(void *)&u,sizeof(uploadsrec));
  2636.           f=sh_close(f);
  2637.         }
  2638.       }
  2639.  
  2640.     }
  2641.     i=nrecno(s,i);
  2642.   }
  2643.   return ret;
  2644. }
  2645.  
  2646. int move_filename(char *fn, int dn)
  2647. {
  2648.   char sx[81],s1[81],s2[81],ch,*ss;
  2649.   int i,i1,ok,d1,d2,done,cp,f, ret=1;
  2650.   uploadsrec u,u1;
  2651.  
  2652. #ifdef FAST_EXTENDED_DESCRIPTION
  2653.   lp_zap_ed_info();
  2654. #endif
  2655.  
  2656.  
  2657.  
  2658.   ok=0;
  2659.  
  2660.  
  2661.   strcpy(sx, fn);
  2662.  
  2663.   dliscan1(dn);
  2664.  
  2665.   align(sx);
  2666.  
  2667.   i=recno(sx);
  2668.   if (i<0) {
  2669.     nl();
  2670.     pl(get_string(89));
  2671.     return ret;
  2672.   }
  2673.   done=0;
  2674.  
  2675.   tmp_disable_conf(1);
  2676.  
  2677.   while ((!hangup) && (i>0) && (!done)) {
  2678.     cp=i;
  2679.     f=sh_open1(dlfn,O_RDONLY | O_BINARY);
  2680.     if(f > 0)
  2681.     {
  2682.       SETREC(f,i);
  2683.       sh_read(f,(void *)&u,sizeof(uploadsrec));
  2684.       f=sh_close(f);
  2685.     }
  2686.  
  2687.     nl();
  2688.     printfileinfo(&u, dn);
  2689.     nl();
  2690.     prt(5,get_string(822));
  2691.     ch=ynq();
  2692.     if (ch=='Q')
  2693.     {
  2694.       done=1;
  2695.       ret=0;
  2696.     }
  2697.     else if (ch=='Y')
  2698.     {
  2699.       sprintf(s1,"%s%s",directories[dn].path,u.filename);
  2700.       do
  2701.       {
  2702.         nl();
  2703.         nl();
  2704.         prt(2,get_string(823));
  2705.         ss=mmkey(1);
  2706.         if (ss[0]=='?')
  2707.         {
  2708.           dirlist();
  2709.           dliscan1(dn);
  2710.         }
  2711.       } while ((!hangup) && (ss[0]=='?'));
  2712.  
  2713.       d1=-1;
  2714.  
  2715.       if (ss[0])
  2716.         for (i1=0; (i1<num_dirs) && (udir[i1].subnum!=-1); i1++)
  2717.           if (strcmp(udir[i1].keys,ss)==0)
  2718.             d1=i1;
  2719.       if (d1!=-1) {
  2720.         ok=1;
  2721.         d1=udir[d1].subnum;
  2722.         dliscan1(d1);
  2723.         if (recno(u.filename)>0) {
  2724.           ok=0;
  2725.           nl();
  2726.           pl(get_string(824));
  2727.         }
  2728.         if (numf>=directories[d1].maxfiles) {
  2729.           ok=0;
  2730.           nl();
  2731.           pl(get_string(825));
  2732.         }
  2733.         if (freek1(directories[d1].path)<((double)(u.numbytes/1024L)+3)) {
  2734.           ok=0;
  2735.           nl();
  2736.           pl(get_string(826));
  2737.         }
  2738.         dliscan();
  2739.       } else
  2740.         ok=0;
  2741.     } else
  2742.       ok=0;
  2743.     if (ok && !done) {
  2744.       prt(5,get_string(934));
  2745.       if (yn()) {
  2746.         time((long *)&u.daten);
  2747.       }
  2748.  
  2749.       --cp;
  2750.       f=sh_open(dlfn,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  2751.  
  2752.       if(f > 0)
  2753.       {
  2754.         for (i1=i; i1<numf; i1++) {
  2755.           SETREC(f,i1+1);
  2756.           sh_read(f,(void *)&u1,sizeof(uploadsrec));
  2757.           SETREC(f,i1);
  2758.           sh_write(f,(void *)&u1,sizeof(uploadsrec));
  2759.         }
  2760.         --numf;
  2761.         SETREC(f,0);
  2762.         sh_read(f, &u1, sizeof(uploadsrec));
  2763.         u1.numbytes=numf;
  2764.         SETREC(f,0);
  2765.         sh_write(f,(void *)&u1,sizeof(uploadsrec));
  2766.         f=sh_close(f);
  2767.       }
  2768.  
  2769.  
  2770.       /* stock read extended only */
  2771.       ss=read_extended_description(u.filename);
  2772.       if (ss)
  2773.         delete_extended_description(u.filename);
  2774.  
  2775.       sprintf(s2,"%s%s",directories[d1].path,u.filename);
  2776.       dliscan1(d1);
  2777.       f=sh_open(dlfn,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  2778.       if(f > 0)
  2779.       {
  2780.         for (i=numf; i>=1; i--) {
  2781.           SETREC(f,i);
  2782.           sh_read(f,(void *)&u1,sizeof(uploadsrec));
  2783.           SETREC(f,i+1);
  2784.           sh_write(f,(void *)&u1,sizeof(uploadsrec));
  2785.         }
  2786.         SETREC(f,1);
  2787.         sh_write(f,(void *)&u,sizeof(uploadsrec));
  2788.         ++numf;
  2789.         SETREC(f,0);
  2790.         sh_read(f, &u1, sizeof(uploadsrec));
  2791.         u1.numbytes=numf;
  2792.         if (u.daten>u1.daten) {
  2793.           u1.daten = u.daten;
  2794.           dir_dates[d1]=u.daten;
  2795.         }
  2796.         SETREC(f,0);
  2797.         sh_write(f,(void *)&u1,sizeof(uploadsrec));
  2798.         f=sh_close(f);
  2799.       }
  2800.  
  2801.  
  2802.       if (ss) {
  2803.         add_extended_description(u.filename,ss);
  2804.         bbsfree(ss);
  2805.       }
  2806.  
  2807.       if ((strcmp(s1,s2)!=0) && (exist(s1))) {
  2808.         d2=0;
  2809.         if ((s1[1]!=':') && (s2[1]!=':'))
  2810.           d2=1;
  2811.         if ((s1[1]==':') && (s2[1]==':') && (s1[0]==s2[0]))
  2812.           d2=1;
  2813.         if (d2) {
  2814.           rename(s1,s2);
  2815.           unlink(s1);
  2816.         } else {
  2817.           copy_file(s1,s2);
  2818.           unlink(s1);
  2819.         }
  2820.       }
  2821.       nl();
  2822.       pl(get_string(827));
  2823.     }
  2824.     dliscan();
  2825.     i=nrecno(sx,cp);
  2826.   }
  2827.  
  2828.   tmp_disable_conf(0);
  2829.  
  2830.   return ret;
  2831. }
  2832.  
  2833. void do_batch_sysop_command(int mode, char *filename)
  2834. {
  2835.   int save_curdir=curdir;
  2836.   int pos=0, done=0;
  2837.  
  2838.   CLS();
  2839.  
  2840.   if(numbatchdl)
  2841.   {
  2842.     while(pos<numbatch && !done)
  2843.     {
  2844.       if(batch[pos].sending)
  2845.       {
  2846.         switch(mode)
  2847.         {
  2848.           case SYSOP_DELETE:
  2849.             if(!remove_filename(batch[pos].filename, batch[pos].dir))
  2850.               done=1;
  2851.             else
  2852.               delbatch(pos);
  2853.             break;
  2854.  
  2855.           case SYSOP_RENAME:
  2856.             if(!rename_filename(batch[pos].filename, batch[pos].dir))
  2857.               done=1;
  2858.             else
  2859.               delbatch(pos);
  2860.             break;
  2861.  
  2862.           case SYSOP_MOVE:
  2863.             if(!move_filename(batch[pos].filename, batch[pos].dir))
  2864.               done=1;
  2865.             else
  2866.               delbatch(pos);
  2867.             break;
  2868.         }
  2869.       }
  2870.       else
  2871.         ++pos;
  2872.     }
  2873.   }
  2874.   else  // Just act on the single file
  2875.   {
  2876.     switch(mode)
  2877.     {
  2878.       case SYSOP_DELETE:
  2879.         remove_filename(filename, udir[curdir].subnum);
  2880.         break;
  2881.  
  2882.       case SYSOP_RENAME:
  2883.         rename_filename(filename, udir[curdir].subnum);
  2884.         break;
  2885.  
  2886.       case SYSOP_MOVE:
  2887.         move_filename(filename, udir[curdir].subnum);
  2888.         break;
  2889.     }
  2890.   }
  2891.  
  2892.  
  2893.   curdir=save_curdir;
  2894.   dliscan();
  2895. }
  2896.  
  2897. void smmsm(void)
  2898. {
  2899.   char s[80], date[20];
  2900.   struct tm *time_then;
  2901.   unsigned short un, sy;
  2902.  
  2903.   parse_email_info("1@8421.WWIVNET", &un, &sy);
  2904.   CLS();
  2905.  
  2906.   if(sy)
  2907.   {
  2908.     sprintf(s, "7*ListPlus - 1%s@%d", syscfg.sysopname, net_sysnum);
  2909.     ssm(1, sy, s);
  2910.  
  2911.     time_then=localtime(&lp_config.fi);
  2912.     strftime(date, 20, "%d %b %y", time_then);
  2913.     sprintf(s, "5First setup: 3%s (Sent %ld times)", date, lp_config.sent);
  2914.     ssm(1, sy, s);
  2915.  
  2916.     ++lp_config.sent;
  2917.   }
  2918.   lp_config.lssm=time(NULL);
  2919.   save_lp_config();
  2920. }
  2921.  
  2922. void check_lp_colors(void)
  2923. {
  2924.   int x;
  2925.  
  2926.   for(x=0; x<32; x++)
  2927.   {
  2928.     if(!config_listing.lp_colors[x])
  2929.       config_listing.lp_colors[x]=1;
  2930.   }
  2931. }
  2932.  
  2933.  
  2934.  
  2935. void load_lp_config(void)
  2936. {
  2937.   if(!lp_config_loaded)
  2938.   {
  2939.     char s[201];
  2940.     int f;
  2941.  
  2942.     sprintf(s, "%s%s", syscfg.datadir, "LISTPLUS.CFG");
  2943.     f=sh_open1(s, O_BINARY | O_RDONLY);
  2944.  
  2945.     if(f<1)
  2946.     {
  2947.       memset((void *)&lp_config, 0, sizeof(struct listplus_config));
  2948.       lp_config.fi=lp_config.lssm=time(NULL);
  2949.  
  2950.  
  2951.       lp_config.normal_highlight   = (YELLOW+(BLACK<<4));
  2952.       lp_config.normal_menu_item   = (CYAN+(BLACK<<4));
  2953.       lp_config.current_highlight  = (BLUE+(LIGHTGRAY<<4));
  2954.       lp_config.current_menu_item  = (BLACK+(LIGHTGRAY<<4));
  2955.  
  2956.       lp_config.tagged_color       = LIGHTGRAY;
  2957.       lp_config.file_num_color     = GREEN;
  2958.  
  2959.       lp_config.found_fore_color   = RED;
  2960.       lp_config.found_back_color   = (LIGHTGRAY)+16;
  2961.  
  2962.       lp_config.current_file_color = BLACK+(LIGHTGRAY<<4);
  2963.  
  2964.       lp_config.max_screen_lines_to_show = 24;
  2965.       lp_config.show_at_least_extended   = 5;
  2966.  
  2967.       lp_config.edit_enable         = 1; // Do or don't let users edit there config
  2968.       lp_config.request_file        = 1; // Do or don't use file request
  2969.       lp_config.colorize_found_text = 1; // Do or don't colorize found text
  2970.       lp_config.search_extended_on  = 0; // Defaults to either on or off in adv search, or is either on or off in simple search
  2971.       lp_config.simple_search       = 1; // Which one is entered when searching, can switch to other still
  2972.       lp_config.no_configuration    = 0; // Toggles configurable menus on and off
  2973.       lp_config.check_exist         = 1; // Will check to see if the file exists on hardrive and put N/A if not
  2974.  
  2975.       lp_config_loaded=1;
  2976.       lp_config.forced_config=0;
  2977.  
  2978.  
  2979.       smmsm();
  2980.       save_lp_config();
  2981.     }
  2982.     else
  2983.     {
  2984.       sh_read(f, (void *)&lp_config, sizeof(struct listplus_config));
  2985.       lp_config_loaded=1;
  2986.       f=sh_close(f);
  2987.     }
  2988.   }
  2989.  
  2990.   if(difftime(time(NULL), lp_config.lssm) > (SECONDS_PER_DAY)*90)
  2991.     smmsm();
  2992.  
  2993.   check_lp_colors();
  2994. }
  2995.  
  2996.  
  2997.  
  2998.  
  2999. void save_lp_config(void)
  3000. {
  3001.   if(lp_config_loaded)
  3002.   {
  3003.     char s[201];
  3004.     int f;
  3005.  
  3006.     sprintf(s, "%s%s", syscfg.datadir, "LISTPLUS.CFG");
  3007.     f=sh_open1(s, O_BINARY | O_RDWR | O_CREAT | O_TRUNC);
  3008.  
  3009.     if(f>0)
  3010.     {
  3011.       sh_write(f, (void *)&lp_config, sizeof(struct listplus_config));
  3012.       f=sh_close(f);
  3013.     }
  3014.     if(difftime(time(NULL), lp_config.lssm) > (SECONDS_PER_DAY)*90)
  3015.       smmsm();
  3016.  
  3017.   }
  3018. }
  3019.  
  3020. int search_criteria(struct search_record *sr)
  3021. {
  3022.   int done=0, x;
  3023.   int all_conf=1, useconf;
  3024.  
  3025.   useconf=((uconfsub[1].confnum!=-1) && okconf(&thisuser));
  3026.  
  3027.  
  3028. LP_SEARCH_HELP:
  3029.   sr->search_extended=lp_config.search_extended_on;
  3030.  
  3031.   CLS();
  3032.   existprint("LPSEARCH");
  3033.  
  3034.   while(!done)
  3035.   {
  3036.     GOTO_XY(1, 15);
  3037.     for(x=0; x<9; x++)
  3038.       { GOTO_XY(1, 15+x); EOL(); }
  3039.     GOTO_XY(1, 15);
  3040.  
  3041.     npr_color("|11A)|14 Filename (wildcards) :|02 %s", sr->filemask);
  3042.     nl();
  3043.     npr_color("|11B)|14 Text (no wildcards)  :|02 %s", sr->search);
  3044.     nl();
  3045.     npr_color("|11C)|14 Which dirs to search :|02 %s", sr->alldirs == THIS_DIR ? "Current Dir" : sr->alldirs==ALL_DIRS ? "All dirs" : "Dirs in NSCAN");
  3046.     nl();
  3047.     npr_color("|11D)|14 Conferences to srch  :|02 %s", all_conf ? "All Conferences" : "This Conference");
  3048.     nl();
  3049.     npr_color("|11E)|14 Srch ext description :|02 %s", sr->search_extended ? "Yes" : "No ");
  3050.     nln(2);
  3051.     npr_color("|15Select option or hit |14<CR>|15 to start search |14Q=Quit|15:|07 ");
  3052.  
  3053.     x = onek("QABCDE\r?");
  3054.  
  3055.     switch(x)
  3056.     {
  3057.       case 'A':
  3058.         npr("Enter filespec to search on : ");
  3059.         mpl(13);
  3060.         input(sr->filemask, 13);
  3061.         break;
  3062.  
  3063.       case 'B':
  3064.         npr("Enter text : ");
  3065.         mpl(60);
  3066.         input(sr->search, 60);
  3067.         break;
  3068.  
  3069.       case 'C':
  3070.         ++sr->alldirs;
  3071.         if(sr->alldirs >= 3)
  3072.           sr->alldirs=0;
  3073.         break;
  3074.  
  3075.       case 'D':
  3076.         all_conf = !all_conf;
  3077.         break;
  3078.  
  3079.       case 'E':
  3080.         sr->search_extended = !sr->search_extended;
  3081.         break;
  3082.  
  3083.       case 'Q':
  3084.         return 0;
  3085.  
  3086.       case '\r':
  3087.         done = 1;
  3088.         break;
  3089.  
  3090.       case '?':
  3091.         goto LP_SEARCH_HELP;
  3092.  
  3093.     }
  3094.   }
  3095.  
  3096.   if(sr->search[0]==' ' && sr->search[1]==0)
  3097.     sr->search[0]=0;
  3098.  
  3099.  
  3100.   if(useconf && all_conf)   /* toggle conferences off */
  3101.     tmp_disable_conf(1);
  3102.  
  3103.  
  3104.   return(x);
  3105. }
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111. void load_listing(void)
  3112. {
  3113.   userrec u;
  3114.  
  3115.   if(usernum!=list_loaded)
  3116.     load_config_listing(usernum);
  3117.  
  3118.  
  3119.   if(!list_loaded)
  3120.   {
  3121.     load_config_listing(1);       /* default to what the sysop has */
  3122.     config_file_list();           /* setup, but still take them to */
  3123.   }                               /* config it for themselves      */
  3124.  
  3125.   /* force filename to be shown */
  3126.   if(!config_listing.lp_options & cfl_fname)
  3127.     config_listing.lp_options |= cfl_fname;
  3128. }
  3129.  
  3130.  
  3131.  
  3132. void view_file(char *filename)
  3133. {
  3134.   char command[151];
  3135.   char temp[30];
  3136.   int i,abort,next,i1,file;
  3137.   uploadsrec u;
  3138.  
  3139.   CLS();
  3140.  
  3141.   strcpy(temp, filename);
  3142.   unalign(temp);
  3143.  
  3144.   if(exist("AVIEWCOM.EXE"))
  3145.   {
  3146.     // Remove -d to allow downloads, change options as desired
  3147.     // I use -i -b for irq and base address for multiline compatibility with
  3148.     // the use of non standard comm ports
  3149.     sprintf(command, "AVIEWCOM.EXE %s%s -p%s -a1 -d -i%d -b%x", directories[udir[curdir].subnum].path, temp, syscfgovr.tempdir, async_irq, base);
  3150.     /* Thanks spotnick */
  3151.     extern_prog(command, EFLAG_INTERNAL|EFLAG_SHRINK|EFLAG_COMIO|EFLAG_NOPAUSE);
  3152.   }
  3153.   else
  3154.   {
  3155.     dliscan();
  3156.     abort=0;
  3157.     next=0;
  3158.     i=recno(filename);
  3159.     do {
  3160.       if (i>0) {
  3161.         file=sh_open1(dlfn,O_RDONLY | O_BINARY);
  3162.  
  3163.         if(file > 0)
  3164.         {
  3165.           SETREC(file,i);
  3166.           sh_read(file,(void *)&u,sizeof(uploadsrec));
  3167.  
  3168.           file=sh_close(file);
  3169.         }
  3170.  
  3171.         i1=list_arc_out(stripfn(u.filename),directories[udir[curdir].subnum].path);
  3172.         if (i1)
  3173.           abort=1;
  3174.         checka(&abort,&next);
  3175.         i=nrecno(filename,i);
  3176.       }
  3177.     } while ((i>0) && (!hangup) && (!abort));
  3178.     nl();
  3179.     pausescr();
  3180.   }
  3181. }
  3182.  
  3183.  
  3184.  
  3185. void download_plus(char *file)
  3186. {
  3187.   char s[81];
  3188.   int dn,count,color;
  3189.  
  3190.   if (numbatchdl!=0) {
  3191.     nl();
  3192.     outstr(get_string(1324));
  3193.     if (ny()) {
  3194.       batchdl(1);
  3195.       return;
  3196.     }
  3197.   }
  3198.   strcpy(s, file);
  3199.   if (s[0]==0)
  3200.     return;
  3201.   if (strchr(s,'.')==NULL)
  3202.     strcat(s,".*");
  3203.   align(s);
  3204.   if (try_to_download(s,udir[curdir].subnum,0)==0) {
  3205.     nl();
  3206.     pl(get_string(789));
  3207.     nl();
  3208.     foundany=dn=0;
  3209.     count=0;
  3210.     color=3;
  3211.     if (!x_only)
  3212.       outstr("\r2Searching ");
  3213.     while ((dn<num_dirs) && (udir[dn].subnum!=-1)) {
  3214.       count++;
  3215.       if (!x_only) {
  3216.         npr("%d.",color);
  3217.         if (count==DOTS) {
  3218.           outstr("\r");
  3219.           outstr(get_string(1184));
  3220.           color++;
  3221.           count=0;
  3222.           if (color==4)
  3223.             color++;
  3224.           if (color==10)
  3225.             color=0;
  3226.         }
  3227.       }
  3228.       if (try_to_download(s,udir[dn].subnum,1)<0)
  3229.         break;
  3230.       else
  3231.         dn++;
  3232.     }
  3233.     if (!foundany) {
  3234.       pl(get_string(89));
  3235.       nl();
  3236.     }
  3237.   }
  3238. }
  3239.  
  3240.     
  3241.  
  3242.  
  3243. void request_file(char *filename)
  3244. {
  3245.   char message[101];
  3246.  
  3247.   CLS();
  3248.   nl();
  3249.  
  3250.   printfile("REQPLUS");
  3251.  
  3252.   ansic(2);
  3253.   npr_color("Send Request for file? ");
  3254.  
  3255.   if(ny())
  3256.   {
  3257.     sprintf(message, "%s is requesting file %s", thisuser.name, filename);
  3258.     ssm(1, 0, message);
  3259.     sysoplog(message);
  3260.     pl("File request sent");
  3261.   }
  3262.   else
  3263.     pl("File request NOT sent");
  3264.  
  3265. }
  3266.  
  3267.  
  3268. int ok_listplus(void)
  3269. {
  3270.   if(!okansi())
  3271.     return 0;
  3272.  
  3273. #ifndef FORCE_LP
  3274.   if((thisuser.sysstatus & sysstatus_no_tag))
  3275.     return 0;
  3276.  
  3277.    if((thisuser.sysstatus & sysstatus_listplus))
  3278.      return 0;
  3279.  
  3280.    if(x_only)
  3281.      return 0;
  3282. #endif
  3283.  
  3284.   return 1;
  3285. }
  3286.  
  3287.  
  3288. int compare_criteria(struct search_record *sr, uploadsrec *ur)
  3289. {
  3290.                         /* get_string(1310) */
  3291.   if(strcmp(sr->filemask,  "        .   ") != 0)
  3292.   {
  3293.     if(!compare(sr->filemask, ur->filename))
  3294.       return 0;
  3295.   }
  3296.   /* the above test was passed if it got here */
  3297.  
  3298.  
  3299.   if(sr->nscandate)
  3300.   {
  3301.     if(ur->daten < sr->nscandate)
  3302.       return 0;
  3303.   }
  3304.   /* the above test was passed if it got here */
  3305.  
  3306.  
  3307.  
  3308.   if(sr->search[0])
  3309.   {
  3310.     char *buff=NULL;
  3311.     int desc_len=0, fname_len=0, ext_len=0;
  3312.  
  3313.     /* we want to seach the filename, description and ext description  */
  3314.     /* as one unit, that way, if you specify something like 'one & two */
  3315.     /* and one is located in the description and two is in the         */
  3316.     /* extended description, then it will properly find the search     */
  3317.  
  3318.  
  3319.     if(sr->search_extended && ur->mask & mask_extended)
  3320.       buff=READ_EXTENDED_DESCRIPTION(ur->filename);
  3321.  
  3322.  
  3323.     desc_len=strlen(ur->description);
  3324.  
  3325.     if(buff)
  3326.       ext_len=strlen(buff);
  3327.     fname_len=strlen(ur->filename);
  3328.  
  3329.     buff=(char *)farrealloc((void *)buff, desc_len + ext_len + fname_len + 10);
  3330.     if(!buff)
  3331.       return 0;
  3332.  
  3333.     buff[ext_len] = 0;
  3334.  
  3335.       /* tag the file name and description on to the end of the extended */
  3336.       /* description (if there is one)                                   */
  3337.     strcat(buff, " ");
  3338.     strcat(buff, ur->filename);
  3339.     strcat(buff, " ");
  3340.     strcat(buff, ur->description);
  3341.  
  3342.     if(lp_compare_strings(buff, sr->search))
  3343.     {
  3344.       bbsfree(buff);
  3345.       return 1;
  3346.     }
  3347.     bbsfree(buff);
  3348.  
  3349.     return 0;  /* if we get here, we failed the search test, so exit with 0 */
  3350.  
  3351.   }
  3352.  
  3353.  
  3354.   return 1;  /* this is return 1 becuase the top two tests were passed */
  3355.              /* and we are not searching on text, so it is assume to   */
  3356.              /* have passed the test                                   */
  3357. }
  3358.  
  3359.  
  3360.  
  3361.  
  3362. int lp_compare_strings(char *raw, char *formula)
  3363. {
  3364.   unsigned x = 0;
  3365.   return(lp_compare_strings_wh(raw, formula, &x, strlen(formula)));
  3366. }
  3367.  
  3368. int lp_compare_strings_wh(char *raw, char *formula, unsigned *pos, int size)
  3369. {
  3370.   int lvalue, rvalue, token;
  3371.  
  3372.   lvalue = lp_get_value(raw, formula, pos);
  3373.   while(*pos < size)
  3374.   {
  3375.     token = lp_get_token(formula, pos);
  3376.  
  3377.     switch(token)
  3378.     {
  3379.       case STR_AND:
  3380.         rvalue = lp_compare_strings_wh(raw, formula, pos, size);
  3381.         lvalue = BOOL(lvalue) & BOOL(rvalue);
  3382.         break;
  3383.  
  3384.       case STR_OR:
  3385.         rvalue = lp_compare_strings_wh(raw, formula, pos, size);
  3386.         lvalue = BOOL(lvalue) | BOOL(rvalue);
  3387.         break;
  3388.  
  3389.       case STR_CLOSE_PAREN:
  3390.       case 0:
  3391.         return lvalue;
  3392.  
  3393.       default:
  3394.         return lvalue;
  3395.     }
  3396.   }
  3397.   return(lvalue);
  3398. }
  3399.  
  3400.  
  3401. int lp_get_token(char *formula, unsigned *pos)
  3402. {
  3403.   char temp[101];
  3404.   int tpos=0;
  3405.  
  3406.   while(formula[*pos] && isspace(formula[*pos]))
  3407.     ++*pos;
  3408.  
  3409.   if(isalpha(formula[*pos]))
  3410.   {
  3411.     /* remove isspace to delemit on a by word basis */
  3412.     while(isalnum(formula[*pos]) || isspace(formula[*pos]))
  3413.     {
  3414.       temp[tpos] = formula[*pos];
  3415.       ++tpos;
  3416.       ++*pos;
  3417.     }
  3418.     temp[tpos] = 0;
  3419.   }
  3420.  
  3421.   ++*pos;
  3422.   return(formula[*pos-1]);
  3423. }
  3424.  
  3425. int lp_get_value(char *raw, char *formula, unsigned *pos)
  3426. {
  3427.   char temp[201];
  3428.   int x, done = 0, tpos = 0;
  3429.   int sign=1, started_number=0;
  3430.  
  3431.   while(formula[*pos] && isspace(formula[*pos]))
  3432.     ++*pos;
  3433.  
  3434.   x = formula[*pos];
  3435.  
  3436. OPERATOR_CHECK_1:
  3437.   switch(x)
  3438.   {
  3439.     case STR_NOT:
  3440.       sign = !sign;
  3441.       ++*pos;
  3442.       if(formula[*pos])
  3443.       {
  3444.         x = formula[*pos];
  3445.         goto OPERATOR_CHECK_1;
  3446.       }
  3447.       return 0;
  3448.  
  3449.     case STR_AND:
  3450.     case STR_OR:
  3451.       return 0;
  3452.   }
  3453.  
  3454.   switch(x)
  3455.   {
  3456.     int temp;
  3457.  
  3458.     case STR_OPEN_PAREN:
  3459.       ++*pos;
  3460.       temp = lp_compare_strings_wh(raw, formula, pos, strlen(formula));
  3461.       if(temp)
  3462.         return(sign ? 1 : 0);
  3463.       else
  3464.         return(sign ? 0 : 1);
  3465.   }
  3466.  
  3467.  
  3468.   while(!done && formula[*pos])
  3469.   {
  3470.     x = formula[*pos];
  3471.  
  3472.     switch(x)
  3473.     {
  3474.       case STR_NOT:
  3475.         if(started_number)
  3476.           { done = 1; break; }
  3477.  
  3478.         sign = !sign;
  3479.         ++*pos;
  3480.         continue;
  3481.  
  3482.       case STR_AND:
  3483.       case STR_OR:
  3484.       case STR_OPEN_PAREN:
  3485.       case STR_CLOSE_PAREN:
  3486.         { done = 1; break; }
  3487.  
  3488.  
  3489.       default:
  3490.         started_number = 1;
  3491.         temp[tpos] = x;
  3492.         ++tpos;
  3493.         ++*pos;
  3494.         break;
  3495.     }
  3496.   }
  3497.   temp[tpos] = 0;
  3498.   strip_string(temp);
  3499.  
  3500.   if(strstr_nocase(raw, temp))
  3501.     return(sign ? 1 : 0);
  3502.   else
  3503.     return(sign ? 0 : 1);
  3504. }
  3505.  
  3506.  
  3507.