Programmer's Reference/Libnc

LIBNC

Introduction

The NetCon Network Service library libnc provides a set of APPLICATION PROGRAM INTERFACE (API's) for UNIX Client programs utilizing NCP and Bindery protocols.

Programs utilizing these calls should be linked to libnc.a and libsocket.a.

Libnc NetCon NCP Network Service Library

AddBinderyObjectToSet

Library

-lnc

Syntax

#include 

int AddBinderyObjectToSet (objname, objtype, propname, membername, membertype)
u_char     *objname, *propname, *membername;
u_int     objtype, membertype;

Description

This function is used to add new entries into the bindery and property databases by adding a bindery object to a property of type Set.

objname Object name (input) This string contains the object name. ALL strings used in this function are 48 characters max including NULL terminator. This is the name of the object in the bindery database to which we will add the new member.

objtype Object type (input) This is the type of object that a new member will be added to.

propname Property name (input) this string contains the name of the property to which a new member will be added.

membername (input) this string is the name of the object to be added to the property.

membertype (input) the type of object to be added.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example usage

NCP Command isssued

0x17, 0x41

CheckMembership (IsBinderyObjectInSet)

Library

-lnc

Syntax

CheckMembership (objname, objtype, propname, membername, membertype)
     u_char     *objname, *propname, *membername;
     u_int     objtype, membertype;

Description

This function is used to determine if an object is a member of a property Set

objname Object name (input) This string contains the object name. ALL strings used in this function are 48 characters max including NULL terminator.

objtype Object type (input) This is the type of object .

propname Property name (input) this string contains the name of the property .

membername (input) this string is the name of the object .

membertype (input) the type of object.

Values

Diagnostics

The return value form this function is 0 upon success and upon failure a NC_ERRNO number will returned.

Example Usage

NCP Command Issued

0x17, 0x43; /* check membership request

Remove/DeleteBinderyObjectFromSet

Library

-lnc

Syntax

RemoveBinderyObjectFromSet (objname, objtype, propname, membername, membertype)
     u_char     *objname, *propname, *membername;
     u_int     objtype, membertype;

Description

This function is used to delete entries from the bindery and property databases by deleting a bindery object from a property of type Set.

objname Object name (input) This string contains the object name. ALL strings used in this function are 48 characters max including NULL terminator. This is the name of the object in the bindery database from which we will delete the member.

objtype Object type (input) This is the type of object that a member will be deleted from.

propname Property name (input) this string contains the name of the property from which a member will be deleted.

membername (input) this string is the name of the object to be deleted from the set.

membertype (input) the type of object to be deleted.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x17, 0x42; /* add-bindery-object-to-set request

MapTrustee

Library

-lnc

Syntax

MapTrustee (objid, objname, objtype, propname, objid, objqty)
     u_long objid;
     u_char     *objname, *propname;
     u_int     objtype;
     char *mobjid;
     u_int *mobjqty;

Description

This function is used map a object to a trustee id

objid Object Id (input) to map

objname Object name (input) This string contains the object name. ALL strings used in this function are 48 characters max including NULL terminator. This is the name of the object in the bindery database to which we will map trustee id.

objtype Object type (input) This is the type of object.

propname Property name (input) this string contains the name of the property which a trustee will be mapped.

mobjectid Mapped object id (output) this is the mapped trustee id that is returned.

mobjqty Mapped object qty (output) this is the quantity of trustees that have been already mapped including this one.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x17, 0x4C; /* Map trustee

AddTrustee

Library

-lnc

Syntax

AddTrustee (path, objid, rights, hndle)
     u_char *path;
     u_long     objid;
     u_int     rights, hndle;

Description

This function adds a trustee to a file or directory's list of trustees.

path (input) this is a NULL terminated string containing the full pathname.

objid (input) this is the trustee unique object id.

rights (input) rights to assign to the file or directory.

hndle (input) file handle.

Values

The bits in the trustee rights mask are.

bit

15 - 9 = not defined.

8 = Supervisor (all rights are granted).

-------

7 = Modify (file attributes can be modified).

6 = Visible ( file can been seen in directory scans.

5 = Access Control ( Trustee rights can be changed).

4 = Delete (file can be deleted).

---------

3 = Create (file can be created).

2 = Reserved.

1 = Write (file reads are allowed).

0 = Read (file reads are allowed).

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x16, 0x27; /* add-trustee request

AttachToFileServer

Library

-lnc

Syntax

AttachToFileServer(sname, connid)
char *sname;
u_short *connid;

Description

This function attaches (connects) to the named file server, resets the PrimaryConnectionID and returns the connection id in connid.

sname (input) Server name NULL terminated string.

connid (output) Connection id.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned. Error 0xf8 = already attached.

Example Usage

NCP Command Issued

DetachFromFileServer

Library

-lnc

Syntax

DetachFromFileServer(connid)
u_short connid;

Description

This function disconnects from the file server references by the connection id connid.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

ChangeBinderyObjectPassword

Library

-lnc

Syntax

ChangeBinderyObjectPassword (objname, objtype, oldpasswd, newpasswd)
     u_char     *objname, *oldpasswd, *newpasswd;
     u_int     objtype;

Description

This function changes the password entry for a bindery object.

objname Object name (input) string 48 characters max including NULL terminator, containing the name of the object.

objtype Object type (input) type of object.

oldpasswd Old password (input) Null terminated string containing the old password (NULL = no password).

newpassword New password (input) Null terminates string containing the new password to be assigned to the bindery object (NULL = no password).

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x17, 0x40; /* create-bindery-object-password request

GetConnectionNumber

Library

-lnc

Syntax

GetConnectionNumber()

Description

This function returns the default connection number.

Values

Diagnostics

The return value from this function is the connection number upon success. Upon failure a -1 will be returned.

Example Usage

NCP Command Issued

GetConnectionInformation

Library

-lnc

Syntax

GetConnectionInformation(conn_num, objname, objtype, objid, logintime)
u_int conn_num;
char *objname;
int *objtype;
u_long *objid;
u_char *logintime;

Description

This function returns information about the user logged in the specified connection number.

conn_num Connection number (input) of the server (1 to 250).

objname Object name (Output) this field receives a string (48 bytes max including the NULL terminator) containing the name of the bindery object logged in at the connection number.

objtype Object type (Output) this field receives the objects type.

objid Object id (Output) receives the objects id.

logintime (Output) the file receives the date and time of the login.

Values

Diagnostics

The return value from this function is 0 upon success.

Example Usage

NCP Command Issued

0x17, 0x16

GetServerSerialNumber

Library

-lnc

Syntax

GetServerSerialNumber(serialno, applno)
u_char *serialno, *applno;

Description

This function fills in the serial and application number of the default connection, both are character arrays. serialno[4] and applhno[2].

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x17, 0x12

GetServerDescription

Library

-lnc

Syntax

GetServerDescription(company,  revision, rdate, notice)
char *company, *revision, *rdate, *notice;

Description

This function returns the strings company, revision, revision date and copyright notice.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x17, 0xc9

GetServerVersion

Library

-lnc

Syntax

GetServerVersion(sname, version, subversion, max_conn, conn_in_use, mvols)
char *sname, *version, *subversion;
u_int *mvols, *max_conn, *conn_in_use;

Description

This function returns information on the named server.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x17, 0x11

CreateDir

Library

-lnc

Syntax

CreateDir (path, rights, hndle)
     u_char     *path;
     u_int     rights, hndle;

Description

This function creates a directory on the default server.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x15, 0x0a

DeleteDir

Library

-lnc

Syntax

DeleteDir (path, rights, hndle)
     u_char     *path;
     u_int     rights, hndle;

Description

This function deletes a directory on the server with the default connection id.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x16, 0x0b

CreateProperty

Library

-lnc

Syntax

CreateProperty (objname, objtype, propname, propflags, propsecurity)
     u_char     *objname, *propname;
     u_int     objtype, propflags, propsecurity;

Description

This function creates a new property for an object.

objname Object name (input) 48 byte max NULL terminated string containing the object name.

objtype Object type (input) type of object.

propname Property name (input) 48 byte max NULL terminated string containing the property name.

propflags Property flags (input) static or dynamic, ORed with item or set.

propsecurity Property security (input) indicates read/write access.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x17, 0x39

CreateBinderyObject

Library

-lnc

Syntax

CreateBinderyObject (objname, objtype, objflag, objsecurity)
     u_char     *objname;
     u_int     objtype, objflag, objsecurity;

Description

This function creates an object in the bindery database

objname Object name (input) 48 byte max including NULL terminator string containing the new object name.

objtype Object type (input) type of new bindery objects.

objflag Object flag (input) dynamic or static.

objsecurity Object security (input) read/write access of object.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x17, 0x32

DeleteBinderyObject

Library

-lnc

Syntax

DeleteBinderyObject(objname, objtype)
     u_char     *objname;
     u_int     objtype;

Description

objname Object name (input) 48 byte max including NULL terminator string containing the object name to delete.

objtype Object type (input) type of bindery objects to delete.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x17, 0x40; /* create-bindery-object-password request

GetBinderyObjectID

Library

-Inc

Syntax

GetBinderyObjectID(objname, objtype, objid)
char *objname;
u_int objtype;
u_long *objid;

Description

This function returns an object unique identification number.

objname Object name (input) 48 byte max including NULL terminator string containing the object name.

objtype Object type (input) type of bindery objects.

objid Object id (output) unique id number.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x17, 0x40; /* create-bindery-object-password request

LoginToFileServer

Library

-Inc

Syntax

LoginToFileServer(objname, objtype, objpasswd)
char *objname, *objpasswd;
u_int objtype;

Description

This function logs a user (bindery object) into a file server.

objname Object name (input) 48 byte max including NULL terminator string containing the object name.

objtype Object type (input) type of bindery objects.

objpasswd Object password (input) 128 max byte NULL terminated string containing the objects password.

Values

Diagnostics

The return value from this function is 0 upon success.

Example Usage

NCP Command Issued

0x17, 0x14

GetBinderyObjectName

Library

-Inc

Syntax

GetBinderyObjectName(objid, objname, objtype)
u_long objid;
char *objname;
u_int *objtype;

Description

This function returns the name and type of an object from the bindery database.

objid Object id (input) unique object id.

objname Object name (output) 48 byte max NULL terminated string containing the object name being returned.

objtype Object type (output) returned.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

0x17, 0x36 Get Bindery Object Name

AttachAndLoginToFileServer

Library

-Inc

Syntax

AttachAndLoginToFileServer(server)
char *server;

Description

This function attaches and logs into the named server with the default user id mapping from the "/usr/lib/netcon/netcpasswd" database.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

net_ioctl_fd (NETC)

Library

-lnc

Syntax

#include "netccals.h"

net_ioctl_fd (fd, proto, cmd, arg)

int fd, cmd, *arg;

char *proto;

Description

Like net ioctl (NETC), this function is used to send specific ioctl (S) commands to socket descriptors. In this case, however, the caller is required to provide a socket descriptor fd, obtained from a socket () call.

This function is not normally called by the user, but by higher- level functions such as netcconnect (NETC), and netclogin (NETC). For example, netcconnect (NETC) calls socket () to obtain a file descriptor. It then calls net ioctl fd (NETC) on that file descriptor to attach to a server. Finally, netcconect (NETC) returns the file descriptor to the caller.

Diagnostics

If the call is sucessful, a value of 0 is returned. Depending on the command, other information may also be returned. Otherwise, -1 is returned and errno has the error number.

Example Usage

The netcconect (NETC) is a good example of opening a socket and making an ioctl() request.

/* Attach to specified server, returning connection ID */

netcconect (server)

char *server;

{

int fd;

if ((fd=socket (AF_NS, SOCK_DGRAM, 0)) <0)

return -1

if (net_ioctl_fd (fd, "NETC", NETC_SYSC_CONNECT,

(int *) &server)) {

close (fd);

return -1

}

SetPrimaryConnectionID (fd);

return fd;

}

See Also

net_ioctl_fd (NETC), ioctl (), socket ().

login_to_server

Library

-Inc

Syntax

login_to_server(connid, server, user, pass)
char *server, *user, *pass;

Description

This function logs into the specified server with the specified users id.

connid Connection id (input).

server Server name (input) string 48 bytes max NULL terminated containing the name of the server to login to.

user User name (input) string 48 bytes max NULL terminated containing the name of the user to login.

pass Password (input) string 128 bytes max with NULL terminator, containing the user's password.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

LoginToFileServer.

netcsetconns (NETC)

Library

-lnc

Syntax

netcsetconns (count)

int count;

Description

count specifies the maximum simultaneous connections to be allowed. This function sets the maximum number of client connections available at one time. The real limit is set by the NetCon kernel code; this function only sets an available maximum that is less than or equal to the kernel limit, but not less than two. Due to system requirements, netcsetconns (NETC) can only be called before netcinit (NETC) has been called.

This function is called by the Unix-to-NetWare password mapping daemon netcpass at startup, before it calls netcinit (NETC).

Diagnostics

netcsetconns (NETC) returns 0 on success. It will fail if netcinit (NETC) has already been called, and will return -1 with errno set to EACCES.

Example Usage

/* Allow up to 10 simultaneous client connections */

if (netcsetconns (10)) {

perror ("Can't set connection count");

exit (1);

}

netcaddgroup NETC)

Library

-lnc

Syntax

netcaddgroup (uid, gid)

int uid, gid

Description

Add a group to a users NetCon supplemental group list. This function will add the group with ID gid to the supplemental group list of the user with ID uid. The uid is the user ID number from the /etc/passwd file, and gid is the group ID number from the /etc/group file that is to be added to the users supplemental group list. If the specified user has no supplemental group list, a new one is created for the user. The NetCon kernel maintains a list of supplemental groups for each user. This table is empty at system startup. netcaddgroup (NETC) is called by netcpass at startup to update the NetCon kernel user/group table from information in the /etc/group file.

Diagnostics

netcaddgroup (NETC) returns 0 if sucessful. It will return -1 if it fails, and set errno to ENOMEM, insufficient memory to increase the table size. No validity checking is done on the user or group ID.

Example Usage

int uid, gid

if (netcaddgroup (uid, gid))

printf ("Error %d adding group. \n", errno);

netcaddentry (NETC)

Library

-lnc

Syntax

#include "netccalls.h"

netcaddentry (server, objid, uid, flags)

char *server;

int uid, flags;

unsigned long objid;

Description

This function updates the Unix user-ID-to_NetWare-Object-ID mapping table in the NetCon kernel. server points to the name of the server which is to be mapped. objid is the NetWare object ID that is to be mapped to the Unix user or group ID uid. The type of entry to be mapped, such as user or group, is indicated with the appropriate flags. The flags may be set or examined via symbolic entries in netccalls.h. The password mapping daemon netcpass calls netcaddentry (NETC) to update the NetCon kernel user map from the mapping information in /usr/lib/netcon/netcpasswd.

Diagnostics

/*

* Map unix group to a netware server group.

*/

#include "netccalls.h"

char *sname;

int unixid, flags;

u_long objid;

sname = "NETWARE";

unixid = unix_group_id;

objid = server_group_objid;

flags = GID_ENTRY;

if (netcaddentry (sname, objid, unixid, flags) <0)

fprintf (stderr,

"Error %d adding entry to kernel! \n, errno);

See Also

netcpasswd (NETC).

netcconninfo (NETC)

Library

-lnc

Syntax

#include "TFSparam.h"

netcconninfo (fd, conn, clen, serv, slen)

struct TFS_conn *conn;

struct TFS_server *serv;

int fd, clen, slen;

Description

netcconninfo (NETC) returns information about the connection specified by file descriptor fd, obtained from a netcconnect (NETC) or socket () call. The information is returned in two buffers with structures that are declared in the header file TFSparam.h. conn and serv point to the two buffers that will receive this information. clen and slen are the respective lengths of these two buffers.

Diagnostics

netcconninfo (NETC) returns 0 on success, and fills in the TFS_conn and TFS_server structures. Otherwise, -1 is returned with errno set to the error number.

Example Usage

#include "TFSparam.h"

struct TFS_conn conn;

struct TFS_server serv;

int slen, clen, fd

if (netcconninfo (fd, &conn, sizeof (conn), &serv, sizeof (serv))

perror ("netcconninfo");

netcgetuseradminreq

Library

-lnc

Syntax

#include "TFSparam.h"

netcgetuseradminreq (req, rlen)

struct Net_User_Req *req;

int *rlen;

Description

netcgetuseradminreq (NETC) is used to service administrative requests from the NetCon kernel. The kernel makes this request to map Unix users and groups to NetWare server users and groups on demand; that is, when a Unix user attempts to use a mounted NetWare server. The user call will block until the kernel makes a request.

Only one netcgetuseradminreq (NETC) administrative request may be outstanding. An attempt to schedule more than one will result in an EAGAIN error on the subsequent attempts. The password mapping daemon netcpass services these administrative requests. netcpass calls this function and waits for kernel requests. Therefore, there is always an outstanding administrative request. No others are permitted while netcpass is running.

Diagnostics

netcgetuseradminreq (NETC) returns 0 on success, with the request structure and the new request length filled in. Otherwise, -1 is returned with errno set to the error number.

Example Usage

netcgetuseradminreq (NETC) uses the following structure to obtain information from the kernel. It is the callers responsibility to declare this structure.

struct Net_User_Req {

int code;

char serv [TFS_SRVNAMESIZ]; unsigned

char data [256];

} req;

int rlen;

rlen = sizeof (req);

if (netcgetuseradminreq (&req, &rlen))

perror ("GetUserAdminReq error");

See Also

netcsenduseradminreply (NETC).

netcsenduseradminreply (NETC)

Library

-lnc

Syntax

#include "TFSparam.h"

netcsenduseradminreply (buf, len, status)

char *buf;

int len, status;

Description

netcsenduseradminreply (NETC) is used to send replies to the administrative requests received from the NetCon kernel via netcgetuseradminreq (NETC). buf is usually a pointer to a TFS_pwent structure, len is the size of the structure, and status is zero to indicate success, or an error number.

The password mapping daemon netcpass uses this function in conjunction with netcgetuseradminreq (NETC) to communicate responses to the kernel requests for mapping information.

Diagnostics

netcsenduseradminreply (NETC) returns 0 on success, -1 on failure with errno set to the error number.

Example Usage

if (netcsenduseradminreply (buf, len, status) <0) {

perror ("SendUserAdminReply error");

return -1;

}

See Also

netcgetuseradminreq (NETC).

netclogin (NETC)

Library

-lnc

Syntax

netclogin (fd, username, passwd)

int fd;

char *username, *passwd;

Description

The netclogin function logs the user specified by username into the server specified by file descriptor fd, using passwd as the users password. The file descriptor, fd is obtained by calling netcconnect (NETC). This login function performs an encrypted login, unlike LoginToFileServer (NETC).

It is also possible to login without a username and password using this function. If the value of the username and passwd parameters is NULL, the default user (see netcpasswd (NETC)) is logged in.

If the encrypted login attempt fails, an unencrypted login is attempted.

Diagnostics

A value of 0 is returned if the login is sucessful. If the login attempt fails, a value of -1 is returned and errno is set to the error number.

Example Usage

int fd;

char *username, *passwd;

if (netclogin (fd, username, passwd)<0)

return -1; /*error*/

else

return 0; /*sucess*/

NCP Command Issued

Encrypted login 0x17, 0x18 or unencrypted login 0x17, 0x14.

See Also

login_to_server (NETC), netcconnect (NETC, netcpasswd (NETC), LoginTOFileServer (NETC).

net_ioctl

Library

-Inc

Syntax

net_ioctl(proto, cmd, arg)
char *proto;
int cmd;
int *arg;

Description

This function is used to send ioctl commands to the socket descriptors see "/usr/lib/netcon/src/h/syscall.h" for all the calls supported by NetCon. All types of communication to and from the kernel can take place through ioctl calls on the UNIX file descriptors returned to user programs from sockets() system calls.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

ncp_init

Library

-Inc

Syntax

ncp_init()

Description

This function initilizes the kernel structures containing the Server tables, the connection table and the user mapping table etc... This function is automatically run by "netcon" and "netcpass" at startup. If the kernel Server table is NULL this can be run at any time.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

net_mount

Library

-Inc

Syntax

net_mount (proto, alen, addr, rdir, ldir, flags)
     char *proto, *addr, *rdir, *ldir;
     int alen, flags;

Description

This function mounts a NOVELL NetWare servers VOLUMES as a UNIX directory. This function is like the UNIX mount command or call.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

net_mount( "NCP", 0, "", "NW386:SYS:/", "/mnt");

NCP Command Issued

NWfh_to_fd (NETC)

Syntax

NWfh_to_fd (fd(fh, off)

char *fh;

off_t off;

Description

Allocate a file descriptor for an open network file. fh is an open file handle. off is the current offset of the file. The file handle and offset are saved in the file descriptor structure, and the file descriptor is returned.

Diagnostics

An integer file descriptor is returned. This file descriptor can be used in subsequent NWread (NETC), NWwrite (NETC), NWlseek (NETC), and NWclose (NETC) calls. -1 is returned if the function fails, and errno is set to the error number. The only error returned is EMFILE, too many open files.

Example Usage

int fd;

fd=NWfh_to_fd (fh, (off_t) 0);

NWclose (fd);

This program is used by the nprint program to allocate a file descriptor for the open file handle returned by the server in response to a CreateQueue request. Subsequent NWwrite (NETC) calls are made using this file descriptor.

ncp_connect

Library

-Inc

Syntax

ncp_connect(server)
char *server;

Description

This function connects to the named server.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

ncp_request

Library

-Inc

Syntax

ncp_request(fd, func_code, reqbuf, reqlen, replybuf, replylen, status)
     char *reqbuf, *replybuf;
     int *status, *replylen;

Description

This function can be used to send out any NCP request you may require to the network. All the required NCP functions are preformed through calls from the higher level interfaces, so programs never have to make NCP calls directly. But we must play so have fun, you had better have a Sniffer for this one.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

NWopen

Library

-Inc

Syntax

NWopen(fname, mode)
     char *fname;

Description

Opens a file on the default file server same as open().

fname Full pathname (input) string 256 bytes max including NULL terminator.

mode Mode (input) 0 = readonly, 1 = write only, 2 = read/write, see "fcntl.h"

Values

Diagnostics

The return value from this function is a UNIX file descriptor upon success and upon failure a -1 will be returned.

Example Usage

NCP Command Issued

NWread

Library

-Inc

Syntax

NWread(fd, buf, len)
     int fd, len;
     char *buf;

Description

This function reads from the file descriptor on the default NetWare server the amount of data specified in len into buf. This file descriptor is established by the an NWopen() call.

fd File descriptor (input) returned from NWopen().

buf Pointer to a buffer (output).

len Length to read from file and write int

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

NWwrite

Library

-Inc

Syntax

NWwrite(fd, buf, len)
     int fd, len;
     char *buf;

Description

This function writes to a file descriptor at the current file pointer position on a NetWare server the amount of data specified by len, from buf.

fd File descriptor (input) returned from NWopen().

buf Pointer to a buffer (input).

len Length of data to write (input).

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

NWclose

Library

-Inc

Syntax

NWclose(fd)
     int fd;

Description

This function closes a file opened with NWopen() see "close()".

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

NWlseek

Library

-Inc

Syntax

NWlseek(fd, off, whence)
     off_t off;
     int fd, whence;

Description

This function sets the file pointer position bases on offset and whence.

fd File Descriptor (input).

off Offset (input) in the file fd.

whence The offset is from whence in the file, 0 = pointer set to off, 1 = pointer set to current plus off, 2 = end of file plus offset.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

ReadPropertyValue

Library

-Inc

Syntax

ReadPropertyValue(objname, objtype, pname, seg, pvalue, moresegs, pflags)
     char *pname, *objname;
     int seg;
     u_int objtype;
     u_char *pvalue, *moresegs, *pflags;

Description

This function returns the value of an object's property from the bindery database.

objname Object name (input) 48 byte string max including the NULL terminator containing the object name.

objtype Object type (input).

pname Property name (input) string 16 bytes long including the NULL terminator containing the name of the property.

seg Segment number (input) number of data reads 1st segment = 1 , 2nd segment = 2 etc...

pvalue Property Value (output) a pointer to a buffer t receives the property value 128 bytes max per segment.

moresegs More segments (output) receives a flag of 0x0 if no more segments, 0xff if more segments follow.

pflags Property flags (output) receives the dynamic or static flag ORed with item or set flags.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

NetwareRequest

Library

-Inc

Syntax

NetwareRequest(code, req, reqlen, reply, replen)
u_int code;
u_char *req, *reply;
int reqlen, *replen;
onID = -1;

Description

This function issues a netware request directly to the network.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

GetDefaultConnectionID

Library

-Inc

Syntax

GetDefaultConnectionID()

Description

This function returns the default connection id.

Values

Diagnostics

The return value from this function is the default connection id upon success and upon failure a -1 will be returned.

Example Usage

NCP Command Issued

GetPreferredConnectionID

Library

-Inc

Syntax

GetPreferredConnectionID()

Description

This function returns the preferred connection id.

Values

Diagnostics

The return value from this function is the preferred connection id upon success and upon failure a -1 will be returned.

Example Usage

NCP Command Issued

SetPreferredConnectionID

Library

-Inc

Syntax

SetPreferredConnectionID(id)

Description

This function sets the preferred connection to id.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

GetPrimaryConnectionID

Library

-Inc

Syntax

GetPrimaryConnectionID()

Description

This function returns the primary connection id

Values

Diagnostics

The return value from this function is the primary connection id upon success and upon failure a -1 will be returned.

Example Usage

NCP Command Issued

SetPrimaryConnectionID

Library

-Inc

Syntax

SetPrimaryConnectionID(id)

Description

This function sets the primary connection to id.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

ScanBinderyObject

Library

-Inc

Syntax

ScanBinderyObject(searchname, searchtype, objid, objname, objtype,
          objhasproperties, objflags, objsecurity)
     char *searchname, *objname;
     u_char *objhasproperties, *objflags, *objsecurity;
     u_int searchtype, *objtype;
     u_long *objid;

Description

This function scans the bindery database for an object.

searchname Object name (input) to search for.

objtype Object type (output) Receives the type of the matching object.

objhasproperties Object has properties (output) this field receives a 0x0 if no properties exist to scan or a 0xff if the object has properties.

objflags Object flags (output) this field is updated with a dynamic or static flag.

objsecurity Object security (output) is updated to indicate read/write access.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

ScanProperty

Library

-Inc

Syntax

ScanProperty( objname, objtype, searchprop, sequencenum,
     propname, propflags, propsecurity, propHasValue, moreflag)
u_char     *objname, *searchprop, *propname, *propflags, *propsecurity, 
     *propHasValue, *moreflag;
u_long     *sequencenum;
u_int     objtype;

Description

This function scans the bindery database for an object's properties.

objname Object name (input) this string is a max of 48 bytes long including the NULL terminator contains the name of the object.

objtype Object type (input) .

searchprop Search property name (input) string is a max of 16 bytes NULL terminated; may contain wildcards, including NULL.

seqencenum Sequence number (input/output) contains the number from the previous search (initial = -1) and is updated each search.

propname Property name (input) 16 byte NULL terminated string matching the property.

propflags Property flags (output) this field is updated with the property flags dynamic or static ORed with item or set.

propsecurity Property security (output) this field is updated to match the read/write access of the property.

propHasValue Property has value (output) updated to indicate the property has a attached value, 0 = no, 0xff = yes.

moreflag More properties (output) updated to indicate the object has more properties to scan for, 0 = no, 0xff = yes.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued

WritePropertyValue

Library

-Inc

Syntax

WritePropertyValue (objname, objtype, propname, segno, eraseflag, value)
     u_char     *objname, *propname, *value;
     u_int     objtype, segno, eraseflag;

Description

This function writes a value to a property of type Item.

objname Object name (input) this string is a max of 48 bytes long including the NULL terminator contains the name of the object.

objtype Object type (input) .

propname Property name (input) string is a max of 16 bytes NULL terminated;

seqencenum Sequence number (input) contains the number of the data to be written (first = 1) and is updated every write.

eraseflag Overwrite property (input).

value Property value (input) to write max of 128 bytes.

Values

Diagnostics

The return value from this function is 0 upon success and upon failure a NC_ERRNO number will be returned.

Example Usage

NCP Command Issued