home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / S12380.ZIP / NETAUDIT.C
C/C++ Source or Header  |  1989-01-16  |  2KB  |  95 lines

  1. /*
  2.  *  This program is to demonstrate the use of NetAuditWrite.
  3.  *  This program will generate an audit record not defined by
  4.  *  the base LAN Manager product.
  5.  *
  6.  *  LANMAN.INI parameter audit MUST be set to YES
  7.  *      audit = yes
  8.  *
  9.  *  This program demonstrates the use of the following API
  10.  *    NetAuditWrite
  11.  *
  12.  *  Compile and Link instructions:
  13.  *
  14.  *    cl -c -Zi -Od netaudit.c
  15.  *    link netaudit/CO,,,netapi netoem;
  16.  *
  17.  *  Execution instructions:
  18.  *
  19.  *    netaudit [<message>]
  20.  *    if message is supplied then that is written into
  21.  *    the audit trail, else a default message is written.
  22.  *
  23.  *  This software is provided for demonstration purposes only.
  24.  *  Microsoft makes no warranty, either express or implied as
  25.  *  to its usability in any given situation.
  26. */
  27.  
  28. #define INCL_BASE
  29. #include <os2.h>
  30. #include <stdio.h>
  31.  
  32. /*
  33.  *  Always include the netcons file prior to other network libraries
  34. */
  35.  
  36. #include <netcons.h>
  37. #include <audit.h>
  38.                     /*  size of message buffer         */
  39. #define DEFAULTMESSAGESIZE        1024
  40.                     /*  buffer for user message         */
  41. char bMessage[DEFAULTMESSAGESIZE];
  42.                     /*  default message             */
  43. #define DEFAULTMESSAGE            "Audit Message: This is just text"
  44.                     /*  pointer to message to write      */
  45. char * psMessage;
  46.                     /*  audit type                 */
  47. #define DEFAULTAUDITTYPE        0x0999
  48.  
  49.  
  50. /**********   PROGRAM STARTS HERE  *****************************************/
  51.  
  52. main(argc, argv)
  53. unsigned short argc;
  54. char **argv;
  55. {
  56.  
  57.   int rc;
  58.  
  59.   int j;
  60.                     /* if there is a message on the      */
  61.                     /* command line then put it in the   */
  62.                     /* bMessage area             */
  63.   if (argc > 1) {
  64.                     /* first make sure bMessage is clear */
  65.     strcpy(bMessage, "");
  66.                     /* now loop through args,         */
  67.     for (j = 1; j < argc; j++) {
  68.                     /* concatenating as we go         */
  69.       strcat(bMessage, argv[j]);
  70.       strcat(bMessage, " ");
  71.     }
  72.                     /* set pointer to bMessage buffer    */
  73.     psMessage = bMessage;
  74.   }
  75.                     /* if there is no message, then use  */
  76.                     /* the default message             */
  77.   else {
  78.     psMessage = DEFAULTMESSAGE;
  79.   }
  80.                     /* write message to audit log         */
  81.  
  82.   rc = NetAuditWrite(DEFAULTAUDITTYPE,
  83.              psMessage,
  84.              strlen(psMessage),
  85.              NULL,
  86.              NULL);
  87.   if (rc) {
  88.     printf("ERROR - NetAuditWrite, rc == %d\n", rc);
  89.     exit(0);
  90.   }
  91.  
  92.   printf("Message successfully written to audit log\n");
  93.  
  94. }
  95.