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 >
Wrap
Text File
|
1993-12-02
|
3KB
|
106 lines
/*
████████████████████████████████████████████████████████████████████████████
█ █
█ doitaudt.c █
█ █
█ Manage DOIT account balance █
█ █
████████████████████████████████████████████████████████████████████████████
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
#include "..\doit.h"
#include <nwcalls.h>
#include "..\doitacct.h"
#define NWDOS
void main()
{
NWCCODE cCode;
int itemsRead;
char chargerName[48];
char chargeeName[48];
NWCONN_HANDLE connID;
FILE *logFile;
AUDIT_RECORD record;
int length;
char *msg;
cCode = NWCallsInit(NULL, NULL);
if (cCode != 0) {
printf("Unable to initialize NetWare interface\n");
exit(-1);
}
/* get the connection ID of the server you're installing on */
cCode = NWGetDefaultConnectionID(&connID);
if (cCode != 0) {
printf("Unable to get connection ID of default server\n");
exit(-1);
}
logFile = fopen("SYS:\\SYSTEM\\DOIT.LOG", "rb");
if (logFile == NULL) {
printf("Unable to open log file\n");
exit(-1);
}
printf("Date/time Entered by Amount For user\n");
printf("----------------- --------------- ---------- ---------------\n");
do {
/* read an audit record */
itemsRead = fread(&record, sizeof(AUDIT_RECORD), 1, logFile);
if (itemsRead == 1) {
cCode = NWGetObjectName(connID, record.chargerID, chargerName, NULL);
if (cCode != SUCCESSFUL)
strcpy(chargerName, "[UNKNOWN]");
cCode = NWGetObjectName(connID, record.chargeeID, chargeeName, NULL);
if (cCode != SUCCESSFUL)
strcpy(chargeeName, "[UNKNOWN]");
/* print contents of audit record */
printf("%02d/%02d/%02d %02d:%02d:%02d %-15.15s %-10ld %-15.15s\n",
record.dateAndTime[1],
record.dateAndTime[2],
record.dateAndTime[0],
record.dateAndTime[3],
record.dateAndTime[4],
record.dateAndTime[5],
chargerName,
record.charge,
chargeeName);
/* if audit record was a note, print the accompanying string */
if (record.recordType == 2) {
itemsRead = fread(&length, sizeof(length), 1, logFile);
if (itemsRead != 1) {
printf("Unable to read log file\n");
exit(-1);
}
msg = (char *)malloc(length+1);
memset(msg, 0, length+1);
itemsRead = fread(msg, length, 1, logFile);
if (itemsRead != 1) {
printf("Unable to read log file\n");
exit(-1);
}
printf("%s\n", msg);
free(msg);
}
}
} while (itemsRead == 1);
printf("\nend of file\n");
}