home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / XSRC_117.ZIP / XTIME.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-26  |  4.8 KB  |  141 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*   XBBS SOURCE CODE copyright (c) 1990 by M. Kimes                        */
  4. /*   All Rights Reserved                                                    */
  5. /*                                                                          */
  6. /*    For complete details of the licensing restrictions, please refer      */
  7. /*    to the License agreement, which is published in its entirety in       */
  8. /*    the in the file LICENSE.XBS.                                          */
  9. /*                                                                          */
  10. /*    USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE      */
  11. /*    XBBS LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF            */
  12. /*    THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO       */
  13. /*    NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES         */
  14. /*    AT THE ADDRESS LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO USE   */
  15. /*    THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING     */
  16. /*    AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH      */
  17. /*    M. KIMES                                                              */
  18. /*                                                                          */
  19. /*                                                                          */
  20. /* You can contact M. Kimes at the following address:                       */
  21. /*                                                                          */
  22. /* M. Kimes                         1:380/16.0@FidoNet                      */
  23. /* 542 Merrick                      (318)222-3455 data                      */
  24. /* Shreveport, LA  71104                                                    */
  25. /*                                                                          */
  26. /*                                                                          */
  27. /* Please feel free to contact me at any time to share your comments about  */
  28. /* my software and/or licensing policies.                                   */
  29. /*                                                                          */
  30. /*--------------------------------------------------------------------------*/
  31. /*======================================================================*/
  32. /*  XBBS Bulletin Board System.....Time routines                        */
  33. /*======================================================================*/
  34.  
  35. #include "msg.h"
  36. #include "xext.h"
  37.  
  38.  
  39. ulong pascal getxbbstime (void) { /* General purpose user timer */
  40.  
  41.  int min;
  42.  int hour;
  43.  struct time dos_time;
  44.  char tempause;
  45.  register word x;
  46.  static ulong xbbs_time;
  47.  static int warned;
  48.  static int lastmin;
  49.  
  50.  gettime(&dos_time);
  51.  hour=dos_time.ti_hour-starter.ti_hour;
  52.  min=dos_time.ti_min-starter.ti_min;
  53.  if (dos_time.ti_hour<starter.ti_hour) hour=hour+24;
  54.  xbbs_time=(long)((hour)*3600)+((min)*60)+(dos_time.ti_sec-starter.ti_sec);
  55.  if (lastmin!=min) {
  56.     lastmin=min;
  57.     if (!conf.whichstat || conf.whichstat==3) redraw_stat(NULL);
  58.     if (timer_off) return (xbbs_time);
  59.     for (x=0;x<10;x++) {
  60.         if (event[x].secsleft) {
  61.             if (((ulong)timelimit*60L)<(xbbs_time+event[x].secsleft)) {
  62.                 event[x].secsleft=0;
  63.                 readfile(event[x].filename,0,0,1);
  64.             }
  65.         }
  66.     }
  67.  }
  68.  
  69.  if (timer_off) return (xbbs_time);
  70.  if (((long)(timelimit*60)<(xbbs_time+120L)) and (!warned)) {
  71.  
  72.     char temp[81];
  73.  
  74.     warned++;
  75.     tempause=pauser;
  76.     sprintf(temp,"\n\07WARNING: Only %u mins left!\n",(word)((long)timelimit-(xbbs_time/60L)));
  77.     printm(temp);
  78.     pauser=tempause;
  79.  }
  80.  if (((long)(timelimit*60) > ((xbbs_time+1L)+120L)) and (warned)) warned=0;
  81.  
  82.  if ((long)(timelimit*60) < (xbbs_time+1)) {
  83.     timer_off=1;
  84.     leaving++;
  85.     say_prompt(176);
  86.     pauser=0;
  87.     say_prompt(177);
  88.     logoff();
  89.     userno=0;
  90.     exit(254);
  91.  }
  92.  return(xbbs_time);
  93. }
  94.  
  95.  
  96.  
  97. void pascal adjust_time (char type) { /* Turn timer on and off */
  98.  
  99.   if (!type) {
  100.     timer_off=1;
  101.     hold_time = timelimit-(word)(getxbbstime()/60L);
  102.     return;
  103.   }
  104.   if (type) {
  105.     gettime(&starter);
  106.     timelimit=hold_time;
  107.     timer_off=0;
  108.   }
  109. }
  110.  
  111.  
  112.  
  113. char * pascal fidodate (void) {   /* Returns proper Fidonet msg datestring */
  114.  
  115.  char months[12][4]={
  116.     "Jan",
  117.     "Feb",
  118.     "Mar",
  119.     "Apr",
  120.     "May",
  121.     "Jun",
  122.     "Jul",
  123.     "Aug",
  124.     "Sep",
  125.     "Oct",
  126.     "Nov",
  127.     "Dec"
  128.  };
  129.  static char fdate[20];
  130.  struct date dos_date;
  131.  struct time dos_time;
  132.  
  133. /* 26 Jul 89  06:23:47 */
  134.  
  135.  getdate(&dos_date);
  136.  gettime(&dos_time);
  137.  
  138.  sprintf(fdate,"%02hu %s %02d  %02hu:%02hu:%02hu",dos_date.da_day,months[dos_date.da_mon-1],dos_date.da_year%100,dos_time.ti_hour,dos_time.ti_min,dos_time.ti_sec);
  139.  return(fdate);
  140. }
  141.