home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
an401x.exe
/
DOITMGT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-24
|
3KB
|
111 lines
/*
████████████████████████████████████████████████████████████████████████████
█ █
█ doitmgt.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;
NWCONN_NUM connNumber;
char userName[48];
NWOBJ_TYPE objectType;
NWCONN_HANDLE connID;
long balance;
long limit;
char response;
BYTE data[128];
int changed = 0;
NWFLAGS more;
cCode = NWCallsInit(NULL, NULL);
if (cCode != 0) {
printf("Call to NWCallsInit failed\n");
exit(-1);
}
/* Get the connection ID of the file server that has the job server's queue */
cCode = NWGetDefaultConnectionID(&connID);
if (cCode != 0) {
printf("Call to NWGetDefaultConnectionID failed\n");
exit(-1);
}
/* get your connection number */
cCode = NWGetConnectionNumber(connID, &connNumber);
if (cCode != 0) {
printf("Unable to get your connection number to default server\n");
exit(-1);
}
/* get user name */
cCode = NWGetConnectionInformation(connID, connNumber, userName, &objectType, NULL, NULL);
if (cCode != 0) {
printf("Unable to get your user name\n");
exit(-1);
}
cCode = NWReadPropertyValue(connID, userName, objectType, "DOIT_ACCT_BAL", 1, data, &more, NULL);
if (cCode != SUCCESSFUL)
printf("Unable to get account status. cCode = %lX\n", cCode);
else {
balance = data[0];
limit = data[4];
printf("Your balance = %ld\n", balance);
printf("Your limit = %ld\n", limit);
do {
printf("\nChange balance? (y/n) ");
response = toupper(getche());
printf("\n");
} while ((response != 'Y') && (response != 'N'));
if (response == 'Y') {
printf("Enter new balance: ");
scanf("%ld", &balance);
printf("\n");
data[0] = balance;
changed = 1;
cCode = DoItSubmitAccountNote(connID, objectType, userName, balance, "User account balance changed");
if (cCode != SUCCESSFUL)
printf("Unable to make audit file entry\n");
}
do {
printf("\nChange limit? (y/n) ");
response = toupper(getche());
printf("\n");
} while ((response != 'Y') && (response != 'N'));
if (response == 'Y') {
printf("Enter new limit: ");
scanf("%ld", &limit);
printf("\n");
data[4] = limit;
changed = 1;
cCode = DoItSubmitAccountNote(connID, objectType, userName, limit, "User account limit changed");
if (cCode != SUCCESSFUL)
printf("Unable to make audit file entry\n");
}
if (changed) {
cCode = NWWritePropertyValue(connID, userName, objectType, "DOIT_ACCT_BAL", 1, data, more);
if (cCode != SUCCESSFUL)
printf("Unable to change balance\n");
}
}
}