home *** CD-ROM | disk | FTP | other *** search
/ The Arcade BBS / arcadebbs.zip / arcadebbs / bbstools / MODS / ALLMODS.ZIP / FMD-41A.ZIP / FMD-41A.MOD < prev   
Encoding:
Text File  |  1995-06-22  |  14.6 KB  |  438 lines

  1. Nicolas Leblanc #2 @20302
  2. Sun Jun 18 23:43:15 1995
  3.    ┌┬─── ──  ─   ─  ── ───────────────────────────────────────────────────┬─ ∙∙
  4.    ││                    Alternative Worlds Presents                      │
  5.    └┼─────────────────────────────────────────────────────────────────────┐
  6.    ││ Mod Name       » FMD-41a.MOD                                        │∙
  7.    ││ Difficulty     » ███▒▒▒▒▒▒▒▒ (3/10)                                 │:
  8.    ││ WWIV Version   » 4.24                                               ││
  9.    ││ Date Affected  » 06/01/95                                           ││
  10.    :│ Files Affected » BBS.C / BBSOVL1.C / VARS.H / VARDEC.H              ││
  11.    ∙│ Description    » Time Window Modification                           ││
  12.     └─────────────────────────────────────────────────────────────────────┼┐
  13.     │       A French Mod Division Release - (C) 1995 FMD Software         ││
  14. ∙∙ ─┴─────────────────────────────────────────────────── ──  ─   ─  ── ───└┘
  15.  
  16.  
  17.  ┌┬══════════════════┐
  18.  ││ Long Description ││
  19.   └══════════════════┴┘
  20.  
  21.   This modification will allow your users to reserve themselves a time on your
  22. system, so they will be sure to have the line. This modification will keep a
  23. "time window" of 15 minutes (configurable) so this user can call, and only
  24. that user. If a user logs before the time window and he has more time
  25. available than the time left before the time window, his time will be
  26. truncated and saved for later use.
  27.  
  28.  
  29. NOTE: This modification is an update of a previous modification released for
  30.       WWIV v4.11 and has been updated by several authors so far. This is the
  31.       original update for the version v4.23 and v4.24 of WWIV. The original
  32.       filename was TIMEMOD2.DOC
  33.  
  34. Revision A:
  35.  
  36.  - Updated for WWIV v4.24
  37.  - Fixed the problem when the user who reserved a time log on
  38.  
  39.  ┌┬═══════┐
  40.  ││ Tests ││
  41.   └═══════┴┘
  42.  
  43.   This modification has been tested on a virgin WWIV v4.24 source using
  44.   Borland C++ v4.5
  45.  
  46. ──────────────────────────────────────────────────────────────────────────────
  47.                                    Legend
  48.                           ╔═══╤══════════════════┐
  49.                           │ + │ Add This Line    │
  50.                           │ - │ Delete This Line │
  51.                           │ * │ Modify This Line │
  52.                           │ = │ Existing Line    │
  53.                           └═══╧══════════════════╝
  54. ───[Step 1]────────────────────────────────────────────────────────────────────
  55.  
  56. Load BBSOVL1.C and copy the following functions at the end of the file.
  57.  
  58. #include <dir.h>
  59.  
  60. void timeedit(void)
  61. {
  62.   char ch, s1[81];
  63.   tmod t;
  64.   int  f, t2file, i, j, done;
  65.   long currrec;
  66.   char save2[81], save1[81];
  67.  
  68.   done = 0;
  69.   do
  70.   {
  71.     if ((sysstatus_expert & thisuser.sysstatus)==0)
  72.      printmenu(40);
  73.     tleft(1);
  74.     nl();
  75.     npr("1T 0- 1%s\r\n",ctim(nsl()));
  76.     prt(2, "TimeWindow: Q,A,E,D,L,?: ");
  77.     ch=onek("Q?AEDL");
  78.     switch(ch)
  79.     {
  80.       case 'Q': done=1; break;
  81.       case 'A':
  82.         prt(1, "Hour (0-24)? ");
  83.         input(save1, 2);
  84.         nl();
  85.         prt(2, "Minute (0-59)? ");
  86.         input(save2, 2);
  87.         nl();
  88.         j=(60*(atoi(save1)) + (atoi(save2)));
  89.         sprintf(s1, "%sTIMEMOD.DAT", syscfg.datadir);
  90.         f = sh_open(s1, O_RDWR | O_CREAT | O_APPEND | O_BINARY, S_IREAD | S_IWRITE);
  91.         currrec = filelength(f) / (long)sizeof(tmod);
  92.         /* Check to see if user already signed up for time. */
  93.         while ((currrec > 0) && (!hangup))
  94.         {
  95.           sh_lseek(f, (currrec - 1) * (long)sizeof(tmod), SEEK_SET);
  96.           currrec--;
  97.           sh_read(f, (void *)(&t), sizeof(tmod));
  98.           /* If thisuser.name = t.username then exit */
  99.           if (!strcmp(thisuser.name, t.username))
  100.           {
  101.             prt(2, "You've already reserved a time!");
  102.             nl();
  103.             sh_close(f);
  104.             done=1;
  105.             break;
  106.           }
  107.  
  108.           /* If time already taken then exit */
  109.           /* j = requested time...i=one of the taken times.  */
  110.           i = 60*(atoi(t.userhour)) + (atoi(t.usermin));
  111.           if ((j>=i) && (j<=i+15))
  112.           {
  113.             prt(2, "Time span already reserved! Try another time.");
  114.             nl();
  115.             sh_close(f);
  116.             done=1;
  117.             break;
  118.           }
  119.         }
  120.         sh_close(f);
  121.         if (!done)
  122.         {
  123.           sprintf(s1, "%sTIMEMOD.DAT", syscfg.datadir);
  124.           f = sh_open(s1, O_RDWR | O_CREAT | O_APPEND | O_BINARY, S_IREAD | S_IWRITE);
  125.           t.username[0]=0;
  126.           strcpy(t.username, thisuser.name);
  127.           strcpy(t.userhour, save1);
  128.           strcpy(t.usermin, save2);
  129.           sh_write(f, (void *)(&t), sizeof(tmod));
  130.           sh_close(f);
  131.         } else {
  132.           done=0;
  133.         }
  134.       break;
  135.       case 'E':
  136.         done = 0;
  137.         prt(1, "Hour (0-24)? ");
  138.         input(save1, 2);
  139.         nl();
  140.         prt(2, "Minute (0-59)? ");
  141.         input(save2, 2);
  142.         nl();
  143.         j=(60*(atoi(save1)) + (atoi(save2)));
  144.         sprintf(s1, "%sTIMEMOD.DAT", syscfg.datadir);
  145.         f = sh_open(s1, O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE);
  146.         currrec = filelength(f) / (long)sizeof(tmod);
  147.         /* Check to see if user already signed up for time. */
  148.         while ((currrec > 0) && (!hangup))
  149.         {
  150.           sh_lseek(f, (currrec - 1) * (long)sizeof(tmod), SEEK_SET);
  151.           currrec--;
  152.           sh_read(f, (void *)(&t), sizeof(tmod));
  153.  
  154.           /* If time already taken then exit */
  155.           /* j = requested time...i=one of the taken times.  */
  156.  
  157.           i = 60*(atoi(t.userhour)) + (atoi(t.usermin));
  158.           if ((j>=i) && (j<=i+15))
  159.           {
  160.             prt(2, "Time span already reserved! Try another time.");
  161.             nl();
  162.             done=1;
  163.             break;
  164.           }
  165.         }
  166.         sh_close(f);
  167.         sprintf(s1, "%sTIMEMOD.DAT", syscfg.datadir);
  168.         f = sh_open(s1, O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE);
  169.         currrec = filelength(f) / (long)sizeof(tmod);
  170.         /* Find users record and allow editing */
  171.         while ((currrec > 0) && (!hangup) && (!done))
  172.         {
  173.           sh_lseek(f, (currrec - 1) * (long)sizeof(tmod), SEEK_SET);
  174.           currrec--;
  175.           sh_read(f, (void *)(&t), sizeof(tmod));
  176.           /* If thisuser.name = t.username then */
  177.           if (!strcmp(thisuser.name, t.username))
  178.           {
  179.             sh_lseek(f, (currrec) * (long)sizeof(tmod), SEEK_SET);
  180.             strcpy(t.userhour, save1);
  181.             strcpy(t.usermin, save2);
  182.             sh_write(f, (void *)(&t), sizeof(tmod));
  183.             sh_close(f);
  184.             nl();
  185.             currrec = 0.0;
  186.           }
  187.         }
  188.         sh_close(f);
  189.       break;
  190.       case 'D':
  191.         sprintf(s1, "%sTIMEMOD.DAT", syscfg.datadir);
  192.         f = sh_open1(s1, O_RDWR | O_BINARY);
  193.         strcpy(s1, syscfg.datadir);
  194.         strcat(s1, "TIMEMOD.TMP");
  195.         remove(s1);
  196.         t2file = sh_open(s1, O_RDWR | O_CREAT | O_APPEND | O_BINARY, S_IREAD | S_IWRITE);
  197.         currrec = filelength(f) / (long)sizeof(tmod);
  198.         /* Check to see if user already signed up for time. */
  199.         while ((currrec > 0) && (!hangup))
  200.         {
  201.           sh_lseek(f, (currrec - 1) * (long)sizeof(tmod), SEEK_SET);
  202.           currrec--;
  203.           sh_read(f, (void *)(&t), sizeof(tmod));
  204.           /* If thisuser.name = t.username then exit */
  205.           if (strcmp(thisuser.name, t.username))
  206.             sh_write(t2file, (void *)(&t), sizeof(tmod));
  207.         }
  208.         sh_close(f);
  209.         sh_close(t2file);
  210.         sprintf(s1, "%sTIMEMOD.DAT", syscfg.datadir);
  211.         remove(s1);
  212.         chdir("DATA");
  213.         rename("TIMEMOD.TMP", "TIMEMOD.DAT");
  214.         chdir("..");
  215.         nl();
  216.       break;
  217.       case 'L':
  218.         nl();
  219.         prt(7, "User Name                       Time");
  220.         nl();
  221.         prt(3, "------------------------------- ---------");
  222.         nl();
  223.         sprintf(s1, "%sTIMEMOD.DAT", syscfg.datadir);
  224.         f=sh_open1(s1, O_RDONLY | O_BINARY);
  225.         currrec=filelength(f) / sizeof(tmod);
  226.         for (i=0; i<currrec; i++)
  227.         {
  228.           sh_lseek(f, (long) (i * sizeof(tmod)), SEEK_SET);
  229.           sh_read(f, (void *)(&t), sizeof(tmod));
  230.           npr("%s%s%s:%s\r\n", t.username, charstr(33-strlen(t.username), ' '),
  231.                t.userhour, t.usermin);
  232.         }
  233.         nl();
  234.         sh_close(f);
  235.       break;
  236.       case '?': printmenu(40); break;
  237.     }
  238.   } while ((!done) && (!hangup));
  239.   nl();
  240. }
  241.  
  242. void check_time_window(void)
  243. {
  244.   tmod t;
  245.   struct tm *currtime;
  246.   long currrec, secs;
  247.   char fname[81];
  248.   int f, timetmp, holdtime, delta=24*60,  nextwindow=-1;
  249.   int found=0, firstwindow=24*60;
  250.  
  251.   time_next_call = 0;
  252.   time(&secs);
  253.   currtime = localtime(&secs);
  254.   holdtime = 60*currtime->tm_hour + currtime->tm_min;
  255.   sprintf(fname, "%sTIMEMOD.DAT", syscfg.datadir);
  256.   f = sh_open1(fname, (O_RDWR | O_BINARY));
  257.   currrec = filelength(f) / (long)sizeof(tmod);
  258.   while (currrec>0 && !hangup)
  259.   {
  260.     sh_lseek(f, (currrec - 1) * (long)sizeof(tmod), SEEK_SET);
  261.     currrec--;
  262.     sh_read(f, (void *)(&t), sizeof(tmod));
  263.     timetmp = atoi(t.userhour)*60 + atoi(t.usermin);
  264.     if (timetmp < firstwindow)
  265.       firstwindow = timetmp;
  266.     if ( holdtime>=timetmp && holdtime<=timetmp+WINDOWSIZE && !found)
  267.     {
  268.       if (strcmp(thisuser.name, t.username))
  269.       {
  270.         pl("A time window is currently active.  Please call back later.");
  271.         hangup=1;
  272.       } else {
  273.         found++;
  274.       }
  275.     } else {
  276.        if ( timetmp-holdtime<delta && timetmp-holdtime>0 &&
  277.            strcmp(thisuser.name, t.username) &&
  278.            !found) {
  279.           nextwindow = timetmp;
  280.        }
  281.     }
  282.   }
  283.   if (nextwindow==-1 && firstwindow!=24*60)
  284.     nextwindow = firstwindow;
  285.   if (nextwindow!=-1 && nextwindow < holdtime)
  286.     holdtime = holdtime - 24*60;
  287.   strcpy(wd_username, t.username);
  288.   wd_holdtime = holdtime;
  289.   wd_nextwindow = nextwindow;             /* quick and dirty, but works. */
  290.   sh_close(f);
  291. }
  292.  
  293. ───[Step 2]────────────────────────────────────────────────────────────────────
  294.  
  295. Load MMENU.C and do the following change to function mainmenu:
  296.  
  297. =      case '#':
  298. =        nl();
  299. =        pl(get_string(939));
  300. =        nl();
  301. =      case '*':
  302. =#ifdef RIPDRIVE
  303. =        rd_coff();
  304. =#endif
  305. =        sublist();
  306. =#ifdef RIPDRIVE
  307. =        rd_con();
  308. =#endif
  309. =        break;
  310. +      case '%': timeedit(); break;
  311. =    }
  312. =  }
  313.  
  314. ───[Step 2]────────────────────────────────────────────────────────────────────
  315.  
  316. Load BBS.C and go to function main and do the following changes:
  317.  
  318. =            write_inst(INST_LOC_MAIN,usub[cursub].subnum,INST_FLAGS_NONE);
  319. =            mainmenu();
  320. =          break;
  321. =        }
  322. =      }
  323. +      if (time_next_call)
  324. +        thisuser.extratime += time_next_call;
  325. =      logoff();
  326. =      end_rip();
  327. =    }
  328.  
  329. ───[Step 4]────────────────────────────────────────────────────────────────────
  330.  
  331. Load VARDEC.H and do add the following structure at the end of confrec:
  332.  
  333. /* Time Window's structure */
  334. typedef struct {
  335.         char            username[31];  /* Name of owner */
  336.         char            userhour[51];  /* Hour of reservation */
  337.         char            usermin[51];   /* Mins of reservation */
  338.         char            reserved[30];  /* Reserved for later use */
  339. } tmod;
  340.  
  341. ───[Step 5]────────────────────────────────────────────────────────────────────
  342.  
  343. Load LILO.C and do the following change to function getuser:
  344.  
  345. =        npr("%d!",i);
  346. =        nl();
  347. =        continue;
  348. =      }
  349. =      ok=1;
  350. =      actsl = syscfg.newusersl;
  351. =      topscreen();
  352. +      check_time_window();
  353. =      outstr(get_string(357));
  354.  
  355. And lower in function logon:
  356.  
  357. =  }
  358. =  if (live_user) {
  359. =    nl();
  360. +    if ( wd_nextwindow!=-1 &&
  361. +         wd_holdtime*60+(long int) nsl() > wd_nextwindow*60 &&
  362. +         wd_holdtime < wd_nextwindow &&
  363. +         strcmp(wd_username, thisuser.name)) {
  364. +      wd_nextwindow *= 60;
  365. +      wd_holdtime *= 60;
  366. +      time_next_call = nsl() - (wd_nextwindow - wd_holdtime);
  367. +      thisuser.extratime -= time_next_call;
  368. +      pl("\76A time window will soon be active.  Your time has been reduced.");
  369. +      nl();
  370. +    }
  371. =
  372. =    outstr(get_string(237));
  373. =    pl(nam(&thisuser,usernum));
  374. =    outstr(get_string(363)); npr("%d\r\n", (int) ((nsl()+30)/60.0));
  375.  
  376. ───[Step 6]────────────────────────────────────────────────────────────────────
  377.  
  378. Load VARS.H and do the following changes:
  379.  
  380. =               ver_no2[51],wwiv_net_no[20], xdate[9], *xenviron[50],
  381. *               dlfn[81],edlfn[81], nete[5], irt_sub[81], wd_username[31];
  382.  
  383. Lower...
  384.  
  385. = __EXTRN__ long hanguptime1, last_time_c, nscandate, this_date,
  386. =                timelastchar1, quotes_nrm_l, quotes_ind_l,
  387. *                mult_time, num_listed, wd_holdtime, wd_nextwindow;
  388. =
  389. = __EXTRN__ unsigned long *dir_dates, *sub_dates, g_flags;
  390. =
  391. = __EXTRN__ unsigned long *qsc, *qsc_n, *qsc_q, *qsc_p;
  392. =
  393. =
  394. * __EXTRN__ float batchtime, time_next_call;
  395. =
  396.  
  397. And then add this line at the end of the file:
  398.  
  399. /* Time Window's Size (Minutes) */
  400. #define WINDOWSIZE 15
  401.  
  402. ───[Step 7]────────────────────────────────────────────────────────────────────
  403.  
  404. Update your menus to add "%" as the time window (or reservation) and add the
  405. file MENU40.MSG to your GFILES directory.
  406.  
  407. ───[Step 8]────────────────────────────────────────────────────────────────────
  408.  
  409. That's it, simply do a MAKE FCNS and recompile the entire system.
  410.  
  411. Enhancements of this modification will be done by request, if you like this
  412. modification, please tell us what can be added to this modification and it
  413. will be our pleasure to update it. We plan to add a "day" field and to
  414. auto-remove the time window after the user logs on, and we plan many
  415. enhancements of the modification. A better instance support and multiple
  416. configuration should be added to the list with a v4.24 version, since
  417. configuration will be easier with the WWIV.INI file.
  418.  
  419.  
  420. French Proverb: Si l'on force trop, la corde casse; Si l'on ne force pas assez,
  421.                 la corde joue mal.
  422.  
  423. For comments, bug report and suggestion, e-mail at the following address:
  424.  
  425. Nicolas LeBlanc  2@20302.WWIVnet (aka Spotnick)
  426.                  -> spotnick@gamemaster.qc.ca
  427. Martin Bourdages 242@20306 / 3@20302.WWIVnet (aka Dark Shadow)
  428.                  -> martin.bourdages@radio.magicnet.com
  429.  
  430.                  =>   French Mod Division Support Sub   <=
  431.                                 SubType: FMD
  432.                            Host: @20302 (WWIVnet)
  433.                       Scan sublist for other networks
  434.  
  435.         Read PRODUCTS.FMD for the full list of our support systems.
  436.  
  437. ───[EOF]──────────────────────────────────────────────────────────────────────
  438.