Ignore:
Timestamp:
Nov 24, 2002, 9:45:05 PM (23 years ago)
Author:
umoeller
Message:

Sources as of 1.0.0.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/lan.c

    r222 r229  
    3939#include <os2.h>
    4040
    41 #define PURE_32
    42 #include <neterr.h>
    43 #include <netcons.h>
    44 #include <server.h>
     41// #define PURE_32
     42// #include <neterr.h>
     43// #include <netcons.h>
     44// #include <server.h>
    4545
    4646#include <stdlib.h>
     
    6767 ********************************************************************/
    6868
    69 typedef API32_FUNCTION NET32WKSTAGETINFO(const unsigned char *pszServer,
     69#define API32_FUNCTION APIRET APIENTRY
     70
     71typedef API32_FUNCTION NET32WKSTAGETINFO(PCSZ pszServer,
    7072                                         unsigned long ulLevel,
    71                                          unsigned char *pbBuffer,
     73                                         PBYTE pbBuffer,
    7274                                         unsigned long ulBuffer,
    7375                                         unsigned long *pulTotalAvail);
    7476
    75 typedef API32_FUNCTION NET32SERVERENUM2(const unsigned char *pszServer,
     77typedef API32_FUNCTION NET32SERVERENUM2(PCSZ pszServer,
    7678                                        unsigned long ulLevel,
    77                                         unsigned char *pbBuffer,
     79                                        PBYTE pbBuffer,
    7880                                        unsigned long cbBuffer,
    7981                                        unsigned long *pcEntriesRead,
    8082                                        unsigned long *pcTotalAvail,
    8183                                        unsigned long flServerType,
    82                                         unsigned char *pszDomain);
     84                                        PBYTE pszDomain);
     85
     86typedef API32_FUNCTION NET32SERVICESTATUS(PCSZ pbBuffer,
     87                                          unsigned long ulBuffer);
     88
     89typedef API32_FUNCTION NET32SERVICEGETINFO(PCSZ pszServer,
     90                                           PCSZ pszService,
     91                                           unsigned long ulLevel,
     92                                           PBYTE pbBuffer,
     93                                           unsigned long ulBuffer,
     94                                           unsigned long *pulTotalAvail);
     95
     96typedef API32_FUNCTION NET32SERVICECONTROL(PCSZ pszServer,
     97                                          PCSZ pszService,
     98                                          unsigned short usOpcode,
     99                                          unsigned short usArg,
     100                                          PBYTE pbBuffer,
     101                                          unsigned long ulBuffer);
     102
     103typedef API32_FUNCTION NET32SERVICEINSTALL(PCSZ pszServer,
     104                                           PCSZ pszService,
     105                                           PCSZ pszCmdArgs,
     106                                           PBYTE pbBuffer,
     107                                           unsigned long ulBuffer);
    83108
    84109/* ******************************************************************
     
    92117NET32WKSTAGETINFO *pNet32WkstaGetInfo = NULL;
    93118NET32SERVERENUM2 *pNet32ServerEnum2 = NULL;
     119NET32SERVICESTATUS *pNet32ServiceStatus = NULL;
     120NET32SERVICEGETINFO *pNet32ServiceGetInfo = NULL;
     121NET32SERVICECONTROL *pNet32ServiceControl = NULL;
     122NET32SERVICEINSTALL *pNet32ServiceInstall = NULL;
    94123
    95124RESOLVEFUNCTION NetResolves[] =
    96125    {
    97126        "Net32WkstaGetInfo", (PFN*)&pNet32WkstaGetInfo,
    98         "Net32ServerEnum2", (PFN*)&pNet32ServerEnum2
     127        "Net32ServerEnum2", (PFN*)&pNet32ServerEnum2,
     128        "Net32ServiceStatus", (PFN*)&pNet32ServiceStatus,
     129        "Net32ServiceGetInfo", (PFN*)&pNet32ServiceGetInfo,
     130        "Net32ServiceControl", (PFN*)&pNet32ServiceControl,
     131        "Net32ServiceInstall", (PFN*)&pNet32ServiceInstall,
    99132    };
    100133
     
    105138/*
    106139 *@@ lanInit:
    107  *
     140 *      initializes the LAN server interface.
     141 *
     142 *      Returns:
     143 *
     144 *      --  NO_ERROR: functions resolved successfully,
     145 *          engine is ready.
     146 *
     147 *      or the error codes from doshResolveImports.
    108148 */
    109149
     
    118158    }
    119159
    120     printf(__FUNCTION__ ": arc %d\n", G_ulNetsResolved);
    121 
    122     return (G_ulNetsResolved);
     160    return G_ulNetsResolved;
    123161}
    124162
     
    139177{
    140178    APIRET arc;
     179
    141180    if (!(arc = lanInit()))
    142181    {
     
    150189            if (!(arc = pNet32ServerEnum2(NULL,
    151190                                          1,          // ulLevel
    152                                           (PUCHAR)pBuf,       // pbBuffer
     191                                          (PBYTE)pBuf,       // pbBuffer
    153192                                          cb,          // cbBuffer,
    154193                                          &ulEntriesRead, // *pcEntriesRead,
     
    170209}
    171210
     211/*
     212 *@@ lanServiceGetInfo:
     213 *      queries the given service.
     214 *
     215 *@@added V1.0.0 (2002-09-24) [umoeller]
     216 */
     217
     218APIRET lanServiceGetInfo(PCSZ pcszServiceName,
     219                         PSERVICEBUF2 pBuf)
     220{
     221    APIRET  arc;
     222
     223    if (!(arc = lanInit()))
     224    {
     225        ULONG   ulBytesAvail = 0;
     226        arc = pNet32ServiceGetInfo(NULL,
     227                                   pcszServiceName,
     228                                   2,        // level
     229                                   (PBYTE)pBuf,
     230                                   sizeof(SERVICEBUF2),
     231                                   &ulBytesAvail);
     232
     233    }
     234
     235    return arc;
     236}
     237/*
     238 *@@ lanServiceInstall:
     239 *      starts the given service. The service name
     240 *      must be fully qualified so you cannot
     241 *      abbreviate "requester" with "req", for
     242 *      example (as valid with the net command).
     243 *
     244 *      Returns, among others:
     245 *
     246 *      --  NO_ERROR
     247 *
     248 *      --  NERR_ServiceInstalled (2182): the service
     249 *          has already been started.
     250 *
     251 *      --  NERR_BadServiceName (2185): invalid service
     252 *          name.
     253 *
     254 *@@added V1.0.0 (2002-09-24) [umoeller]
     255 */
     256
     257APIRET lanServiceInstall(PCSZ pcszServiceName,
     258                         PSERVICEBUF2 pBuf2)        // out: service data
     259{
     260    APIRET  arc;
     261
     262    if (!(arc = lanInit()))
     263    {
     264        SERVICEBUF2 buf2;
     265
     266        if (!(arc = pNet32ServiceInstall(NULL,
     267                                         pcszServiceName,
     268                                         NULL,
     269                                         (PBYTE)pBuf2,
     270                                         sizeof(SERVICEBUF2))))
     271            ;
     272    }
     273
     274    return arc;
     275}
     276
     277/*
     278 *@@ lanServiceControl:
     279 *      queries, pauses, resumes, or stops the given service.
     280 *
     281 *      opcode must be one of:
     282 *
     283 *      --  SERVICE_CTRL_INTERROGATE (0): interrogate service status.
     284 *
     285 *      --  SERVICE_CTRL_PAUSE (1): pause service.
     286 *
     287 *      --  SERVICE_CTRL_CONTINUE (2): continue service.
     288 *
     289 *      --  SERVICE_CTRL_UNINSTALL (3): stop service.
     290 *
     291 *@@added V1.0.0 (2002-09-24) [umoeller]
     292 */
     293
     294APIRET lanServiceControl(PCSZ pcszServiceName,
     295                         ULONG opcode,
     296                         PSERVICEBUF2 pBuf2)        // out: service data
     297{
     298    APIRET  arc;
     299
     300    if (!(arc = lanInit()))
     301    {
     302       if (!(arc = pNet32ServiceControl(NULL,
     303                                        pcszServiceName,
     304                                        opcode,
     305                                        0,
     306                                        (PBYTE)pBuf2,
     307                                        sizeof(SERVICEBUF2))))
     308            ;
     309
     310    }
     311
     312    return arc;
     313}
     314
    172315#ifdef __LAN_TEST__
    173316
Note: See TracChangeset for help on using the changeset viewer.