home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / clipper / nettos11.zip / ACCTNG / SACCHLD.PRG < prev    next >
Text File  |  1993-02-23  |  4KB  |  120 lines

  1. /*
  2.  * File......: SACCHLD.PRG
  3.  * Author....: Joseph D. Booth
  4.  * CIS ID....: 72040,2112
  5.  * Date......: $Date$
  6.  * Revision..: $Revision$
  7.  * Log file..: $Logfile$
  8.  * 
  9.  * This is an original work by Joseph D. Booth 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.  *     FN_sAccHold()
  23.  *  $CATEGORY$
  24.  *     Accounting
  25.  *  $ONELINER$
  26.  *     Submit a hold request to an Object's account
  27.  *  $SYNTAX$
  28.  *     nResult := FN_sAccHold( cObjName,nObjType,nHold_Amt )
  29.  *
  30.  *  $ARGUMENTS$
  31.  *     <cObjName> is the name of the bindery object to request a hold against.
  32.  *                Wildcards cannot be used.
  33.  *     <nObjType> is the object type of the bindery object being held..
  34.  *     <nHoldAmt> is the amount of the hold to request.
  35.  *
  36.  *  $RETURNS$
  37.  *
  38.  *      <nResult> is numeric value indicating the status of the request
  39.  *
  40.  *                  0   = Successful
  41.  *                192   = Object cannot submit charges
  42.  *                193   = No account balance for object being charged
  43.  *                194   = Credit limit exceeded
  44.  *                195   = Object has too many holds
  45.  *
  46.  *     
  47.  *  $DESCRIPTION$
  48.  *     
  49.  *  This function attempts to submit a hold to an object in the bindery.
  50.  *  In general, when a service wants to bill another bindery object, it
  51.  *  should submit a hold against that objects account.  The hold amount
  52.  *  is then reserved until a charge is submitted against the account in
  53.  *  which case the hold will be removed.  If the SUBMIT hold fails, then
  54.  *  the service request should be denied.
  55.  *
  56.  *  An object can only submit charges if it's object ID is one entry
  57.  *  in the SET property "ACCOUNT_SERVERS" on the file server where
  58.  *  accounting is installed.
  59.  *
  60.  *  $EXAMPLES$
  61.  *
  62.  *   #define        CD_ROM_CHARGE     5.00
  63.  *   #define        SERVER_TYPE          4
  64.  *   #define        CONNECT_TIME         1
  65.  *   #define        DISK_USAGE           2
  66.  *
  67.  *   function UseCDrom(cObject,nType)
  68.  *   //
  69.  *   // Assumes your software is used to access the CD-ROM attached to the
  70.  *   // network and you charge the accounts for it's use
  71.  *   //
  72.  *   ok := FN_sAccHold(cObject,nType,CD_ROM_CHARGE)   // Reserve the funds
  73.  *   if ! ok
  74.  *      Alert( "You do not have a enough funds!!")
  75.  *      return .F.
  76.  *   endif
  77.  *   //
  78.  *   //  Allow user to browse the CD_ROM file, limited to ten minutes
  79.  *   //
  80.  *   FN_sAccChg(cObject,nType,SERVER_TYPE,CD_ROM_CHARGE,;
  81.  *                      CD_ROM_CHARGE,CONNECT_TIME, ;
  82.  *                      { 10,;         // Ten minutes being charged
  83.  *                        100,;        // Network requests
  84.  *                        100000,;     // 100,000 bytes read
  85.  *                             0 } }   // 0 bytes written
  86.  *   return .T.
  87.  *
  88.  *
  89.  *  $SEEALSO$
  90.  *      FN_gAccSta()  FN_sAccChg() FN_sAccNote()
  91.  *  $INCLUDE$
  92.  *
  93.  *  $END$
  94.  */
  95.  
  96.  
  97. #include "ftint86.ch"
  98. #include "netto.ch"
  99.  
  100. #define REQUEST_HOLD    152      /* 97h */
  101. #define NW_ACCOUNT_CALL 227      /* E3h */
  102.  
  103.  
  104. function FN_sAccHold( cObject,nType,nHoldAmt )
  105. LOCAL cRequest, cReply, nReturn := 0
  106.  
  107. default nType to  OT_USER
  108.  
  109. cRequest := I2BYTE( REQUEST_HOLD )+;
  110.             L2HILO( nHoldAmt )+;
  111.             W2HILO( nType )+;
  112.             FN_NAMEL( cObject )
  113. cReply   := repl( chr(0), 2 )
  114.  
  115. if _fnReq( NW_ACCOUNT_CALL, cRequest, @cReply ) <> 0
  116.    nReturn := FN_Error()
  117. endif
  118.  
  119. return nReturn
  120.