2 * Copyright (c) 1999, 2000, 2001 Boris Popov
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Boris Popov.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #ifndef _NETNCP_NCP_LIB_H_
36 #define _NETNCP_NCP_LIB_H_
41 #include <netncp/ncp.h>
42 #include <netncp/ncp_conn.h>
43 #include <netncp/ncp_user.h>
44 #include <netncp/ncp_rq.h>
46 #define ncp_printf printf
48 #define sipx_cnetwork sipx_addr.x_net.c_net
49 #define sipx_node sipx_addr.x_host.c_host
50 #define ipx_netlong(iaddr) (((union ipx_net_u *)(&((iaddr).x_net)))->long_e)
52 #define STDPARAM_ARGS 'A':case 'B':case 'C':case 'I':case 'M': \
53 case 'N':case 'U':case 'R':case 'S':case 'T': \
54 case 'W':case 'O':case 'P'
56 #define STDPARAM_OPT "A:BCI:M:NO:P:U:R:S:T:W:"
59 #define min(a,b) (((a)<(b)) ? (a) : (b))
64 * An attempt to do a unified options parser
66 enum ncp_argtype
{NCA_STR
,NCA_INT
,NCA_BOOL
};
70 typedef int ncp_setopt_t (struct ncp_args
*);
72 #define NAFL_NONE 0x0000
73 #define NAFL_HAVEMIN 0x0001
74 #define NAFL_HAVEMAX 0x0002
75 #define NAFL_MINMAX NAFL_HAVEMIN | NAFL_HAVEMAX
79 int opt
; /* command line option */
80 char *name
; /* rc file equiv */
81 int flag
; /* NAFL_* */
82 int ival
; /* int/bool values, or max len for str value */
83 char *str
; /* string value */
84 int min
; /* min for ival */
85 int max
; /* max for ival */
86 ncp_setopt_t
*fn
;/* call back to validate */
95 /* hours is a nuint16 so that this structure will be the same length as a dword */
109 int ncp_args_parserc(struct ncp_args
*, char *, ncp_setopt_t
*);
110 int ncp_args_parseopt(struct ncp_args
*, int, char *, ncp_setopt_t
*);
119 int ncp_initlib(void);
120 int ncp_connect(struct ncp_conn_args
*, int *);
121 int ncp_connect_addr(struct sockaddr
*, NWCONN_HANDLE
*);
122 int ncp_disconnect(int);
123 int ncp_request(int, int, struct ncp_buf
*);
124 int ncp_conn_request(int, struct ncp_buf
*);
125 int ncp_login(int, const char *, int, const char *);
126 int ncp_conn_scan(struct ncp_conn_loginfo
*, int *);
127 int ncp_conn_cnt(void);
128 void *ncp_conn_list(void);
129 int ncp_conn_getinfo(int, struct ncp_conn_stat
*);
130 int ncp_conn_getuser(int, char **);
131 int ncp_conn2ref(int, int *);
132 int ncp_conn_dup(NWCONN_HANDLE
, NWCONN_HANDLE
*);
133 int ncp_path2conn(char *, int *);
134 int ncp_li_init(struct ncp_conn_loginfo
*, int, char *[]);
135 void ncp_li_done(struct ncp_conn_loginfo
*);
136 int ncp_li_login(struct ncp_conn_loginfo
*, int *);
137 int ncp_li_readrc(struct ncp_conn_loginfo
*);
138 int ncp_li_check(struct ncp_conn_loginfo
*);
139 int ncp_li_arg(struct ncp_conn_loginfo
*, int, char *);
140 int ncp_li_setserver(struct ncp_conn_loginfo
*, const char *);
141 int ncp_li_setuser(struct ncp_conn_loginfo
*, char *);
142 int ncp_li_setpassword(struct ncp_conn_loginfo
*, const char *);
143 int ncp_conn_setflags(int, u_int16_t
, u_int16_t
);
144 int ncp_conn_find(char *, char *);
145 NWCCODE
NWRequest(NWCONN_HANDLE
, nuint16
, nuint16
, NW_FRAGMENT
*,
146 nuint16
, NW_FRAGMENT
*);
148 #define ncp_setpermanent(connHandle,on) ncp_conn_setflags(connHandle, NCPFL_PERMANENT, (on) ? NCPFL_PERMANENT : 0)
149 #define ncp_setprimary(connHandle,on) ncp_conn_setflags(connHandle, NCPFL_PRIMARY, (on) ? NCPFL_PRIMARY : 0)
151 int ncp_find_fileserver(struct ncp_conn_loginfo
*, int, char *);
152 int ncp_find_server(struct ncp_conn_loginfo
*, int, int, char *);
155 char* ncp_str_upper(char *);
156 int ncp_open_rcfile(void);
157 int ncp_getopt(int, char * const *, const char *);
158 void NWUnpackDateTime(nuint32
, NW_DATE
*, NW_TIME
*);
159 void NWUnpackDate(nuint16
, NW_DATE
*);
160 void NWUnpackTime(nuint16
, NW_TIME
*);
161 time_t ncp_UnpackDateTime(nuint32
);
162 int ncp_GetFileServerDateAndTime(NWCONN_HANDLE
, time_t *);
163 int ncp_SetFileServerDateAndTime(NWCONN_HANDLE
, time_t *);
164 NWCCODE
NWDownFileServer(NWCONN_HANDLE
, int);
165 NWCCODE
NWCloseBindery(NWCONN_HANDLE
);
166 NWCCODE
NWOpenBindery(NWCONN_HANDLE
);
167 NWCCODE
NWDisableTTS(NWCONN_HANDLE
);
168 NWCCODE
NWEnableTTS(NWCONN_HANDLE
);
169 NWCCODE
NWDisableFileServerLogin(NWCONN_HANDLE
);
170 NWCCODE
NWEnableFileServerLogin(NWCONN_HANDLE
);
171 void ncp_error(const char *, int, ...) __printf0like(1, 3);
172 char *ncp_printb(char *, int, const struct ncp_bitname
*);
173 void nw_keyhash(const u_char
*, const u_char
*, int, u_char
*);
174 void nw_encrypt(const u_char
*, const u_char
*, u_char
*);
175 void ipx_print_addr(struct ipx_addr
*);
178 int ncp_get_bindery_object_id(NWCONN_HANDLE
, u_int16_t
, const char *,
179 struct ncp_bindery_object
*);
180 int ncp_get_bindery_object_name(NWCONN_HANDLE
, u_int32_t
,
181 struct ncp_bindery_object
*);
182 int ncp_scan_bindery_object(NWCONN_HANDLE
, u_int32_t
, u_int16_t
,
183 char *, struct ncp_bindery_object
*);
184 int ncp_read_property_value(NWCONN_HANDLE
, int object_type
, const char *,
185 int, const char *, struct nw_property
*);
186 int ncp_get_encryption_key(NWCONN_HANDLE
, char *);
187 int ncp_change_obj_passwd(NWCONN_HANDLE
,
188 const struct ncp_bindery_object
*, const u_char
*,
189 const u_char
*, const u_char
*);
190 int ncp_keyed_verify_password(NWCONN_HANDLE
, char *, char *,
191 struct ncp_bindery_object
*);
194 int ncp_create_queue_job_and_file(NWCONN_HANDLE
, u_int32_t
, struct queue_job
*);
195 int ncp_close_file_and_start_job(NWCONN_HANDLE
, u_int32_t
, struct queue_job
*);
196 int ncp_attach_to_queue(NWCONN_HANDLE
, u_int32_t
);
197 int ncp_detach_from_queue(NWCONN_HANDLE
, u_int32_t
);
198 int ncp_service_queue_job(NWCONN_HANDLE
, u_int32_t
, u_int16_t
,
200 int ncp_finish_servicing_job(NWCONN_HANDLE
, u_int32_t
, u_int32_t
, u_int32_t
);
201 int ncp_abort_servicing_job(NWCONN_HANDLE
, u_int32_t
, u_int32_t
);
202 int ncp_get_queue_length(NWCONN_HANDLE
, u_int32_t
, u_int32_t
*);
203 int ncp_get_queue_job_ids(NWCONN_HANDLE
, u_int32_t
, u_int32_t
,
204 u_int32_t
*, u_int32_t
*, u_int32_t
[]);
205 int ncp_get_queue_job_info(NWCONN_HANDLE
, u_int32_t
, u_int32_t
,
206 struct nw_queue_job_entry
*);
208 * filesystem and volume calls
210 int ncp_read(NWCONN_HANDLE
, ncp_fh
*, off_t
, size_t, char *);
211 int ncp_write(NWCONN_HANDLE
, ncp_fh
*, off_t
, size_t, char *);
212 int ncp_geteinfo(char *, struct nw_entry_info
*);
213 int ncp_NSEntryInfo(NWCONN_HANDLE
, nuint8
, nuint8
, nuint32
, NW_ENTRY_INFO
*);
215 NWCCODE
NWGetVolumeName(NWCONN_HANDLE
, u_char
, char *);
218 int ncp_get_file_server_information(NWCONN_HANDLE
, struct ncp_file_server_info
*);
219 int ncp_get_stations_logged_info(NWCONN_HANDLE
, u_int32_t
,
220 struct ncp_bindery_object
*, time_t *);
221 int ncp_get_internet_address(NWCONN_HANDLE
, u_int32_t
, struct ipx_addr
*,
223 NWCCODE
NWGetObjectConnectionNumbers(NWCONN_HANDLE
, pnstr8
, nuint16
,
224 pnuint16
, pnuint16
, nuint16
);
228 NWCCODE
NWDisableBroadcasts(NWCONN_HANDLE
);
229 NWCCODE
NWEnableBroadcasts(NWCONN_HANDLE
);
230 NWCCODE
NWBroadcastToConsole(NWCONN_HANDLE
, pnstr8
);
231 NWCCODE
NWSendBroadcastMessage(NWCONN_HANDLE
, pnstr8
, nuint16
, pnuint16
, pnuint8
);
232 NWCCODE
NWGetBroadcastMessage(NWCONN_HANDLE
, pnstr8
);
237 NWCCODE
NWSMExecuteNCFFile(NWCONN_HANDLE
, pnstr8
);
238 NWCCODE
NWSMLoadNLM(NWCONN_HANDLE
, pnstr8
);
239 NWCCODE
NWSMUnloadNLM(NWCONN_HANDLE
, pnstr8
);
240 NWCCODE
NWSMMountVolume(NWCONN_HANDLE
, pnstr8
, nuint32
*);
241 NWCCODE
NWSMDismountVolumeByName(NWCONN_HANDLE
, pnstr8
);
242 NWCCODE
NWSMSetDynamicCmdIntValue(NWCONN_HANDLE
, pnstr8
, nuint32
);
243 NWCCODE
NWSMSetDynamicCmdStrValue(NWCONN_HANDLE
, pnstr8
, pnstr8
);
247 extern int ncp_opterr
, ncp_optind
, ncp_optopt
, ncp_optreset
;
248 extern char *ncp_optarg
;
250 extern struct rcfile
*ncp_rc
;
251 extern int sysentoffset
;
252 #endif /* _NETNCP_NCP_LIB_H_ */