home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / doom_i / program / tcpsrv12.exe / TCPSRV12.TAR / log.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-27  |  1019 b   |  53 lines

  1. /* log.c */
  2. /*
  3.  
  4.  * Copyright 1994 A.Oliver De Guzman
  5.  * All rights reserved
  6.  
  7.  *   Permission is granted to any individual to copy, use, and/or
  8.  * distribute this software provided that the distribution retains this
  9.  * entire copyright notice. No part of this software may be used and/or
  10.  * sold for profit or used with any commercial product.
  11.  
  12.  * DISCLAIMER:
  13.  *   This software comes with NO WARRANTIES of any kind. In no event
  14.  * will the author be liable for any financial, physical, moral, and/or
  15.  * mental damages incurred directly or indirectly by the use or intent
  16.  * to use of this software.
  17.  
  18.  */
  19.  
  20. #include <stdlib.h>
  21. #include <stdio.h>
  22. #include <ctype.h>
  23. #include <time.h>
  24. #include "log.h"
  25.  
  26. FILE *openlog(fname)
  27. char *fname;
  28. {
  29.     return(fopen(fname, "a+"));
  30. }
  31.  
  32. int closelog(fp)
  33. FILE *fp;
  34. {
  35.     if (fp) fclose(fp);
  36. }
  37.  
  38. int logger(fp, s)
  39. FILE *fp;
  40. char *s;
  41. {
  42.     time_t t;
  43.     char st[64];
  44.  
  45.     if (fp){
  46.         t = time(NULL);
  47.         strcpy(st, ctime(&t));
  48.         st[strlen(st)-1] = '\0';
  49.         fprintf(fp, "%s %s\n", st, s);
  50.         fflush(fp);
  51.     }
  52. }
  53.