enum {
Vvol = -2, // version field of volumes
Vinfo = -3, // Version field of info files
Proot = -2, // root dir is a volume & has the this path
};
enum {
CACHETIME = 3, // read-ahead caches timeout after this many secs.
IOCHUNK = 4096, // file IO must be at offsets module this
NCPVER = 1, // NCP version
BASEMTU = 8300, // MUT used to login
MTU = 0xffff, // MTU hoped for (maybe negoiated down)
OBJNAMLEN = 48, // max object name len
PROPNAMLEN = 16, // max property name len
PROPLEN = 128, // max property len
PATHLEN = 256, // max path len
VOLNAMLEN = 17, // max volume name len
FILENAMLEN = 14, // max file name len
NWKEYLEN = 8, // KEY len
MAXCONN = 300, // realistic max number of conn's on server
MAXTRENAM = 16, // max length of an NDS tree name
IPXADDRLEN = 12, // IPX address length
};
enum { /* internal: type of subfunction */
Tvarlen = 1, // add a subfunc byte and subfunc length
Tsubfun = 2, // add a subfunc byte only
Tsimple = 3, // no subfunction (old style)
};
enum { /* NCP message types */
Mattach = 0x1111,
Mdetach = 0x4444,
Mrequest = 0x2222,
Mreply = 0x3333,
Mdisconnected = 0xbbbb // gleaned from experience rather than documentation
};
enum { /* Object types */
OTwild = 0xffff,
OTuser = 1,
OTgroup = 2,
OTprintqueue = 3,
OTfileserver = 4,
OTtreename = 0x0278,
OTlaserjet = 0x030C,
OTbtrive = 0x004B
};
enum { /* File Attributes */
FAnormal = 0x00,
FAreadonly = 0x01,
FAhidden = 0x02,
FAsystem = 0x04,
FAexecuteonly = 0x08,
FAdirectory = 0x10,
FAneedsarchive = 0x20,
FAshareable = 0x80
};
enum { /* Search Attributes */
SAhidden = 1,
SAsystem = 2,
SAdironly = 4,
SAsubdironly = 0x10,
SAsubdirfiles = 0x8000,
SAall = 0x8006,
};
enum { /* Effective Rights */
ERnone = 0x00,
ERread = 0x01,
ERwrite = 0x02,
ERopen = 0x04,
ERcreate = 0x08,
ERdelete = 0x10,
ERownership = 0x20,
ERsearch = 0x40,
ERmodify = 0x80,
ERall = 0xff
};
enum { /* Name Spaces */
NSdos = 0,
NSmac = 1,
NSnfs = 2,
NSftam = 3,
NSos2 = 4,
NSlong = 4,
NSwinnt = 5,
};
enum { /* Data Streams */
DSdos = 0, /* DOS data */
DSresource = 0, /* Mac resource fork */
DSdata = 1, /* Mac data fork */
};
enum { /* open create mode */
OCMopen = 0x01,
OCMtruncate = 0x02,
OCMcreate = 0x08,
};
enum { /* open/create action */
OCAopened = 0x01,
OCAcreated = 0x02,
OCAreplaced = 0x04,
};
enum { /* desired access rights */
DARreadonly = 0x01, /* file rights */
DARwriteonly = 0x02,
DARdenyread = 0x04,
DARdenywrite = 0x08,
DARcompatibility = 0x10,
DARwritethrough = 0x40,
DARdeleteonclose = 0x400,
DARreadexisting = 0x01, /* directory rights */
DARwriteexisting = 0x02,
DARoldopenexisting = 0x04,
DARcreatenewentry = 0x08,
DARdeleteexisting = 0x10,
DARchangeacl = 0x20,
DARsearch = 0x40,
DARmodify = 0x80,
DARsuporvisor = 0x100,
};
enum { /* ReturnInfo mask */
RIMname = 0x1, /* noop */
RIMspace = 0x2,
RIMattr = 0x4,
RIMsize = 0x8,
RIMalloc = 0x10,
RIMeattr = 0x20,
RIMarch = 0x40,
RIMmodif = 0x80,
RIMcreate = 0x100,
RIMns = 0x200,
RIMdir = 0x400,
RIMrights = 0x800,
};
typedef struct { /* file information */
long attr;
int flags;
long size;
long created;
int creator;
long modified;
int modifier;
long accessed;
long archived;
int archiver;
int rights;
long dirent;
long dosdir;
int vol;
int creatns;
char name[PATHLEN];
}FInfo;
enum { /* Modify FileFInformation flags */
MFIattr = 0x02,
MFIcreated = 0x0c,
MFIcreator = 0x8,
MFIarchived = 0x60,
MFIarchiver = 0x80,
MFImodified = 0x300,
MFImodifier = 0x400,
MFIaccessed = 0x800,
MFIrights = 0x1000,
MFIquota = 0x2000,
};
typedef struct { /* File ServerFInformation */
char name[OBJNAMLEN];
int fsvermaj;
int fsvermin;
int maxconn;
int numconn;
int numvol;
int rev;
int sftlev;
int ttslev;
int mostconn;
int acctver;
int vapver;
int quever;
int lprver;
int consver;
int restrct;
int bridgeflag;
int mixedpaths;
int locallogin;
int prodmaj;
int prodmin;
int prodver;
int lang;
int bigfiles;
} FSInfo;
typedef struct { /* Msdos file info */
long attr;
long created;
int creator;
long modified;
int modifier;
long archived;
int archiver;
short accessed;
short grant;
short revoke;
long quota;
} Mfi;
typedef uchar Fh[6]; // file handle
typedef uchar Srch[9]; // search state handle
typedef struct Session Session;
struct Session {
int fd; // file descriptor for I/O
long txsig; // our signature
long rxsig; // their signature
int seq; // sequence number
int conn; // server's connection number
int task; // client's transaction level
int type; // do we need to add a sunfunc length ?
int mtu; // max packet size
uchar *buf; // packet buffer
uchar *p; // current pos in packet
int rxlen; // receive length
};
typedef struct VInfo VInfo;
struct VInfo {
int total;
int free;
int purgable;
int notpurged;
int dir_total;
int dir_avail;
int sectperblock;
char name[VOLNAMLEN];
};
/* bsearch.c */
extern void *bsearch(void *, void *, long, long, int (*cmp )(void *, void *));
/* conv.c */
extern Session *Attach(int);
extern int Detach(Session *);
extern int Logout(Session *);
extern int LoginObject(Session *, char *, int, char *);
extern int KeyedObjectLogin(Session *, int, char *, uchar *);
extern int GetLoginKey(Session *, int, uchar *);
extern int NegotiateBufferSize(Session *, int *);
extern int GetFileServerInfo(Session *, FSInfo *);
extern int GetStationsLoggedInfo(Session *, long, int *, int *, char *, long *);
extern int GetInternetAddress(Session *, long, uchar *, int *);
extern int GetFileServerDateAndTime(Session *, long *);
extern int GetVolumeName(Session *, int, char *);
extern int GetVolumeNumber(Session *, char *, int *);
extern int GetVolumeAndPurgeInfo(Session *, int, VInfo *);
extern int GetBinderyObjectName(Session *, ulong, char *, int *);
extern int GetBinderyObjectId(Session *, char *, int, ulong *);
extern int ScanBinderyObject(Session *, char *, int, int *, char *, int *, int *, int *, int *);
extern int ScanProperty(Session *, char *, int, char *, long *, char *, int *, int *, int *, int *);
extern int ReadPropertyValue(Session *, char *, int, char *, int, void *, int *, int *);
extern int DeteleFileOrDir(Session *, int, int, char *);
extern int RenameOrMoveFileOrDir(Session *, int, int, int, char *, char *);
extern int ModifyFileOrDirInfo(Session *, int, int, int, Mfi *, char *);
extern int OpenCreateFileOrSubdir(Session *, int, int, int, long, int, long, char *, int *, Fh,FInfo *);
extern int ReadFromAFile(Session *, Fh, void *, long *, long);
extern int WriteToAFile(Session *, Fh, void *, int, long);
extern int CommitFile(Session *, Fh);
extern int CloseFile(Session *, Fh);
extern int InitializeSearch(Session *, int, char *, Srch);
extern int SearchFileOrSubdirectory(Session *, Srch, int, int, int, char *, int,FInfo *);
extern int SearchFileOrSubdirectorySet(Session *, Srch, int, int, int, char *, long,FInfo *, int *, int *);
extern int ObtainFileOrDirInfo(Session *, int, int, long, char *,FInfo *);
/* exch.c */
extern int ncphdr(Session *, int, int);
extern int ncpcall(Session *);
extern void pstr(Session *, char *);
extern void pmem(Session *, void *, int);
extern void pb32(Session *, uint);
extern void pl32(Session *, uint);
extern void pb16(Session *, ushort);
extern void pl16(Session *, ushort);
extern void p8(Session *, uchar);
extern void gfhand32(Session *, Fh);
extern void ginfo(Session *,FInfo *);
extern void phps(Session *, char *);
extern void pphs2(Session *, char *, char *);
extern void gmem(Session *, void *, int);
extern void gstr(Session *, char *, int);
extern uint gb32(Session *);
extern uint gl32(Session *);
extern ushort gb16(Session *);
extern ushort gl16(Session *);
extern uchar g8(Session *);
extern void pdatetime(Session *, long);
extern void pdate(Session *, long);
extern long gdatetime(Session *);
extern long gdate(Session *);
extern long gtbuf(Session *);
extern char *strupr(char *);
extern char *strlwr(char *);
/* names.c */
extern void uid2names(Session *, ulong, char **, char **);
/* ncpfmt.c */
extern int ncpfmt(Fmt *);
/* ncpfs.c */
extern void usage(void);
extern void main(int, char **);
/* nwcrypt.c */
extern void shuffle(u8int *, u8int *, int, u8int *);
extern void nw_encrypt(u8int *, u8int *, u8int *);
/* nwerrstr.c */
extern char *nwerrstr(uint);
/* info.c */
extern int numinfo(void);
extern int dirgeninfo(int, Dir *);
extern int makeinfo(int);
extern int readinfo(int, char *, int, int);
extern void freeinfo(int);
extern int walkinfo(char *);
/* bindery.c */
extern int servers(Fmt *);
extern int session(Fmt *);
extern int printers(Fmt *);
extern int users(Fmt *);
extern int who(Fmt *);
extern int whoami(Fmt *);
extern int bindery(Fmt *);
extern int groups(Fmt *);
extern int volumes(Fmt *);
extern int ping(Fmt *);
#pragma varargck type "N" void*
extern char Host[]; // host connected to
extern int Numvol; // number of volumes
extern int Debug; // Packet hex-dump
extern int Maxio; // Maximum IO chunk size
extern int Slip; // time slip in secs between server and us
extern int Fsver; // server software version * 1000
extern int Bigfiles; // flag: 64 bit files possible on this server
extern Qid Root; // root of remote system
extern Session *Sess; // netware session
extern ulong Myuid; // my UID
|