home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / tsr / mgabra / mgnet.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-05  |  38.3 KB  |  1,716 lines

  1. /*****************************************
  2.       NETWORK FUNCTION LIBRARY
  3. *****************************************/
  4.  
  5. /*
  6.  
  7. The following library was built over several years of hacking with the
  8. Novell OS.  Not all the code is guaranteed to exemplify good programming.
  9. (In fact, some of it is darnright embarrassing). The nastiest part of
  10. dealing with the Novell OS is the fact that integers (2 bytes) and
  11. especially troublesome long integers (4 bytes) are swapped in their
  12. byte order. You don't have to worry about that because these functions
  13. handle that. However be careful. I haven't always written everything
  14. clearly enough to show which  swapping return values or parameters
  15. should have.
  16.  
  17. Not all the functions available are here by far. These are just the
  18. ones I found necessary while writing Utilities.
  19.  
  20. I recently rewrote some of the library to use dynamic (on stack) buffers
  21. for the packets. Before I was using statics which consumed data space in
  22. an unnecessarily wasteful manner. I haven't been able to test ALL the
  23. rewritten functions for bugs. If you do have trouble it helps to have the:
  24.  
  25. APPLICATION PROGRAMMER'S GUIDE TO NETWARE AND FUNCTION CALL REFERENCE
  26.  
  27. Which is available from Novell.
  28.  
  29. Walt Howard
  30. 1-31-90
  31. */
  32.  
  33. #include <dos.h>
  34. #include <string.h>
  35. #include <stdio.h>
  36. #include <dir.h>
  37.  
  38. #define WILD 0xFFFF
  39. #define UNKNOWN_TYPE 0
  40. #define NET_USER 1
  41. #define USER_GROUP 2
  42. #define PRINT_SERVER 3
  43. #define FILE_SERVER 4
  44. #define SENDFUNC 0xE1
  45. #define LACKOFSPACE 0xFE
  46. #define DOSSERVICE 0x21
  47. #define MAXBROAD 60
  48. #define LOGFUNC 0xE3
  49. #define DIRFUNC 0xE2
  50. #define TSR 1
  51. #define GETMAP 0x01
  52. #define MAXPATHLENGTH 64
  53. #define GETFILEINFO 0x0f
  54. #define ALLOCATEBASE 0x12
  55.  
  56. #define GETOBJECT 0x16
  57. #define SCANBIND 0x37
  58. #define READPROP 0x3D
  59. #define SEARCH_PATTERN_LENGTH 20
  60. #define BINDERY 0xE3
  61. #define BUZZ 0x00
  62. #define CASTOFF 0x02
  63. #define CASTON 0x03
  64. #define PREF 0xF0
  65. #define FILEINFO 0x0F
  66. #define GETIDNAME 0x36
  67.  
  68. #define MAXSTATIONS 100
  69. #define MAXSEND 60
  70.  
  71. #define WILD 0xFFFF
  72. #define UNKNOWN_TYPE 0
  73. #define NET_USER 1
  74. #define USER_GROUP 2
  75. #define PRINT_SERVER 3
  76. #define FILE_SERVER 4
  77. #define GETOBJECT 0x16
  78. #define SCANBIND 0x37
  79. #define SEARCH_PATTERN_LENGTH 20
  80. #define BINDERY 0xE3
  81. #define MAXSTATIONS 100
  82. #define    COMMFUNC  0xE1
  83. #define OPENPIPE 0x06
  84. #define GETMSG 0x05
  85. #define SENDMSG 0x04
  86. #define PIPESTAT 0x08
  87. #define CLOSEPIPE 0x07
  88. #define MAXMSG 126
  89.  
  90. #define PIPEGOOD 0x00
  91. #define PIPEHALF 0xFE
  92. #define NOSTATION 0xFF
  93.  
  94. typedef int NATIVE;
  95. typedef int WORD;
  96. typedef long LONG;
  97. typedef char BYTE;
  98.  
  99. BYTE spare;
  100. typedef unsigned int REGISTER;
  101.  
  102. union trans {
  103.    char byte[4];
  104.    int intval;
  105.    long longval;
  106. } transform;
  107.  
  108. /*****************************************
  109.                  NETCALL
  110. *****************************************/
  111.  
  112. int netcall(BYTE funcfamily, void far *req, void far *rep)
  113. {
  114.    int rval;
  115.  
  116.    #ifdef TSR
  117.       swapno();
  118.    #endif
  119.    _DI = FP_OFF(rep);
  120.    _SI = FP_OFF(req);
  121.    _ES = FP_SEG(rep);
  122.    _DS = FP_SEG(req);
  123.    _AL = 0;
  124.    _AH = funcfamily;
  125.  
  126.    geninterrupt(0x21);
  127.  
  128.    rval = (int) _AL;
  129.  
  130.    #ifdef TSR
  131.       swapyes();
  132.    #endif
  133.  
  134.    return(rval);
  135.  
  136. }
  137.  
  138. /*****************************************
  139.      BYTE ORDER SWAPPING FUNCTIONS
  140. *****************************************/
  141.  
  142. long swaplong(long longint)
  143. {
  144.  
  145.    transform.longval = longint;
  146.  
  147.    spare = transform.byte[0];
  148.    transform.byte[0] = transform.byte[3];
  149.    transform.byte[3] = spare;
  150.  
  151.    spare = transform.byte[1];
  152.    transform.byte[1] = transform.byte[2];
  153.    transform.byte[2] = spare;
  154.  
  155.    return(transform.longval);
  156.  
  157. }
  158.  
  159. /*****************************************
  160.                 SWAPINT
  161. *****************************************/
  162.  
  163. int swapint(int val)
  164. {
  165.  
  166.    transform.intval = val;
  167.    spare = transform.byte[0];
  168.    transform.byte[0] = transform.byte[1];
  169.    transform.byte[1] = spare;
  170.    return(transform.intval);
  171.  
  172. }
  173.  
  174. #define PROPERTY_SET 0x02
  175. #define GETOBJECTID 0x35
  176. #define ENVIRONMENT 0xF3
  177. #define ADDTRUSTEE 0x0d
  178.  
  179. #define CREATEOBJECT 0x32
  180. #define ADDPROPERTY 0x39
  181. #define MAXOBJECTNAMELENGTH 128
  182. #define MAXPROPERTYNAMELENGTH 128
  183. #define ADDVALUE 0x41
  184. #define MAXMEMBERNAMELENGTH 128
  185. #define ADDITEMVALUE 0x3e
  186. #define SET 0x02
  187. #define ITEM 0x00
  188.  
  189. /* SECURITY DEFINES */
  190.  
  191. #define READ_ANYONE 0xf0
  192. #define READ_ANYONE_LOGGED 0xf1
  193. #define READ_OBJECT_OR_SUPERVISOR 0xf2
  194. #define READ_SUPERVISOR 0xf3
  195. #define READ_BINDERY 0xf4
  196.  
  197. #define WRITE_ANYONE 0x0f
  198. #define WRITE_ANYONE_LOGGED 0x1f
  199. #define WRITE_OBJECT_OR_SUPERVISOR 0x2f
  200. #define WRITE_SUPERVISOR 0x3f
  201. #define WRITE_BINDERY 0x4f
  202.  
  203. /*****************************************
  204.          NOVELL PIPE FUNCTIONS
  205. *****************************************/
  206.  
  207. #define COMMFUNC 0xE1
  208. #define OPENPIPE 0x06
  209. #define GETMSG 0x05
  210. #define SENDMSG 0x04
  211. #define PIPESTAT 0x08
  212. #define CLOSEPIPE 0x07
  213. #define MAXMSG 126
  214. #define PIPEGOOD 0x00
  215. #define PIPEHALF 0xFE
  216. #define NOSTATION 0xFF
  217.  
  218. /*****************************************
  219.              BINDFINDFIRST
  220. *****************************************/
  221.  
  222. static LONG lastobject;
  223.  
  224. int bindfindfirst(WORD patterntype, char *pattern)
  225. {
  226.    int rval;
  227.  
  228.    struct {
  229.       NATIVE packetlength;
  230.       BYTE function;
  231.       LONG lastobjectseen;
  232.       WORD patterntype;
  233.       BYTE patternlength;
  234.       BYTE searchpattern[SEARCH_PATTERN_LENGTH];
  235.    } send;
  236.  
  237.    struct {
  238.       NATIVE packetlength;
  239.       LONG uniqueobjectid;
  240.       WORD objecttype;
  241.       BYTE objectname[48];
  242.       BYTE objectflags;
  243.       BYTE objectsecurity;
  244.       BYTE propertiesexist;
  245.    } recv;
  246.  
  247.    lastobject = -1;
  248.    send.lastobjectseen = swaplong(lastobject);
  249.    lastobject = send.lastobjectseen;
  250.    send.packetlength = sizeof(send) - sizeof(send.packetlength);
  251.    send.function = SCANBIND;
  252.    send.patterntype = swapint(patterntype);
  253.    stpcpy(send.searchpattern, pattern);
  254.    send.patternlength = strlen(send.searchpattern);
  255.    recv.packetlength = sizeof(recv);
  256.    rval = (int) netcall(BINDERY,  &send,  &recv);
  257.    lastobject = recv.uniqueobjectid;
  258.    return(rval);
  259. }
  260.  
  261. /*****************************************
  262.               BINDFINDNEXT
  263. *****************************************/
  264.  
  265. long bindfindnext(void)
  266. {
  267.    int rval;
  268.  
  269.    struct {
  270.       NATIVE packetlength;
  271.       BYTE function;
  272.       LONG lastobjectseen;
  273.       WORD patterntype;
  274.       BYTE patternlength;
  275.       char searchpattern[SEARCH_PATTERN_LENGTH];
  276.    } send;
  277.  
  278.    struct {
  279.       NATIVE packetlength;
  280.       LONG uniqueobjectid;
  281.       WORD objecttype;
  282.       BYTE objectname[48];
  283.       BYTE objectflags;
  284.       BYTE objectsecurity;
  285.       BYTE propertiesexist;
  286.    } recv;
  287.  
  288.    send.packetlength = sizeof(send) - sizeof(send.packetlength);
  289.    send.function = SCANBIND;
  290.    send.lastobjectseen = lastobject;
  291.    recv.packetlength = sizeof(recv);
  292.    rval = netcall(BINDERY,  &send,  &recv);
  293.    lastobject = recv.uniqueobjectid;
  294.    return(rval);
  295.  
  296. }
  297.  
  298. /*****************************************
  299.               GETOBJECTID
  300. *****************************************/
  301.  
  302. long getobjectid(char *name, WORD objecttype)
  303. {
  304.    int rval;
  305.    long temp;
  306.  
  307.    struct {
  308.       NATIVE packetlength;
  309.       BYTE function;
  310.       WORD objecttype;
  311.       BYTE objectnamelength;
  312.       BYTE objectname[MAXOBJECTNAMELENGTH];
  313.    } send;
  314.  
  315.    struct {
  316.       NATIVE packetlength;
  317.       LONG objectid;
  318.       WORD objecttype;
  319.       BYTE objectname[MAXOBJECTNAMELENGTH];
  320.    } recv;
  321.  
  322.    send.function = GETOBJECTID;
  323.    send.objecttype = swapint(objecttype);
  324.    send.objectnamelength = (char) strlen(name);
  325.    strcpy(send.objectname, name);
  326.    send.packetlength = send.objectnamelength + 4;
  327.    recv.packetlength = 54;
  328.    recv.objectid = 0L;
  329.    rval = netcall(BINDERY,  &send,  &recv);
  330.    temp = swaplong(recv.objectid);
  331.    if (rval == 0) return(temp);
  332.    return(0L);
  333.    }
  334.  
  335. /****************************************
  336.              READ PROPERTY
  337. ****************************************/
  338.  
  339. char *getproperty(char *user, char *property)
  340. {
  341.    int rval;
  342.    int temp;
  343.  
  344.    char send[256];
  345.  
  346.    struct {
  347.       NATIVE packetlen;
  348.       BYTE data[128];
  349.       BYTE more;
  350.       BYTE propertyflags;
  351.    } recv;
  352.  
  353.    send[2] = READPROP;
  354.    send[3] = NET_USER >> 8;
  355.    send[4] = NET_USER & 255;
  356.    send[5] = strlen(user);
  357.    strcpy(&send[6], user);
  358.    temp = 6 + send[5];
  359.    send[temp++] = 1;
  360.    send[temp++] = strlen(property);
  361.    strcpy(&send[temp], property);
  362.    temp = temp + send[temp];
  363.    send[0] = temp & 255;
  364.    send[1] = temp >> 8;
  365.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  366.    rval = netcall(BINDERY,  send,  &recv);
  367.    if (rval != 0) return(0);
  368.    recv.more = 0;
  369.    return(recv.data);
  370.  
  371. }
  372.  
  373. /*****************************************
  374.              SCAN PROPERTY
  375. *****************************************/
  376.  
  377. LONG lastinstance;
  378.  
  379. char *scanproperty(WORD objtype, char *objname, LONG instance, char *property)
  380. {
  381.    int rval;
  382.    int temp;
  383.  
  384.    char send[256];
  385.  
  386.    struct {
  387.       NATIVE packetlen;
  388.       BYTE propertyname[16];
  389.       BYTE propertyflags;
  390.       BYTE propertysec;
  391.       LONG searchinstance;
  392.       BYTE valueavailable;
  393.       BYTE morecvperties;
  394.    } recv;
  395.  
  396.    if (instance == -1L) lastinstance = swaplong(-1L);
  397.    if (instance != -1L) lastinstance = recv.searchinstance;
  398.    send[2] = 60;
  399.    send[3] = objtype >> 8;
  400.    send[4] = objtype & 255;
  401.    send[5] = strlen(objname);
  402.    strcpy(&send[6], objname);
  403.    temp = 6 + send[5];
  404.    *((long *) &send[temp]) = lastinstance;
  405.    temp += 4;
  406.    send[temp++] = (char) strlen(property);
  407.    strcpy(&send[temp], property);
  408.    temp = temp + send[temp];
  409.    send[0] = temp & 255;
  410.    send[1] = temp >> 8;
  411.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  412.    rval = netcall(BINDERY,  send,  &recv);
  413.    if (rval != 0) return(0);
  414.    return(recv.propertyname);
  415. }
  416.  
  417. /*****************************************
  418.   WHOUSER - RETURNS USER OF CONNECTION
  419. *****************************************/
  420.  
  421. char objectname[48];
  422.  
  423. char *whouser(int connection)
  424. {
  425.    int rval;
  426.  
  427.    struct {
  428.       NATIVE packetlen;
  429.       BYTE function;
  430.       BYTE connection;
  431.    } send;
  432.  
  433.    struct {
  434.       NATIVE packetlen;
  435.       LONG uniqueid;
  436.       WORD type;
  437.       BYTE objectname[48];
  438.       BYTE logtime[8];
  439.    } recv;
  440.  
  441.    send.function = GETOBJECT;
  442.    send.connection = (char) connection;
  443.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  444.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  445.    rval = netcall(BINDERY,  &send,  &recv);
  446.    if(!rval) strcpy(objectname, recv.objectname); else return(0);
  447.    objectname[10] = 0;
  448.    return(objectname);
  449. }
  450.  
  451.  
  452. /*****************************************
  453.                 OPENPIPE
  454. *****************************************/
  455.  
  456. int openpipe(int station)
  457. {
  458.    int rval;
  459.  
  460.    struct {
  461.       NATIVE packetlen;
  462.       BYTE function;
  463.       BYTE numstations;
  464.       BYTE station;
  465.    } send;
  466.  
  467.    struct {
  468.       NATIVE packetlen;
  469.       BYTE numstations;
  470.       BYTE pipestat;
  471.    } recv;
  472.  
  473.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  474.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  475.    send.function = OPENPIPE;
  476.    send.numstations = 1;
  477.    send.station = (BYTE) station;
  478.    rval = netcall(COMMFUNC,  &send,  &recv);
  479.    if (rval == LACKOFSPACE) perror("NETWORK LACK OF PIPE SPACE");
  480.    return((int) recv.pipestat);
  481.  
  482. }
  483.  
  484. /*****************************************
  485.                PIPE STATUS
  486. *****************************************/
  487.  
  488. int pipestat(int station)
  489. {
  490.    int rval;
  491.  
  492.    struct {
  493.       NATIVE packetlen;
  494.       BYTE function;
  495.       BYTE numstations;
  496.       BYTE station;
  497.    } send;
  498.  
  499.    struct {
  500.       NATIVE packetlen;
  501.       BYTE numstations;
  502.       BYTE status;
  503.    } recv;
  504.  
  505.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  506.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  507.    send.function = PIPESTAT;
  508.    send.numstations = 1;
  509.    send.station = (BYTE) station;
  510.    rval = netcall(COMMFUNC,  &send,  &recv);
  511.    if (rval == LACKOFSPACE) perror("NETWORK LACK OF PIPE SPACE");
  512.    return((int) recv.status);
  513. }
  514.  
  515. /*****************************************
  516.                 GETMESSAGE
  517. *****************************************/
  518.  
  519. char *getmessage()
  520. {
  521.    int rval;
  522.  
  523.    struct {
  524.       NATIVE packetlen;
  525.       BYTE function;
  526.    } send;
  527.  
  528.    struct {
  529.       NATIVE packetlen;
  530.       BYTE source;
  531.       BYTE msglen;
  532.       BYTE message[126];
  533.    } recv;
  534.  
  535.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  536.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  537.    send.function = GETMSG;
  538.    rval = netcall(COMMFUNC,  &send,  &recv);
  539.    if (rval == LACKOFSPACE) perror("NETWORK LACK OF PIPE SPACE");
  540.    recv.message[recv.msglen] = 0;
  541.    if(!recv.msglen && !recv.source) return(0); else return(&recv.source);
  542. }
  543.  
  544. /************************************************
  545. SENDMESSAGE - SEND A MESSAGE TO ANOTHER STATION
  546. ************************************************/
  547.  
  548. int sendmess(int station, void *msg)
  549. {
  550.    int rval;
  551.  
  552.    struct {
  553.       NATIVE packetlen;
  554.       BYTE function;
  555.       BYTE numstations;
  556.       BYTE station;
  557.       BYTE msglen;
  558.       BYTE message[MAXMSG];
  559.    } send;
  560.  
  561.    struct {
  562.       NATIVE packetlen;
  563.       BYTE numstations;
  564.       BYTE recvt;
  565.    } recv;
  566.  
  567.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  568.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  569.    send.function = SENDMSG;
  570.    send.numstations = 1;
  571.    send.station = (BYTE) station;
  572.    send.msglen = (BYTE) strlen(msg);
  573.    strcpy(send.message, msg);
  574.    rval = netcall(COMMFUNC,  &send,  &recv);
  575.    if (rval == LACKOFSPACE) perror("NETWORK LACK OF PIPE SPACE");
  576.    return((int) recv.recvt);
  577. }
  578.  
  579. /*****************************************
  580.   CLOSEPIPE - CLOSE PIPE TO A STATION
  581. *****************************************/
  582.  
  583. int closepipe(int station)
  584. {
  585.    struct {
  586.       NATIVE packetlen;
  587.       BYTE function;
  588.       BYTE numstations;
  589.       BYTE station;
  590.    } send;
  591.  
  592.    struct {
  593.       NATIVE packetlen;
  594.       BYTE numstations;
  595.       BYTE pipestat;
  596.    } recv;
  597.  
  598.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  599.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  600.    send.function = CLOSEPIPE;
  601.    send.numstations = 1;
  602.    send.station = (BYTE) station;
  603.    netcall(COMMFUNC,  &send,  &recv);
  604.    return((int) recv.pipestat);
  605. }
  606.  
  607. /*****************************************
  608.            ENVIRONMENTAL CALLS
  609. *****************************************/
  610.  
  611.  
  612. /*****************************************
  613.      GET THIS STATIONS CONNECTION
  614. *****************************************/
  615.  
  616. int myconnection(void)
  617. {
  618.    _AH = 0xDC;
  619.    geninterrupt(0x21);
  620.    return((int) _AL);
  621. }
  622.  
  623. /*****************************************
  624.         SEND - DO A NETWORK SEND
  625. *****************************************/
  626.  
  627. int netsend(int station, char *msg)
  628. {
  629.    int rval;
  630.  
  631.    struct {
  632.       NATIVE packetlen;
  633.       BYTE function;
  634.       BYTE numstations;
  635.       BYTE station;
  636.       BYTE messagelen;
  637.       BYTE message[MAXSEND+1];
  638.    } send;
  639.  
  640.    struct {
  641.       NATIVE packetlen;
  642.       BYTE numstations;
  643.       BYTE recvt;
  644.    } recv;
  645.  
  646.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  647.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  648.    send.numstations = 1;
  649.    send.station = (char) station;
  650.    send.function = BUZZ;
  651.    send.messagelen = (char) strlen(msg);
  652.    strcpy(send.message, msg);
  653.  
  654.    netcall(SENDFUNC,  &send,  &recv);
  655.  
  656.    rval = recv.recvt;
  657.  
  658.    return(rval);
  659. }
  660.  
  661. /*****************************************
  662.  CASTOFF - DISABLE BROADCAST RECEIVE
  663. *****************************************/
  664.  
  665. int castoff(void)
  666. {
  667.    int rval;
  668.  
  669.    struct {
  670.       NATIVE packetlen;
  671.       BYTE function;
  672.    } send;
  673.  
  674.    struct {
  675.       NATIVE packetlen;
  676.    } recv;
  677.  
  678.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  679.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  680.    send.function = CASTOFF;
  681.    rval = netcall(SENDFUNC,  &send,  &recv);
  682.    return(rval);
  683. }
  684.  
  685. /*****************************************
  686.    CASTON - ENABLE BROADCAST RECEIVE
  687. *****************************************/
  688.  
  689. int caston(void)
  690. {
  691.    int rval;
  692.  
  693.    struct {
  694.       NATIVE packetlen;
  695.       BYTE function;
  696.    } send;
  697.  
  698.    struct {
  699.       NATIVE packetlen;
  700.    } recv;
  701.  
  702.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  703.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  704.    send.function = CASTON;
  705.    rval = netcall(SENDFUNC,  &send,  &recv);
  706.    return(rval);
  707. }
  708.  
  709. /*****************************************
  710.   GETBROADCAST - IF BROADCASTS DISABLED
  711.   YOU CAN GET YOUR BROADCAST MESSAGE
  712.   WITH THIS.
  713. *****************************************/
  714.  
  715. char *getbroadcast(void)
  716. {
  717.    struct {
  718.       NATIVE packetlen;
  719.       BYTE function;
  720.    } send;
  721.  
  722.    struct {
  723.       NATIVE packetlen;
  724.       BYTE messagelen;
  725.       BYTE message[MAXBROAD+1];
  726.    } recv;
  727.  
  728.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  729.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  730.    send.function = 0x01;
  731.    netcall(SENDFUNC,  &send,  &recv);
  732.    if (recv.messagelen == 0) return(0);
  733.    recv.message[recv.messagelen] = 0;
  734.    return(recv.message);
  735. }
  736.  
  737. /*****************************************
  738.         BROADCASTMODE
  739.         _AH is mode
  740.         0 accept all
  741.         1 accept console only
  742.         2 accept NO messages
  743.         3 storecvt don't interrupt
  744.         4 return currecvmode
  745.         5 disable timer checks
  746.         6 enable timer checks
  747. *****************************************/
  748.  
  749. int broadcastmode(int mode)
  750. {
  751.    int rval;
  752.    _AH = 0xDE;
  753.    _DL = (char) mode;
  754.    geninterrupt(0x21);
  755.    rval = (int) _AL;
  756.    return(rval);
  757. }
  758.  
  759. /*****************************************
  760.       GETPREF - GET PREFERRED SERVER
  761. *****************************************/
  762.  
  763. int getpref(void)
  764. {
  765.    int rval;
  766.    _AH = PREF;
  767.    _AL = (char) 1;
  768.    geninterrupt(DOSSERVICE);
  769.    rval = (int) _AL;
  770.    return(rval);
  771. }
  772.  
  773. /*****************************************
  774.      SETPREF - SET PREFSERVER
  775. *****************************************/
  776.  
  777. int setpref(int servernumber)
  778. {
  779.    int rval;
  780.    _AH = PREF;
  781.    _AL = (char) 0;
  782.    _DL = (char) servernumber;
  783.    geninterrupt(DOSSERVICE);
  784.    rval = (int) _AL;
  785.    return(rval);
  786. }
  787.  
  788. /*****************************************
  789.       GETEFFECTIVE - GET EFFECTIVE
  790. *****************************************/
  791.  
  792. int geteffective(void)
  793. {
  794.    int rval;
  795.    _AH = PREF;
  796.    _AL = (char) 2;
  797.    geninterrupt(DOSSERVICE);
  798.    rval = (int) _AL;
  799.    return(rval);
  800. }
  801.  
  802. /*****************************************
  803.               SHELL VERSION
  804. *****************************************/
  805.  
  806. int shellversion(void)
  807. {
  808.    int rval;
  809.    _AH = 0xEA;
  810.    _AL = 0;
  811.    geninterrupt(0x21);
  812.    rval = _AH;
  813.    return(rval);
  814. }
  815.  
  816. /************************************************
  817.                   SERVER DATA
  818. ************************************************/
  819.  
  820. #define GETSERVERINFO 0x11
  821.  
  822. struct {
  823.    NATIVE packetlen;
  824.    BYTE function;
  825. } send11;
  826.  
  827. struct {
  828.    NATIVE packetlen;
  829.    BYTE servername[48];
  830.    BYTE version;
  831.    BYTE subversion;
  832.    WORD connectionssupported;
  833.    WORD connectionsinuse;
  834.    WORD maxconnectedvolumes;
  835.    BYTE undefinded[72];
  836. } recv11;
  837.  
  838. void serverinfo(void)
  839. {
  840.    send11.packetlen = sizeof(send11) - sizeof(send11.packetlen);
  841.    recv11.packetlen = sizeof(recv11) - sizeof(recv11.packetlen);
  842.    send11.function = GETSERVERINFO;
  843.    netcall(LOGFUNC,  &send11,  &recv11);
  844. }
  845.  
  846. /*****************************************
  847.                 VERSION
  848. *****************************************/
  849.  
  850. int netwareversion(void)
  851. {
  852.    serverinfo();
  853.    return((int) recv11.version);
  854. }
  855.  
  856. /*****************************************
  857.                 SUBVERSION
  858. *****************************************/
  859.  
  860. int subversion(void)
  861. {
  862.    serverinfo();
  863.    return((int) recv11.subversion);
  864. }
  865.  
  866. /*****************************************
  867.                 SERVERNAME
  868. *****************************************/
  869.  
  870. char *servername(void)
  871. {
  872.    serverinfo();
  873.    return(recv11.servername);
  874. }
  875.  
  876. /*****************************************
  877.                 CONNECTIONS
  878. *****************************************/
  879.  
  880. int connections(void)
  881. {
  882.    serverinfo();
  883.    return(swapint(recv11.connectionsinuse));
  884. }
  885.  
  886. /*****************************************
  887.                 OBJECTNAME
  888. *****************************************/
  889.  
  890. struct {
  891.    NATIVE packetlen;
  892.    LONG objectid;
  893.    WORD objecttype;
  894.    BYTE name[48];
  895. } recv36;
  896.  
  897. int getobjectdata(LONG id)
  898. {
  899.  
  900.    int rval;
  901.  
  902.    struct {
  903.       NATIVE packetlen;
  904.       BYTE function;
  905.       LONG objectid;
  906.    } send;
  907.  
  908.    send.function = GETIDNAME;
  909.    send.objectid = swaplong(id);
  910.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  911.    recv36.packetlen = sizeof(recv36) - sizeof(recv36.packetlen);
  912.    rval = netcall(BINDERY,  &send,  &recv36);
  913.    return(rval);
  914. }
  915.  
  916. char *getobjectname(LONG id)
  917. {
  918.    int rval;
  919.    rval = getobjectdata(id);
  920.    if (rval) recv36.name[0] = 0;
  921.    return(recv36.name);
  922. }
  923.  
  924. WORD getobjecttype(LONG id)
  925. {
  926.  
  927.    int rval;
  928.    rval = getobjectdata(id);
  929.    if (rval) recv36.objecttype = 0;
  930.    return(swapint(recv36.objecttype));
  931.  
  932. }
  933.  
  934. /*****************************************
  935.                 BASEDATA
  936. *****************************************/
  937.  
  938. struct {
  939.    NATIVE packetlen;
  940.    BYTE function;
  941.    BYTE base;
  942. } send15;
  943.  
  944. struct {
  945.    NATIVE packetlen;
  946.    WORD sectorsperblock;
  947.    WORD totalblocks;
  948.    WORD availableblocks;
  949.    WORD totaldirs;
  950.    WORD availabledirs;
  951.    BYTE volname[16];
  952.    WORD removeable;
  953. } recv15;
  954.  
  955. /*****************************************
  956.            CURRENTBASE
  957. *****************************************/
  958.  
  959. int currentbase(void)
  960. {
  961.    int rval, dval;
  962.    dval = getdisk();
  963.    _AH = 0xe9;
  964.    _AL = 0;
  965.    _DX = dval;
  966.    geninterrupt(0x21);
  967.    rval = _AX;
  968.    return(rval);
  969.    /* remember AL = base number AH = base flags */
  970. }
  971.  
  972. /****************************************
  973.        FILE ATTRIBUTE FUNCTIONS
  974. ****************************************/
  975.  
  976. struct NETDIRINFO {
  977.    NATIVE packetlen;
  978.    BYTE subdirname[16];
  979.    BYTE creationdate[2];
  980.    BYTE creationtime[2];
  981.    LONG owner;
  982.    BYTE rights;
  983.    BYTE pad;
  984.    WORD subdirnumber;
  985. };
  986.  
  987. struct NETDIRINFO netdirdata;
  988.  
  989. #define GETDIRINFO 0x02
  990.  
  991. struct NETDIRINFO *getdirinfo(char *pathspec)
  992. {
  993.    int rval;
  994.    static int dirslot;
  995.  
  996.    struct {
  997.       NATIVE packetlen;
  998.       BYTE function;
  999.       BYTE base;
  1000.       WORD searchstart;
  1001.       BYTE pathlen;
  1002.       BYTE pathspec[MAXPATHLENGTH];
  1003.    } send;
  1004.  
  1005.    send.searchstart = swapint(1);
  1006.  
  1007.    if (strchr(pathspec, '*')) send.searchstart = swapint(dirslot);
  1008.    if (strchr(pathspec, '?')) send.searchstart = swapint(dirslot);
  1009.  
  1010.    send.function = GETDIRINFO;
  1011.    send.base = (BYTE) (currentbase() & 127);
  1012.    send.pathlen = strlen(pathspec);
  1013.    strcpy(send.pathspec, pathspec);
  1014.    send.packetlen = 7 + send.pathlen;
  1015.    netdirdata.packetlen = 28;
  1016.    rval = netcall(DIRFUNC, &send, &netdirdata);
  1017.    dirslot = swapint(netdirdata.subdirnumber) + 1;
  1018.    if (!strchr(pathspec, '*')) dirslot = 1;
  1019.    if (!strchr(pathspec, '?')) dirslot = 1;
  1020.    if (!rval) return(&netdirdata);
  1021.    memset(&netdirdata, 0, sizeof(netdirdata));
  1022.    return((struct NETDIRINFO *) 0);
  1023. }
  1024.  
  1025. char *getdirname(char *path)
  1026. {
  1027.    getdirinfo(path);
  1028.    return(netdirdata.subdirname);
  1029. }
  1030.  
  1031. struct NETWORKFILEDATA {
  1032.    NATIVE packetlen;
  1033.    WORD slotnum;
  1034.    BYTE name[14];
  1035.    BYTE attribs;
  1036.    BYTE exectype;
  1037.    LONG size;
  1038.    WORD create;
  1039.    WORD access;
  1040.    WORD updatedate;
  1041.    WORD updatetime;
  1042.    LONG owner;
  1043.    BYTE undefined[120];
  1044. };
  1045.  
  1046. struct NETWORKFILEDATA netfiledata;
  1047.  
  1048. static slotnum = 0xffff;
  1049.  
  1050. struct NETWORKFILEDATA *getfileinfo(char *path)
  1051. {
  1052.  
  1053.    int temp;
  1054.  
  1055.    struct {
  1056.       NATIVE packetlen;
  1057.       BYTE function;
  1058.       WORD lastslot;
  1059.       BYTE base;
  1060.       BYTE attrib;
  1061.       BYTE pathlen;
  1062.       BYTE path[MAXPATHLENGTH];
  1063.    } send;
  1064.  
  1065.    send.lastslot = swapint(0xffff);
  1066.  
  1067.    if (strchr(path, '*')); send.lastslot = slotnum;
  1068.    if (strchr(path, '?')); send.lastslot = slotnum;
  1069.  
  1070.    send.function = GETFILEINFO;
  1071.    send.base = (BYTE) (currentbase() & 127);
  1072.    send.attrib = 0; /* FA_RDONLY | FA_HIDDEN | FA_SYSTEM; */
  1073.    strncpy(send.path, path, MAXPATHLENGTH);
  1074.    send.pathlen = (char) strlen(send.path);
  1075.    send.packetlen = send.pathlen + 6;
  1076.    netfiledata.packetlen = 143;
  1077.    temp = netcall(LOGFUNC,  &send,  &netfiledata);
  1078.    slotnum = netfiledata.slotnum;
  1079.    if (!temp) return(&netfiledata);
  1080.    memset(&netfiledata, 0, sizeof(netfiledata));
  1081.    return((struct NETWORKFILEDATA *) 0);
  1082. }
  1083.  
  1084. /*****************************************
  1085.                 FILENAME
  1086. *****************************************/
  1087.  
  1088. char *filename(char *path)
  1089. {
  1090.    getfileinfo(path);
  1091.    return(netfiledata.name);
  1092. }
  1093.  
  1094. /*****************************************
  1095.                 FILEOWNER
  1096. *****************************************/
  1097.  
  1098. long fileowner(char *path)
  1099. {
  1100.    getfileinfo(path);
  1101.    return(netfiledata.owner);
  1102. }
  1103.  
  1104. /*****************************************
  1105.              FILESIZE
  1106. *****************************************/
  1107.  
  1108. long filesize(char *path)
  1109. {
  1110.    getfileinfo(path);
  1111.    return(swaplong(netfiledata.size));
  1112. }
  1113.  
  1114. WORD fileupdatedate(char *path)
  1115. {
  1116.    getfileinfo(path);
  1117.    return(swapint(netfiledata.updatedate));
  1118. }
  1119.  
  1120. WORD fileupdatetime(char *path)
  1121. {
  1122.    getfileinfo(path);
  1123.    return(swapint(netfiledata.updatetime));
  1124. }
  1125.  
  1126. WORD filelastaccess(char *path)
  1127. {
  1128.    getfileinfo(path);
  1129.    return(swapint(netfiledata.access));
  1130. }
  1131.  
  1132. WORD filecreation(char *path)
  1133. {
  1134.    getfileinfo(path);
  1135.    return(swapint(netfiledata.create));
  1136. }
  1137.  
  1138. BYTE fileattribs(char *path)
  1139. {
  1140.    getfileinfo(path);
  1141.    return(netfiledata.attribs);
  1142. }
  1143.  
  1144. struct SETFILEDATA {
  1145.    NATIVE packetlen;
  1146.    BYTE function;
  1147.    BYTE attribs;
  1148.    BYTE exectype;
  1149.    BYTE filler[4];
  1150.    WORD create;
  1151.    WORD access;
  1152.    WORD updatedate;
  1153.    WORD updatetime;
  1154.    LONG owner;
  1155.    BYTE undefined[60];
  1156.    BYTE base;
  1157.    BYTE search;
  1158.    BYTE pathlen;
  1159.    BYTE path[MAXPATHLENGTH];
  1160. };
  1161.  
  1162. struct SETFILEDATA setfile;
  1163.  
  1164. struct SETFILEDATA *getcurrentdata(char *path)
  1165. {
  1166.    struct NETWORKFILEDATA *n;
  1167.    n = getfileinfo(path);
  1168.    if (!n) return(0);
  1169.    setfile.function = 0x10;
  1170.    setfile.attribs = n->attribs;
  1171.    setfile.exectype = n->exectype;
  1172.    setfile.create = n->create;
  1173.    setfile.access = n->access;
  1174.    setfile.updatedate = n->updatedate;
  1175.    setfile.updatetime = n->updatetime;
  1176.    setfile.owner = n->owner;
  1177.    setfile.base = currentbase();
  1178.    setfile.search = 0;
  1179.    setfile.pathlen = strlen(n->name);
  1180.    strcpy(setfile.path, n->name);
  1181.    setfile.packetlen = sizeof(setfile) - 2 - MAXPATHLENGTH + setfile.pathlen;
  1182.    return((struct SETFILEDATA *) &setfile);
  1183. }
  1184.  
  1185. LONG setfileowner(char *path, LONG id)
  1186. {
  1187.    int rval;
  1188.  
  1189.    struct {
  1190.       NATIVE packetlen;
  1191.    } recv;
  1192.  
  1193.    if (!getcurrentdata(path)) return(0);
  1194.    setfile.owner = id;
  1195.    recv.packetlen = 0;
  1196.    rval = netcall(LOGFUNC, &setfile, &recv);
  1197.    if (!rval) return(setfile.owner);
  1198.    return(0);
  1199. }
  1200.  
  1201. WORD setfileattribs(char *path, WORD attribs)
  1202. {
  1203.    int rval;
  1204.  
  1205.    struct {
  1206.       NATIVE packetlen;
  1207.    } recv;
  1208.  
  1209.    if (!getcurrentdata(path)) return(-1);
  1210.    setfile.attribs = attribs;
  1211.    recv.packetlen = 0;
  1212.    rval = netcall(LOGFUNC, &setfile, &recv);
  1213.    return(rval);
  1214. }
  1215.  
  1216. WORD setfileupdate(char *path, WORD date)
  1217. {
  1218.    int rval;
  1219.  
  1220.    struct {
  1221.       NATIVE packetlen;
  1222.    } recv;
  1223.  
  1224.    if (!getcurrentdata(path)) return(-1);
  1225.    setfile.updatedate = date;
  1226.    recv.packetlen = 0;
  1227.    rval = netcall(LOGFUNC, &setfile, &recv);
  1228.    return(rval);
  1229. }
  1230.  
  1231. WORD setfilecreate(char *path, WORD date)
  1232. {
  1233.    int rval;
  1234.  
  1235.    struct {
  1236.       NATIVE packetlen;
  1237.    } recv;
  1238.  
  1239.    if (!getcurrentdata(path)) return(-1);
  1240.    setfile.create = date;
  1241.    recv.packetlen = 0;
  1242.    rval = netcall(LOGFUNC, &setfile, &recv);
  1243.    return(rval);
  1244. }
  1245.  
  1246. WORD setfiletime(char *path, WORD time)
  1247. {
  1248.    int rval;
  1249.  
  1250.    struct {
  1251.       NATIVE packetlen;
  1252.    } recv;
  1253.  
  1254.    if (!getcurrentdata(path)) return(-1);
  1255.    setfile.updatetime = time;
  1256.    recv.packetlen = 0;
  1257.    rval = netcall(LOGFUNC, &setfile, &recv);
  1258.    return(rval);
  1259. }
  1260.  
  1261. WORD setfileaccessed(char *path, WORD date)
  1262. {
  1263.    int rval;
  1264.  
  1265.    struct {
  1266.       NATIVE packetlen;
  1267.    } recv;
  1268.  
  1269.    if (!getcurrentdata(path)) return(-1);
  1270.    setfile.access = date;
  1271.    recv.packetlen = 0;
  1272.    rval = netcall(LOGFUNC, &setfile, &recv);
  1273.    return(rval);
  1274. }
  1275.  
  1276.  
  1277. /*****************************************
  1278.              GET BASE PATH
  1279. *****************************************/
  1280.  
  1281. struct {
  1282.    NATIVE packetlen;
  1283.    BYTE stringlen;
  1284.    BYTE path[MAXPATHLENGTH];
  1285. } recv01;
  1286.  
  1287. char *getbasepath(BYTE base)
  1288. {
  1289.    int rval;
  1290.  
  1291.    struct {
  1292.       NATIVE packetlen;
  1293.       BYTE function;
  1294.       BYTE base;
  1295.    } send;
  1296.  
  1297.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  1298.    send.function = GETMAP;
  1299.    send.base = base;
  1300.    rval = netcall(DIRFUNC,  &send,  &recv01);
  1301.    if (rval) return(0);
  1302.    return(recv01.path);
  1303. }
  1304.  
  1305. /*****************************************
  1306.         ALLOCATE PERMANENT BASE
  1307. *****************************************/
  1308.  
  1309. int allocatebase(char *dirspec, char drive)
  1310. {
  1311.  
  1312.    int rval;
  1313.  
  1314.    struct {
  1315.       NATIVE packetlen;
  1316.       BYTE function;
  1317.       BYTE sourcebase;
  1318.       BYTE drivename;
  1319.       BYTE speclength;
  1320.       BYTE pathspec[40];
  1321.    } send;
  1322.  
  1323.    struct {
  1324.       NATIVE packetlen;
  1325.       BYTE newbase;
  1326.       BYTE accessmask;
  1327.    } recv;
  1328.  
  1329.    send.sourcebase = 0;
  1330.    send.drivename = drive;
  1331.    send.speclength = strlen(dirspec);
  1332.    strcpy(send.pathspec, dirspec);
  1333.    send.function = ALLOCATEBASE;
  1334.    send.packetlen = sizeof(send) - sizeof(send.pathspec) + strlen(dirspec) - sizeof(send.packetlen);
  1335.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  1336.    rval = netcall(DIRFUNC,  &recv,  &recv);
  1337.    if (rval) return(0);
  1338.    return(recv.newbase);
  1339. }
  1340.  
  1341. /*****************************************
  1342.                 GETVOLNUM
  1343. *****************************************/
  1344.  
  1345. int getvolnum(char *volname)
  1346. {
  1347.  
  1348.    struct {
  1349.       NATIVE packetlen;
  1350.       BYTE function;
  1351.       BYTE namelength;
  1352.       BYTE volname[50];
  1353.    } send;
  1354.  
  1355.    struct {
  1356.       NATIVE packetlen;
  1357.       BYTE volnumber;
  1358.    } recv;
  1359.  
  1360.    int namelen;
  1361.    namelen = strlen(volname);
  1362.    send.namelength = namelen;
  1363.    strcpy(send.volname, volname);
  1364.    send.packetlen = namelen + 2;
  1365.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  1366.    send.function = 5;
  1367.    netcall(DIRFUNC,  &send,  &recv);
  1368.    return(recv.volnumber);
  1369. }
  1370.  
  1371. int netid[14];
  1372.  
  1373. int *psn(void)
  1374. {
  1375.    _AH = 0xEE;
  1376.    geninterrupt(0x21);
  1377.    netid[0] = _CX;
  1378.    netid[1] = _BX;
  1379.    netid[2] = _AX;
  1380.    netid[3] = 0;
  1381.    return(netid);
  1382. }
  1383.  
  1384. /*****************************************
  1385.                 GETSTATIONS
  1386. *****************************************/
  1387.  
  1388. char *getstations(char *objname)
  1389. {
  1390.  
  1391.    struct {
  1392.       NATIVE packetlen;
  1393.       BYTE function;
  1394.       BYTE namelength;
  1395.       BYTE name[60];
  1396.    } send;
  1397.  
  1398.    struct {
  1399.       NATIVE packetlen;
  1400.       BYTE listlen;
  1401.       BYTE list[80];
  1402.    } recv;
  1403.  
  1404.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  1405.    send.function = 0x02;
  1406.    send.namelength = (char) strlen(objname);
  1407.    strcpy(send.name, objname);
  1408.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  1409.    netcall(LOGFUNC,  &send,  &recv);
  1410.    recv.list[recv.listlen] = 0;
  1411.    return(recv.list);
  1412. }
  1413.  
  1414. /*****************************************
  1415.                 TRUSTEE PATHS
  1416. *****************************************/
  1417.  
  1418. WORD lastsequence;
  1419.  
  1420. char *trusteepath(char *objname, BYTE vol, WORD objecttype, WORD sequence)
  1421. {
  1422.  
  1423.    int rval;
  1424.  
  1425.    struct {
  1426.       NATIVE packetlen;
  1427.       BYTE function;
  1428.       BYTE volumenumber;
  1429.       WORD lastsequence;
  1430.       LONG objectid;
  1431.    } send;
  1432.  
  1433.    struct {
  1434.       NATIVE packetlen;
  1435.       WORD lastsequence;
  1436.       LONG objectid;
  1437.       BYTE accessmask;
  1438.       BYTE pathlen;
  1439.       BYTE path[256];
  1440.    } recv;
  1441.  
  1442.    send.objectid = getobjectid(objname, objecttype);
  1443.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  1444.    send.function = 0x47;
  1445.    send.volumenumber = vol;
  1446.    if (sequence == 0) send.lastsequence = 0;
  1447.    else send.lastsequence = lastsequence;
  1448.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  1449.    rval = netcall(BINDERY,  &send,  &recv);
  1450.    if (rval) return(0);
  1451.    lastsequence = recv.lastsequence;
  1452.    recv.path[recv.pathlen] = 0;
  1453.    recv.path[recv.pathlen + 1] = recv.accessmask;
  1454.    return(recv.path);
  1455. }
  1456.  
  1457. /*****************************************
  1458.                 NUMTOVOL
  1459. *****************************************/
  1460.  
  1461. char *numtovol(int volnum)
  1462. {
  1463.  
  1464.    struct {
  1465.       NATIVE packetlen;
  1466.       BYTE function;
  1467.       BYTE volnum;
  1468.    } send;
  1469.  
  1470.   struct {
  1471.       NATIVE packetlen;
  1472.       BYTE namelen;
  1473.       BYTE volname[48];
  1474.    } recv;
  1475.  
  1476.    send.volnum = volnum;
  1477.    send.function = 0x06;
  1478.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  1479.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  1480.    netcall(DIRFUNC,  &send,  &recv);
  1481.    if (!recv.namelen) return(0);
  1482.    return(recv.volname);
  1483. }
  1484.  
  1485. /*****************************************
  1486.            INTERNET ADDRESS
  1487. *****************************************/
  1488.  
  1489. char *internet(int connection)
  1490. {
  1491.  
  1492.    struct {
  1493.       NATIVE packetlen;
  1494.       BYTE function;
  1495.       BYTE connection;
  1496.    } send;
  1497.  
  1498.    struct {
  1499.       NATIVE packetlen;
  1500.       BYTE internet[4];
  1501.       BYTE host[6];
  1502.       BYTE socket[2];
  1503.    } recv;
  1504.  
  1505.    send.packetlen = sizeof(send) - sizeof(send.packetlen);
  1506.    recv.packetlen = sizeof(recv) - sizeof(recv.packetlen);
  1507.    send.connection = connection;
  1508.    send.function = 0x13;
  1509.    netcall(LOGFUNC,  &send,  &recv);
  1510.    return(recv.internet);
  1511. }
  1512.  
  1513. /************************************************
  1514.                 CREATEOBJECT
  1515. ************************************************/
  1516.  
  1517. int createobject(char *name, WORD type, BYTE flags, BYTE security)
  1518. {
  1519.  
  1520.    int rval;
  1521.  
  1522.    struct {
  1523.       NATIVE packetlength;
  1524.       BYTE function;
  1525.       BYTE flags;
  1526.       BYTE security;
  1527.       WORD type;
  1528.       BYTE namelength;
  1529.       BYTE name[MAXOBJECTNAMELENGTH];
  1530.    } send;
  1531.  
  1532.    struct {
  1533.       NATIVE packetlength;
  1534.    } recv;
  1535.  
  1536.    send.flags = flags;
  1537.    send.type = swapint(type);
  1538.    send.function = CREATEOBJECT;
  1539.    send.security = security;
  1540.    strncpy(send.name, name, MAXOBJECTNAMELENGTH);
  1541.    send.namelength = (BYTE) strlen(send.name);
  1542.    send.packetlength = send.namelength + 6;
  1543.    recv.packetlength = 0;
  1544.    rval = netcall(BINDERY,  &send,  &recv);
  1545.    return(rval);
  1546. }
  1547.  
  1548. /************************************************
  1549.                 ADDPROPERTY
  1550. ************************************************/
  1551.  
  1552. int addproperty(char *object, WORD objecttype, char *property, char propertytype, char security)
  1553. {
  1554.  
  1555.    int rval;
  1556.    BYTE *offset;
  1557.  
  1558.    struct {
  1559.       NATIVE packetlength;
  1560.       BYTE function;
  1561.       WORD objecttype;
  1562.       BYTE objectnamelength;
  1563.       BYTE remainder[MAXOBJECTNAMELENGTH + MAXPROPERTYNAMELENGTH + 3];
  1564.    } send;
  1565.  
  1566.    struct {
  1567.       NATIVE packetlength;
  1568.    } recv;
  1569.  
  1570.    send.objecttype = swapint(objecttype);
  1571.    send.function = (BYTE) ADDPROPERTY;
  1572.    send.objectnamelength = (BYTE) strlen(object);
  1573.    strcpy(send.remainder, object);
  1574.    offset = strchr(send.remainder, 0);
  1575.    strcpy(offset, property);
  1576.    *offset++ = (char) propertytype;
  1577.    *offset++ = (char) security;
  1578.    *offset++ = (char) strlen(property);
  1579.    strcpy(offset, property);
  1580.    send.packetlength = send.objectnamelength + strlen(property) + 6 + 3;
  1581.  
  1582.    recv.packetlength = 0;
  1583.    rval = netcall(BINDERY,  &send,  &recv);
  1584.    return(rval);
  1585. }
  1586.  
  1587. /************************************************
  1588.              ADDSETPROPERTYVALUE
  1589. ************************************************/
  1590.  
  1591. int addsetvalue(char *object, WORD objecttype, char *property, char *member, WORD membertype)
  1592. {
  1593.  
  1594.    int rval;
  1595.    BYTE *offset;
  1596.    WORD *wordptr;
  1597.  
  1598.    struct {
  1599.       NATIVE packetlength;
  1600.       BYTE function;
  1601.       WORD objecttype;
  1602.       BYTE objectnamelength;
  1603.       BYTE remainder[MAXOBJECTNAMELENGTH + MAXPROPERTYNAMELENGTH + 3 + MAXMEMBERNAMELENGTH];
  1604.    } send;
  1605.  
  1606.    struct {
  1607.       NATIVE packetlength;
  1608.    } recv;
  1609.  
  1610.    send.objecttype = swapint(objecttype);
  1611.    send.function = (BYTE) ADDVALUE;
  1612.    send.objectnamelength = (BYTE) strlen(object);
  1613.    strcpy(send.remainder, object);
  1614.  
  1615.    offset = strchr(send.remainder, 0);
  1616.    *offset++ = (char) strlen(property);
  1617.    strcpy(offset, property);
  1618.    offset = strchr(offset, 0);
  1619.  
  1620.    wordptr = (WORD *) offset;
  1621.    *wordptr = swapint(membertype);
  1622.    offset += 2;
  1623.    *offset++ = (char) strlen(member);
  1624.    strcpy(offset, member);
  1625.  
  1626.    send.packetlength = strlen(member) + strlen(property) + strlen(member) + 10;
  1627.  
  1628.    recv.packetlength = 0;
  1629.    rval = netcall(BINDERY,  &send,  &recv);
  1630.    return(rval);
  1631. }
  1632.  
  1633. /************************************************
  1634.              ADDITEMPROPERTYVALUE
  1635. ************************************************/
  1636.  
  1637. int additemvalue(char *object, WORD objecttype, char *property, char *data)
  1638. {
  1639.  
  1640.    int rval;
  1641.    BYTE *offset;
  1642.  
  1643.    struct {
  1644.       NATIVE packetlength;
  1645.       BYTE function;
  1646.       WORD objecttype;
  1647.       BYTE objectnamelength;
  1648.       BYTE remainder[MAXOBJECTNAMELENGTH + MAXPROPERTYNAMELENGTH + 3 + MAXMEMBERNAMELENGTH];
  1649.    } send;
  1650.  
  1651.    struct {
  1652.       NATIVE packetlength;
  1653.    } recv;
  1654.  
  1655.    send.objecttype = swapint(objecttype);
  1656.    send.function = (BYTE) ADDITEMVALUE;
  1657.    send.objectnamelength = (BYTE) strlen(object);
  1658.    strcpy(send.remainder, object);
  1659.  
  1660.    offset = strchr(send.remainder, 0);
  1661.  
  1662.    *offset++ = 1;
  1663.    *offset++ = 0;
  1664.    *offset++ = (char) strlen(property);
  1665.    strcpy(offset, property);
  1666.    offset = strchr(offset, 0);
  1667.    strcpy(offset, data);
  1668.  
  1669.    send.packetlength = strlen(object) + strlen(property) + strlen(data) + 9;
  1670.  
  1671.    recv.packetlength = 0;
  1672.    rval = netcall(BINDERY,  &send,  &recv);
  1673.    return(rval);
  1674. }
  1675.  
  1676. /*****************************************
  1677.                 ADD TRUSTEE
  1678. *****************************************/
  1679.  
  1680. int addtrustee(char *directory, LONG userid, BYTE access)
  1681. {
  1682.  
  1683.    int rval;
  1684.  
  1685.    struct {
  1686.       NATIVE packetlength;
  1687.       BYTE function;
  1688.       BYTE sourcebase;
  1689.       LONG trustee;
  1690.       BYTE accessmask;
  1691.       BYTE speclength;
  1692.       BYTE pathspec[64];
  1693.    } send;
  1694.  
  1695.    struct {
  1696.       NATIVE packetlength;
  1697.    } recv;
  1698.  
  1699.    send.function = ADDTRUSTEE;
  1700.    send.trustee = swaplong(userid);
  1701.    send.sourcebase = 0;
  1702.    send.accessmask = access;
  1703.    send.speclength = strlen(directory);
  1704.    strcpy(send.pathspec, directory);
  1705.    send.packetlength = (char)(send.speclength + 8);
  1706.  
  1707.    recv.packetlength = 0;
  1708.    rval = netcall(DIRFUNC,  &send,  &recv);
  1709.    return(rval);
  1710. }
  1711.  
  1712. /**********************************
  1713.  END OF NOVELL NETWORK FUNCTIONS
  1714. **********************************/
  1715.  
  1716.