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

  1. /*
  2.  * File......: CRTPROP.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_creProp()
  23.  *  $CATEGORY$
  24.  *     Bindery
  25.  *  $ONELINER$
  26.  *     Create Property
  27.  *  $SYNTAX$
  28.  *
  29.  *     FN_creProp(cObjectName, nObjectType, cProperty, lDynamic,
  30.  *                lSet, nWrite, nRead)  => lCreated
  31.  *
  32.  *  $ARGUMENTS$
  33.  *
  34.  *     <cObjectName> is the name of the Bindery Object that you are
  35.  *                   trying to create a property for.
  36.  *
  37.  *     <nObjectType> is the Bindery Object Type.  Manifest constants
  38.  *             describing the defined types are included in the
  39.  *             NETTO.CH header file.
  40.  *
  41.  *     <cProperty> is the name of the property you want to create.
  42.  *           The name can be up to 16 characters.
  43.  *
  44.  *     <lDynamic> if the new property will be dynamic or static. Set it
  45.  *          to true for dynamic and false for static.  Dynamic
  46.  *        properties get deleted when the file server is initialized.
  47.  *
  48.  *     <lSet> if the new property will be a set or a item. Set it to
  49.  *            true for a set and false for an item.
  50.  *
  51.  *     <nWrite> is the Property write security as an integer.
  52.  *              The integer indicates who can change the property.
  53.  *
  54.  *     <nRead> is the Property read security as an integer.
  55.  *           The integer indicates who can read and scan
  56.  *          for the property
  57.  *
  58.  *         ┌─────────────────────────────────┐
  59.  *         │ Read and Write Security Levels  │
  60.  *         ├──┬──────────────────────────────┤
  61.  *         │ 0│ Anyone                       │
  62.  *         ├──┼──────────────────────────────┤
  63.  *         │ 1│ Logged                       │
  64.  *         ├──┼──────────────────────────────┤
  65.  *         │ 2│ Object                       │
  66.  *         ├──┼──────────────────────────────┤
  67.  *         │ 3│ Supervisor                   │
  68.  *         ├──┼──────────────────────────────┤
  69.  *         │ 4│ Netware Operating System     │
  70.  *         └──┴──────────────────────────────┘
  71.  *
  72.  *  $RETURNS$
  73.  *
  74.  *     <lCreated> logical if property was created.
  75.  *
  76.  *  $DESCRIPTION$
  77.  *
  78.  *     This function creates a property for a bindery object.
  79.  *
  80.  *  $SEEALSO$
  81.  *     fn_delProp() fn_creBndO()
  82.  *  $EXAMPLES$
  83.  *
  84.  *     lCreated :=  FN_creProp("KEVIN", OT_USER, "GROUPS_I'M_IN",;
  85.  *                             .T., .F., 1, 1 )
  86.  *
  87.  *  $END$
  88.  */
  89.  
  90. #include "ftint86.ch"
  91. #include "netto.ch"
  92.  
  93. #xcommand DEFAULT <v1> TO <x1> [, <vN> TO <xN> ];
  94.       => IIF((<v1>)=NIL,<v1>:=<x1>,NIL) [; IF((<vN>)=NIL,<vN>:=<xN>,NIL)]
  95.  
  96. #define NW_LOG 227
  97.  
  98. #ifdef FT_TEST
  99.   FUNCTION MAIN(cObject, nType, cProperty, IsSet)
  100.     DEFAULT cObject    TO "TESTUSER"
  101.     DEFAULT nType      TO "1" // OT_USER
  102.     DEFAULT cProperty  TO "GROUPS_I'M_IN"
  103.     DEFAULT IsSet      TO "Y"
  104.  
  105.     IF FN_creProp(cObject, Val(nType), cProperty, .T., IsSet=="Y", 1, 1 )
  106.       QOut("property has been created.")
  107.     ELSE
  108.       QOut("property has not been created.")
  109.     ENDIF
  110.  
  111.   RETURN ( nil )
  112.  
  113. #endif
  114.  
  115. FUNCTION FN_creProp(cObject, nType, cProperty, lDynamic, lSet, nWrite, nRead )
  116.  
  117.   LOCAL cSend := I2BYTE(57);            // 39h API Request Code
  118.            + W2HILO(nType);         // nw_int Object type
  119.            + fn_NameL(cObject,48);        // Object Name
  120.            + I2BYTE(Iif(lDynamic, 1, 0);    // Set Dynamic/Static bit
  121.               + Iif(lSet, 2, 0));    // Set the ITEM/SET bit
  122.            + I2BYTE((nWrite * 16) + nRead); // Security Level
  123.            + fn_NameL(Upper(cProperty),16)    // Property Name
  124.  
  125.        // Note that property is converted to UPPER here for consistency.
  126.        // Netware automatically creates the property name in upppercase,
  127.        // but does not convert other calls that use propertyname to
  128.        // to use uppercase.  i.e. if you try to write a property value,
  129.        // you must specify the property name in uppercase.
  130.        // These bindery functions will handle that upper() for the user,
  131.        // and this UPPER is placed here to protect against possible future
  132.        // changes by Novell.  If for some reason, they allow lower case
  133.        // names in the future, this function would act differently than
  134.        // the others.  Therefore it is safer to make this one work the
  135.        // same as the others, and not rely on Novell keeping this
  136.        // consistently inconsistent.
  137.  
  138. RETURN _fnReq(NW_LOG,cSend,"") == ESUCCESS
  139.