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 >
C/C++ Source or Header  |  1993-11-24  |  3KB  |  111 lines

  1. /*
  2.  ████████████████████████████████████████████████████████████████████████████
  3.  █                                                                          █
  4.  █ doitmgt.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.     NWCONN_NUM        connNumber;
  26.     char            userName[48];
  27.     NWOBJ_TYPE        objectType;
  28.     NWCONN_HANDLE    connID;
  29.     long            balance;
  30.     long            limit;
  31.     char            response;
  32.     BYTE            data[128];
  33.     int                changed = 0;
  34.     NWFLAGS            more;
  35.  
  36.     cCode = NWCallsInit(NULL, NULL);
  37.     if (cCode != 0) {
  38.         printf("Call to NWCallsInit failed\n");
  39.         exit(-1);
  40.     }
  41.  
  42.     /* Get the connection ID of the file server that has the job server's queue */
  43.     cCode = NWGetDefaultConnectionID(&connID);
  44.     if (cCode != 0) {
  45.         printf("Call to NWGetDefaultConnectionID failed\n");
  46.         exit(-1);
  47.     }
  48.  
  49.     /* get your connection number */
  50.     cCode = NWGetConnectionNumber(connID, &connNumber);
  51.     if (cCode != 0) {
  52.         printf("Unable to get your connection number to default server\n");
  53.         exit(-1);
  54.     }
  55.  
  56.     /* get user name */
  57.     cCode = NWGetConnectionInformation(connID, connNumber, userName, &objectType, NULL, NULL);
  58.     if (cCode != 0) {
  59.         printf("Unable to get your user name\n");
  60.         exit(-1);
  61.     }
  62.  
  63.     cCode = NWReadPropertyValue(connID, userName, objectType, "DOIT_ACCT_BAL", 1, data, &more, NULL);
  64.     if (cCode != SUCCESSFUL)
  65.         printf("Unable to get account status.  cCode = %lX\n", cCode);
  66.     else {
  67.         balance = data[0];
  68.         limit = data[4];
  69.         printf("Your balance = %ld\n", balance);
  70.         printf("Your limit   = %ld\n", limit);
  71.  
  72.         do {
  73.             printf("\nChange balance? (y/n) ");
  74.             response = toupper(getche());
  75.             printf("\n");
  76.         } while ((response != 'Y') && (response != 'N'));
  77.         if (response == 'Y') {
  78.             printf("Enter new balance: ");
  79.             scanf("%ld", &balance);
  80.             printf("\n");
  81.             data[0] = balance;
  82.             changed = 1;
  83.             cCode = DoItSubmitAccountNote(connID, objectType, userName, balance, "User account balance changed");
  84.             if (cCode != SUCCESSFUL)
  85.                 printf("Unable to make audit file entry\n");
  86.         }
  87.  
  88.         do {
  89.             printf("\nChange limit? (y/n) ");
  90.             response = toupper(getche());
  91.             printf("\n");
  92.         } while ((response != 'Y') && (response != 'N'));
  93.         if (response  == 'Y') {
  94.             printf("Enter new limit: ");
  95.             scanf("%ld", &limit);
  96.             printf("\n");
  97.             data[4] = limit;
  98.             changed = 1;
  99.             cCode = DoItSubmitAccountNote(connID, objectType, userName, limit, "User account limit changed");
  100.             if (cCode != SUCCESSFUL)
  101.                 printf("Unable to make audit file entry\n");
  102.         }
  103.  
  104.         if (changed) {
  105.             cCode = NWWritePropertyValue(connID, userName, objectType, "DOIT_ACCT_BAL", 1, data, more);
  106.             if (cCode != SUCCESSFUL)
  107.                 printf("Unable to change balance\n");
  108.         }
  109.     }
  110. }
  111.