|
|
1.1 root 1: /* system.h
2: Header file for system dependent stuff in the Taylor UUCP package.
3: This file is not itself system dependent.
4:
5: Copyright (C) 1991, 1992 Ian Lance Taylor
6:
7: This file is part of the Taylor UUCP package.
8:
9: This program is free software; you can redistribute it and/or
10: modify it under the terms of the GNU General Public License as
11: published by the Free Software Foundation; either version 2 of the
12: License, or (at your option) any later version.
13:
14: This program is distributed in the hope that it will be useful, but
15: WITHOUT ANY WARRANTY; without even the implied warranty of
16: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: General Public License for more details.
18:
19: You should have received a copy of the GNU General Public License
20: along with this program; if not, write to the Free Software
21: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22:
23: The author of the program may be contacted at [email protected] or
24: c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
25: */
26:
27: #ifndef SYSTEM_H
28:
29: #define SYSTEM_H
30:
31: #if ANSI_C
32: /* These structures are used in prototypes but are not defined in this
33: header file. */
34: struct tm;
35: struct uuconf_system;
36: struct uuconf_port;
37: struct sconnection;
38: struct sstatus;
39: struct scmd;
40: #endif
41:
42: /* Any function which returns an error should also report an error
43: message, unless otherwise indicated.
44:
45: Any function that returns a char *, rather than a const char *, is
46: returning a pointer to a buffer allocated by zbufalc which must be
47: freed using ubuffree, unless otherwise indicated. */
48:
49: /* The maximum length of a remote system name. */
50: extern size_t cSysdep_max_name_len;
51:
52: /* Initialize. If something goes wrong, this routine should just
53: exit. The flag argument is 0, or a combination of any of the
54: following flags. */
55:
56: /* This program needs to know the current working directory. This is
57: used because on Unix it can be expensive to determine the current
58: working directory (some versions of getcwd fork a process), but in
59: most cases we don't need to know it. However, we are going to
60: chdir to the spool directory (unless INIT_CHDIR is set), so we have
61: to get the cwd now if we are ever going to get it. Both uucp and
62: uux use the function fsysdep_needs_cwd to determine whether they
63: will need the current working directory, and pass the argument to
64: usysdep_initialize appropriately. There's probably a cleaner way
65: to handle this, but this will suffice for now. */
66: #define INIT_GETCWD (01)
67:
68: /* This program should not chdir to the spool directory. This may
69: only make sense on Unix. It is set by cu. */
70: #define INIT_NOCHDIR (02)
71:
72: /* This program needs special access to the spool directories. That
73: means, on Unix, this program is normally installed setuid. */
74: #define INIT_SUID (04)
75:
76: extern void usysdep_initialize P((pointer puuconf, int iflags));
77:
78: /* Exit the program. The fsuccess argument indicates whether to
79: return an indication of success or failure to the outer
80: environment. This routine should not return. */
81: extern void usysdep_exit P((boolean fsuccess));
82:
83: /* Called when a non-standard configuration file is being used, to
84: avoid handing out privileged access. If it returns FALSE, default
85: configuration file will be used. This is called before the
86: usysdep_initialize function is called. */
87: extern boolean fsysdep_other_config P((const char *));
88:
89: /* Detach from the controlling terminal. This probably only makes
90: sense on Unix. It is called by uucico to try to get the modem port
91: as a controlling terminal. It is also called by uucico before it
92: starts up uuxqt, so that uuxqt will be a complete daemon. */
93: extern void usysdep_detach P((void));
94:
95: /* Get the local node name if it is not specified in the configuration
96: files. Returns NULL on error; otherwise the return value should
97: point to a static buffer. */
98: extern const char *zsysdep_localname P((void));
99:
100: /* Get the login name. This is used when uucico is started up with no
101: arguments in slave mode, which causes it to assume that somebody
102: has logged in. It also used by uucp and uux for recording the user
103: name. This may not return NULL. The return value should point to
104: a static buffer. */
105: extern const char *zsysdep_login_name P((void));
106:
107: /* Set a signal handler for a signal. If the signal occurs, the
108: appropriate element of afSignal should be set to the signal number
109: (see the declaration of afSignal in uucp.h). This routine might be
110: able to just use signal, but Unix requires more complex handling.
111: This is called before usysdep_initialize. */
112: extern void usysdep_signal P((int isig));
113:
114: /* Catch a signal. This is actually defined as a macro in the system
115: dependent header file, and the prototype here just indicates how it
116: should be called. It is called before a routine which must exit if
117: a signal occurs, and is expected to set do a setjmp (which is why
118: it must be a macro). It is actually only called in one place in
119: the system independent code, before the call to read stdin in uux.
120: This is needed to handle 4.2 BSD restartable system calls, which
121: require a longjmp. On systems which don't need to do
122: setjmp/longjmp around system calls, this can be redefined in
123: sysdep.h to TRUE. It should return TRUE if the routine should
124: proceed, or FALSE if a signal occurred. After having this return
125: TRUE, usysdep_start_catch should be used to start catching the
126: signal; this basically tells the signal handler that it's OK to do
127: the longjmp, if fsysdep_catch did not already do so. */
128: #ifndef fsysdep_catch
129: extern boolean fsysdep_catch P((void));
130: #endif
131:
132: /* Start catching a signal. This is called after fsysdep_catch to
133: tell the signal handler to go ahead and do the longjmp. This may
134: be implemented as a macro in sysdep.h. */
135: #ifndef usysdep_start_catch
136: extern void usysdep_start_catch P((void));
137: #endif
138:
139: /* Stop catching a signal. This is called when it is no longer
140: necessary for fsysdep_catch to handle signals. This may be
141: implemented as a macro in sysdep.h. */
142: #ifndef usysdep_end_catch
143: extern void usysdep_end_catch P((void));
144: #endif
145:
146: /* Link two files. On Unix this should attempt the link. If it
147: succeeds it should return TRUE with *pfworked set to TRUE. If the
148: link fails because it must go across a device, it should return
149: TRUE with *pfworked set to FALSE. If the link fails for some other
150: reason, it should log an error message and return FALSE. On a
151: system which does not support links to files, this should just
152: return TRUE with *pfworked set to FALSE. */
153: extern boolean fsysdep_link P((const char *zfrom, const char *zto,
154: boolean *pfworked));
155:
156: /* Get the port name. This is used when uucico is started up in slave
157: mode to figure out which port was used to call in so that it can
158: determine any appropriate protocol parameters. This may return
159: NULL if the port cannot be determined, which will just mean that no
160: protocol parameters are applied. The name returned should be the
161: sort of name that would appear in the port file. This should set
162: *pftcp_port to TRUE if it can determine that the port is a TCP
163: connection rather than a normal serial port. The return value (if
164: not NULL) should point to a static buffer. */
165: extern const char *zsysdep_port_name P((boolean *pftcp_port));
166:
167: /* Expand a file name on the local system. On Unix, if the zfile
168: argument begins with ~user/ it goes in that users home directory,
169: and if it begins with ~/ it goes in the public directory (the
170: public directory is passed to this routine, since each system may
171: have its own public directory). Similar conventions may be
172: desirable on other systems. This should always return an absolute
173: path name, probably in the public directory. It should return NULL
174: on error; otherwise the return value should be allocated using
175: zbufcpy or zbufalc. */
176: extern char *zsysdep_local_file P((const char *zname,
177: const char *zpubdir));
178:
179: /* Return whether a file name is in a directory, and check for read or
180: write access. This should check whether zfile is within zdir (or
181: is zdir itself). If it is not, it should return FALSE. If zfile
182: is in zdir, then fcheck indicates whether further checking should
183: be done. If fcheck is FALSE, no further checking is done.
184: Otherwise, if freadable is TRUE the user zuser should have search
185: access to all directories from zdir down to zfile and should have
186: read access on zfile itself (if zfile does not exist, or is not a
187: regular file, this function may return FALSE but does not have to).
188: If freadable is FALSE, the user zuser should have search access to
189: all directories from zdir down to zfile and should have write
190: access on zfile (which may be a directory, or may not actually
191: exist, which is acceptable). The zuser argument may be NULL, in
192: which case the check should be made for any user, not just zuser.
193: There is no way for this function to return error. */
194: extern boolean fsysdep_in_directory P((const char *zfile,
195: const char *zdir,
196: boolean fcheck,
197: boolean freadable,
198: const char *zuser));
199:
200: /* Return TRUE if a file exists, FALSE otherwise. There is no way to
201: return error. */
202: extern boolean fsysdep_file_exists P((const char *zfile));
203:
204: /* Start up a program. The code expects fsysdep_run to return after
205: doing a fork, but at least for now everything will work fine if it
206: does not (on a system which does not support forking). The three
207: string arguments may be catenated together to form the program to
208: execute; I did it this way to make it easy to call execl(2), and
209: because I never needed more than two arguments. The program will
210: always be "uucico" or "uuxqt". The return value will be passed
211: directly to usysdep_exit, and should be TRUE on success, FALSE on
212: error. */
213: extern boolean fsysdep_run P((const char *zprogram, const char *zarg1,
214: const char *zarg2));
215:
216: /* Send a mail message. This function will be passed an array of
217: strings. All necessary newlines are already included; the strings
218: should simply be concatenated together to form the mail message.
219: It should return FALSE on error, although the return value is often
220: ignored. */
221: extern boolean fsysdep_mail P((const char *zto, const char *zsubject,
222: int cstrs, const char **paz));
223:
224: /* Get the time in seconds since some epoch. The actual epoch is
225: unimportant, so long as the time values are consistent across
226: program executions and the value is never negative. If the
227: pimicros argument is not NULL, it should be set to the number of
228: microseconds (if this is not available, *pimicros should be set to
229: zero). */
230: extern long ixsysdep_time P((long *pimicros));
231:
232: /* Get the time in seconds and microseconds (millionths of a second)
233: since some epoch. The actual epoch is not important, and it may
234: change in between program invocations; this is provided because on
235: Unix the times function may be used. If microseconds can not be
236: determined, *pimicros can just be set to zero. */
237: extern long ixsysdep_process_time P((long *pimicros));
238:
239: /* Parse the value returned by ixsysdep_time into a struct tm. I
240: assume that this structure is defined in <time.h>. This is
241: basically just localtime, except that the ANSI function takes a
242: time_t which may not be what is returned by ixsysdep_time. */
243: extern void usysdep_localtime P((long itime, struct tm *q));
244:
245: /* Sleep for a number of seconds. */
246: extern void usysdep_sleep P((int cseconds));
247:
248: /* Pause for half a second, or 1 second if subsecond sleeps are not
249: possible. */
250: extern void usysdep_pause P((void));
251:
252: /* Lock a remote system. This should return FALSE if the system is
253: already locked (no error should be reported). */
254: extern boolean fsysdep_lock_system P((const struct uuconf_system *qsys));
255:
256: /* Unlock a remote system. This should return FALSE on error
257: (although the return value is generally ignored). */
258: extern boolean fsysdep_unlock_system P((const struct uuconf_system *qsys));
259:
260: /* Get the conversation sequence number for a remote system, and
261: increment it for next time. This should return -1 on error. */
262: extern long ixsysdep_get_sequence P((const struct uuconf_system *qsys));
263:
264: /* Get the status of a remote system. This should return FALSE on
265: error. Otherwise it should set *qret to the status. If no status
266: information is available, this should set *qret to sensible values
267: and return TRUE. If pfnone is not NULL, then it should be set to
268: TRUE if no status information was available or FALSE otherwise. */
269: extern boolean fsysdep_get_status P((const struct uuconf_system *qsys,
270: struct sstatus *qret,
271: boolean *pfnone));
272:
273: /* Set the status of a remote system. This should return FALSE on
274: error. The system will be locked before this call is made. */
275: extern boolean fsysdep_set_status P((const struct uuconf_system *qsys,
276: const struct sstatus *qset));
277:
278: /* See whether a remote system is permitted to log in. This is just
279: to support the remote.unknown shell script for HDB. The zscript
280: argument is the script name, as return by uuconf_remote_unknown.
281: The zsystem argument is the name given by the remote system. If
282: the system is not permitted to log in, this function should log an
283: error and return FALSE. */
284: extern boolean fsysdep_unknown_caller P((const char *zscript,
285: const char *zsystem));
286:
287: /* Check whether there is work for a remote system. It should return
288: TRUE if there is work, FALSE otherwise; there is no way to indicate
289: an error. */
290: extern boolean fsysdep_has_work P((const struct uuconf_system *qsys));
291:
292: /* Initialize the work scan. This will be called before
293: fsysdep_get_work. The bgrade argument is the minimum grade of
294: execution files that should be considered (e.g. a bgrade of 'd'
295: will allow all grades from 'A' to 'Z' and 'a' to 'd'). This
296: function should return FALSE on error. */
297: extern boolean fsysdep_get_work_init P((const struct uuconf_system *qsys,
298: int bgrade));
299:
300: /* Get the next command to be executed for a remote system. The
301: bgrade argument will be the same as for fsysdep_get_work_init;
302: probably only one of these functions will use it, namely the
303: function for which it is more convenient. This should return FALSE
304: on error. The structure pointed to by qcmd should be filled in.
305: The strings may point into a static buffer; they will be copied out
306: if necessary. If there is no more work, this should set qcmd->bcmd
307: to 'H' and return TRUE. This should set qcmd->pseq to something
308: which can be passed to fsysdep_did_work to remove the job from the
309: queue when it has been completed. This may set qcmd->bcmd to 'P'
310: to represent a poll file; the main code will just pass the pseq
311: element of such a structure to fsysdep_did_work if the system is
312: called. */
313: extern boolean fsysdep_get_work P((const struct uuconf_system *qsys,
314: int bgrade, struct scmd *qcmd));
315:
316: /* Remove a job from the work queue. This must also remove the
317: temporary file used for a send command, if there is one. It should
318: return FALSE on error. */
319: extern boolean fsysdep_did_work P((pointer pseq));
320:
321: /* Save the temporary file for a send command. This function should
322: return a string that will be put into a mail message. On success
323: this string should say something like ``The file has been saved as
324: ...''. On failure it could say something like ``The file could not
325: be saved because ...''. If there is no temporary file, or for some
326: reason it's not appropriate to include a message, this function
327: should just return NULL. This function is used when a file send
328: fails for some reason, to make sure that we don't completely lost
329: the file. */
330: extern const char *zsysdep_save_temp_file P((pointer pseq));
331:
332: /* Cleanup anything left over by fsysdep_get_work_init and
333: fsysdep_get_work. This may be called even though
334: fsysdep_get_work_init has not been. */
335: extern void usysdep_get_work_free P((const struct uuconf_system *qsys));
336:
337: /* Add a base name to a file if it is a directory. If zfile names a
338: directory, then return a string naming a file within the directory
339: with the base file name of zname. This should return NULL on
340: error. */
341: extern char *zsysdep_add_base P((const char *zfile,
342: const char *zname));
343:
344: /* Get a file name from the spool directory. This should return NULL
345: on error. The pseq argument is TRUE if the file was found from
346: searching the work directory; this is, unfortunately, needed to
347: support SVR4 spool directories. */
348: extern char *zsysdep_spool_file_name P((const struct uuconf_system *qsys,
349: const char *zfile,
350: pointer pseq));
351:
352: /* Make necessary directories. This should create all non-existent
353: directories for a file. If the fpublic argument is TRUE, anybody
354: should be permitted to create and remove files in the directory;
355: otherwise anybody can list the directory, but only the UUCP system
356: can create and remove files. It should return FALSE on error. */
357: extern boolean fsysdep_make_dirs P((const char *zfile, boolean fpublic));
358:
359: /* Create a stdio file, setting appropriate protection. If the
360: fpublic argument is TRUE, the file is made publically accessible;
361: otherwise it is treated as a private data file. If the fappend
362: argument is TRUE, the file is opened in append mode; otherwise any
363: previously existing file of the same name is removed. If the
364: fmkdirs argument is TRUE, then any necessary directories should
365: also be created. On a system in which file protections are
366: unimportant and the necessary directories exist, this may be
367: implemented as
368:
369: fopen (zfile, fappend ? "a" : "w");
370:
371: */
372: extern FILE *esysdep_fopen P((const char *zfile, boolean fpublic,
373: boolean fappend, boolean fmkdirs));
374:
375: /* Open a file, using the access permission of the user who invoked
376: the program. The frd argument is TRUE if the file should be opened
377: for reading, and the fbinary argument is TRUE if the file should be
378: opened as a binary file (this is ignored on Unix, since there all
379: files are binary files). This returns an openfile_t, not a FILE *.
380: This is supposed to be able to open a file even if it can not be
381: read by the uucp user. This is not possible on some older Unix
382: systems. */
383: extern openfile_t esysdep_user_fopen P((const char *zfile,
384: boolean frd, boolean fbinary));
385:
386: /* Open a file to send to another system; the qsys argument is the
387: system the file is being sent to. If fcheck is TRUE, it should
388: make sure that the file is readable by zuser (if zuser is NULL the
389: file must be readable by anybody). This is to eliminate a window
390: between fsysdep_in_directory and esysdep_open_send. If an error
391: occurs, it should return EFILECLOSED. */
392: extern openfile_t esysdep_open_send P((const struct uuconf_system *qsys,
393: const char *zname,
394: boolean fcheck,
395: const char *zuser));
396:
397: /* Return a temporary file name to receive into. This file will be
398: opened by esysdep_open_receive. The qsys argument is the system
399: the file is coming from, the zto argument is the name the file will
400: have after it has been fully received, and the ztemp argument, if
401: it is not NULL, is from the command sent by the remote system. The
402: return value must be freed using ubuffree. The function should
403: return NULL on error. */
404: extern char *zsysdep_receive_temp P((const struct uuconf_system *qsys,
405: const char *zfile,
406: const char *ztemp));
407:
408: /* Open a file to receive from another system. The zreceive argument
409: is the return value of zsysdep_receive_temp with the same qsys,
410: zfile and ztemp arguments. If the function can determine that this
411: file has already been partially received, it should set *pcrestart
412: to the number of bytes that have been received. If the file has
413: not been partially received, *pcrestart should be set to -1. The
414: function should return EFILECLOSED on error. After the file is
415: written, fsysdep_move_file will be called to move the file to its
416: final destination, and to set the correct file mode. */
417: extern openfile_t esysdep_open_receive P((const struct uuconf_system *qsys,
418: const char *zto,
419: const char *ztemp,
420: const char *zreceive,
421: long *pcrestart));
422:
423: /* Move a file. This is used to move a received file to its final
424: location. The zto argument is the file to create. The zorig
425: argument is the name of the file to move. If fmkdirs is TRUE, then
426: any necessary directories are created; fpublic indicates whether
427: they should be publically writeable or not. If fcheck is TRUE,
428: this should make sure the directory is writeable by the user zuser
429: (if zuser is NULL, then it must be writeable by any user); this is
430: to avoid a window of vulnerability between fsysdep_in_directory and
431: fsysdep_move_file. This function should return FALSE on error; the
432: zorig file should be removed even if an error occurs. */
433: extern boolean fsysdep_move_file P((const char *zorig, const char *zto,
434: boolean fmkdirs, boolean fpublic,
435: boolean fcheck, const char *zuser));
436:
437: /* Change the mode of a file. The imode argument is a Unix mode.
438: This should return FALSE on error. */
439: extern boolean fsysdep_change_mode P((const char *zfile,
440: unsigned int imode));
441:
442: /* Truncate a file which we are receiving into. This may be done by
443: closing the original file, removing it and reopening it. This
444: should return FALSE on error. */
445: extern openfile_t esysdep_truncate P((openfile_t e, const char *zname));
446:
447: /* It is possible for the acknowledgement of a received file to be
448: lost. The sending system will then now know that the file was
449: correctly received, and will send it again. This can be a problem
450: particularly with protocols which support channels, since they may
451: send several small files in a single window, all of which may be
452: received correctly although the sending system never sees the
453: acknowledgement. If these files involve an execution, the
454: execution will happen twice, which will be bad.
455:
456: This function is called when a file is completely received. It is
457: supposed to try and remember the reception, in case the connection
458: is lost. It is passed the system, the file name to receive to, and
459: the temporary file name from the sending system. It should return
460: FALSE on error. */
461: extern boolean fsysdep_remember_reception P((const struct uuconf_system *qsys,
462: const char *zto,
463: const char *ztemp));
464:
465: /* This function is called to see if a file has already been received
466: successfully. It gets the same arguments as
467: fsysdep_remember_reception. It should return TRUE if the file was
468: already received, FALSE otherwise. There is no way to report
469: error. */
470: extern boolean fsysdep_already_received P((const struct uuconf_system *qsys,
471: const char *zto,
472: const char *ztemp));
473:
474: /* This function is called when it is no longer necessary to remember
475: that a file has been received. This will be called when the
476: protocol knows that the receive message has been acknowledged. It
477: gets the same arguments as fsysdep_remember_reception. it should
478: return FALSE on error. */
479: extern boolean fsysdep_forget_reception P((const struct uuconf_system *qsys,
480: const char *zto,
481: const char *ztemp));
482:
483: /* Start expanding a wildcarded file name. This should return FALSE
484: on error; otherwise subsequent calls to zsysdep_wildcard should
485: return file names. */
486: extern boolean fsysdep_wildcard_start P((const char *zfile));
487:
488: /* Get the next wildcard name. This should return NULL when there are
489: no more names to return. The return value should be freed using
490: ubuffree. The argument should be the same as that to
491: fsysdep_wildcard_start. There is no way to return error. */
492: extern char *zsysdep_wildcard P((const char *zfile));
493:
494: /* Finish getting wildcard names. This may be called before or after
495: zsysdep_wildcard has returned NULL. It should return FALSE on
496: error. */
497: extern boolean fsysdep_wildcard_end P((void));
498:
499: /* Prepare to execute a bunch of file transfer requests. This should
500: make an entry in the spool directory so that the next time uucico
501: is started up it will transfer these files. The bgrade argument
502: specifies the grade of the commands. The commands themselves are
503: in the pascmds array, which has ccmds entries. The function should
504: return NULL on error, or the jobid on success. The jobid is a
505: string that may be printed or passed to fsysdep_kill_job and
506: related functions, but is otherwise uninterpreted. */
507: extern char *zsysdep_spool_commands P((const struct uuconf_system *qsys,
508: int bgrade, int ccmds,
509: const struct scmd *pascmds));
510:
511: /* Get a file name to use for a data file to be copied to another
512: system. The ztname, zdname and zxname arguments will all either be
513: NULL or point to an array of CFILE_NAME_LEN characters in length.
514: The ztname array should be set to a temporary file name that could
515: be passed to zsysdep_spool_file_name to retrieve the return value
516: of this function; this will be appropriate for the temporary name
517: in a send request. The zdname array should be set to a data file
518: name that is appropriate for the spool directory of the other
519: system; this will be appropriate for the name of the destination
520: file in a send request of a data file for an execution of some
521: sort. The zxname array should be set to an execute file name that
522: is appropriate for the other system. The zlocalname argument is
523: the name of the local system as seen by the remote system, the
524: bgrade argument is the grade, and fxqt is TRUE if this file is
525: going to become an execution file. This should return NULL on
526: error. */
527: #define CFILE_NAME_LEN (15)
528:
529: extern char *zsysdep_data_file_name P((const struct uuconf_system *qsys,
530: const char *zlocalname,
531: int bgrade, boolean fxqt,
532: char *ztname, char *zdname,
533: char *zxname));
534:
535: /* Get a name for a local execute file. This is used by uux for a
536: local command with remote files. Returns NULL on error. */
537: extern char *zsysdep_xqt_file_name P((void));
538:
539: /* Beginning getting execute files. To get a list of execute files,
540: first fsysdep_get_xqt_init is called, then zsysdep_get_xqt is
541: called several times until it returns NULL, then finally
542: usysdep_get_xqt_free is called. */
543: extern boolean fsysdep_get_xqt_init P((void));
544:
545: /* Get the next execute file. This should return NULL when finished
546: (with *pferr set to FALSE). On an error this should return NULL
547: with *pferr set to TRUE. This should set *pzsystem to the name of
548: the system for which the execute file was created. Both the return
549: value and *pzsystem should be freed using ubuffree. */
550: extern char *zsysdep_get_xqt P((char **pzsystem,
551: boolean *pferr));
552:
553: /* Clean up after getting execute files. */
554: extern void usysdep_get_xqt_free P((void));
555:
556: /* Get the absolute pathname of a command to execute. This is given
557: the legal list of commands (which may be the special case "ALL")
558: and the path. It must return an absolute pathname to the command.
559: If it gets an error it should set *pferr to TRUE and return NULL;
560: if the command is not found it should set *pferr to FALSE and
561: return NULL. */
562: extern char *zsysdep_find_command P((const char *zcmd, char **pzcmds,
563: char **pzpath, boolean *pferr));
564:
565: /* Expand file names for uuxqt. This exists because uuxqt on Unix has
566: to expand file names which begin with a ~. It does not want to
567: expand any other type of file name, and it turns a double ~ into a
568: single one without expanding. If this returns NULL, the file does
569: not need to be changed; otherwise it returns a zbufalc'ed string.
570: There is no way to report error. */
571: extern char *zsysdep_xqt_local_file P((const struct uuconf_system *qsys,
572: const char *zfile));
573:
574: #if ! ALLOW_FILENAME_ARGUMENTS
575: /* Check an argument to an execution command to make sure that it
576: doesn't refer to a file name that may not be accessed. This should
577: check the argument to see if it is a filename. If it is, it should
578: either reject it out of hand or it should call fin_directory_list
579: on the file with both qsys->zremote_receive and qsys->zremote_send.
580: If the file is rejected, it should log an error and return FALSE.
581: Otherwise it should return TRUE. */
582: extern boolean fsysdep_xqt_check_file P((const struct uuconf_system *qsys,
583: const char *zfile));
584: #endif /* ! ALLOW_FILENAME_ARGUMENTS */
585:
586: /* Run an execute file. The arguments are:
587:
588: qsys -- system for which execute file was created
589: zuser -- user who requested execution
590: pazargs -- list of arguments to command (element 0 is command)
591: zfullcmd -- command and arguments stuck together in one string
592: zinput -- file name for standard input (may be NULL)
593: zoutput -- file name for standard output (may be NULL)
594: fshell -- if TRUE, use /bin/sh to execute file
595: ilock -- return value of ixsysdep_lock_uuxqt
596: pzerror -- set to name of standard error file
597: pftemp -- set to TRUE if error is temporary, FALSE otherwise
598:
599: If fshell is TRUE, the command should be executed with /bin/sh
600: (obviously, this can only really be done on Unix systems). If an
601: error occurs this should return FALSE and set *pftemp
602: appropriately. *pzerror should be freed using ubuffree. */
603: extern boolean fsysdep_execute P((const struct uuconf_system *qsys,
604: const char *zuser,
605: const char **pazargs,
606: const char *zfullcmd,
607: const char *zinput,
608: const char *zoutput,
609: boolean fshell,
610: int ilock,
611: char **pzerror,
612: boolean *pftemp));
613:
614: /* Lock for uuxqt execution. If the cmaxuuxqts argument is not zero,
615: this should make sure that no more than cmaxuuxqts uuxqt processes
616: are running at once. Also, only one uuxqt may execute a particular
617: command (specified by the -c option) at a time. If zcmd is not
618: NULL, it is a command that must be locked. This should return a
619: nonnegative number which will be passed to other routines,
620: including fsysdep_unlock_uuxqt, or -1 on error. */
621: extern int ixsysdep_lock_uuxqt P((const char *zcmd,
622: int cmaxuuxqts));
623:
624: /* Unlock a uuxqt process. This is passed the return value of
625: ixsysdep_lock_uuxqt, as well as the arguments passed to
626: ixsysdep_lock_uuxqt. It may return FALSE on error, but at present
627: the return value is ignored. */
628: extern boolean fsysdep_unlock_uuxqt P((int iseq, const char *zcmd,
629: int cmaxuuxqts));
630:
631: /* See whether a particular uuxqt command is locked. This should
632: return TRUE if the command is locked (because ixsysdep_lock_uuxqt
633: was called with it as an argument), FALSE otherwise. There is no
634: way to return error. */
635: extern boolean fsysdep_uuxqt_locked P((const char *zcmd));
636:
637: /* Lock an execute file in order to execute it. This should return
638: FALSE if the execute file is already locked. There is no way to
639: return error. */
640: extern boolean fsysdep_lock_uuxqt_file P((const char *zfile));
641:
642: /* Unlock an execute file. This should return FALSE on error. */
643: extern boolean fsysdep_unlock_uuxqt_file P((const char *zfile));
644:
645: /* Lock the execution directory. The ilock argument is the return
646: value of ixsysdep_lock_uuxqt. This should return FALSE if the
647: directory is already locked. There is no way to return error. */
648: extern boolean fsysdep_lock_uuxqt_dir P((int ilock));
649:
650: /* Remove all files in the execution directory, and unlock it. This
651: should return FALSE on error. */
652: extern boolean fsysdep_unlock_uuxqt_dir P((int ilock));
653:
654: /* Move files into or out of the execution directory. The code will
655: already have checked that all the files exist. The elements in the
656: pzfrom array will be complete filenames, and the elements in the
657: pzto array will be either NULL (in which case the file should not
658: be moved) or simple base names. If fto is TRUE, the files in
659: pzfrom should be moved to pzto; otherwise, the files in pzto should
660: be moved to pzfrom (this is used if a temporary failure occurs, in
661: which case the execution will be retried later). If pzinput and
662: *pzinput are not NULL, then it is the name of the standard input
663: file; if it is the same as any element of pzfrom, then *pzinput
664: should be set to the zbufcpy of the corresponding pzto value, if
665: any. */
666: extern boolean fsysdep_move_uuxqt_files P((int cfiles,
667: const char *const *pzfrom,
668: const char *const *pzto,
669: boolean fto, int ilock,
670: char **pzinput));
671:
672: /* Expand a file name on the local system, defaulting to the current
673: directory. This is just like zsysdep_local_file, except that
674: relative files are placed in the working directory the program
675: started in rather than in the public directory. This should return
676: NULL on error. */
677: extern char *zsysdep_local_file_cwd P((const char *zname,
678: const char *zpubdir));
679:
680: /* Add the working directory to a file name. The named file is
681: actually on a remote system. If the file already has a directory,
682: it should not be changed. This should return NULL on error. */
683: extern char *zsysdep_add_cwd P((const char *zfile));
684:
685: /* See whether a file name will need the current working directory
686: when zsysdep_local_file_cwd or zsysdep_add_cwd is called on it.
687: This will be called before usysdep_initialize. It should just
688: check whether the argument is an absolute path. See the comment
689: above usysdep_initialize in this file for an explanation of why
690: things are done this way. */
691: extern boolean fsysdep_needs_cwd P((const char *zfile));
692:
693: /* Get the base name of a file. The file will be a local file name,
694: and this function should return the base file name, ideally in a
695: form which will make sense on most systems; it will be used if the
696: destination of a uucp is a directory. */
697: extern char *zsysdep_base_name P((const char *zfile));
698:
699: /* Return a filename within a directory. */
700: extern char *zsysdep_in_dir P((const char *zdir, const char *zfile));
701:
702: /* Get the mode of a file. This should return a Unix style file mode.
703: It should return 0 on error. */
704: extern unsigned int ixsysdep_file_mode P((const char *zfile));
705:
706: /* See whether the user has access to a file. This is called by uucp
707: and uux to prevent copying of a file which uucp can read but the
708: user cannot. If access is denied, this should log an error message
709: and return FALSE. */
710: extern boolean fsysdep_access P((const char *zfile));
711:
712: /* See whether the daemon has access to a file. This is called by
713: uucp and uux when a file is queued up for transfer without being
714: copied into the spool directory. It is merely an early error
715: check, as the daemon would of course discover the error itself when
716: it tried the transfer. If access would be denied, this should log
717: an error message and return FALSE. */
718: extern boolean fsysdep_daemon_access P((const char *zfile));
719:
720: /* Translate a destination from system!user to a place in the public
721: directory where uupick will get the file. On Unix this produces
722: system!~/receive/user/localname, and that's probably what it has to
723: produce on any other system as well. Returns NULL on a usage
724: error, or otherwise returns string allocated by zbufcpy. */
725: extern char *zsysdep_uuto P((const char *zdest,
726: const char *zlocalname));
727:
728: /* Return TRUE if a pathname exists and is a directory. */
729: extern boolean fsysdep_directory P((const char *zpath));
730:
731: /* Walk a directory tree. The zdir argument is the directory to walk.
732: The pufn argument is a function to call on each regular file in the
733: tree. The first argument to pufn should be the full filename; the
734: second argument to pufn should be the filename relative to zdir;
735: the third argument to pufn should be the pinfo argument to
736: usysdep_walk_tree. The usysdep_walk_tree function should return
737: FALSE on error. */
738: extern boolean usysdep_walk_tree P((const char *zdir,
739: void (*pufn) P((const char *zfull,
740: const char *zrelative,
741: pointer pinfo)),
742: pointer pinfo));
743:
744: /* Return the jobid of a work file, given the sequence value. On
745: error this should log an error and return NULL. The jobid is a
746: string which may be printed out and read in and passed to
747: fsysdep_kill_job, etc., but is not otherwise interpreted. */
748: extern char *zsysdep_jobid P((const struct uuconf_system *qsys,
749: pointer pseq));
750:
751: /* See whether the current user is permitted to kill jobs submitted by
752: another user. This should return TRUE if permission is granted,
753: FALSE otherwise. */
754: extern boolean fsysdep_privileged P((void));
755:
756: /* Kill a job, given the jobid. This should remove all associated
757: files and in general eliminate the job completely. On error it
758: should log an error message and return FALSE. */
759: extern boolean fsysdep_kill_job P((pointer puuconf,
760: const char *zjobid));
761:
762: /* Rejuvenate a job, given the jobid. If possible, this should update
763: the time associated with the job such that it will not be
764: eliminated by uustat -K or similar programs that check the creation
765: time. This should affect the return value of ixsysdep_work_time.
766: On error it should log an error message and return FALSE. */
767: extern boolean fsysdep_rejuvenate_job P((pointer puuconf,
768: const char *zjobid));
769:
770: /* Get the time a job was queued, given the sequence number. There is
771: no way to indicate error. The return value must use the same epoch
772: as ixsysdep_time. */
773: extern long ixsysdep_work_time P((const struct uuconf_system *qsys,
774: pointer pseq));
775:
776: /* Get the time a file was created. This is called by uustat on
777: execution files. There is no way to indicate error. The return
778: value must use the same epoch as ixsysdep_time. */
779: extern long ixsysdep_file_time P((const char *zfile));
780:
781: /* Get the size in bytes of a file. If this file does not exist, this
782: should not give an error message, but should return -1. If some
783: other error occurs, this should return -2. */
784: extern long csysdep_size P((const char *zfile));
785:
786: /* Return the amount of free space on the containing the given file
787: name (the file may or may not exist). If the amount of free space
788: cannot be determined, the function should return -1. */
789: extern long csysdep_bytes_free P((const char *zfile));
790:
791: /* Start getting status information for all systems with available
792: status information. There may be status information for unknown
793: systems, which is why this series of functions is used. The phold
794: argument is used to pass information around, to possibly avoid the
795: use of static variables. On error this should log an error and
796: return FALSE. */
797: extern boolean fsysdep_all_status_init P((pointer *phold));
798:
799: /* Get status information for the next system. This should return the
800: system name and fill in the qstat argument. The phold argument
801: will be that set by fsysdep_all_status_init. On error this should
802: log an error, set *pferr to TRUE, and return NULL. */
803: extern char *zsysdep_all_status P((pointer phold, boolean *pferr,
804: struct sstatus *qstat));
805:
806: /* Free up anything allocated by fsysdep_all_status_init and
807: zsysdep_all_status. The phold argument is that set by
808: fsysdep_all_status_init. */
809: extern void usysdep_all_status_free P((pointer phold));
810:
811: /* Display the process status of all processes holding lock files.
812: This is uustat -p. The return value is passed to usysdep_exit. */
813: extern boolean fsysdep_lock_status P((void));
814:
815: /* Return TRUE if the user has legitimate access to the port. This is
816: used by cu to control whether the user can open a port directly,
817: rather than merely being able to dial out on it. Opening a port
818: directly allows the modem to be reprogrammed. */
819: extern boolean fsysdep_port_access P((struct uuconf_port *qport));
820:
821: /* Return whether the given port could be named by the given line. On
822: Unix, the line argument would be something like "ttyd0", and this
823: function should return TRUE if the named port is "/dev/ttyd0". */
824: extern boolean fsysdep_port_is_line P((struct uuconf_port *qport,
825: const char *zline));
826:
827: /* Set the terminal into raw mode. In this mode no input characters
828: should be treated specially, and characters should be made
829: available as they are typed. The original terminal mode should be
830: saved, so that it can be restored by fsysdep_terminal_restore. If
831: flocalecho is TRUE, then local echoing should still be done;
832: otherwise echoing should be disabled. This function returns FALSE
833: on error. */
834: extern boolean fsysdep_terminal_raw P((boolean flocalecho));
835:
836: /* Restore the terminal back to the original setting, before
837: fsysdep_terminal_raw was called. Returns FALSE on error. */
838: extern boolean fsysdep_terminal_restore P((void));
839:
840: /* Read a line from the terminal. The fsysdep_terminal_raw function
841: will have been called. This should print the zprompt argument
842: (unless it is NULL) and return the line, allocated by zbufcpy, or
843: NULL on error. */
844: extern char *zsysdep_terminal_line P((const char *zprompt));
845:
846: /* Write a line to the terminal, ending with a newline. This is
847: basically just puts (zline, stdout), except that the terminal will
848: be in raw mode, so on ASCII Unix systems the line needs to end with
849: \r\n. */
850: extern boolean fsysdep_terminal_puts P((const char *zline));
851:
852: /* If faccept is TRUE, permit the user to generate signals from the
853: terminal. If faccept is FALSE, turn signals off again. After
854: fsysdep_terminal_raw is called, signals should be off. Return
855: FALSE on error. */
856: extern boolean fsysdep_terminal_signals P((boolean faccept));
857:
858: /* The cu program expects the system dependent code to handle the
859: details of copying data from the communications port to the
860: terminal. This should be set up by fsysdep_cu_init, and done while
861: fsysdep_cu is called. It is permissible to do it on a continual
862: basis (on Unix a subprocess handles it) so long as the copying can
863: be stopped by the fsysdep_cu_copy function.
864:
865: The fsysdep_cu_init function does any system dependent
866: initialization needed for this. */
867: extern boolean fsysdep_cu_init P((struct sconnection *qconn));
868:
869: /* Copy all data from the communications port to the terminal, and all
870: data from the terminal to the communications port. Keep this up
871: until the escape character *zCuvar_escape is seen. Set *pbcmd to
872: the character following the escape character; after the escape
873: character, zlocalname should be printed, possibly after a delay.
874: If two escape characters are entered in sequence, this function
875: should send a single escape character to the port, and not return.
876: Returns FALSE on error. */
877: extern boolean fsysdep_cu P((struct sconnection *qconn,
878: char *pbcmd,
879: const char *zlocalname));
880:
881: /* If fcopy is TRUE, start copying data from the communications port
882: to the terminal. If fcopy is FALSE, stop copying data. This
883: function may be called several times during a cu session. It
884: should return FALSE on error. */
885: extern boolean fsysdep_cu_copy P((boolean fcopy));
886:
887: /* Stop copying data from the communications port to the terminal, and
888: generally clean up after fsysdep_cu_init and fsysdep_cu. Returns
889: FALSE on error. */
890: extern boolean fsysdep_cu_finish P((void));
891:
892: /* Run a shell command. If zcmd is NULL, or *zcmd == '\0', just
893: start up a shell. The second argument is one of the following
894: values. This should return FALSE on error. */
895: enum tshell_cmd
896: {
897: /* Attach stdin and stdout to the terminal. */
898: SHELL_NORMAL,
899: /* Attach stdout to the communications port, stdin to the terminal. */
900: SHELL_STDOUT_TO_PORT,
901: /* Attach stdin to the communications port, stdout to the terminal. */
902: SHELL_STDIN_FROM_PORT,
903: /* Attach both stdin and stdout to the communications port. */
904: SHELL_STDIO_ON_PORT
905: };
906:
907: extern boolean fsysdep_shell P((struct sconnection *qconn,
908: const char *zcmd,
909: enum tshell_cmd tcmd));
910:
911: /* Change directory. If zdir is NULL, or *zdir == '\0', change to the
912: user's home directory. Return FALSE on error. */
913: extern boolean fsysdep_chdir P((const char *zdir));
914:
915: /* Suspend the current process. This is only expected to work on Unix
916: versions that support SIGTSTP. In general, people can just shell
917: out. */
918: extern boolean fsysdep_suspend P((void));
919:
920: /* Start getting files for uupick. The zsystem argument may be NULL
921: to get files from all systems, or it may specify a particular
922: system. The zpubdir argument is the public directory to use. This
923: returns FALSE on error. */
924: extern boolean fsysdep_uupick_init P((const char *zsystem,
925: const char *zpubdir));
926:
927: /* Get the next file for uupick. This returns the basic file name.
928: It sets *pzfull to the full name, and *pzfrom to the name of the
929: system which sent this file over; both should be freed using
930: ubuffree. *pzfull should be passed to ubuffree after it is no
931: longer needed. The zsystem and zpubdir arguments should be the
932: same as the arguments to fsysdep_uupick_init. This returns NULL
933: when all files been returned. */
934: extern char *zsysdep_uupick P((const char *zsystem, const char *zpubdir,
935: char **pzfrom, char **pzfull));
936:
937: /* Clean up after getting files for uupick. */
938: extern boolean fsysdep_uupick_free P((const char *zsystem,
939: const char *zpubdir));
940:
941: /* Translate a local file name for uupick. On Unix this is just like
942: zsysdep_local_file_cwd except that a file beginning with ~/ is
943: placed in the user's home directory rather than in the public
944: directory. */
945: extern char *zsysdep_uupick_local_file P((const char *zfile));
946:
947: /* Remove a directory and all the files in it. */
948: extern boolean fsysdep_rmdir P((const char *zdir));
949:
950: #endif /* ! defined (SYSTEM_H) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.