home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / com / bbs / lora / lora234s.exe / LASTCALL.C < prev    next >
C/C++ Source or Header  |  1993-10-17  |  2KB  |  79 lines

  1. /*
  2.  
  3.                       LoraBBS (DOS / OS2) Ver. 2.33
  4.  
  5.     Copyright (c) 1989, 1990, 1991, 1992, 1993 by Marco Maccaferri.
  6.                           All rights reserved.
  7.  
  8.  
  9.                           Source code examples
  10.                        Set/Read lastcaller record
  11.  
  12.  
  13.   You may use this structures at your own risk. The author cannot guarantee
  14.   that this structures are maintained in all future versions of the program.
  15.   You can freely (and you are encouraged on that) distribute this file
  16.   without limitations.
  17.  
  18.   You can contact the autor at one of the following address:
  19.  
  20.   Marco Maccaferri
  21.   BBS: 39-51-6331730 (2:332/402)
  22.  
  23. */
  24. #include <stdio.h>
  25. #include <io.h>
  26. #include <time.h>
  27. #include <fcntl.h>
  28. #include <string.h>
  29. #include <mem.h>
  30. #include <sys/stat.h>
  31.  
  32. #include "lora.h"
  33.  
  34. void get_last_caller(task)
  35. int task;
  36. {
  37.    int fd;
  38.    struct _lastcall lastcall;
  39.  
  40.    fd = open("LASTCALL.BBS", O_RDONLY|O_BINARY|O_CREAT,S_IREAD|S_IWRITE);
  41.  
  42.    while (read(fd, (char *)&lastcall, sizeof(struct _lastcall)) == sizeof(struct _lastcall))
  43.    {
  44.       if (lastcall.line != task)
  45.          strcpy(lastcall.name, "None");
  46.    }
  47.  
  48.    close (fd);
  49. }
  50.  
  51. void set_last_caller(usr, task, rate)
  52. struct _usr *usr;
  53. int task, rate;
  54. {
  55.    int fd;
  56.    long tempo;
  57.    struct tm *tim;
  58.    struct _lastcall lc;
  59.  
  60.    fd = open("LASTCALL.BBS", O_APPEND|O_WRONLY|O_BINARY|O_CREAT,S_IREAD|S_IWRITE);
  61.  
  62.    memset((char *)&lc, 0, sizeof(struct _lastcall));
  63.  
  64.    lc.line = task;
  65.    strcpy(lc.name, usr->name);
  66.    strcpy(lc.city, usr->city);
  67.    lc.baud = rate;
  68.    lc.times = usr->times;
  69.    strncpy(lc.logon, &usr->ldate[11], 5);
  70.    tempo = time (NULL);
  71.    tim = localtime (&tempo);
  72.    sprintf(lc.logoff,"%2d:%02d",tim->tm_hour,tim->tm_min);
  73.  
  74.    write(fd, (char *)&lc, sizeof(struct _lastcall));
  75.  
  76.    close (fd);
  77. }
  78.  
  79.