home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / clipper / nettos11.zip / ACCTNG / XACCTNG.PRG < prev   
Text File  |  1993-02-26  |  10KB  |  281 lines

  1. /*
  2.  * File......: XACCTNG.PRG
  3.  * Author....: Glenn Scott
  4.  * CIS ID....: 71620,1521
  5.  * Date......: $Date$
  6.  * Revision..: $Revision$
  7.  * Log file..: $Logfile$
  8.  * 
  9.  * This is an original work by Glenn Scott and is placed in the
  10.  * public domain.
  11.  *
  12.  * Modification history:
  13.  * ---------------------
  14.  *
  15.  * $Log$
  16.  *
  17.  */
  18.  
  19.  
  20. /*  $DOC$
  21.  *  $FUNCNAME$
  22.  *     Overview
  23.  *  $CATEGORY$
  24.  *     Accounting
  25.  *  $ONELINER$
  26.  *     Accounting Services Overview
  27.  *  $SYNTAX$
  28.  *     
  29.  *  $ARGUMENTS$
  30.  *     
  31.  *  $RETURNS$
  32.  *     
  33.  *  $DESCRIPTION$
  34.  *     
  35.  *
  36.  *       In order to use accounting services, the file server
  37.  *       must have accounting installed.  This is accomplished
  38.  *       via SYSCON.
  39.  *
  40.  *       In addition, any object that submits charges must have
  41.  *       its bindery object ID in the file server's ACCOUNT_SERVERS
  42.  *       set property.  Only a supervisor-equivalent user can 
  43.  *       assign a bindery object ID to this property.
  44.  *
  45.  *       Before using any accounting API call, call FN_ACCINST()
  46.  *       first.  This will tell you whether or not accounting is
  47.  *       installed on the current file server. Alternatively, 
  48.  *       you can call FN_ACCINST( nConnID ) to test other file
  49.  *       servers you are connected to.  See the documentation.
  50.  *
  51.  *       NET$ACCT.DAT
  52.  *
  53.  *       When accounting is installed on a server, the network
  54.  *       keeps an audit trail of all accounting transactions.
  55.  *       This audit trail is stored in a file called NET$ACCT.DAT
  56.  *       which resides in the SYS:SYSTEM directory. This is regular
  57.  *       file with normal attributes.
  58.  *
  59.  *       Each time the accounting API's to submit charges or record
  60.  *       notes are called, an entry is written into this audit file.
  61.  *
  62.  *       Charge records, from the FN_SaccChg() function, have the
  63.  *       following format:
  64.  *
  65.  *       Bytes      Description
  66.  *       -----      -------------
  67.  *        0-2       Record length -2 (excludes 2 bytes for length)
  68.  *        2-4       Server bindery object id
  69.  *        6-6       Time stamp, six single bytes for
  70.  *                       Year-1900
  71.  *                       Month
  72.  *                       Day
  73.  *                       Hour
  74.  *                       Minute
  75.  *                       Second
  76.  *       12-1       Record type (1=Charge record)
  77.  *       13-1       Completion code (0=Successful,194=Credit exceeded)
  78.  *       14-2       Service type (Normally bindery object type of server)
  79.  *       16-4       Client bindery object id (who was charged for services)
  80.  *       20-4       Amount charged
  81.  *       24-2       Comment type
  82.  *       26-x       Text of comment
  83.  *
  84.  *       The comment field contains a string of binary information
  85.  *       packed together.  The string's contents vary depending on
  86.  *       the comment type.  (See the section on Comment types below)
  87.  *
  88.  *       Note records, from the FN_SaccNote() function, have the
  89.  *       following format:
  90.  *
  91.  *       Bytes      Description
  92.  *       -----      -------------
  93.  *        0-2       Record length -2 (excludes 2 bytes for length)
  94.  *        2-4       Server bindery object id
  95.  *        6-6       Time stamp, six single bytes for
  96.  *                       Year-1900
  97.  *                       Month
  98.  *                       Day
  99.  *                       Hour
  100.  *                       Minute
  101.  *                       Second
  102.  *       12-1       Record type (2=Note record)
  103.  *       13-1       Reserved
  104.  *       14-2       Service type (Normally bindery object type of server)
  105.  *       16-4       Client bindery object id (who was charged for services)
  106.  *       20-2       Comment type
  107.  *       22-x       Text of comment
  108.  *
  109.  *       The comment field contains a string of binary information
  110.  *       packed together.  The string's contents vary depending on
  111.  *       the comment type.  (See the section on Comment types below)
  112.  *
  113.  *       NET$REC.DAT
  114.  *
  115.  *       This file contains the formatting instructions for all comment
  116.  *       types. NET$REC.DAT is also stored in SYS:SYSTEM as a regular
  117.  *       file.  It's structure is shown here:
  118.  *
  119.  *       Bytes      Description
  120.  *       -----      -------------
  121.  *        0-2       Record length -2 (excludes 2 bytes for length)
  122.  *        2-2       Comment type
  123.  *        4-1       Number of fields in this comment type
  124.  *        5-?       Data types of each field in the comment string
  125.  *        ?-x       Length of the format string
  126.  *        ?-y       Actual format string.
  127.  *
  128.  *       For example, the format record for DISK STORAGE CHARGE NOTE
  129.  *       would look like the following:
  130.  *
  131.  *       ┌──┬──┬─┬─┬─┬──┬──────────────────────────────────────────┐
  132.  *       │48│ 2│2│3│3│42│%lu disk blocks stored for %lu half-hours.│
  133.  *       └──┴──┴─┴─┴─┴──┴──────────────────────────────────────────┘
  134.  *
  135.  *       Comments and Comment Types
  136.  *
  137.  *       Novell supports the following comment types in a charge record.
  138.  *       Developers of Netware applications may create additional comment
  139.  *       types which would have different numbers.
  140.  *
  141.  *       Comment type 1 - Connect time charge
  142.  *       This comment type indicates the number of minutes that a station
  143.  *       was connected to the server, the number of packets sent, and the
  144.  *       number of disk operations.
  145.  *
  146.  *       Bytes      Description
  147.  *       -----      -------------
  148.  *        0-4       Connect time in minutes
  149.  *        4-4       Number of packet requests
  150.  *        8-6       Number of bytes read
  151.  *       14-6       Number of bytes written
  152.  *
  153.  *
  154.  *       Comment type 2 - Disk storage charge
  155.  *       This comment type charges for the number of storage blocks owned
  156.  *       and the amount of time they were owned for (in half-hour increments).
  157.  *
  158.  *       Bytes      Description
  159.  *       -----      -------------
  160.  *        0-4       Blocks owned
  161.  *        4-4       Number of half hours owned
  162.  *
  163.  *       Comment type 3 - Login to server note
  164.  *       This comment type records the station number whenever an object
  165.  *       logins to the server.
  166.  *
  167.  *       Bytes      Description
  168.  *       -----      -------------
  169.  *        0-4       Network address
  170.  *        4-6       Node login to
  171.  *
  172.  *       Comment type 4 - Logout from server note
  173.  *       This comment type records the station number whenever an object
  174.  *       log outs from a server.
  175.  *
  176.  *       Bytes      Description
  177.  *       -----      -------------
  178.  *        0-4       Network address
  179.  *        4-6       Node logged out from
  180.  *
  181.  *       Comment type 5 - Account locked note
  182.  *       This comment type records the station number whenever an intruder
  183.  *       detection event occurs.  The client number field in the note record
  184.  *       indicates the object number that has been locked out.
  185.  *
  186.  *       Bytes      Description
  187.  *       -----      -------------
  188.  *        0-4       Network address
  189.  *        4-6       Node logged out from
  190.  *
  191.  *       Comment type 6 - Server time changed note
  192.  *       This comment type records whenever the time is changed on the
  193.  *       file server.  The client number field in the note record indicates
  194.  *       the user that made the time change. The comment indicates the new
  195.  *       date that the server was changed to.
  196.  *
  197.  *       Bytes      Description
  198.  *       -----      -------------
  199.  *        0-6       Time stamp, six single bytes for
  200.  *                       Year-1900
  201.  *                       Month
  202.  *                       Day
  203.  *                       Hour
  204.  *                       Minute
  205.  *                       Second
  206.  *
  207.  *
  208.  *
  209.  *       A sample report server
  210.  *
  211.  *       Assume that you have a Clipper application that processes
  212.  *       some files and produces a laser printed report. This program
  213.  *       runs at night and reads a DBF file to determine what to print.
  214.  *       The DBF file contains the requesting user's object name, the
  215.  *       directory to run the report in, and the report name.  It also
  216.  *       contains a status field that gets filled in after the report
  217.  *       has run.
  218.  *
  219.  *       The following code illustrates the Clipper program to process
  220.  *       the requests database and run the reports. It bills the user
  221.  *       for these reporting services and denies service if the user id
  222.  *       does not have sufficient credit.
  223.  *
  224.  *
  225.  *       #define  COST_PER_REPORT      5.00
  226.  *       #define  ACCOUNT_BALANCE     aStatus[1]
  227.  *       #define  CREDIT_LIMIT        aStatus[2]
  228.  *
  229.  *       procedure main
  230.  *       LOCAL aStatus
  231.  *       LOCAL cMsg
  232.  *       LOCAL nResult
  233.  *       use REQUESTS exclusive
  234.  *       go top
  235.  *       do while !eof()
  236.  *          //
  237.  *          // Check if user has sufficient funds
  238.  *          //
  239.  *          aStatus := Fn_GAccStat( REQUESTS->username,1 )
  240.  *          cMsg    := "Report run ok..."
  241.  *          if !empty(aStatus)
  242.  *             if ACCOUNT_BALANCE > CREDIT_LIMIT
  243.  *                nResult := FN_sAccHold( REQUESTS->username,;
  244.  *                                        1,COST_PER_REPORT )
  245.  *                if nResult == 0
  246.  *                   //
  247.  *                   Do_Report( REQUESTS->dir,REQUEST->rpt_name )
  248.  *                   //
  249.  *                   FN_sAccChg( REQUESTS->username,1,1,;
  250.  *                               COST_PER_REPORT,;
  251.  *                               COST_PER_REPORT,1,;
  252.  *                               { 5,100,100,100 } )
  253.  *                else
  254.  *                   cMsg := "Problem ("+alltrim(str(nResult))+") occurred"
  255.  *                endif
  256.  *             else
  257.  *                cMsg := "Over credit limit..."
  258.  *             endif
  259.  *          else
  260.  *             cMsg := "No account balance"
  261.  *          endif
  262.  *          replace REQUESTS->status with cMsg
  263.  *          select REQUESTS
  264.  *          skip +1
  265.  *       enddo
  266.  *       close databases
  267.  *
  268.  *
  269.  *
  270.  *  $EXAMPLES$
  271.  *     
  272.  *  $SEEALSO$
  273.  *     
  274.  *  $INCLUDE$
  275.  *     
  276.  *  $END$
  277.  */
  278.  
  279. static function xacctng()
  280.     return nil
  281.