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

  1. /*
  2.  * File......: SCANOBJ.PRG
  3.  * Author....: Kevin Maher/Steve Tyrakowski
  4.  * CIS ID....: 73766,1224
  5.  * Date......: $Date$
  6.  * Revision..: $Revision$
  7.  * Log file..: $Logfile$
  8.  *
  9.  * This is an original work by Kevin Maher and Steve Tyrakowski
  10.  * and is placed in the public domain.
  11.  *
  12.  * Modification history:
  13.  * ---------------------
  14.  *
  15.  * $Log$
  16.  *
  17.  */
  18.  
  19.  
  20. /*  $DOC$
  21.  *  $FUNCNAME$
  22.  *     FN_scaBndO()
  23.  *  $CATEGORY$
  24.  *     Bindery
  25.  *  $ONELINER$
  26.  *     Scan Bindery Object
  27.  *  $SYNTAX$
  28.  *
  29.  *     FN_scaBndO(cObjectName, nObjectType) => aObjectInfo
  30.  *
  31.  *  $ARGUMENTS$
  32.  *
  33.  *     <cObjectName> is the name of the Object that you are trying
  34.  *       to find.  Wild Cards are allowed. Max Length = 47
  35.  *
  36.  *     <nObjectType> is the Bindery Object Type.  Manifest constants
  37.  *       describing the defined types are included in the NETTO.CH
  38.  *       header file.  Wild Card value OT_WILD is allowed.
  39.  *
  40.  *  $RETURNS$
  41.  *
  42.  *     <aObjectInfo>
  43.  *
  44.  *     Is an array which contains one or more elements, depending
  45.  *     if wild cards are used, which have seven values each.
  46.  *
  47.  *
  48.  *     aObjectInfo[x,1] is the Object Name from the Bindery that
  49.  *              corresponds to the ObjectId (i.e. the return
  50.  *              value from the GetBinderyObjectName call)
  51.  *
  52.  *     aObjectInfo[x,2] is the ObjectId which is used as a parameter
  53.  *              for other Bindery Functions
  54.  *
  55.  *     aObjectInfo[x,3] is the Object Type for this element in the SET.
  56.  *              see the OT_????? definitions in the NFNET.CH
  57.  *              for more info about what types have been defined.
  58.  *
  59.  *     aObjectInfo[x,4] is true if the property is dynamic and false
  60.  *              if property is static.
  61.  *
  62.  *     aObjectInfo[x,5] is the object write security as an integer.
  63.  *                        The integer indicates who can change the object
  64.  *                        and add properties to the bindery object.
  65.  *
  66.  *     aObjectInfo[x,6] is the object read security as an integer.
  67.  *              The integer indicates who can scan for
  68.  *              and find the object.
  69.  *
  70.  *          ┌─────────────────────────────────┐
  71.  *          │ Read and Write Security Levels  │
  72.  *          ├──┬──────────────────────────────┤
  73.  *          │ 0│ Anyone                       │
  74.  *          ├──┼──────────────────────────────┤
  75.  *          │ 1│ Logged                       │
  76.  *          ├──┼──────────────────────────────┤
  77.  *          │ 2│ Object                       │
  78.  *          ├──┼──────────────────────────────┤
  79.  *          │ 3│ Supervisor                   │
  80.  *          ├──┼──────────────────────────────┤
  81.  *          │ 4│ Netware Operating System     │
  82.  *          └──┴──────────────────────────────┘
  83.  *
  84.  *     aObjectInfo[x,7] is true if Object has properties to scan.
  85.  *
  86.  *  $DESCRIPTION$
  87.  *
  88.  *     This function lets you scan for bindery objects by name and type.
  89.  *     Wild card can be used for both name and type.  The Objects get
  90.  *     returned as an array in which each element cooresponds to a
  91.  *     different object. If an error occurs or no objects were found
  92.  *     matching search string, nil is returned
  93.  *
  94.  *  $EXAMPLES$
  95.  *
  96.  *     // this will return an array with info to all users of a network
  97.  *     aObjects := FN_scaBndO("*", OT_USER)
  98.  *
  99.  *  $END$
  100.  */
  101.  
  102. #include "ftint86.ch"
  103. #include "netto.ch"
  104.  
  105. #define NW_LOG     227
  106.  
  107. #xcommand DEFAULT <v1> TO <x1> [, <vN> TO <xN> ];
  108.       => IIF((<v1>)=NIL,<v1>:=<x1>,NIL) [; IF((<vN>)=NIL,<vN>:=<xN>,NIL)]
  109.  
  110. #ifdef FT_TEST
  111.   FUNCTION MAIN(cObject, nType)
  112.   LOCAL aObjects
  113.     DEFAULT cObject TO "*"
  114.     DEFAULT nType   TO "1"  // OT_USER
  115.     aObjects := FN_scaBndO(cObject, Val(nType))
  116.     Qout("Object                   ID           TYPE ISDYNAMIC    WRITE    READ IFVALUE")
  117.     Aeval(aObjects, {|aObj| Qout(PAD(aObj[1],20),aObj[2],aObj[3],aObj[4],aObj[5],aObj[6],aObj[7])})
  118.     Qout(fn_error())
  119.  
  120.   RETURN ( nil )
  121.  
  122. #endif
  123.  
  124. FUNCTION FN_scaBndO(cObject, nType)
  125.   LOCAL cReceive := Space(57)
  126.   LOCAL aObjects := {}
  127.   LOCAL nError
  128.   LOCAL cSend := I2BYTE(55);   //37h
  129.         +L2HILO(-1);
  130.         +W2HILO(nType);
  131.         +FN_NAMEL(cObject,48)
  132.  
  133.   DO WHILE (nError := _fnReq(NW_LOG, cSend, @cReceive)) == ESUCCESS
  134.  
  135.     Aadd(aObjects, { ;
  136.     FN_NoNull(Substr(cReceive,7,48));               // object name
  137.         , HILO2L(Left(cReceive,4));                 // object id
  138.         , HILO2W(Substr(cReceive,5,2));             // object type
  139.         , Substr(cReceive,55,1) == Chr(1);          // static/dynamic flag
  140.         , Int(BYTE2I(Substr(cReceive,56,1))/16);    // property_write_security
  141.         , Int(BYTE2I(Substr(cReceive,56,1)) % 16) ; // property_read_security
  142.         , Substr(cReceive,57,1) == Chr(255) })      // object_has_value
  143.  
  144.     // call again with this object id, so that it will
  145.     // find the NEXT one after it.
  146.     cSend := Stuff(cSend, 2, 4, Left(cReceive, 4))
  147.  
  148.   ENDDO
  149.  
  150.   IF nError == NO_SUCH_OBJECT .AND. !Empty(aObjects)
  151.     // error is 252 when there are no more Objects to search
  152.     _fnSetErr(ESUCCESS)
  153.   ELSE
  154.     // if no Objects were found or an error occured, return nil
  155.     aObjects := nil
  156.   ENDIF
  157.  
  158. RETURN aObjects
  159.