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

  1. /*
  2.  * File......: SCANPROP.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_ScaProp()
  23.  *  $CATEGORY$
  24.  *     Bindery
  25.  *  $ONELINER$
  26.  *     Scan Property
  27.  *  $SYNTAX$
  28.  *
  29.  *     FN_ScaProp(cObjectName, nObjectType, cProperty) => aPropInfo
  30.  *
  31.  *  $ARGUMENTS$
  32.  *
  33.  *     <cObjectName> is the name of the Bindery Object that you are trying
  34.  *       to find properties for.  Wildcard characters are not allowed.
  35.  *       Max Length = 47
  36.  *
  37.  *     <nObjectType> is the Bindery Object Type.  Manifest constants
  38.  *       describing the defined types are included in the NETTO.CH
  39.  *       header file.  Wildcard characters are not allowed.
  40.  *
  41.  *     <cProperty> is the string containing the name of the property
  42.  *       to search for.  A maximum of 15 characters and wildcard
  43.  *       characters may be used.
  44.  *
  45.  *  $RETURNS$
  46.  *
  47.  *     <aPropInfo>
  48.  *
  49.  *     Is an array which contains one or more elements, depending
  50.  *     if wild cards are used, which have seven values each.
  51.  *
  52.  *     aPropInfo[x,1] is name of the objects property.
  53.  *
  54.  *     aPropInfo[x,2] is true if the property is a set and false if
  55.  *            the property is an item.
  56.  *
  57.  *     aPropInfo[x,3] is true if the property is dynamic and false
  58.  *            if property is static.
  59.  *
  60.  *     aPropInfo[x,4] is the Property write security as an integer.
  61.  *                      The integer indicates who can change the
  62.  *                      property.
  63.  *
  64.  *     aPropInfo[x,5] is the Property read security as an integer.
  65.  *            The integer indicates who can read and scan
  66.  *                      for the property.
  67.  *
  68.  *           ┌─────────────────────────────────┐
  69.  *           │ Read and Write Security Levels  │
  70.  *           ├──┬──────────────────────────────┤
  71.  *           │ 0│ Anyone                       │
  72.  *           ├──┼──────────────────────────────┤
  73.  *           │ 1│ Logged                       │
  74.  *           ├──┼──────────────────────────────┤
  75.  *           │ 2│ Object                       │
  76.  *           ├──┼──────────────────────────────┤
  77.  *           │ 3│ Supervisor                   │
  78.  *           ├──┼──────────────────────────────┤
  79.  *           │ 4│ Netware Operating System     │
  80.  *           └──┴──────────────────────────────┘
  81.  *
  82.  *     aPropInfo[x,6] is true if the property has value.
  83.  *
  84.  *     aPropInfo[x,7] return value from FN_rdproval if the property
  85.  *            has value.
  86.  *
  87.  *
  88.  *  $DESCRIPTION$
  89.  *
  90.  *     This function lets you scan the bindery for an object's properties.
  91.  *     A wild card can be used for the property parameter.  The return value
  92.  *     will be a multidimentional array in which each element will contain an
  93.  *     array of values cooresponding to each property found.  If no
  94.  *     properties are found or an error occurs, nil will be returned.
  95.  *
  96.  *     This function requires FT_IsBit() and FN_rdproval
  97.  *
  98.  *  $EXAMPLES$
  99.  *
  100.  *     aProperties := fn_scaprop("EVERYONE", OT_USER_GROUP, "*")
  101.  *     QOut(aProperties[1]) //result  GROUP_MEMBERS
  102.  *
  103.  *  $END$
  104.  */
  105.  
  106. #include "ftint86.ch"
  107. #include "netto.ch"
  108. #define NW_LOG     227
  109.  
  110. #xcommand DEFAULT <v1> TO <x1> [, <vN> TO <xN> ];
  111.       => IIF((<v1>)=NIL,<v1>:=<x1>,NIL) [; IF((<vN>)=NIL,<vN>:=<xN>,NIL)]
  112.  
  113. #ifdef FT_TEST
  114.   FUNCTION MAIN(cObject, nType, cProperty)
  115.   LOCAL aProperties
  116.     DEFAULT cObject TO "EVERYONE"
  117.     DEFAULT nType   TO "2"  // OT_USER_GROUP
  118.     DEFAULT cProperty TO "*"   // all properties
  119.  
  120.     aProperties := FN_ScaProp(cObject, Val(nType), cProperty)
  121.  
  122.     QOut("Property Name   IsSet IsDyn     Write     Read HasValue")
  123.     Aeval(aProperties, {|aObj| Qout(aObj[1],aObj[2],aObj[3],aObj[4],aObj[5],aObj[6])})
  124.  
  125.     Qout(fn_error())
  126.  
  127.   RETURN ( nil )
  128. #endif
  129.  
  130. FUNCTION FN_ScaProp(cObject, nType, cProperty)
  131.   LOCAL cReceive    := Space(24)
  132.   LOCAL aProperties := {}
  133.   LOCAL cSend := I2BYTE(60);             // 3Ch API Request Code
  134.          + W2HILO(nType);             // Object Type
  135.          + fn_NameL(cObject,48);         // Object Name
  136.          + L2HILO(-1);  // set sequence numer to -1 first time thru loop
  137.          + fn_NameL(Upper(cProperty),16) // Property Name
  138.  
  139.         // See  crtprop.prg for Upper(cProperty) discussion
  140.  
  141.   DO WHILE ( _fnReq(NW_LOG, cSend, @cReceive) ) == ESUCCESS
  142.  
  143.     Aadd(aProperties, {;
  144.     fn_noNull(Left(cReceive,16));        // property name
  145.         , ft_IsBit(Substr(cReceive,17,1),1);       // is item or set
  146.         , ft_IsBit(Substr(cReceive,17,1),0);       // is static or dynamic
  147.         , Int(BYTE2I(Substr(cReceive,18,1))/16);   // property_write_security
  148.         , Int(BYTE2I(Substr(cReceive,18,1)) % 16); // property_read_security
  149.         , Substr(cReceive,23,1) == Chr(255);       // property_has_value
  150.         , Fn_rdProVal(cObject, nType, Left(cReceive,16))})  // get the value
  151.  
  152.     // replace sequence number with last one received
  153.     cSend := Stuff(cSend, 53, 4, Substr(cReceive,19,4))
  154.  
  155.   ENDDO
  156.  
  157.   IF FN_Error() == NO_SUCH_PROPERTY .AND. !Empty(aProperties)
  158.       // Error is 251 when there are no more properties to search
  159.       // This is ok, as long as we found at least one.
  160.       _fnSetErr(ESUCCESS)
  161.   ELSE
  162.       // if no Properties found, or a different error occured, return nil
  163.       aProperties := nil
  164.   ENDIF
  165.  
  166. RETURN aProperties
  167.