1 /*********************************************************************** 2 * * 3 * This software is part of the ast package * 4 * Copyright (c) 1982-2013 AT&T Intellectual Property * 5 * and is licensed under the * 6 * Eclipse Public License, Version 1.0 * 7 * by AT&T Intellectual Property * 8 * * 9 * A copy of the License is available at * 10 * http://www.eclipse.org/org/documents/epl-v10.html * 11 * (with md5 checksum b35adb5213ca9657e911e9befb180842) * 12 * * 13 * Information and Software Systems Research * 14 * AT&T Research * 15 * Florham Park NJ * 16 * * 17 * David Korn <dgkorn@gmail.com> * 18 * * 19 ***********************************************************************/ 20 // 21 // UNIX shell 22 // David Korn 23 // 24 #ifndef _IO_H 25 #define _IO_H 1 26 27 #include "shell.h" 28 29 #define IOBSIZE (SF_BUFSIZE * _ast_sizeof_pointer) 30 #define IOMAXTRY 20 31 32 #define IOREAD 001 33 #define IOWRITE 002 34 #define IODUP 004 35 #define IOSEEK 010 36 #define IONOSEEK 020 37 #define IOTTY 040 38 #define IOCLEX 0100 39 #define IOCLOSE (IOSEEK | IONOSEEK) 40 41 #define IOSUBSHELL 0x8000 // must be larger than any file descriptor 42 #define IOPICKFD 0x10000 // file descriptor number was selected automatically 43 #define IOHERESTRING 0x20000 // allow here documents to be string streams 44 #define IOSAVESTRING 0x40000 // string file was saved 45 #define IOUSEVEX 0x80000 // use spawnvex to save and restore 46 47 // 48 // The remainder of this file is only used when compiled with shell. 49 // 50 #ifndef ARG_RAW 51 struct ionod; 52 #endif // !ARG_RAW 53 54 extern int sh_iocheckfd(Shell_t *, int, int); 55 extern void sh_ioinit(Shell_t *); 56 extern int sh_iomovefd(Shell_t *, int); 57 extern int sh_iorenumber(Shell_t *, int, int); 58 extern void sh_pclose(int[]); 59 extern void sh_rpipe(int[]); 60 extern void sh_iorestore(Shell_t *, int, int); 61 #if USE_SPAWN 62 extern void sh_vexrestore(Shell_t *, int); 63 extern void sh_vexsave(Shell_t *, int, int, Spawnvex_f, void *); 64 #endif // USE_SPAWN 65 extern Sfio_t *sh_iostream(Shell_t *, int, int); 66 extern int sh_redirect(Shell_t *, struct ionod *, int); 67 extern void sh_iosave(Shell_t *, int, int, char *); 68 extern int sh_get_unused_fd(Shell_t *shp, int min_fd); 69 extern bool sh_iovalidfd(Shell_t *, int); 70 extern bool sh_inuse(Shell_t *, int); 71 extern void sh_iounsave(Shell_t *); 72 extern void sh_iounpipe(Shell_t *); 73 extern int sh_chkopen(const char *); 74 extern int sh_ioaccess(int, int); 75 extern bool sh_isdevfd(const char *); 76 extern bool sh_source(Shell_t *, Sfio_t *, const char *); 77 78 // The following are readonly. 79 extern const char e_copexists[]; 80 extern const char e_query[]; 81 extern const char e_history[]; 82 extern const char e_argtype[]; 83 extern const char e_create[]; 84 extern const char e_tmpcreate[]; 85 extern const char e_exists[]; 86 extern const char e_file[]; 87 extern const char e_redirect[]; 88 extern const char e_io[]; 89 extern const char e_formspec[]; 90 extern const char e_badregexp[]; 91 extern const char e_open[]; 92 extern const char e_notseek[]; 93 extern const char e_noread[]; 94 extern const char e_badseek[]; 95 extern const char e_badwrite[]; 96 extern const char e_badpattern[]; 97 extern const char e_toomany[]; 98 extern const char e_pipe[]; 99 extern const char e_unknown[]; 100 extern const char e_profile[]; 101 extern const char e_sysprofile[]; 102 extern const char e_sysrc[]; 103 #if SHOPT_BASH 104 extern const char e_bash_sysrc[]; 105 extern const char e_bash_rc[]; 106 extern const char e_bash_login[]; 107 extern const char e_bash_logout[]; 108 extern const char e_bash_profile[]; 109 #endif // SHOPT_BASH 110 extern const char e_stdprompt[]; 111 extern const char e_supprompt[]; 112 extern const char e_ambiguous[]; 113 114 #endif // _IO_H 115