home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / an401x.exe / DOITAUDT.C < prev    next >
Text File  |  1993-12-02  |  3KB  |  106 lines

  1. /*
  2.  ████████████████████████████████████████████████████████████████████████████
  3.  █                                                                          █
  4.  █ doitaudt.c                                                               █
  5.  █                                                                          █
  6.  █ Manage DOIT account balance                                              █
  7.  █                                                                          █
  8.  ████████████████████████████████████████████████████████████████████████████
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <conio.h>
  15. #include <ctype.h>
  16. #include "..\doit.h"
  17. #include <nwcalls.h>
  18. #include "..\doitacct.h"
  19.  
  20. #define NWDOS
  21.  
  22. void main()
  23. {
  24.     NWCCODE            cCode;
  25.     int                itemsRead;
  26.     char            chargerName[48];
  27.     char            chargeeName[48];
  28.     NWCONN_HANDLE    connID;
  29.     FILE            *logFile;
  30.     AUDIT_RECORD    record;
  31.     int                length;
  32.     char            *msg;
  33.  
  34.     cCode = NWCallsInit(NULL, NULL);
  35.     if (cCode != 0) {
  36.         printf("Unable to initialize NetWare interface\n");
  37.         exit(-1);
  38.     }
  39.  
  40.     /* get the connection ID of the server you're installing on */
  41.     cCode = NWGetDefaultConnectionID(&connID);
  42.     if (cCode != 0) {
  43.         printf("Unable to get connection ID of default server\n");
  44.         exit(-1);
  45.     }
  46.  
  47.     logFile = fopen("SYS:\\SYSTEM\\DOIT.LOG", "rb");
  48.     if (logFile == NULL) {
  49.         printf("Unable to open log file\n");
  50.         exit(-1);
  51.     }
  52.  
  53.     printf("Date/time         Entered by      Amount     For user\n");
  54.     printf("----------------- --------------- ---------- ---------------\n");
  55.  
  56.     do {
  57.         /* read an audit record */
  58.         itemsRead = fread(&record, sizeof(AUDIT_RECORD), 1, logFile);
  59.         if (itemsRead == 1) {
  60.             cCode = NWGetObjectName(connID, record.chargerID, chargerName, NULL);
  61.             if (cCode != SUCCESSFUL)
  62.                 strcpy(chargerName, "[UNKNOWN]");
  63.  
  64.             cCode = NWGetObjectName(connID, record.chargeeID, chargeeName, NULL);
  65.             if (cCode != SUCCESSFUL)
  66.                 strcpy(chargeeName, "[UNKNOWN]");
  67.  
  68.             /* print contents of audit record */
  69.             printf("%02d/%02d/%02d %02d:%02d:%02d %-15.15s %-10ld %-15.15s\n",
  70.                     record.dateAndTime[1],
  71.                     record.dateAndTime[2],
  72.                     record.dateAndTime[0],
  73.                     record.dateAndTime[3],
  74.                     record.dateAndTime[4],
  75.                     record.dateAndTime[5],
  76.                     chargerName,
  77.                     record.charge,
  78.                     chargeeName);
  79.  
  80.             /* if audit record was a note, print the accompanying string */
  81.             if (record.recordType == 2) {
  82.                 itemsRead = fread(&length, sizeof(length), 1, logFile);
  83.                 if (itemsRead != 1) {
  84.                     printf("Unable to read log file\n");
  85.                     exit(-1);
  86.                 }
  87.  
  88.                 msg = (char *)malloc(length+1);
  89.                 memset(msg, 0, length+1);
  90.  
  91.                 itemsRead = fread(msg, length, 1, logFile);
  92.                 if (itemsRead != 1) {
  93.                     printf("Unable to read log file\n");
  94.                     exit(-1);
  95.                 }
  96.  
  97.                 printf("%s\n", msg);
  98.  
  99.                 free(msg);
  100.             }
  101.         }
  102.     } while (itemsRead == 1);
  103.  
  104.     printf("\nend of file\n");
  105. }
  106.