diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2012-06-24 22:28:35 +0000 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2012-06-24 22:28:35 +0000 |
commit | 3950ffe2a485479f6561c27364d3d7df5a21d124 (patch) | |
tree | 468c6e14449d1b1e279222ec32f676b0311917d2 /src/lib/libast/include | |
download | ksh-3950ffe2a485479f6561c27364d3d7df5a21d124.tar.gz |
Imported Upstream version 93u+upstream
Diffstat (limited to 'src/lib/libast/include')
53 files changed, 6263 insertions, 0 deletions
diff --git a/src/lib/libast/include/aso.h b/src/lib/libast/include/aso.h new file mode 100644 index 0000000..1007e93 --- /dev/null +++ b/src/lib/libast/include/aso.h @@ -0,0 +1,183 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +#ifndef _ASO_H +#define _ASO_H 1 + +#define ASO_VERSION 20111111L + +#include <ast_common.h> + +/* + * ast atomic scalar operations interface definitions + */ + +/* asometh() types (ordered mutually exclusive flags) */ +#define ASO_NEXT (-1) +#define ASO_SIGNAL 1 +#define ASO_THREAD 2 +#define ASO_PROCESS 4 +#define ASO_INTRINSIC 8 + +/* asolock() operations */ +#define ASO_UNLOCK 0 /* unlock if key matches */ +#define ASO_TRYLOCK 1 /* matched key means successful attempt */ +#define ASO_LOCK 2 /* matched key first, then spin-lock */ +#define ASO_SPINLOCK 3 /* no matching of key before locking */ + +/* Asoerror_f types */ +#define ASO_EMETHOD 0 /* method specific error */ +#define ASO_EHUNG 1 /* asoloop() possibly hung */ + +/* for internal use, but standardized for libs such as CDT and Vmalloc */ +#define ASO_RELAX ((1<<2)-1) /* cycles between spin-loop yield */ +#define ASOLOOP(k) asoloop(++(k)) + +#define ASODISC(d,e) (memset(d,0,sizeof(*(d))),(d)->version=ASO_VERSION,(d)->errorf=(e)) + +typedef int (*Asoerror_f)(int, const char*); +typedef void* (*Asoinit_f)(void*, const char*); +typedef ssize_t (*Asolock_f)(void*, ssize_t, void volatile*); + +typedef struct Asodisc_s +{ + uint32_t version; + unsigned int hung; + Asoerror_f errorf; +} Asodisc_t; + +typedef struct Asometh_s +{ + const char* name; + int type; + Asoinit_f initf; + Asolock_f lockf; + const char* details; +} Asometh_t; + +#if (_BLD_aso || _BLD_taso) && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !(_BLD_aso || _BLD_taso) && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Asometh_t* asometh(int, void*); + +#undef extern + +#if _BLD_aso && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_aso && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Asometh_t* _asometh(int, void*); +extern int asoinit(const char*, Asometh_t*, Asodisc_t*); +extern int asolock(unsigned int volatile*, unsigned int, int); +extern int asoloop(uintmax_t); +extern int asorelax(long); + +extern uint8_t asocas8(uint8_t volatile*, int, int); +extern uint8_t asoget8(uint8_t volatile*); +extern uint8_t asoinc8(uint8_t volatile*); +extern uint8_t asodec8(uint8_t volatile*); + +#define asocaschar(p,o,n) asocas8(p,o,n) +#define asogetchar(p) asoget8(p) +#define asoincchar(p) asoinc8(p) +#define asodecchar(p) asodec8(p) + +extern uint16_t asocas16(uint16_t volatile*, uint16_t, uint16_t); +extern uint16_t asoget16(uint16_t volatile*); +extern uint16_t asoinc16(uint16_t volatile*); +extern uint16_t asodec16(uint16_t volatile*); + +#define asocasshort(p,o,n) asocas16(p,o,n) +#define asogetshort(p) asoget16(p) +#define asoincshort(p) asoinc16(p) +#define asodecshort(p) asodec16(p) + +extern uint32_t asocas32(uint32_t volatile*, uint32_t, uint32_t); +extern uint32_t asoget32(uint32_t volatile*); +extern uint32_t asoinc32(uint32_t volatile*); +extern uint32_t asodec32(uint32_t volatile*); + +#if _ast_sizeof_int == 4 +#define asocasint(p,o,n) asocas32((uint32_t volatile*)p,o,n) +#define asogetint(p) asoget32((uint32_t volatile*)p) +#define asoincint(p) asoinc32((uint32_t volatile*)p) +#define asodecint(p) asodec32((uint32_t volatile*)p) +#endif + +#if _ast_sizeof_long == 4 +#define asocaslong(p,o,n) asocas32((uint32_t volatile*)p,o,n) +#define asogetlong(p) asoget32((uint32_t volatile*)p) +#define asoinclong(p) asoinc32((uint32_t volatile*)p) +#define asodeclong(p) asodec32((uint32_t volatile*)p) +#endif + +#if _ast_sizeof_size_t == 4 +#define asocassize(p,o,n) asocas32((uint32_t volatile*)p,o,n) +#define asogetsize(p) asoget32((uint32_t volatile*)p) +#define asoincsize(p) asoinc32((uint32_t volatile*)p) +#define asodecsize(p) asodec32((uint32_t volatile*)p) +#endif + +#ifdef _ast_int8_t + +extern uint64_t asocas64(uint64_t volatile*, uint64_t, uint64_t); +extern uint64_t asoget64(uint64_t volatile*); +extern uint64_t asoinc64(uint64_t volatile*); +extern uint64_t asodec64(uint64_t volatile*); + +#if _ast_sizeof_int == 8 +#define asocasint(p,o,n) asocas64((uint64_t volatile*)p,o,n) +#define asogetint(p) asoget64((uint64_t volatile*)p) +#define asoincint(p) asoinc64((uint64_t volatile*)p) +#define asodecint(p) asodec64((uint64_t volatile*)p) +#endif + +#if _ast_sizeof_long == 8 +#define asocaslong(p,o,n) asocas64((uint64_t volatile*)p,o,n) +#define asogetlong(p) asoget64((uint64_t volatile*)p) +#define asoinclong(p) asoinc64((uint64_t volatile*)p) +#define asodeclong(p) asodec64((uint64_t volatile*)p) +#endif + +#if _ast_sizeof_size_t == 8 +#define asocassize(p,o,n) asocas64((uint64_t volatile*)p,o,n) +#define asogetsize(p) asoget64((uint64_t volatile*)p) +#define asoincsize(p) asoinc64((uint64_t volatile*)p) +#define asodecsize(p) asodec64((uint64_t volatile*)p) +#endif + +#endif + +extern void* asocasptr(void volatile*, void*, void*); +extern void* asogetptr(void volatile*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/ast.h b/src/lib/libast/include/ast.h new file mode 100644 index 0000000..719e7a9 --- /dev/null +++ b/src/lib/libast/include/ast.h @@ -0,0 +1,405 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Advanced Software Technology Library + * AT&T Research + * + * std + posix + ast + */ + +#ifndef _AST_H +#define _AST_H + +#ifndef _AST_STD_H +#include <ast_std.h> +#endif + +#ifndef _SFIO_H +#include <sfio.h> +#endif + +#ifndef ast +#define ast _ast_info +#endif + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +/* + * workaround botched headers that assume <stdio.h> + */ + +#ifndef FILE +#ifndef _SFIO_H +struct _sfio_s; +#endif +#define FILE struct _sfio_s +#ifndef __FILE_typedef +#define __FILE_typedef 1 +#endif +#ifndef _FILEDEFED +#define _FILEDEFED 1 +#endif +#endif + +/* + * exit() support -- this matches shell exit codes + */ + +#define EXIT_BITS 8 /* # exit status bits */ + +#define EXIT_USAGE 2 /* usage exit code */ +#define EXIT_QUIT ((1<<(EXIT_BITS))-1) /* parent should quit */ +#define EXIT_NOTFOUND ((1<<(EXIT_BITS-1))-1) /* command not found */ +#define EXIT_NOEXEC ((1<<(EXIT_BITS-1))-2) /* other exec error */ + +#define EXIT_CODE(x) ((x)&((1<<EXIT_BITS)-1)) +#define EXIT_CORE(x) (EXIT_CODE(x)|(1<<EXIT_BITS)|(1<<(EXIT_BITS-1))) +#define EXIT_TERM(x) (EXIT_CODE(x)|(1<<EXIT_BITS)) + +/* + * NOTE: for compatibility the following work for EXIT_BITS={7,8} + */ + +#define EXIT_STATUS(x) (((x)&((1<<(EXIT_BITS-2))-1))?(x):EXIT_CODE((x)>>EXIT_BITS)) + +#define EXITED_CORE(x) (((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))==((1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))||((x)&((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))==((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2)))) +#define EXITED_TERM(x) ((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))) + +/* + * astconflist() flags + */ + +#define ASTCONF_parse 0x0001 +#define ASTCONF_write 0x0002 +#define ASTCONF_read 0x0004 +#define ASTCONF_lower 0x0008 +#define ASTCONF_base 0x0010 +#define ASTCONF_defined 0x0020 +#define ASTCONF_quote 0x0040 +#define ASTCONF_table 0x0080 +#define ASTCONF_matchcall 0x0100 +#define ASTCONF_matchname 0x0200 +#define ASTCONF_matchstandard 0x0400 +#define ASTCONF_error 0x0800 +#define ASTCONF_system 0x1000 +#define ASTCONF_AST 0x2000 + +/* + * pathcanon() flags + */ + +#define PATH_PHYSICAL 01 +#define PATH_DOTDOT 02 +#define PATH_EXISTS 04 +#define PATH_VERIFIED(n) (((n)&01777)<<5) + +/* + * pathaccess() flags + */ + +#define PATH_READ 004 +#define PATH_WRITE 002 +#define PATH_EXECUTE 001 +#define PATH_REGULAR 010 +#define PATH_ABSOLUTE 020 + +/* + * touch() flags + */ + +#define PATH_TOUCH_CREATE 01 +#define PATH_TOUCH_VERBATIM 02 + +/* + * pathcheck() info + */ + +typedef struct +{ + unsigned long date; + char* feature; + char* host; + char* user; +} Pathcheck_t; + +/* + * strgrpmatch() flags + */ + +#define STR_MAXIMAL 01 /* maximal match */ +#define STR_LEFT 02 /* implicit left anchor */ +#define STR_RIGHT 04 /* implicit right anchor */ +#define STR_ICASE 010 /* ignore case */ +#define STR_GROUP 020 /* (|&) inside [@|&](...) only */ + +/* + * fmtquote() flags + */ + +#define FMT_ALWAYS 0x01 /* always quote */ +#define FMT_ESCAPED 0x02 /* already escaped */ +#define FMT_SHELL 0x04 /* escape $ ` too */ +#define FMT_WIDE 0x08 /* don't escape 8 bit chars */ +#define FMT_PARAM 0x10 /* disable FMT_SHELL ${$( quote */ + +/* + * chrexp() flags + */ + +#define FMT_EXP_CHAR 0x020 /* expand single byte chars */ +#define FMT_EXP_LINE 0x040 /* expand \n and \r */ +#define FMT_EXP_WIDE 0x080 /* expand \u \U \x wide chars */ +#define FMT_EXP_NOCR 0x100 /* skip \r */ +#define FMT_EXP_NONL 0x200 /* skip \n */ + +/* + * multibyte macros + */ + +#define mbmax() (ast.mb_cur_max) +#define mberr() (ast.tmp_int<0) + +#define mbcoll() (ast.mb_xfrm!=0) +#define mbwide() (mbmax()>1) + +#define mb2wc(w,p,n) (*ast.mb_towc)(&w,(char*)p,n) +#define mbchar(p) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),mbmax()))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p+=ast.mb_sync+1,ast.tmp_int)):(*(unsigned char*)(p++))) +#define mbnchar(p,n) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),n))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p+=ast.mb_sync+1,ast.tmp_int)):(*(unsigned char*)(p++))) +#define mbinit() (mbwide()?(*ast.mb_towc)((wchar_t*)0,(char*)0,mbmax()):0) +#define mbsize(p) (mbwide()?(*ast.mb_len)((char*)(p),mbmax()):((p),1)) +#define mbnsize(p,n) (mbwide()?(*ast.mb_len)((char*)(p),n):((p),1)) +#define mbconv(s,w) (ast.mb_conv?(*ast.mb_conv)(s,w):((*(s)=(w)),1)) +#define mbwidth(w) (ast.mb_width?(*ast.mb_width)(w):1) +#define mbxfrm(t,f,n) (mbcoll()?(*ast.mb_xfrm)((char*)(t),(char*)(f),n):0) +#define mbalpha(w) (ast.mb_alpha?(*ast.mb_alpha)(w):isalpha((w)&0xff)) + +/* + * common macros + */ + +#define elementsof(x) (sizeof(x)/sizeof(x[0])) +#define integralof(x) (((char*)(x))-((char*)0)) +#define newof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)calloc(1,sizeof(t)*(n)+(x))) +#define oldof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)malloc(sizeof(t)*(n)+(x))) +#define pointerof(x) ((void*)((char*)0+(x))) +#define roundof(x,y) (((x)+(y)-1)&~((y)-1)) +#define ssizeof(x) ((int)sizeof(x)) + +#define streq(a,b) (*(a)==*(b)&&!strcmp(a,b)) +#define strneq(a,b,n) (*(a)==*(b)&&!strncmp(a,b,n)) +#define strsignal(s) fmtsignal(s) + +#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) +#define NiL 0 +#define NoP(x) (void)(x) +#else +#define NiL ((char*)0) +#define NoP(x) (&x,1) +#endif + +#if !defined(NoF) +#define NoF(x) void _DATA_ ## x () {} +#if !defined(_DATA_) +#define _DATA_ +#endif +#endif + +#if !defined(NoN) +#define NoN(x) void _STUB_ ## x () {} +#if !defined(_STUB_) +#define _STUB_ +#endif +#endif + +#define NOT_USED(x) NoP(x) + +typedef int (*Error_f)(void*, void*, int, ...); + +typedef int (*Ast_confdisc_f)(const char*, const char*, const char*); +typedef int (*Strcmp_context_f)(const char*, const char*, void*); +typedef int (*Strcmp_f)(const char*, const char*); + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern char* astgetconf(const char*, const char*, const char*, int, Error_f); +extern char* astconf(const char*, const char*, const char*); +extern Ast_confdisc_f astconfdisc(Ast_confdisc_f); +extern void astconflist(Sfio_t*, const char*, int, const char*); +extern off_t astcopy(int, int, off_t); +extern int astlicense(char*, int, char*, char*, int, int, int); +extern int astquery(int, const char*, ...); +extern void astwinsize(int, int*, int*); + +extern ssize_t base64encode(const void*, size_t, void**, void*, size_t, void**); +extern ssize_t base64decode(const void*, size_t, void**, void*, size_t, void**); +extern int chresc(const char*, char**); +extern int chrexp(const char*, char**, int*, int); +extern int chrtoi(const char*); +extern char* conformance(const char*, size_t); +extern int eaccess(const char*, int); +extern char* fmtbase(intmax_t, int, int); +#define fmtbasell(a,b,c) fmtbase(a,b,c) /* until 2014-01-01 */ +extern char* fmtbuf(size_t); +extern char* fmtclock(Sfulong_t); +extern char* fmtelapsed(unsigned long, int); +extern char* fmterror(int); +extern char* fmtesc(const char*); +extern char* fmtesq(const char*, const char*); +extern char* fmtident(const char*); +extern char* fmtip4(uint32_t, int); +extern char* fmtfmt(const char*); +extern char* fmtgid(int); +extern char* fmtint(intmax_t, int); +extern char* fmtmatch(const char*); +extern char* fmtmode(int, int); +extern char* fmtnesq(const char*, const char*, size_t); +extern char* fmtnum(unsigned long, int); +extern char* fmtperm(int); +extern char* fmtquote(const char*, const char*, const char*, size_t, int); +extern char* fmtre(const char*); +extern char* fmtscale(Sfulong_t, int); +extern char* fmtsignal(int); +extern char* fmttime(const char*, time_t); +extern char* fmtuid(int); +extern char* fmtversion(unsigned long); +extern void* memdup(const void*, size_t); +extern void memfatal(void); +extern unsigned int memhash(const void*, int); +extern unsigned long memsum(const void*, int, unsigned long); +extern char* pathaccess(char*, const char*, const char*, const char*, int); +extern char* pathaccess_20100601(const char*, const char*, const char*, int, char*, size_t); +extern char* pathbin(void); +extern char* pathcanon(char*, int); +extern char* pathcanon_20100601(char*, size_t, int); +extern char* pathcat(char*, const char*, int, const char*, const char*); +extern char* pathcat_20100601(const char*, int, const char*, const char*, char*, size_t); +extern int pathcd(const char*, const char*); +extern int pathcheck(const char*, const char*, Pathcheck_t*); +extern int pathexists(char*, int); +extern char* pathfind(const char*, const char*, const char*, char*, size_t); +extern int pathgetlink(const char*, char*, int); +extern int pathinclude(const char*); +extern char* pathkey(char*, char*, const char*, const char*, const char*); +extern char* pathkey_20100601(const char*, const char*, const char*, char*, size_t, char*, size_t); +extern size_t pathnative(const char*, char*, size_t); +extern char* pathpath(char*, const char*, const char*, int); +extern char* pathpath_20100601(const char*, const char*, int, char*, size_t); +extern size_t pathposix(const char*, char*, size_t); +extern char* pathprobe(char*, char*, const char*, const char*, const char*, int); +extern char* pathprobe_20100601(const char*, const char*, const char*, int, char*, size_t, char*, size_t); +extern size_t pathprog(const char*, char*, size_t); +extern char* pathrepl(char*, const char*, const char*); +extern char* pathrepl_20100601(char*, size_t, const char*, const char*); +extern int pathsetlink(const char*, const char*); +extern char* pathshell(void); +extern char* pathtemp(char*, size_t, const char*, const char*, int*); +extern char* pathtmp(char*, const char*, const char*, int*); +extern char* setenviron(const char*); +extern int stracmp(const char*, const char*); +extern char* strcopy(char*, const char*); +extern unsigned long strelapsed(const char*, char**, int); +extern int stresc(char*); +extern int strexp(char*, int); +extern long streval(const char*, char**, long(*)(const char*, char**)); +extern long strexpr(const char*, char**, long(*)(const char*, char**, void*), void*); +extern int strgid(const char*); +extern int strgrpmatch(const char*, const char*, int*, int, int); +extern unsigned int strhash(const char*); +extern void* strlook(const void*, size_t, const char*); +extern int strmatch(const char*, const char*); +extern int strmode(const char*); +extern int strnacmp(const char*, const char*, size_t); +extern char* strncopy(char*, const char*, size_t); +extern int strnpcmp(const char*, const char*, size_t); +extern double strntod(const char*, size_t, char**); +extern _ast_fltmax_t strntold(const char*, size_t, char**); +extern long strntol(const char*, size_t, char**, int); +extern intmax_t strntoll(const char*, size_t, char**, int); +extern long strnton(const char*, size_t, char**, char*, int); +extern unsigned long strntoul(const char*, size_t, char**, int); +extern intmax_t strntonll(const char*, size_t, char**, char*, int); +extern uintmax_t strntoull(const char*, size_t, char**, int); +extern int strnvcmp(const char*, const char*, size_t); +extern int stropt(const char*, const void*, int, int(*)(void*, const void*, int, const char*), void*); +extern int strpcmp(const char*, const char*); +extern int strperm(const char*, char**, int); +extern void* strpsearch(const void*, size_t, size_t, const char*, char**); +extern void* strsearch(const void*, size_t, size_t, Strcmp_f, const char*, void*); +extern void strsort(char**, int, int(*)(const char*, const char*)); +extern char* strsubmatch(const char*, const char*, int); +extern unsigned long strsum(const char*, unsigned long); +extern char* strtape(const char*, char**); +extern int strtoip4(const char*, char**, uint32_t*, unsigned char*); +extern long strton(const char*, char**, char*, int); +extern intmax_t strtonll(const char*, char**, char*, int); +extern int struid(const char*); +extern int struniq(char**, int); +extern int strvcmp(const char*, const char*); +extern int wc2utf8(char*, uint32_t); + +#undef extern + +/* + * C library global data symbols not prototyped by <unistd.h> + */ + +#if !defined(environ) && defined(__DYNAMIC__) +#define environ __DYNAMIC__(environ) +#else +extern char** environ; +#endif + +/* + * really handy malloc()/free() (__FILE__,__LINE__,__FUNCTION__) tracing + * make with VMDEBUG==1 or debug=1 or CCFLAGS=$(CC.DEBUG) + * VMDEBUG==0 disables + * at runtime export VMALLOC_OPTIONS per vmalloc.3 + * to list originating call locations + */ + +#if !_std_malloc && !defined(VMFL) && !defined(_VMHDR_H) && \ + (VMDEBUG || !defined(VMDEBUG) && _BLD_DEBUG) + +#define VMFL 1 +#include <vmalloc.h> + +#endif + +#include <ast_api.h> + +#undef AST_PLUGIN_VERSION +#define AST_PLUGIN_VERSION(v) ((v)>AST_VERSION?(v):AST_VERSION) + +#if defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern unsigned long plugin_version(void); + +#undef extern + +#endif diff --git a/src/lib/libast/include/ast_dir.h b/src/lib/libast/include/ast_dir.h new file mode 100644 index 0000000..260d4b6 --- /dev/null +++ b/src/lib/libast/include/ast_dir.h @@ -0,0 +1,77 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +/* + * AT&T Research + * + * common dirent maintenance interface + */ + +#ifndef _AST_DIR_H +#define _AST_DIR_H + +#include <ast_lib.h> + +#if _mem_d_fileno_dirent || _mem_d_ino_dirent +#if !_mem_d_fileno_dirent +#undef _mem_d_fileno_dirent +#define _mem_d_fileno_dirent 1 +#define d_fileno d_ino +#endif +#endif + +#if _BLD_ast +#include "dirlib.h" +#else +#include <dirent.h> +#endif + +#if _mem_d_fileno_dirent +#define D_FILENO(d) ((d)->d_fileno) +#endif + +#if _mem_d_namlen_dirent +#define D_NAMLEN(d) ((d)->d_namlen) +#else +#define D_NAMLEN(d) (strlen((d)->d_name)) +#endif + +#if _mem_d_reclen_dirent +#define D_RECLEN(d) ((d)->d_reclen) +#else +#define D_RECLEN(d) D_RECSIZ(d,D_NAMLEN(d)) +#endif + +#define D_RECSIZ(d,n) (sizeof(*(d))-sizeof((d)->d_name)+((n)+sizeof(char*))&~(sizeof(char*)-1)) + +/* + * NOTE: 2003-03-27 mac osx bug symlink==DT_REG bug discovered; + * the kernel *and* all directories must be fixed, so d_type + * is summarily disabled until we see that happen + */ + +#if _mem_d_type_dirent && defined(DT_UNKNOWN) && defined(DT_REG) && defined(DT_DIR) && defined(DT_LNK) && ! ( __APPLE__ || __MACH__ ) +#define D_TYPE(d) ((d)->d_type) +#endif + +#endif diff --git a/src/lib/libast/include/ast_getopt.h b/src/lib/libast/include/ast_getopt.h new file mode 100644 index 0000000..cf5efd3 --- /dev/null +++ b/src/lib/libast/include/ast_getopt.h @@ -0,0 +1,42 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * legacy standard getopt interface + */ + +#ifdef _AST_STD_I +#undef _AST_GETOPT_H +#define _AST_GETOPT_H -1 +#endif +#ifndef _AST_GETOPT_H +#define _AST_GETOPT_H 1 + +extern int opterr; +extern int optind; +extern int optopt; +extern char* optarg; + +extern int getopt(int, char* const*, const char*); +extern int getsubopt(char**, char* const*, char**); + +#endif diff --git a/src/lib/libast/include/ast_std.h b/src/lib/libast/include/ast_std.h new file mode 100644 index 0000000..03f4fb3 --- /dev/null +++ b/src/lib/libast/include/ast_std.h @@ -0,0 +1,362 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Advanced Software Technology Library + * AT&T Research + * + * a union of standard headers that works + * with local extensions enabled + * and local omission compensation + */ + +#ifndef _AST_STD_H +#define _AST_STD_H 1 +#define _AST_STD_I 1 + +#include <ast_common.h> + +#if _BLD_ast +#define _BLD_aso 1 +#define _BLD_cdt 1 +#define _BLD_sfio 1 +#if !_UWIN +#define _BLD_vmalloc 1 +#endif +#endif + +#ifdef _SFSTDIO_H +#define _SKIP_SFSTDIO_H +#else +#define _SFSTDIO_H +#ifndef FILE +#ifndef _SFIO_H +struct _sfio_s; +#endif +#define FILE struct _sfio_s +#ifndef __FILE_typedef +#define __FILE_typedef 1 +#endif +#ifndef _FILEDEFED +#define _FILEDEFED 1 +#endif +#endif +#endif + +#include <ast_lib.h> +#include <ast_sys.h> +#include <ast_getopt.h> /* <stdlib.h> does this */ +#include <ast_fcntl.h> +#include <ast_limits.h> +#include <ast_botch.h> + +#ifdef _SKIP_SFSTDIO_H +#undef _SKIP_SFSTDIO_H +#else +#undef _SFSTDIO_H +#undef FILE +#endif + +/* locale stuff */ + +#if !_hdr_locale + +struct lconv +{ + char* decimal_point; + char* thousands_sep; + char* grouping; + char* int_curr_symbol; + char* currency_symbol; + char* mon_decimal_point; + char* mon_thousands_sep; + char* mon_grouping; + char* positive_sign; + char* negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; +}; + +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +#if !_UWIN /* for ast54 compatibility */ + +#undef getenv +#define getenv _ast_getenv + +#undef setenviron +#define setenviron _ast_setenviron + +extern char* getenv(const char*); + +#endif + +#undef localeconv +#define localeconv _ast_localeconv + +#undef setlocale +#define setlocale _ast_setlocale + +#undef strerror +#define strerror _ast_strerror + +extern struct lconv* localeconv(void); +extern char* setenviron(const char*); +extern char* setlocale(int, const char*); +extern char* strerror(int); + +#define AST_MESSAGE_SET 3 /* see <mc.h> mcindex() */ + +/* + * maintain this order when adding categories + */ + +#define AST_LC_ALL 0 +#define AST_LC_COLLATE 1 +#define AST_LC_CTYPE 2 +#define AST_LC_MESSAGES 3 +#define AST_LC_MONETARY 4 +#define AST_LC_NUMERIC 5 +#define AST_LC_TIME 6 +#define AST_LC_IDENTIFICATION 7 +#define AST_LC_ADDRESS 8 +#define AST_LC_NAME 9 +#define AST_LC_TELEPHONE 10 +#define AST_LC_XLITERATE 11 +#define AST_LC_MEASUREMENT 12 +#define AST_LC_PAPER 13 +#define AST_LC_COUNT 14 +#define AST_LC_LANG 255 + +#define AST_LC_internal 1 +#define AST_LC_test (1L<<26) +#define AST_LC_setenv (1L<<27) +#define AST_LC_find (1L<<28) +#define AST_LC_debug (1L<<29) +#define AST_LC_setlocale (1L<<30) +#define AST_LC_translate (1L<<31) + +#ifndef LC_ALL +#define LC_ALL (-AST_LC_ALL) +#endif +#ifndef LC_COLLATE +#define LC_COLLATE (-AST_LC_COLLATE) +#endif +#ifndef LC_CTYPE +#define LC_CTYPE (-AST_LC_CTYPE) +#endif +#ifndef LC_MESSAGES +#define LC_MESSAGES (-AST_LC_MESSAGES) +#endif +#ifndef LC_MONETARY +#define LC_MONETARY (-AST_LC_MONETARY) +#endif +#ifndef LC_NUMERIC +#define LC_NUMERIC (-AST_LC_NUMERIC) +#endif +#ifndef LC_TIME +#define LC_TIME (-AST_LC_TIME) +#endif +#ifndef LC_ADDRESS +#define LC_ADDRESS (-AST_LC_ADDRESS) +#endif +#ifndef LC_IDENTIFICATION +#define LC_IDENTIFICATION (-AST_LC_IDENTIFICATION) +#endif +#ifndef LC_NAME +#define LC_NAME (-AST_LC_NAME) +#endif +#ifndef LC_TELEPHONE +#define LC_TELEPHONE (-AST_LC_TELEPHONE) +#endif +#ifndef LC_XLITERATE +#define LC_XLITERATE (-AST_LC_XLITERATE) +#endif +#ifndef LC_MEASUREMENT +#define LC_MEASUREMENT (-AST_LC_MEASUREMENT) +#endif +#ifndef LC_PAPER +#define LC_PAPER (-AST_LC_PAPER) +#endif +#ifndef LC_LANG +#define LC_LANG (-AST_LC_LANG) +#endif + +#undef extern + +#undef strcoll +#if _std_strcoll +#define strcoll _ast_info.collate +#else +#define strcoll strcmp +#endif + +typedef struct +{ + + char* id; + + struct + { + uint32_t serial; + uint32_t set; + } locale; + + long tmp_long; + size_t tmp_size; + short tmp_short; + char tmp_char; + wchar_t tmp_wchar; + + int (*collate)(const char*, const char*); + + int tmp_int; + void* tmp_pointer; + + int mb_cur_max; + int (*mb_len)(const char*, size_t); + int (*mb_towc)(wchar_t*, const char*, size_t); + size_t (*mb_xfrm)(char*, const char*, size_t); + int (*mb_width)(wchar_t); + int (*mb_conv)(char*, wchar_t); + + uint32_t env_serial; + uint32_t mb_sync; + uint32_t version; + + int (*mb_alpha)(wchar_t); + + char pad[936 - sizeof(void*)]; + +} _Ast_info_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern _Ast_info_t _ast_info; + +#undef extern + +/* largefile hackery -- ast uses the large versions by default */ + +#if _typ_off64_t +#undef off_t +#define off_t off64_t +#endif +#if !defined(ftruncate) && _lib_ftruncate64 +#define ftruncate ftruncate64 +extern int ftruncate64(int, off64_t); +#endif +#if !defined(lseek) && _lib_lseek64 +#define lseek lseek64 +extern off64_t lseek64(int, off64_t, int); +#endif +#if !defined(truncate) && _lib_truncate64 +#define truncate truncate64 +extern int truncate64(const char*, off64_t); +#endif + +/* direct macro access for bsd crossover */ + +#if !defined(__cplusplus) + +#if !defined(memcpy) && !defined(_lib_memcpy) && defined(_lib_bcopy) +#define memcpy(t,f,n) (bcopy(f,t,n),(t)) +#endif + +#if !defined(memzero) && !defined(_lib_memzero) +#if defined(_lib_memset) || !defined(_lib_bzero) +#define memzero(b,n) memset(b,0,n) +#else +#define memzero(b,n) (bzero(b,n),(b)) +#endif +#endif + +#endif + +#if !defined(remove) +extern int remove(const char*); +#endif + +#if !defined(rename) +extern int rename(const char*, const char*); +#endif + +#if !defined(strchr) && !defined(_lib_strchr) && defined(_lib_index) +#define strchr(s,c) index(s,c) +#endif + +#if !defined(strrchr) && !defined(_lib_strrchr) && defined(_lib_rindex) +#define strrchr(s,c) rindex(s,c) +#endif + +/* and now introducing prototypes botched by the standard(s) */ + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +#undef getpgrp +#define getpgrp() _ast_getpgrp() +extern int _ast_getpgrp(void); + +#undef extern + +/* + * and finally, standard interfaces hijacked by ast + * _AST_STD_I delays headers that require <ast_map.h> + */ + +#include <ast_map.h> + +#undef _AST_STD_I + +#if _AST_GETOPT_H < 0 +#undef _AST_GETOPT_H +#include <ast_getopt.h> +#endif + +#if _GETOPT_H < 0 +#undef _GETOPT_H +#include <getopt.h> +#endif + +#if _REGEX_H < 0 +#undef _REGEX_H +#include <regex.h> +#endif + +#endif diff --git a/src/lib/libast/include/ast_windows.h b/src/lib/libast/include/ast_windows.h new file mode 100644 index 0000000..ed853e9 --- /dev/null +++ b/src/lib/libast/include/ast_windows.h @@ -0,0 +1,39 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +/* + * AT&T Research + * + * ast <windows.h> wrapper + * for libast only + * include after ast headers + */ + +#ifndef _AST_WINDOWS_H +#define _AST_WINDOWS_H 1 + +#undef SF_ERROR /* clash in <oaidl.h> */ + +#include <windows.h> + +#endif diff --git a/src/lib/libast/include/ccode.h b/src/lib/libast/include/ccode.h new file mode 100644 index 0000000..1335c85 --- /dev/null +++ b/src/lib/libast/include/ccode.h @@ -0,0 +1,90 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +/* + * Glenn Fowler + * AT&T Research + * + * character code map interface + * + * NOTE: used for mapping between 8-bit character encodings + * ISO character sets are handled by sfio + */ + +#ifndef _CHARCODE_H +#define _CHARCODE_H 1 + +#include <ast_common.h> +#include <ast_ccode.h> + +typedef struct Ccmap_s +{ + const char* name; /* code set name */ + const char* match; /* strmatch() pattern */ + const char* desc; /* code set description */ + const char* canon; /* canonical name format */ + const char* index; /* default index */ + int ccode; /* <ccode.h> code index */ + void* data; /* map specific data */ +} Ccmap_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern unsigned char* _ccmap(int, int); +extern void* _ccmapcpy(unsigned char*, void*, const void*, size_t); +extern void* _ccmapstr(unsigned char*, void*, size_t); + +extern int ccmapid(const char*); +extern char* ccmapname(int); +extern void* ccnative(void*, const void*, size_t); +extern Ccmap_t* ccmaplist(Ccmap_t*); + +#undef extern + +#define CCOP(i,o) ((i)==(o)?0:(((o)<<8)|(i))) +#define CCIN(x) ((x)&0xFF) +#define CCOUT(x) (((x)>>8)&0xFF) +#define CCCONVERT(x) ((x)&0xFF00) + +#define CCCVT(x) CCMAP(x,0) +#define CCMAP(i,o) ((i)==(o)?(unsigned char*)0:_ccmap(i,o)) +#define CCMAPCHR(m,c) ((m)?(m)[c]:(c)) +#define CCMAPCPY(m,t,f,n) ((m)?_ccmapcpy(m,t,f,n):memcpy(t,f,n)) +#define CCMAPSTR(m,s,n) ((m)?_ccmapstr(m,s,n):(void*)(s)) + +#define ccmap(i,o) CCMAP(i,o) +#define ccmapchr(m,c) CCMAPCHR(m,c) +#define ccmapcpy(m,t,f,n) CCMAPCPY(m,t,f,n) +#define ccmapstr(m,s,n) CCMAPSTR(m,s,n) + +#define CCMAPC(c,i,o) ((i)==(o)?(c):CCMAP(i,o)[c]) +#define CCMAPM(t,f,n,i,o) ((i)==(o)?memcpy(t,f,n):_ccmapcpy(CCMAP(i,o),t,f,n)) +#define CCMAPS(s,n,i,o) ((i)==(o)?(void*)(s):_ccmapstr(CCMAP(i,o),s,n)) + +#define ccmapc(c,i,o) CCMAPC(c,i,o) +#define ccmapm(t,f,n,i,o) CCMAPM(t,f,n,i,o) +#define ccmaps(s,n,i,o) CCMAPS(s,n,i,o) + +#endif diff --git a/src/lib/libast/include/cdt.h b/src/lib/libast/include/cdt.h new file mode 100644 index 0000000..b757e74 --- /dev/null +++ b/src/lib/libast/include/cdt.h @@ -0,0 +1,354 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#ifndef _CDT_H +#define _CDT_H 1 + +/* Public interface for the dictionary library +** +** Written by Kiem-Phong Vo +*/ + +#ifndef CDT_VERSION +#ifdef _API_ast +#define CDT_VERSION _API_ast +#else +#define CDT_VERSION 20111111L +#endif /*_AST_api*/ +#endif /*CDT_VERSION*/ +#ifndef AST_PLUGIN_VERSION +#define AST_PLUGIN_VERSION(v) (v) +#endif +#define CDT_PLUGIN_VERSION AST_PLUGIN_VERSION(20111111L) + +#if _PACKAGE_ast +#include <ast_std.h> +#else +#include <ast_common.h> +#include <string.h> +#endif + +/* commonly used integers */ +#define DT_ZERO ((unsigned int)0) /* all zero bits */ +#define DT_ONES (~DT_ZERO) /* all one bits */ +#define DT_HIBIT (~(DT_ONES >> 1) ) /* highest 1 bit */ +#define DT_LOBIT ((unsigned int)1) /* lowest 1 bit */ +#define DT_NBITS (sizeof(unsigned int)*8) /* #bits */ + +/* type of an integer with the same size as a pointer */ +#define Dtuint_t uintptr_t + +/* various types used by CDT */ +typedef struct _dtlink_s Dtlink_t; +typedef struct _dthold_s Dthold_t; +typedef struct _dtdisc_s Dtdisc_t; +typedef struct _dtmethod_s Dtmethod_t; +typedef struct _dtdata_s Dtdata_t; +typedef struct _dtuser_s Dtuser_t; +typedef struct _dt_s Dt_t; +typedef struct _dtstat_s Dtstat_t; +typedef Void_t* (*Dtsearch_f)_ARG_((Dt_t*,Void_t*,int)); +typedef Void_t* (*Dtmake_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*)); +typedef void (*Dtfree_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*)); +typedef int (*Dtcompar_f)_ARG_((Dt_t*,Void_t*,Void_t*,Dtdisc_t*)); +typedef unsigned int (*Dthash_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*)); +typedef Void_t* (*Dtmemory_f)_ARG_((Dt_t*,Void_t*,size_t,Dtdisc_t*)); +typedef int (*Dtevent_f)_ARG_((Dt_t*,int,Void_t*,Dtdisc_t*)); +typedef int (*Dttype_f)_ARG_((Dt_t*,int)); + +struct _dtuser_s /* for application to access and use */ +{ unsigned int lock; /* used by dtapplock */ + Void_t* data; /* for whatever data */ +}; + +struct _dtlink_s +{ +#if CDT_VERSION < 20111111L + Dtlink_t* right; /* right child */ + union + { unsigned int _hash; /* hash value */ + Dtlink_t* _left; /* left child */ + } hl; +#else + union + { Dtlink_t* __rght; /* right child or next */ + Dtlink_t* __ptbl; /* Dtrehash parent tbl */ + } rh; + union + { Dtlink_t* __left; /* left child or prev */ + unsigned int __hash; /* hash value of object */ + } lh; +#endif +}; + +/* private structure to hold an object */ +struct _dthold_s +{ Dtlink_t hdr; /* header to hold obj */ + Void_t* obj; /* application object */ +}; + +/* method to manipulate dictionary structure */ +struct _dtmethod_s +{ Dtsearch_f searchf; /* search function */ + unsigned int type; /* type of operation */ + int (*eventf)_ARG_((Dt_t*, int, Void_t*)); + char* name; /* name of method */ + char* description; /* description */ +}; + +/* structure to hold methods that manipulate an object */ +struct _dtdisc_s +{ int key; /* where the key resides */ + int size; /* key size and type */ + int link; /* offset to Dtlink_t field */ + Dtmake_f makef; /* object constructor */ + Dtfree_f freef; /* object destructor */ + Dtcompar_f comparf;/* to compare two objects */ + Dthash_f hashf; /* to compute hash value */ + Dtmemory_f memoryf;/* to allocate/free memory */ + Dtevent_f eventf; /* to process events */ +}; + +#define DTDISC(dc,ky,sz,lk,mkf,frf,cmpf,hshf,memf,evf) \ + ( (dc)->key = (int)(ky), (dc)->size = (int)(sz), (dc)->link = (int)(lk), \ + (dc)->makef = (mkf), (dc)->freef = (frf), \ + (dc)->comparf = (cmpf), (dc)->hashf = (hshf), \ + (dc)->memoryf = (memf), (dc)->eventf = (evf) ) + +#ifdef offsetof +#define DTOFFSET(struct_s, member) offsetof(struct_s, member) +#else +#define DTOFFSET(struct_s, member) ((int)(&((struct_s*)0)->member)) +#endif + +/* the dictionary structure itself */ +struct _dt_s +{ Dtsearch_f searchf;/* search function */ + Dtdisc_t* disc; /* object type definitition */ + Dtdata_t* data; /* sharable data */ + Dtmemory_f memoryf;/* for memory allocation */ + Dtmethod_t* meth; /* storage method */ + ssize_t nview; /* #parent view dictionaries */ + Dt_t* view; /* next on viewpath */ + Dt_t* walk; /* dictionary being walked */ + Dtuser_t* user; /* for user's usage */ + Dttype_f typef; /* for binary compatibility */ +}; + +/* structure to get status of a dictionary */ +#define DT_MAXRECURSE 1024 /* limit to avoid stack overflow */ +#define DT_MAXSIZE 256 /* limit for size of below arrays */ +struct _dtstat_s +{ unsigned int meth; /* method type */ + ssize_t size; /* total # of elements in dictionary */ + ssize_t space; /* memory usage of data structure */ + ssize_t mlev; /* max #levels in tree or hash table */ + ssize_t msize; /* max #defined elts in below arrays */ + ssize_t lsize[DT_MAXSIZE]; /* #objects by level */ + ssize_t tsize[DT_MAXSIZE]; /* #tables by level */ +}; + +/* supported storage methods */ +#define DT_SET 0000000001 /* unordered set, unique elements */ +#define DT_BAG 0000000002 /* unordered set, repeated elements */ +#define DT_OSET 0000000004 /* ordered set */ +#define DT_OBAG 0000000010 /* ordered multiset */ +#define DT_LIST 0000000020 /* linked list */ +#define DT_STACK 0000000040 /* stack: insert/delete at top */ +#define DT_QUEUE 0000000100 /* queue: insert top, delete at tail */ +#define DT_DEQUE 0000000200 /* deque: insert top, append at tail */ +#define DT_RHSET 0000000400 /* rhset: sharable unique objects */ +#define DT_RHBAG 0000001000 /* rhbag: sharable repeated objects */ +#define DT_METHODS 0000001777 /* all currently supported methods */ +#define DT_ORDERED (DT_OSET|DT_OBAG) + +/* asserts to dtdisc() to improve performance when changing disciplines */ +#define DT_SAMECMP 0000000001 /* compare functions are equivalent */ +#define DT_SAMEHASH 0000000002 /* hash functions are equivalent */ + +/* operation types */ +#define DT_INSERT 0000000001 /* insert object if not found */ +#define DT_DELETE 0000000002 /* delete a matching object if any */ +#define DT_SEARCH 0000000004 /* look for an object */ +#define DT_NEXT 0000000010 /* look for next element */ +#define DT_PREV 0000000020 /* find previous element */ +#define DT_FIRST 0000000200 /* get first object */ +#define DT_LAST 0000000400 /* get last object */ +#define DT_MATCH 0000001000 /* find object matching key */ +#define DT_ATTACH 0000004000 /* attach an object to dictionary */ +#define DT_DETACH 0000010000 /* detach an object from dictionary */ +#define DT_APPEND 0000020000 /* append an object */ +#define DT_ATLEAST 0000040000 /* find the least elt >= object */ +#define DT_ATMOST 0000100000 /* find the biggest elt <= object */ +#define DT_REMOVE 0002000000 /* remove a specific object */ +#define DT_TOANNOUNCE (DT_INSERT|DT_DELETE|DT_SEARCH|DT_NEXT|DT_PREV|DT_FIRST|DT_LAST|DT_MATCH|DT_ATTACH|DT_DETACH|DT_APPEND|DT_ATLEAST|DT_ATMOST|DT_REMOVE) + +#define DT_RELINK 0000002000 /* re-inserting (dtdisc,dtmethod...) */ +#define DT_FLATTEN 0000000040 /* flatten objects into a list */ +#define DT_CLEAR 0000000100 /* clearing all objects */ +#define DT_EXTRACT 0000200000 /* FLATTEN and clear dictionary */ +#define DT_RESTORE 0000400000 /* reinsert a list of elements */ +#define DT_STAT 0001000000 /* get statistics of dictionary */ +#define DT_OPERATIONS (DT_TOANNOUNCE|DT_RELINK|DT_FLATTEN|DT_CLEAR|DT_EXTRACT|DT_RESTORE|DT_STAT) + +/* these bits may combine with the DT_METHODS and DT_OPERATIONS bits */ +#define DT_INDATA 0010000000 /* Dt_t was allocated with Dtdata_t */ +#define DT_SHARE 0020000000 /* concurrent access mode */ +#define DT_ANNOUNCE 0040000000 /* announcing a successful operation */ + /* the actual event will be this bit */ + /* combined with the operation bit */ +#define DT_OPTIMIZE 0100000000 /* optimizing data structure */ + +/* events for discipline and method event-handling functions */ +#define DT_OPEN 1 /* a dictionary is being opened */ +#define DT_ENDOPEN 5 /* end of dictionary opening */ +#define DT_CLOSE 2 /* a dictionary is being closed */ +#define DT_ENDCLOSE 6 /* end of dictionary closing */ +#define DT_DISC 3 /* discipline is about to be changed */ +#define DT_METH 4 /* method is about to be changed */ +#define DT_HASHSIZE 7 /* initialize hash table size */ +#define DT_ERROR 0xbad /* announcing an error */ + +_BEGIN_EXTERNS_ /* data structures and functions */ +#if _BLD_cdt && defined(__EXPORT__) +#define extern __EXPORT__ +#endif +#if !_BLD_cdt && defined(__IMPORT__) +#define extern __IMPORT__ +#endif + +extern Dtmethod_t* Dtset; +extern Dtmethod_t* Dtbag; +extern Dtmethod_t* Dtoset; +extern Dtmethod_t* Dtobag; +extern Dtmethod_t* Dtlist; +extern Dtmethod_t* Dtstack; +extern Dtmethod_t* Dtqueue; +extern Dtmethod_t* Dtdeque; + +#if _PACKAGE_ast /* dtplugin() for proprietary and non-standard methods -- requires -ldll */ + +#define dtplugin(name) ((Dtmethod_t*)dllmeth("cdt", name, CDT_PLUGIN_VERSION)) + +#define Dtrhbag dtplugin("rehash:Dtrhbag") +#define Dtrhset dtplugin("rehash:Dtrhset") + +#else + +#if CDTPROPRIETARY + +extern Dtmethod_t* Dtrhset; +extern Dtmethod_t* Dtrhbag; + +#endif /*CDTPROPRIETARY*/ + +#endif /*_PACKAGE_ast*/ + +#undef extern + +#if _BLD_cdt && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Dt_t* dtopen _ARG_((Dtdisc_t*, Dtmethod_t*)); +extern int dtclose _ARG_((Dt_t*)); +extern Dt_t* dtview _ARG_((Dt_t*, Dt_t*)); +extern Dtdisc_t* dtdisc _ARG_((Dt_t* dt, Dtdisc_t*, int)); +extern Dtmethod_t* dtmethod _ARG_((Dt_t*, Dtmethod_t*)); +extern int dtwalk _ARG_((Dt_t*, int(*)(Dt_t*,Void_t*,Void_t*), Void_t*)); +extern int dtcustomize _ARG_((Dt_t*, int, int)); +extern unsigned int dtstrhash _ARG_((unsigned int, Void_t*, ssize_t)); +extern int dtuserlock _ARG_((Dt_t*, unsigned int, int)); +extern Void_t* dtuserdata _ARG_((Dt_t*, Void_t*, unsigned int)); + +/* deal with upward binary compatibility (operation bit translation, etc.) */ +extern Dt_t* _dtopen _ARG_((Dtdisc_t*, Dtmethod_t*, unsigned long)); +#define dtopen(dc,mt) _dtopen((dc), (mt), CDT_VERSION) + +#undef extern + +#if _PACKAGE_ast && !defined(_CDTLIB_H) + +#if _BLD_dll && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern void* dllmeth(const char*, const char*, unsigned long); + +#undef extern + +#endif + +_END_EXTERNS_ + +/* internal functions for translating among holder, object and key */ +#define _DT(dt) ((Dt_t*)(dt)) + +#define _DTLNK(dc,o) ((Dtlink_t*)((char*)(o) + (dc)->link) ) /* get link from obj */ + +#define _DTO(dc,l) (Void_t*)((char*)(l) - (dc)->link) /* get object from link */ +#define _DTOBJ(dc,l) ((dc)->link >= 0 ? _DTO(dc,l) : ((Dthold_t*)(l))->obj ) + +#define _DTK(dc,o) ((char*)(o) + (dc)->key) /* get key from object */ +#define _DTKEY(dc,o) (Void_t*)((dc)->size >= 0 ? _DTK(dc,o) : *((char**)_DTK(dc,o)) ) + +#define _DTCMP(dt,k1,k2,dc) \ + ((dc)->comparf ? (*(dc)->comparf)((dt), (k1), (k2), (dc)) : \ + (dc)->size > 0 ? memcmp((Void_t*)(k1), ((Void_t*)k2), (dc)->size) : \ + strcmp((char*)(k1), ((char*)k2)) ) + +#define _DTHSH(dt,ky,dc) ((dc)->hashf ? (*(dc)->hashf)((dt), (ky), (dc)) : \ + dtstrhash(0, (ky), (dc)->size) ) + +#define dtvnext(d) (_DT(d)->view) +#define dtvcount(d) (_DT(d)->nview) +#define dtvhere(d) (_DT(d)->walk) + +#define dtlink(d,e) (((Dtlink_t*)(e))->rh.__rght) +#define dtobj(d,e) _DTOBJ(_DT(d)->disc, (e)) + +#define dtfirst(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_FIRST) +#define dtnext(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_NEXT) +#define dtatleast(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_ATLEAST) +#define dtlast(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_LAST) +#define dtprev(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_PREV) +#define dtatmost(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_ATMOST) +#define dtsearch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH) +#define dtmatch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_MATCH) +#define dtinsert(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_INSERT) +#define dtappend(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_APPEND) +#define dtdelete(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DELETE) +#define dtremove(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_REMOVE) +#define dtattach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_ATTACH) +#define dtdetach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DETACH) +#define dtclear(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_CLEAR) + +#define dtflatten(d) (Dtlink_t*)(*(_DT(d)->searchf))((d),(Void_t*)(0),DT_FLATTEN) +#define dtextract(d) (Dtlink_t*)(*(_DT(d)->searchf))((d),(Void_t*)(0),DT_EXTRACT) +#define dtrestore(d,l) (Dtlink_t*)(*(_DT(d)->searchf))((d),(Void_t*)(l),DT_RESTORE) + +#define dtstat(d,s) (ssize_t)(*(_DT(d)->searchf))((d),(Void_t*)(s),DT_STAT) +#define dtsize(d) (ssize_t)(*(_DT(d)->searchf))((d),(Void_t*)(0),DT_STAT) + +#define DT_PRIME 17109811 /* 2#00000001 00000101 00010011 00110011 */ +#define dtcharhash(h,c) (((unsigned int)(h) + (unsigned int)(c)) * DT_PRIME ) + +#endif /* _CDT_H */ diff --git a/src/lib/libast/include/cmdarg.h b/src/lib/libast/include/cmdarg.h new file mode 100644 index 0000000..94ad39e --- /dev/null +++ b/src/lib/libast/include/cmdarg.h @@ -0,0 +1,92 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * xargs/tw command arg list interface definitions + */ + +#ifndef _CMDARG_H +#define _CMDARG_H + +#include <error.h> + +#define CMD_CHECKED (1<<9) /* cmdopen() argv[0] ok */ +#define CMD_EMPTY (1<<0) /* run once, even if no args */ +#define CMD_EXACT (1<<1) /* last command must have argmax*/ +#define CMD_EXIT (1<<11) /* fatal error_info.exit() */ +#define CMD_IGNORE (1<<2) /* ignore EXIT_QUIT exit */ +#define CMD_INSERT (1<<3) /* argpat for insertion */ +#define CMD_MINIMUM (1<<4) /* argmax is a minimum */ +#define CMD_NEWLINE (1<<5) /* echo separator is newline */ +#define CMD_POST (1<<6) /* argpat is post arg position */ +#define CMD_QUERY (1<<7) /* trace and query each command */ +#define CMD_SILENT (1<<10) /* no error messages */ +#define CMD_TRACE (1<<8) /* trace each command */ + +#define CMD_USER (1<<12) + +typedef struct Cmdarg_s /* cmd + args info */ +{ + struct + { + size_t args; /* total args */ + size_t commands; /* total commands */ + } total; + + Error_f errorf; /* optional error callback */ + + int argcount; /* current arg count */ + int argmax; /* max # args */ + int echo; /* just an echo */ + int flags; /* CMD_* flags */ + int insertlen; /* strlen(insert) */ + int offset; /* post arg offset */ + + char** argv; /* exec argv */ + char** firstarg; /* first argv file arg */ + char** insertarg; /* argv before insert */ + char** postarg; /* start of post arg list */ + char** nextarg; /* next argv file arg */ + char* nextstr; /* next string ends before here */ + char* laststr; /* last string ends before here */ + char* insert; /* replace with current arg */ + char buf[1]; /* argv and arg buffer */ +} Cmdarg_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +#ifndef cmdopen +extern Cmdarg_t* cmdopen(char**, int, int, const char*, int); +#endif +extern Cmdarg_t* cmdopen_20110505(char**, int, int, const char*, int, Error_f); +extern int cmdflush(Cmdarg_t*); +extern int cmdarg(Cmdarg_t*, const char*, int); +extern int cmdclose(Cmdarg_t*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/debug.h b/src/lib/libast/include/debug.h new file mode 100644 index 0000000..994fedb --- /dev/null +++ b/src/lib/libast/include/debug.h @@ -0,0 +1,109 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * common ast debug definitions + * include after the ast headers + */ + +#ifndef _DEBUG_H +#define _DEBUG_H + +#include <ast.h> +#include <error.h> + +#if !defined(DEBUG) && _BLD_DEBUG +#define DEBUG _BLD_DEBUG +#endif + +#if DEBUG || _BLD_DEBUG + +#define debug(x) x +#define message(x) do if (error_info.trace < 0) { error x; } while (0) +#define messagef(x) do if (error_info.trace < 0) { errorf x; } while (0) + +#define DEBUG_BEGTIME() debug_elapsed(1) +#define DEBUG_GETTIME() debug_elapsed(0) +#define DEBUG_ASSERT(p) ((p) ? 0 : (debug_fatal(__FILE__, __LINE__),0)) +#define DEBUG_COUNT(n) ((n) += 1) +#define DEBUG_TALLY(c,n,v) ((c) ? ((n) += (v)) : (n)) +#define DEBUG_INCREASE(n) ((n) += 1) +#define DEBUG_DECREASE(n) ((n) -= 1) +#define DEBUG_DECLARE(t,v) t v +#define DEBUG_SET(n,v) ((n) = (v)) +#define DEBUG_PRINT(fd,s,v) do {char _b[1024];write(fd,_b,sfsprintf(_b,sizeof(_b),s,v));} while(0) +#define DEBUG_WRITE(fd,d,n) write((fd),(d),(n)) +#define DEBUG_TEMP(temp) (temp) /* debugging stuff that should be removed */ +#define DEBUG_BREAK break +#define DEBUG_CONTINUE continue +#define DEBUG_GOTO(label) do { debug_fatal(__FILE__, __LINE__); goto label; } while(0) +#define DEBUG_RETURN(x) do { debug_fatal(__FILE__, __LINE__); return(x); } while(0) + +#else + +#define debug(x) +#define message(x) +#define messagef(x) + +#define DEBUG_BEGTIME() +#define DEBUG_GETTIME() +#define DEBUG_ASSERT(p) +#define DEBUG_COUNT(n) +#define DEBUG_TALLY(c,n,v) +#define DEBUG_INCREASE(n) +#define DEBUG_DECREASE(n) +#define DEBUG_DECLARE(t,v) +#define DEBUG_SET(n,v) +#define DEBUG_PRINT(fd,s,v) +#define DEBUG_WRITE(fd,d,n) +#define DEBUG_TEMP(x) +#define DEBUG_BREAK break +#define DEBUG_CONTINUE continue +#define DEBUG_GOTO(label) goto label +#define DEBUG_RETURN(x) return(x) + +#endif + +#ifndef BREAK +#define BREAK DEBUG_BREAK +#endif +#ifndef CONTINUE +#define CONTINUE DEBUG_CONTINUE +#endif +#ifndef GOTO +#define GOTO(label) DEBUG_GOTO(label) +#endif +#ifndef RETURN +#define RETURN(x) DEBUG_RETURN(x) +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern double debug_elapsed(int); +extern void debug_fatal(const char*, int); +extern void systrace(const char*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/dt.h b/src/lib/libast/include/dt.h new file mode 100644 index 0000000..acc6713 --- /dev/null +++ b/src/lib/libast/include/dt.h @@ -0,0 +1,41 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +#ifndef _DT_H +#define _DT_H 1 + +#include <cdt.h> +#include <vmalloc.h> + +#if _BLD_cdt && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Dt_t* dtnew(Vmalloc_t*, Dtdisc_t*, Dtmethod_t*); +extern Dt_t* _dtnew(Vmalloc_t*, Dtdisc_t*, Dtmethod_t*, unsigned long); + +#undef extern + +#define dtnew(v,d,m) _dtnew(v,d,m,CDT_VERSION) + +#endif diff --git a/src/lib/libast/include/error.h b/src/lib/libast/include/error.h new file mode 100644 index 0000000..0253e4d --- /dev/null +++ b/src/lib/libast/include/error.h @@ -0,0 +1,182 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * option, error and message formatter external definitions + */ + +#ifndef _ERROR_H +#define _ERROR_H + +#include <ast.h> +#include <option.h> +#include <errno.h> + +#define ERROR_VERSION 20070319L + +#if !defined(errno) && defined(__DYNAMIC__) +#define errno __DYNAMIC__(errno) +#endif + +#define ERROR_debug(n) (-(n)) +#define ERROR_exit(n) ((n)+ERROR_ERROR) +#define ERROR_system(n) (((n)+ERROR_ERROR)|ERROR_SYSTEM) +#define ERROR_usage(n) ((((n)?2:0)+ERROR_ERROR)|ERROR_USAGE) +#define ERROR_warn(n) (ERROR_WARNING) + +#ifndef ERROR_catalog +#define ERROR_catalog(t) t +#endif +#ifndef ERROR_dictionary +#define ERROR_dictionary(t) t +#endif + +#ifndef ERROR_translate +#define ERROR_translating() (error_info.translate&&(ast.locale.set&(1<<AST_LC_MESSAGES))) +#define ERROR_translate(l,i,d,m) (ERROR_translating()?errorx((const char*)(l),(const char*)(i),(const char*)(d),(const char*)(m)):(char*)(m)) +#endif + +#define ERROR_INFO 0 /* info message -- no err_id */ +#define ERROR_WARNING 1 /* warning message */ +#define ERROR_ERROR 2 /* error message -- no err_exit */ +#define ERROR_FATAL 3 /* error message with err_exit */ +#define ERROR_NOEXEC EXIT_NOEXEC /* shell convention */ +#define ERROR_NOENT EXIT_NOTFOUND /* shell convention */ +#define ERROR_PANIC ERROR_LEVEL /* panic message with err_exit */ + +#define ERROR_LEVEL 0x00ff /* level portion of status */ +#define ERROR_SYSTEM 0x0100 /* report system errno message */ +#define ERROR_OUTPUT 0x0200 /* next arg is error fd */ +#define ERROR_SOURCE 0x0400 /* next 2 args are FILE,LINE */ +#define ERROR_USAGE 0x0800 /* usage message */ +#define ERROR_PROMPT 0x1000 /* omit trailing newline */ +#define ERROR_NOID 0x2000 /* omit err_id */ +#define ERROR_LIBRARY 0x4000 /* library routine error */ + +#define ERROR_INTERACTIVE 0x0001 /* context is interactive */ +#define ERROR_SILENT 0x0002 /* context is silent */ +#define ERROR_NOTIFY 0x0004 /* main(-sig,0,ctx) on signal */ + +#define ERROR_FREE 0x0010 /* free context on pop */ +#define ERROR_POP 0x0020 /* pop context */ +#define ERROR_PUSH 0x0040 /* push context */ +#define ERROR_SET 0x0080 /* set context */ + +/* + * errorpush()/errorpop() are obsolete -- use errorctx() instead + */ + +#ifndef ERROR_CONTEXT_T +#define ERROR_CONTEXT_T Error_info_t +#endif + +#define ERROR_CONTEXT_BASE ((Error_context_t*)&error_info.context) + +#define errorpush(p,f) (*(p)=*ERROR_CONTEXT_BASE,*ERROR_CONTEXT_BASE=error_info.empty,error_info.context=(Error_context_t*)(p),error_info.flags=(f)) +#define errorpop(p) (*ERROR_CONTEXT_BASE=*(p)) + +typedef struct Error_info_s Error_info_t; +typedef struct Error_context_s Error_context_t; + +#define ERROR_CONTEXT \ + ERROR_CONTEXT_T* context; /* prev context stack element */ \ + int errors; /* >= ERROR_ERROR count */ \ + int flags; /* context flags */ \ + int line; /* input|output line number */ \ + int warnings; /* ERROR_WARNING count */ \ + char* file; /* input|output file name */ \ + char* id; /* command id */ + +struct Error_context_s /* context stack element */ +{ + ERROR_CONTEXT +}; + +struct Error_info_s /* error state */ +{ + int fd; /* write(2) fd */ + + void (*exit)(int); /* error exit */ + ssize_t (*write)(int, const void*, size_t); /* error output */ + + /* the rest are implicitly initialized */ + + int clear; /* default clear ERROR_* flags */ + int core; /* level>=core -> core dump */ + int indent; /* debug trace indent level */ + int init; /* initialized */ + int last_errno; /* last reported errno */ + int mask; /* multi level debug trace mask */ + int set; /* default set ERROR_* flags */ + int trace; /* debug trace level */ + + char* version; /* ERROR_SOURCE command version */ + + int (*auxilliary)(Sfio_t*, int, int); /* aux info to append */ + + ERROR_CONTEXT /* top of context stack */ + + Error_context_t empty; /* empty context stack element */ + + unsigned long time; /* debug time trace */ + + char* (*translate)(const char*, const char*, const char*, const char*); /* format translator */ + + const char* catalog; /* message catalog */ +}; + +#ifndef errno +extern int errno; /* system call error status */ +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Error_info_t* _error_infop_; + +#define error_info (*_error_infop_) + +#undef extern + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern void error(int, ...); +extern int errormsg(const char*, int, ...); +extern int errorf(void*, void*, int, ...); +extern void errorv(const char*, int, va_list); +#ifndef errorx +extern char* errorx(const char*, const char*, const char*, const char*); +#endif +extern Error_info_t* errorctx(Error_info_t*, int, int); + +#undef extern + +#endif diff --git a/src/lib/libast/include/find.h b/src/lib/libast/include/find.h new file mode 100644 index 0000000..81049be --- /dev/null +++ b/src/lib/libast/include/find.h @@ -0,0 +1,86 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * fast find interface definitions + */ + +#ifndef _FIND_H +#define _FIND_H + +#define FIND_VERSION 19980301L + +#ifndef FIND_CODES +#define FIND_CODES "lib/find/codes" +#endif + +#define FIND_CODES_ENV "FINDCODES" + +#define FIND_GENERATE (1<<0) /* generate new codes */ +#define FIND_ICASE (1<<1) /* ignore case in match */ +#define FIND_GNU (1<<2) /* generate gnu format codes */ +#define FIND_OLD (1<<3) /* generate old format codes */ +#define FIND_TYPE (1<<4) /* generate type with codes */ +#define FIND_VERIFY (1<<5) /* verify the dir hierarchy */ + +#define FIND_USER (1L<<16) /* first user flag bit */ + +struct Find_s; +struct Finddisc_s; + +typedef int (*Findverify_f)(struct Find_s*, const char*, size_t, struct Finddisc_s*); + +typedef struct Finddisc_s +{ + unsigned long version; /* interface version */ + unsigned long flags; /* FIND_* flags */ + Error_f errorf; /* error function */ + Findverify_f verifyf; /* dir verify function */ + char** dirs; /* dir prefixes to search */ +} Finddisc_t; + +typedef struct Find_s +{ + const char* id; /* library id string */ + unsigned long stamp; /* codes time stamp */ + +#ifdef _FIND_PRIVATE_ + _FIND_PRIVATE_ +#endif + +} Find_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Find_t* findopen(const char*, const char*, const char*, Finddisc_t*); +extern char* findread(Find_t*); +extern int findwrite(Find_t*, const char*, size_t, const char*); +extern int findclose(Find_t*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/fnv.h b/src/lib/libast/include/fnv.h new file mode 100644 index 0000000..793dde0 --- /dev/null +++ b/src/lib/libast/include/fnv.h @@ -0,0 +1,72 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * Landon Kurt Knoll + * Phong Vo + * + * FNV-1 linear congruent checksum/hash/PRNG + * see http://www.isthe.com/chongo/tech/comp/fnv/ + */ + +#ifndef _FNV_H +#define _FNV_H + +#include <ast_common.h> + +#define FNV_INIT 0x811c9dc5L +#define FNV_MULT 0x01000193L + +#define FNVINIT(h) (h = FNV_INIT) +#define FNVPART(h,c) (h = (h) * FNV_MULT ^ (c)) +#define FNVSUM(h,s,n) do { \ + register size_t _i_ = 0; \ + while (_i_ < n) \ + FNVPART(h, ((unsigned char*)s)[_i_++]); \ + } while (0) + +#if _typ_int64_t + +#ifdef _ast_LL + +#define FNV_INIT64 0xcbf29ce484222325LL +#define FNV_MULT64 0x00000100000001b3LL + +#else + +#define FNV_INIT64 ((int64_t)0xcbf29ce484222325) +#define FNV_MULT64 ((int64_t)0x00000100000001b3) + +#endif + +#define FNVINIT64(h) (h = FNV_INIT64) +#define FNVPART64(h,c) (h = (h) * FNV_MULT64 ^ (c)) +#define FNVSUM64(h,s,n) do { \ + register int _i_ = 0; \ + while (_i_ < n) \ + FNVPART64(h, ((unsigned char*)s)[_i_++]); \ + } while (0) + +#endif + +#endif diff --git a/src/lib/libast/include/fs3d.h b/src/lib/libast/include/fs3d.h new file mode 100644 index 0000000..9d3c992 --- /dev/null +++ b/src/lib/libast/include/fs3d.h @@ -0,0 +1,117 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * 3d fs interface definitions + */ + +#ifndef _FS3D_H +#define _FS3D_H + +#include <ast_fs.h> + +#if _int_st_spare1 +#define iview(p) ((p)->st_spare1) +#define IVIEW(p,v) ((p)->st_spare1=(v)) +#else +#if _ary_st_spare4 +#define iview(p) ((p)->st_spare4[0]) +#define IVIEW(p,v) ((p)->st_spare4[0]=(v)) +#else +#if _ary_st_extra +#define iview(p) ((p)->st_extra[0]) +#define IVIEW(p,v) ((p)->st_extra[0]=(v)) +#else +#if _ary_st_pad4 +#define iview(p) ((p)->st_pad4[0]) +#define IVIEW(p,v) ((p)->st_pad4[0]=(v)) +#else +#if _mem_st_rdev_stat +#define iview(p) ((S_ISBLK((p)->st_mode)||S_ISCHR((p)->st_mode))?0:(p)->st_rdev) +#define IVIEW(p,v) do{if(!S_ISBLK((p)->st_mode)&&!S_ISCHR((p)->st_mode))(p)->st_rdev=(v);}while(0) +#else +#define iview(p) 0 +#define IVIEW(p,v) +#endif +#endif +#endif +#endif +#endif + +/* + * special options + */ + +#define FS3D_init "/#option/init" +#define FS3D_on "/#option/3d" +#define FS3D_off "/#option/2d" + +/* + * fs3d(3) ops + */ + +#define FS3D_OP(o,a) (((a)<<3)|(o)) + +#define FS3D_INIT FS3D_OP_INIT /* re-initialize tables */ +#define FS3D_OFF FS3D_OP_OFF +#define FS3D_ON FS3D_OP_ON +#define FS3D_TEST FS3D_OP_TEST +#define FS3D_LIMIT(n) FS3D_OP(FS3D_OP_LIMIT,n) + +#define FS3D_op(x) ((x)&07) +#define FS3D_arg(x) (((x)>>3)&07777) + +#define FS3D_OP_OFF 0 +#define FS3D_OP_ON 1 +#define FS3D_OP_TEST 2 +#define FS3D_OP_LIMIT 3 +#define FS3D_OP_INIT 7 + +/* + * mount(2) ops + */ + +#define FS3D_ALL (FS3D_VIEW|FS3D_VERSION) +#define FS3D_VIEW 002 +#define FS3D_VERSION 004 +#define FS3D_GET 010 +#define FS3D_SIZE(n) ((n)<<4) +#define FS3D_SIZEOF(n) ((n)>>4) + +#if !_BLD_3d +#define mount(s,t,f,d) fs3d_mount(s,t,f,d) +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int fs3d(int); +extern int fs3d_mount(const char*, char*, int, void*); +extern char* pathnext(char*, char*, long*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/fts.h b/src/lib/libast/include/fts.h new file mode 100644 index 0000000..3a22ad2 --- /dev/null +++ b/src/lib/libast/include/fts.h @@ -0,0 +1,162 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * David Korn + * Phong Vo + * AT&T Research + * + * fts interface definitions + */ + +#ifndef _FTS_H +#define _FTS_H + +#include <ast_std.h> +#include <ast_fs.h> +#include <ast_mode.h> + +/* + * fts_open flags + */ + +#define FTS_LOGICAL 0 /* logical traversal, follow symlinks */ +#define FTS_META (1<<0) /* follow top dir symlinks even if phys */ +#define FTS_NOCHDIR (1<<1) /* don't chdir */ +#define FTS_NOPOSTORDER (1<<2) /* no postorder visits */ +#define FTS_NOPREORDER (1<<3) /* no preorder visits */ +#define FTS_NOSEEDOTDIR (1<<11) /* never retain leading . dir */ +#define FTS_NOSTAT (1<<4) /* don't stat children */ +#define FTS_ONEPATH (1<<5) /* pathnames arg is one const char* */ +#define FTS_PHYSICAL (1<<6) /* physical traversal, don't follow */ +#define FTS_SEEDOT (1<<7) /* return . and .. */ +#define FTS_SEEDOTDIR (1<<10) /* always retain leading . dir */ +#define FTS_TOP (1<<8) /* don't traverse subdirectories */ +#define FTS_XDEV (1<<9) /* don't cross mount points */ + +#define FTS_USER (1<<12) /* first user flag bit */ + +#define FTS_COMFOLLOW FTS_META + +/* + * fts_info flags + */ + +#define FTS_DEFAULT 0 /* ok, someone must have wanted this */ + +#define FTS_NS (1<<0) /* stat failed */ +#define FTS_F (1<<1) /* file - not directory or symbolic link*/ +#define FTS_SL (1<<2) /* symbolic link */ +#define FTS_D (1<<3) /* directory - pre-order visit */ + +#define FTS_C (1<<4) /* causes cycle */ +#define FTS_ERR (1<<5) /* some other error */ +#define FTS_DD (1<<6) /* . or .. */ +#define FTS_NR (1<<7) /* cannot read */ +#define FTS_NX (1<<8) /* cannot search */ +#define FTS_OK (1<<9) /* no info but otherwise ok */ +#define FTS_P (1<<10) /* post-order visit */ + +#define FTS_DC (FTS_D|FTS_C) /* dir - would cause cycle */ +#define FTS_DNR (FTS_D|FTS_NR) /* dir - no read permission */ +#define FTS_DNX (FTS_D|FTS_NX) /* dir - no search permission */ +#define FTS_DOT (FTS_D|FTS_DD) /* . or .. */ +#define FTS_DP (FTS_D|FTS_P) /* dir - post-order visit */ +#define FTS_NSOK (FTS_NS|FTS_OK) /* no stat (because you asked) */ +#define FTS_SLNONE (FTS_SL|FTS_NS) /* symlink - to nowhere */ + +/* + * fts_set flags + */ + +#define FTS_AGAIN FTS_TOP /* process entry again */ +#define FTS_FOLLOW FTS_META /* follow FTS_SL symlink */ +#define FTS_SKIP FTS_NOSTAT /* skip FTS_D directory */ +#define FTS_STAT FTS_PHYSICAL /* stat() done by user */ + +typedef struct Fts FTS; +typedef struct Ftsent FTSENT; + +struct Ftsent +{ + char* fts_accpath; /* path relative to . */ + char* fts_name; /* file name */ + char* fts_path; /* path relative to top dir */ + FTSENT* fts_cycle; /* offender if cycle */ + FTSENT* fts_link; /* next child */ + FTSENT* fts_parent; /* parent directory */ + struct stat* fts_statp; /* stat info */ +#ifdef _FTSENT_LOCAL_PRIVATE_ + _FTSENT_LOCAL_PRIVATE_ +#else + void* fts_pointer; /* local pointer value */ +#endif + long fts_number; /* local numeric value */ + int fts_errno; /* errno for this entry */ + unsigned short fts_info; /* info flags */ + + unsigned short _fts_namelen; /* old fts_namelen */ + unsigned short _fts_pathlen; /* old fts_pathlen */ + short _fts_level; /* old fts_level */ + + short _fts_status; /* <ftwalk.h> compatibility */ + struct stat _fts_statb; /* <ftwalk.h> compatibility */ + + FTS* fts; /* fts_open() handle */ + size_t fts_namelen; /* strlen(fts_name) */ + size_t fts_pathlen; /* strlen(fts_path) */ + ssize_t fts_level; /* file tree depth, 0 at top */ + +#ifdef _FTSENT_PRIVATE_ + _FTSENT_PRIVATE_ +#endif + +}; + +struct Fts +{ + int fts_errno; /* last errno */ + void* fts_handle; /* user defined handle */ + +#ifdef _FTS_PRIVATE_ + _FTS_PRIVATE_ +#endif + +}; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern FTSENT* fts_children(FTS*, int); +extern int fts_close(FTS*); +extern int fts_flags(void); +extern int fts_local(FTSENT*); +extern int fts_notify(int(*)(FTS*, FTSENT*, void*), void*); +extern FTS* fts_open(char* const*, int, int(*)(FTSENT* const*, FTSENT* const*)); +extern FTSENT* fts_read(FTS*); +extern int fts_set(FTS*, FTSENT*, int); + +#undef extern + +#endif diff --git a/src/lib/libast/include/ftwalk.h b/src/lib/libast/include/ftwalk.h new file mode 100644 index 0000000..a4f3955 --- /dev/null +++ b/src/lib/libast/include/ftwalk.h @@ -0,0 +1,124 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Phong Vo + * Glenn Fowler + * AT&T Research + * + * ast ftwalk interface definitions + * ftwalk was the initial improvement on ftw and nftw + * which formed the basis for the POSIX fts proposal + * + * NOTE: this file is in cahoots with the fts implementation + */ + +#ifndef _FTWALK_H +#define _FTWALK_H + +#define fts_info info +#define fts_level level +#define fts_link link +#define fts_name name +#define fts_namelen namelen +#define fts_parent parent +#define fts_path path +#define fts_pathlen pathlen +#define _fts_status status +#define _fts_statb statb + +#define FTSENT Ftw_t /* <fts.h> internal */ +#define Ftsent FTW /* <fts.h> internal */ + +#define _FTSENT_LOCAL_PRIVATE_ /* <fts.h> internal */ \ + union \ + { \ + long number; /* local numeric value */ \ + void* pointer; /* local pointer value */ \ + } local; + +#include <fts.h> + +/* + * ftwalk() argument flags + */ + +#define FTW_CANON FTS_CANON +#define FTW_CHILDREN (FTS_USER<<0) +#define FTW_DELAY FTS_NOSTAT +#define FTW_DOT FTS_NOCHDIR +#define FTW_META FTS_META +#define FTW_MOUNT FTS_XDEV +#define FTW_MULTIPLE FTS_ONEPATH +#define FTW_NOSEEDOTDIR FTS_NOSEEDOTDIR +#define FTW_PHYSICAL FTS_PHYSICAL +#define FTW_POST (FTS_USER<<1) +#define FTW_SEEDOTDIR FTS_SEEDOTDIR +#define FTW_TOP FTS_TOP +#define FTW_TWICE (FTS_USER<<2) +#define FTW_USER (FTS_USER<<3) + +/* + * Ftw_t.info type bits + */ + +#define FTW_C FTS_C +#define FTW_D FTS_D +#define FTW_DC FTS_DC +#define FTW_DNR FTS_DNR +#define FTW_DNX FTS_DNX +#define FTW_DP FTS_DP +#define FTW_F FTS_F +#define FTW_NR FTS_NR +#define FTW_NS FTS_NS +#define FTW_NSOK FTS_NSOK +#define FTW_NX FTS_NX +#define FTW_P FTS_P +#define FTW_SL FTS_SL + +/* + * Ftw_t.status entry values + */ + +#define FTW_NAME FTS_DOT /* access by Ftw_t.name */ +#define FTW_PATH FTS_NOCHDIR /* access by Ftw_t.path */ + +/* + * Ftw_t.status return values + */ + +#define FTW_AGAIN FTS_AGAIN +#define FTW_FOLLOW FTS_FOLLOW +#define FTW_NOPOST FTS_NOPOSTORDER +#define FTW_SKIP FTS_SKIP +#define FTW_STAT FTS_STAT + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int ftwalk(const char*, int(*)(Ftw_t*), int, int(*)(Ftw_t*, Ftw_t*)); +extern int ftwflags(void); + +#undef extern + +#endif diff --git a/src/lib/libast/include/glob.h b/src/lib/libast/include/glob.h new file mode 100644 index 0000000..a118db9 --- /dev/null +++ b/src/lib/libast/include/glob.h @@ -0,0 +1,146 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * posix glob interface definitions with gnu extensions + */ + +#ifndef _GLOB_H +#define _GLOB_H + +#define GLOB_VERSION 20060717L + +#include <stdlib.h> + +struct dirent; +struct stat; + +struct _glob_; +struct _globlist_; + +typedef struct _glob_ glob_t; +typedef struct _globlist_ globlist_t; + +struct _globlist_ +{ + globlist_t* gl_next; + char* gl_begin; + unsigned char gl_flags; + char gl_path[1]; +}; + +struct _glob_ +{ + size_t gl_pathc; + char** gl_pathv; + size_t gl_offs; + globlist_t* gl_list; + int gl_flags; + + /* GLOB_DISC data -- memset(&gl,0,sizeof(gl)) before using! */ + + const char* gl_fignore; + const char* gl_suffix; + unsigned char* gl_intr; + + int gl_delim; + + void* gl_handle; + void* (*gl_diropen)(glob_t*, const char*); + char* (*gl_dirnext)(glob_t*, void*); + void (*gl_dirclose)(glob_t*, void*); + int (*gl_type)(glob_t*, const char*, int); + int (*gl_attr)(glob_t*, const char*, int); + + /* gnu extensions -- but how do you synthesize dirent and stat? */ + + void* (*gl_opendir)(const char*); + struct dirent* (*gl_readdir)(void*); + void (*gl_closedir)(void*); + int (*gl_stat)(const char*, struct stat*); + int (*gl_lstat)(const char*, struct stat*); + + /* ast additions */ + + char* (*gl_nextdir)(glob_t*, char*); + unsigned long gl_status; + unsigned long gl_version; + unsigned short gl_extra; + +#ifdef _GLOB_PRIVATE_ + _GLOB_PRIVATE_ +#else + char* gl_pad[23]; +#endif + +}; + +/* standard interface */ +#define GLOB_APPEND 0x0001 /* append to previous */ +#define GLOB_DOOFFS 0x0002 /* gl_offs defines argv offset */ +#define GLOB_ERR 0x0004 /* abort on error */ +#define GLOB_MARK 0x0008 /* append / to directories */ +#define GLOB_NOCHECK 0x0010 /* nomatch is original pattern */ +#define GLOB_NOESCAPE 0x0020 /* don't treat \ specially */ +#define GLOB_NOSORT 0x0040 /* don't sort the list */ + +/* extended interface */ +#define GLOB_STARSTAR 0x0080 /* enable [/]**[/] expansion */ +#define GLOB_BRACE 0x0100 /* enable {...} expansion */ +#define GLOB_ICASE 0x0200 /* ignore case on match */ +#define GLOB_COMPLETE 0x0400 /* shell file completeion */ +#define GLOB_AUGMENTED 0x0800 /* augmented shell patterns */ +#define GLOB_STACK 0x1000 /* allocate on current stack */ +#define GLOB_LIST 0x2000 /* just create gl_list */ +#define GLOB_ALTDIRFUNC 0x4000 /* gnu discipline functions */ +#define GLOB_DISC 0x8000 /* discipline initialized */ + +#define GLOB_GROUP 0x10000 /* REG_SHELL_GROUP */ + +/* gl_status */ +#define GLOB_NOTDIR 0x0001 /* last gl_dirnext() not a dir */ + +/* gl_type return */ +#define GLOB_NOTFOUND 0 /* does not exist */ +#define GLOB_DEV 1 /* exists but not DIR EXE REG */ +#define GLOB_DIR 2 /* directory */ +#define GLOB_EXE 3 /* executable regular file */ +#define GLOB_REG 4 /* regular file */ + +/* error return values */ +#define GLOB_ABORTED 1 +#define GLOB_NOMATCH 2 +#define GLOB_NOSPACE 3 +#define GLOB_INTR 4 +#define GLOB_APPERR 5 +#define GLOB_NOSYS 6 + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int glob(const char*, int, int(*)(const char*,int), glob_t*); +extern void globfree(glob_t*); + +#undef extern + +#endif /* _GLOB_H */ diff --git a/src/lib/libast/include/hash.h b/src/lib/libast/include/hash.h new file mode 100644 index 0000000..b91e550 --- /dev/null +++ b/src/lib/libast/include/hash.h @@ -0,0 +1,202 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * hash table library interface definitions + * + * NOTE: new code should use the more general <cdt.h> + */ + +#ifndef _HASH_H +#define _HASH_H + +#define HASH_ALLOCATE (1L<<0) /* allocate new key names */ +#define HASH_FIXED (1L<<1) /* fixed table size */ +#define HASH_HASHED (1L<<6) /* key names already hashed */ +#define HASH_RESIZE (1L<<2) /* table has been resized */ +#define HASH_SCANNING (1L<<3) /* currently scanning scope */ +#define HASH_SCOPE (1L<<4) /* push scope / create in bot */ +#define HASH_STATIC (1L<<5) /* static table allocation */ + +#define HASH_CREATE (1L<<8) /* create bucket if not found */ +#define HASH_DELETE (1L<<9) /* delete bucket if found */ +#define HASH_LOOKUP 0 /* default op */ +#define HASH_RENAME (1L<<7) /* rename bucket if found */ + +#define HASH_BUCKET (1L<<11) /* name is installed bucket */ +#define HASH_INSTALL (1L<<12) /* install allocated bucket */ +#define HASH_NOSCOPE (1L<<13) /* top scope only */ +#define HASH_OPAQUE (1L<<14) /* opaque bucket */ +#define HASH_VALUE (1L<<15) /* value bucket field used */ + +#define HASH_SIZE(n) (((long)(n))<<16) /* fixed bucket size */ +#define HASH_SIZEOF(f) ((((long)(f))>>16)&0xffff) /* extract size */ + +#define HASH_DELETED ((unsigned long)1<<(8*sizeof(int)-1)) /* deleted placeholder */ +#define HASH_KEEP (1L<<(8*sizeof(int)-2)) /* no free on bucket */ +#define HASH_HIDDEN (1L<<(8*sizeof(int)-3)) /* hidden by scope */ +#define HASH_HIDES (1L<<(8*sizeof(int)-4)) /* hides lower scope */ +#define HASH_OPAQUED (1L<<(8*sizeof(int)-5)) /* opaqued placeholder */ +#define HASH_FREENAME (1L<<(8*sizeof(int)-6)) /* free bucket name */ + +#define HASH_RESET (HASH_RESIZE|HASH_SCOPE|HASH_STATIC|HASH_VALUE) +#define HASH_INTERNAL (HASH_BUCKET|HASH_RESIZE|HASH_SCANNING|HASH_STATIC) +#define HASH_FLAGS (HASH_DELETED|HASH_FREENAME|HASH_HIDDEN|HASH_HIDES|HASH_KEEP|HASH_OPAQUED) + +#define HASH_alloc 1 +#define HASH_clear 2 +#define HASH_compare 3 +#define HASH_free 4 +#define HASH_hash 5 +#define HASH_meanchain 6 +#define HASH_name 7 +#define HASH_namesize 8 +#define HASH_set 9 +#define HASH_size 10 +#define HASH_table 11 +#define HASH_va_list 12 + +#define HASH_bucketsize 13 + +#define HASH_region 14 + +#include <hashpart.h> + +#define hashclear(t,f) ((t)->flags &= ~((f) & ~HASH_INTERNAL)) +#define hashcover(b) (((b)->hash&HASH_HIDES)?(Hash_bucket_t*)((b)->name):(Hash_bucket_t*)0) +#define hashdel(t,n) hashlook(t, (char*)(n), HASH_DELETE, (char*)0) +#define hashget(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_VALUE, (char*)0) +#define hashgetbucket(s) ((Hash_bucket_t*)((s)-((sizeof(Hash_bucket_t)+sizeof(char*)-1)/sizeof(char*))*sizeof(char*))) +#define hashkeep(b) ((b)->hash|=HASH_KEEP) +#define hashname(b) ((((b)->hash&HASH_HIDES)?((Hash_bucket_t*)((b)->name)):(b))->name) +#define hashput(t,n,v) hashlook(t, (char*)(n), HASH_CREATE|HASH_VALUE, (char*)(v)) +#define hashref(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_INTERNAL|HASH_VALUE, (char*)0) +#define hashscope(t) ((t)->scope) +#define hashset(t,f) ((t)->flags |= ((f) & ~HASH_INTERNAL)) + +/* + * DEPRECATED renames for compatibility + */ + +#define Hashbin_t Hash_bucket_t +#define HASHBUCKET Hash_bucket_t +#define Hashhdr_t Hash_header_t +#define HASHHEADER Hash_header_t +#define Hashpos_t Hash_position_t +#define HASHPOSITION Hash_position_t +#define Hashtab_t Hash_table_t +#define HASHTABLE Hash_table_t + +#define vhashalloc hashvalloc +#define hashvalloc(t,a) hashalloc(t,HASH_va_list,a,0) + +/* + * the #define's avoid union tags + */ + +typedef struct Hash_bucket Hash_bucket_t; +typedef struct Hash_root Hash_root_t; +typedef struct Hash_table Hash_table_t; + +#define HASH_HEADER /* common bucket header */ \ + Hash_bucket_t* next; /* next in collision chain */ \ + unsigned int hash; /* hash flags and value */ \ + char* name /* key name */ + +#define HASH_DEFAULT /* HASH_VALUE bucket elements */ \ + char* value /* key value */ + +typedef struct /* bucket header */ +{ + HASH_HEADER; +} Hash_header_t; + +struct Hash_bucket /* prototype bucket */ +{ + HASH_HEADER; + HASH_DEFAULT; +}; + +typedef struct /* hash scan bucket position */ +{ + Hash_bucket_t* bucket; /* bucket */ +#ifdef _HASH_POSITION_PRIVATE_ + _HASH_POSITION_PRIVATE_ +#endif +} Hash_position_t; + +typedef struct /* last lookup cache */ +{ + Hash_table_t* table; /* last lookup table */ + Hash_bucket_t* bucket; /* last lookup bucket */ +#ifdef _HASH_LAST_PRIVATE_ + _HASH_LAST_PRIVATE_ +#endif +} Hash_last_t; + +struct Hash_root /* root hash table information */ +{ + int accesses; /* number of accesses */ + int collisions; /* number of collisions */ + int flags; /* flags: see HASH_[A-Z]* */ + Hash_last_t last; /* last lookup cache */ + void* context; /* user defined context */ +#ifdef _HASH_ROOT_PRIVATE_ + _HASH_ROOT_PRIVATE_ +#endif +}; + +struct Hash_table /* hash table information */ +{ + Hash_root_t* root; /* root hash table information */ + int size; /* table size */ + int buckets; /* active bucket count */ + char* name; /* table name */ + Hash_table_t* scope; /* scope covered table */ + short flags; /* flags: see HASH_[A-Z]* */ +#ifdef _HASH_TABLE_PRIVATE_ + _HASH_TABLE_PRIVATE_ +#endif +}; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Hash_table_t* hashalloc(Hash_table_t*, ...); +extern void hashdone(Hash_position_t*); +extern void hashdump(Hash_table_t*, int); +extern Hash_table_t* hashfree(Hash_table_t*); +extern Hash_bucket_t* hashlast(Hash_table_t*); +extern char* hashlook(Hash_table_t*, const char*, long, const char*); +extern Hash_bucket_t* hashnext(Hash_position_t*); +extern Hash_position_t* hashscan(Hash_table_t*, int); +extern void hashsize(Hash_table_t*, int); +extern Hash_table_t* hashview(Hash_table_t*, Hash_table_t*); +extern int hashwalk(Hash_table_t*, int, int (*)(const char*, char*, void*), void*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/hashkey.h b/src/lib/libast/include/hashkey.h new file mode 100644 index 0000000..338f017 --- /dev/null +++ b/src/lib/libast/include/hashkey.h @@ -0,0 +1,62 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * 1-6 char lower-case keyword -> long hash + * digit args passed as HASHKEYN('2') + */ + +#ifndef _HASHKEY_H +#define _HASHKEY_H + +#define HASHKEYMAX 6 +#define HASHKEYBIT 5 +#define HASHKEYOFF ('a'-1) +#define HASHKEYPART(h,c) (((h)<<HASHKEYBIT)+HASHKEY1(c)) + +#define HASHKEYN(n) ((n)-'0'+'z'+1) + +#define HASHKEY1(c1) ((c1)-HASHKEYOFF) +#define HASHKEY2(c1,c2) HASHKEYPART(HASHKEY1(c1),c2) +#define HASHKEY3(c1,c2,c3) HASHKEYPART(HASHKEY2(c1,c2),c3) +#define HASHKEY4(c1,c2,c3,c4) HASHKEYPART(HASHKEY3(c1,c2,c3),c4) +#define HASHKEY5(c1,c2,c3,c4,c5) HASHKEYPART(HASHKEY4(c1,c2,c3,c4),c5) +#define HASHKEY6(c1,c2,c3,c4,c5,c6) HASHKEYPART(HASHKEY5(c1,c2,c3,c4,c5),c6) + +#define HASHNKEY1(n,c1) HASHKEY2((n)+HASHKEYOFF,c1) +#define HASHNKEY2(n,c2,c1) HASHKEY3((n)+HASHKEYOFF,c2,c1) +#define HASHNKEY3(n,c3,c2,c1) HASHKEY4((n)+HASHKEYOFF,c3,c2,c1) +#define HASHNKEY4(n,c4,c3,c2,c1) HASHKEY5((n)+'a',c4,c3,c2,c1) +#define HASHNKEY5(n,c5,c4,c3,c2,c1) HASHKEY6((n)+'a',c5,c4,c3,c2,c1) + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern long strkey(const char*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/hashpart.h b/src/lib/libast/include/hashpart.h new file mode 100644 index 0000000..ae38262 --- /dev/null +++ b/src/lib/libast/include/hashpart.h @@ -0,0 +1,51 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * K. P. Vo + * G. S. Fowler + * AT&T Research + * + * ``the best'' combined linear congruent checksum/hash/PRNG + */ + +#ifndef _HASHPART_H +#define _HASHPART_H + +#define HASH_ADD(h) (0x9c39c33dL) + +#if __sparc__ || __sparc || sparc + +#define HASH_A(h,n) ((((h) << 2) - (h)) << (n)) +#define HASH_B(h,n) ((((h) << 4) - (h)) << (n)) +#define HASH_C(h,n) ((HASH_A(h,7) + HASH_B(h,0)) << (n)) +#define HASH_MPY(h) (HASH_C(h,22)+HASH_C(h,10)+HASH_A(h,6)+HASH_A(h,3)+(h)) + +#else + +#define HASH_MPY(h) ((h)*0x63c63cd9L) + +#endif + +#define HASHPART(h,c) (h = HASH_MPY(h) + HASH_ADD(h) + (c)) + +#endif diff --git a/src/lib/libast/include/ip6.h b/src/lib/libast/include/ip6.h new file mode 100644 index 0000000..382ead8 --- /dev/null +++ b/src/lib/libast/include/ip6.h @@ -0,0 +1,40 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +#ifndef _IP6_H +#define _IP6_H 1 + +#define IP6ADDR 16 +#define IP6BITS IP6ADDR +#define IP6PREFIX (IP6ADDR+1) + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern char* fmtip6(const unsigned char*, int); +extern int strtoip6(const char*, char**, unsigned char*, unsigned char*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/ls.h b/src/lib/libast/include/ls.h new file mode 100644 index 0000000..fc1d623 --- /dev/null +++ b/src/lib/libast/include/ls.h @@ -0,0 +1,88 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * ls formatter interface definitions + */ + +#ifndef _LS_H +#define _LS_H + +#include <ast_std.h> +#include <ast_fs.h> +#include <ast_mode.h> + +/* + * some systems (could it beee AIX) pollute the std name space + */ + +#undef fileid +#define fileid fileID + +#define LS_BLOCKSIZE 512 + +#define iblocks(p) _iblocks(p) + +#if _mem_st_rdev_stat +#define idevice(p) ((p)->st_rdev) +#define IDEVICE(p,v) ((p)->st_rdev=(v)) +#else +#define idevice(p) 0 +#define IDEVICE(p,v) +#endif + +#define LS_ATIME (1<<0) /* list st_atime */ +#define LS_BLOCKS (1<<1) /* list blocks used by file */ +#define LS_CTIME (1<<2) /* list st_ctime */ +#define LS_EXTERNAL (1<<3) /* st_mode is modex canonical */ +#define LS_INUMBER (1<<4) /* list st_ino */ +#define LS_LONG (1<<5) /* long listing */ +#define LS_MARK (1<<6) /* append file name marks */ +#define LS_NOGROUP (1<<7) /* omit group name for LS_LONG */ +#define LS_NOUSER (1<<8) /* omit user name for LS_LONG */ +#define LS_NUMBER (1<<9) /* number instead of name */ + +#define LS_USER (1<<10) /* first user flag bit */ + +#define LS_W_BLOCKS 6 /* LS_BLOCKS field width */ +#define LS_W_INUMBER 9 /* LS_INUMBER field width */ +#define LS_W_LONG 57 /* LS_LONG width (w/o names) */ +#define LS_W_LINK 4 /* link text width (w/o names) */ +#define LS_W_MARK 1 /* LS_MARK field width */ +#define LS_W_NAME 9 /* group|user name field width */ + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern off_t _iblocks(struct stat*); +extern char* fmtdev(struct stat*); +extern char* fmtfs(struct stat*); +extern char* fmtls(char*, const char*, struct stat*, const char*, const char*, int); +extern int pathstat(const char*, struct stat*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/magic.h b/src/lib/libast/include/magic.h new file mode 100644 index 0000000..9b2f96b --- /dev/null +++ b/src/lib/libast/include/magic.h @@ -0,0 +1,86 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * magic interface definitions + */ + +#ifndef _MAGIC_H +#define _MAGIC_H + +#include <sfio.h> +#include <ls.h> + +#define MAGIC_VERSION 19961031L + +#ifndef MAGIC_FILE +#define MAGIC_FILE "lib/file/magic" +#endif + +#ifndef MAGIC_DIR +#define MAGIC_DIR "lib/file" +#endif + +#define MAGIC_FILE_ENV "MAGICFILE" + +#define MAGIC_MIME (1<<0) /* magictype returns MIME type */ +#define MAGIC_VERBOSE (1<<1) /* verbose magic file errors */ +#define MAGIC_ALL (1<<2) /* list all table matches */ + +#define MAGIC_USER (1L<<16) /* first user flag bit */ + +struct Magic_s; +struct Magicdisc_s; + +typedef struct Magicdisc_s +{ + unsigned long version; /* interface version */ + unsigned long flags; /* MAGIC_* flags */ + Error_f errorf; /* error function */ +} Magicdisc_t; + +typedef struct Magic_s +{ + const char* id; /* library id string */ + +#ifdef _MAGIC_PRIVATE_ + _MAGIC_PRIVATE_ +#endif + +} Magic_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Magic_t* magicopen(Magicdisc_t*); +extern int magicload(Magic_t*, const char*, unsigned long); +extern int magiclist(Magic_t*, Sfio_t*); +extern char* magictype(Magic_t*, Sfio_t*, const char*, struct stat*); +extern int magicclose(Magic_t*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/magicid.h b/src/lib/libast/include/magicid.h new file mode 100644 index 0000000..73197d7 --- /dev/null +++ b/src/lib/libast/include/magicid.h @@ -0,0 +1,46 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +/* + * generic binary magic id definitions + */ + +#ifndef _MAGICID_H +#define _MAGICID_H 1 + +#include <ast_common.h> + +#define MAGICID 0x00010203 + +typedef uint32_t Magicid_data_t; + +typedef struct Magicid_s +{ + Magicid_data_t magic; /* magic number */ + char name[8]; /* generic data/application name*/ + char type[12]; /* specific data type */ + Magicid_data_t version; /* YYYYMMDD or 0xWWXXYYZZ */ + Magicid_data_t size; +} Magicid_t; + +#endif diff --git a/src/lib/libast/include/mc.h b/src/lib/libast/include/mc.h new file mode 100644 index 0000000..a23c7bb --- /dev/null +++ b/src/lib/libast/include/mc.h @@ -0,0 +1,96 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +/* + * machine independent binary message catalog interface + * + * file layout + * all numbers are sfputu() format + * + * 4 char magic (^M^S^G0) + * <method locale YYYY-MM-DD>\0 + * (<optional strings>\0)* + * \0 + * string table size + * #msgs total + * #max set number + * #set-id 1 + * #msgs in set 1 + * ... + * #set-id #sets + * #msgs in set #sets + * end of sets (0) + * msg(1,1) size + * ... + * msg(#sets,#msgs) size + * string table + */ + +#ifndef _MC_H +#define _MC_H + +#include <ast.h> + +#define MC_MAGIC "\015\023\007\000" +#define MC_MAGIC_SIZE 4 + +#define MC_SET_MAX 1023 +#define MC_NUM_MAX 32767 + +#define MC_NLS (1<<10) + +#define MC_MESSAGE_SET(s) mcindex(s,NiL,NiL,NiL) + +typedef struct Mcset_s +{ + char** msg; + int num; + int gen; +} Mcset_t; + +typedef struct Mc_s +{ + Mcset_t* set; + int num; + int gen; + char* translation; +#ifdef _MC_PRIVATE_ + _MC_PRIVATE_ +#endif +} Mc_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern char* mcfind(const char*, const char*, int, int, char*, size_t); +extern Mc_t* mcopen(Sfio_t*); +extern char* mcget(Mc_t*, int, int, const char*); +extern int mcput(Mc_t*, int, int, const char*); +extern int mcdump(Mc_t*, Sfio_t*); +extern int mcindex(const char*, char**, int*, int*); +extern int mcclose(Mc_t*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/mime.h b/src/lib/libast/include/mime.h new file mode 100644 index 0000000..6fa7657 --- /dev/null +++ b/src/lib/libast/include/mime.h @@ -0,0 +1,91 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +/* + * mime/mailcap interface + */ + +#ifndef _MIMETYPE_H +#define _MIMETYPE_H 1 + +#include <sfio.h> +#include <ls.h> + +#define MIME_VERSION 19970717L + +#ifndef MIME_FILES +#define MIME_FILES "~/.mailcap:/usr/local/etc/mailcap:/usr/etc/mailcap:/etc/mailcap:/etc/mail/mailcap:/usr/public/lib/mailcap" +#endif + +#define MIME_FILES_ENV "MAILCAP" + +#define MIME_LIST (1<<0) /* mimeload arg is : list */ +#define MIME_NOMAGIC (1<<1) /* no magic for mimetype() */ +#define MIME_PIPE (1<<2) /* mimeview() io is piped */ +#define MIME_REPLACE (1<<3) /* replace existing definition */ + +#define MIME_USER (1L<<16) /* first user flag bit */ + +struct Mime_s; +typedef struct Mime_s Mime_t; + +struct Mimedisc_s; +typedef struct Mimedisc_s Mimedisc_t; + +typedef int (*Mimevalue_f)(Mime_t*, void*, char*, size_t, Mimedisc_t*); + +struct Mimedisc_s +{ + unsigned long version; /* interface version */ + unsigned long flags; /* MIME_* flags */ + Error_f errorf; /* error function */ + Mimevalue_f valuef; /* value extraction function */ +}; + +struct Mime_s +{ + const char* id; /* library id string */ + +#ifdef _MIME_PRIVATE_ + _MIME_PRIVATE_ +#endif + +}; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Mime_t* mimeopen(Mimedisc_t*); +extern int mimeload(Mime_t*, const char*, unsigned long); +extern int mimelist(Mime_t*, Sfio_t*, const char*); +extern int mimeclose(Mime_t*); +extern int mimeset(Mime_t*, char*, unsigned long); +extern char* mimetype(Mime_t*, Sfio_t*, const char*, struct stat*); +extern char* mimeview(Mime_t*, const char*, const char*, const char*, const char*); +extern int mimehead(Mime_t*, void*, size_t, size_t, char*); +extern int mimecmp(const char*, const char*, char**); + +#undef extern + +#endif diff --git a/src/lib/libast/include/mnt.h b/src/lib/libast/include/mnt.h new file mode 100644 index 0000000..698c730 --- /dev/null +++ b/src/lib/libast/include/mnt.h @@ -0,0 +1,58 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * mounted filesystem scan interface + */ + +#ifndef _MNT_H +#define _MNT_H 1 + +#undef MNT_REMOTE /* aix clash */ +#define MNT_REMOTE (1<<0) /* remote mount */ + +typedef struct +{ + char* fs; /* filesystem name */ + char* dir; /* mounted dir */ + char* type; /* filesystem type */ + char* options; /* options */ + int freq; /* backup frequency */ + int npass; /* number of parallel passes */ + int flags; /* MNT_* flags */ +} Mnt_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern void* mntopen(const char*, const char*); +extern Mnt_t* mntread(void*); +extern int mntwrite(void*, const Mnt_t*); +extern int mntclose(void*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/modecanon.h b/src/lib/libast/include/modecanon.h new file mode 100644 index 0000000..5d1721f --- /dev/null +++ b/src/lib/libast/include/modecanon.h @@ -0,0 +1,65 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * canonical mode_t representation + */ + +#ifndef _MODECANON_H +#define _MODECANON_H + +#define X_ITYPE(m) ((m)&X_IFMT) + +#define X_IFMT 0170000 +#define X_IFWHT 0160000 +#define X_IFDOOR 0150000 +#define X_IFSOCK 0140000 +#define X_IFLNK 0120000 +#define X_IFCTG 0110000 +#define X_IFREG 0100000 +#define X_IFBLK 0060000 +#define X_IFDIR 0040000 +#define X_IFCHR 0020000 +#define X_IFIFO 0010000 + +#define X_IPERM 0007777 +#define X_ISUID 0004000 +#define X_ISGID 0002000 +#define X_ISVTX 0001000 +#define X_IRUSR 0000400 +#define X_IWUSR 0000200 +#define X_IXUSR 0000100 +#define X_IRGRP 0000040 +#define X_IWGRP 0000020 +#define X_IXGRP 0000010 +#define X_IROTH 0000004 +#define X_IWOTH 0000002 +#define X_IXOTH 0000001 + +#define X_IRWXU (X_IRUSR|X_IWUSR|X_IXUSR) +#define X_IRWXG (X_IRGRP|X_IWGRP|X_IXGRP) +#define X_IRWXO (X_IROTH|X_IWOTH|X_IXOTH) + +#endif diff --git a/src/lib/libast/include/modex.h b/src/lib/libast/include/modex.h new file mode 100644 index 0000000..e8b52f7 --- /dev/null +++ b/src/lib/libast/include/modex.h @@ -0,0 +1,51 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * AT&T Research + * + * external mode_t representation support + */ + +#ifndef _MODEX_H +#define _MODEX_H + +#include <ast_fs.h> +#include <modecanon.h> + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int modei(int); +extern int modex(int); + +#undef extern + +#if _S_IDPERM +#define modei(m) ((m)&X_IPERM) +#if _S_IDTYPE +#define modex(m) (m) +#endif +#endif + +#endif diff --git a/src/lib/libast/include/namval.h b/src/lib/libast/include/namval.h new file mode 100644 index 0000000..9c055cc --- /dev/null +++ b/src/lib/libast/include/namval.h @@ -0,0 +1,42 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * common name-value struct support + */ + +#ifndef _NAMVAL_H +#define _NAMVAL_H + +typedef struct +{ + char* name; + int value; +#ifdef _NAMVAL_PRIVATE_ + _NAMVAL_PRIVATE_ +#endif +} Namval_t; + +#endif diff --git a/src/lib/libast/include/option.h b/src/lib/libast/include/option.h new file mode 100644 index 0000000..1d24690 --- /dev/null +++ b/src/lib/libast/include/option.h @@ -0,0 +1,106 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * command line option parse interface + */ + +#ifndef _OPTION_H +#define _OPTION_H + +#include <ast.h> + +#define OPT_VERSION 20070319L + +#define OPT_USER (1L<<16) /* first user flag bit */ + +struct Opt_s; +struct Optdisc_s; + +typedef int (*Optinfo_f)(struct Opt_s*, Sfio_t*, const char*, struct Optdisc_s*); + +typedef struct Optdisc_s +{ + unsigned long version; /* OPT_VERSION */ + unsigned long flags; /* OPT_* flags */ + char* catalog; /* error catalog id */ + Optinfo_f infof; /* runtime info function */ +} Optdisc_t; + +/* NOTE: Opt_t member order fixed by a previous binary release */ + +#ifndef _OPT_PRIVATE_ +#define _OPT_PRIVATE_ \ + char pad[3*sizeof(void*)]; +#endif + +typedef struct Opt_s +{ + int again; /* see optjoin() */ + char* arg; /* {:,#} string argument */ + char** argv; /* most recent argv */ + int index; /* argv index */ + char* msg; /* error/usage message buffer */ + long num; /* OBSOLETE -- use number */ + int offset; /* char offset in argv[index] */ + char option[8]; /* current flag {-,+} + option */ + char name[64]; /* current long name or flag */ + Optdisc_t* disc; /* user discipline */ + intmax_t number; /* # numeric argument */ + unsigned char assignment; /* option arg assigment op */ + unsigned char pads[sizeof(void*)-1]; + _OPT_PRIVATE_ +} Opt_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Opt_t* _opt_infop_; + +#define opt_info (*_opt_infop_) + +#undef extern + +#define optinit(d,f) (memset(d,0,sizeof(*(d))),(d)->version=OPT_VERSION,(d)->infof=(f),opt_info.disc=(d)) + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int optget(char**, const char*); +extern int optjoin(char**, ...); +extern char* opthelp(const char*, const char*); +extern char* optusage(const char*); +extern int optstr(const char*, const char*); +extern int optesc(Sfio_t*, const char*, int); +extern Opt_t* optctx(Opt_t*, Opt_t*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/proc.h b/src/lib/libast/include/proc.h new file mode 100644 index 0000000..76fdf83 --- /dev/null +++ b/src/lib/libast/include/proc.h @@ -0,0 +1,108 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +/* + * process library interface + */ + +#ifndef _PROC_H +#define _PROC_H + +#include <ast.h> + +#define PROC_ARGMOD (1<<0) /* argv[-1],argv[0] can be modified */ +#define PROC_BACKGROUND (1<<1) /* shell background (&) setup */ +#define PROC_CHECK (1<<17) /* check that command exists */ +#define PROC_CLEANUP (1<<2) /* close parent redirect fds on error */ +#define PROC_DAEMON (1<<3) /* daemon setup */ +#define PROC_ENVCLEAR (1<<4) /* clear environment */ +#define PROC_FOREGROUND (1<<14) /* system(3) setup */ +#define PROC_GID (1<<5) /* setgid(getgid()) */ +#define PROC_IGNORE (1<<6) /* ignore parent pipe errors */ +#define PROC_IGNOREPATH (1<<16) /* procrun() intercept to ignore path */ +#define PROC_ORPHAN (1<<18) /* create orphaned process */ +#define PROC_OVERLAY (1<<7) /* overlay current process if possible */ +#define PROC_PARANOID (1<<8) /* restrict everything */ +#define PROC_PRIVELEGED (1<<9) /* setuid(0), setgid(getegid()) */ +#define PROC_READ (1<<10) /* proc pipe fd 1 returned */ +#define PROC_SESSION (1<<11) /* session leader */ +#define PROC_UID (1<<12) /* setuid(getuid()) */ +#define PROC_WRITE (1<<13) /* proc pipe fd 0 returned */ +#define PROC_ZOMBIE (1<<15) /* proc may leave a zombie behind */ + +#define PROC_ARG_BIT 14 /* bits per op arg */ +#define PROC_OP_BIT 4 /* bits per op */ + +#define PROC_ARG_NULL ((1<<PROC_ARG_BIT)-1) + +#define PROC_fd_dup 0x4 +#define PROC_FD_CHILD 0x1 +#define PROC_FD_PARENT 0x2 + +#define PROC_sig_dfl 0x8 +#define PROC_sig_ign 0x9 + +#define PROC_sys_pgrp 0xa +#define PROC_sys_umask 0xb + +#define PROC_fd_ctty 0xc + +#define PROC_op1(o,a) (((o)<<(2*PROC_ARG_BIT))|((a)&((PROC_ARG_NULL<<PROC_ARG_BIT)|PROC_ARG_NULL))) +#define PROC_op2(o,a,b) (((o)<<(2*PROC_ARG_BIT))|(((b)&PROC_ARG_NULL)<<PROC_ARG_BIT)|((a)&PROC_ARG_NULL)) + +#define PROC_FD_CLOSE(p,f) PROC_op2(PROC_fd_dup|(f),p,PROC_ARG_NULL) +#define PROC_FD_CTTY(f) PROC_op1(PROC_fd_ctty,f) +#define PROC_FD_DUP(p,c,f) PROC_op2(PROC_fd_dup|(f),p,c) +#define PROC_SIG_DFL(s) PROC_op1(PROC_sig_dfl,s,0) +#define PROC_SIG_IGN(s) PROC_op1(PROC_sig_ign,s,0) +#define PROC_SYS_PGRP(g) PROC_op1(PROC_sys_pgrp,g) +#define PROC_SYS_UMASK(m) PROC_op1(PROC_sys_umask,m,0) + +#define PROC_OP(x) (((x)>>(2*PROC_ARG_BIT))&((1<<PROC_OP_BIT)-1)) +#define PROC_ARG(x,n) ((n)?(((x)>>(((n)-1)*PROC_ARG_BIT))&PROC_ARG_NULL):(((x)&~((1<<(2*PROC_ARG_BIT))-1))==~((1<<(2*PROC_ARG_BIT))-1))?(-1):((x)&~((1<<(2*PROC_ARG_BIT))-1))) + +typedef struct +{ + pid_t pid; /* process id */ + pid_t pgrp; /* process group id */ + int rfd; /* read fd if applicable */ + int wfd; /* write fd if applicable */ + +#ifdef _PROC_PRIVATE_ +_PROC_PRIVATE_ +#endif + +} Proc_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int procclose(Proc_t*); +extern int procfree(Proc_t*); +extern Proc_t* procopen(const char*, char**, char**, long*, int); +extern int procrun(const char*, char**, int); + +#undef extern + +#endif diff --git a/src/lib/libast/include/recfmt.h b/src/lib/libast/include/recfmt.h new file mode 100644 index 0000000..aaae3c0 --- /dev/null +++ b/src/lib/libast/include/recfmt.h @@ -0,0 +1,83 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * record format interface + */ + +#ifndef _RECFMT_H +#define _RECFMT_H 1 + +#include <ast.h> + +typedef uint32_t Recfmt_t; + +#define REC_delimited 0 +#define REC_fixed 1 +#define REC_variable 2 +#define REC_method 14 +#define REC_none 15 + +#define REC_M_path 0 +#define REC_M_data 1 + +#define RECTYPE(f) (((f)>>28)&((1<<4)-1)) + +#define REC_D_TYPE(d) ((REC_delimited<<28)|((d)&((1<<8)-1))) +#define REC_D_DELIMITER(f) ((f)&((1<<8)-1)) + +#define REC_F_TYPE(s) ((REC_fixed<<28)|((s)&((1<<28)-1))) +#define REC_F_SIZE(f) ((f)&((1<<28)-1)) + +#define REC_U_TYPE(t,a) (((t)<<28)|((a)&((1<<28)-1))) +#define REC_U_ATTRIBUTES(f) ((f)&~((1<<28)-1)) + +#define REC_V_TYPE(h,o,z,l,i) ((REC_variable<<28)|((h)<<23)|((o)<<19)|(((z)-1)<<18)|((l)<<17)|((i)<<16)) +#define REC_V_RECORD(f,s) (((f)&(((1<<16)-1)<<16))|(s)) +#define REC_V_HEADER(f) (((f)>>23)&((1<<5)-1)) +#define REC_V_OFFSET(f) (((f)>>19)&((1<<4)-1)) +#define REC_V_LENGTH(f) ((((f)>>18)&1)+1) +#define REC_V_LITTLE(f) (((f)>>17)&1) +#define REC_V_INCLUSIVE(f) (((f)>>16)&1) +#define REC_V_SIZE(f) ((f)&((1<<16)-1)) +#define REC_V_ATTRIBUTES(f) ((f)&~((1<<16)-1)) + +#define REC_M_TYPE(i) ((REC_method<<28)|(i)) +#define REC_M_INDEX(f) ((f)&((1<<28)-1)) + +#define REC_N_TYPE() 0xffffffff + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern char* fmtrec(Recfmt_t, int); +extern Recfmt_t recfmt(const void*, size_t, off_t); +extern Recfmt_t recstr(const char*, char**); +extern ssize_t reclen(Recfmt_t, const void*, size_t); + +#undef extern + +#endif diff --git a/src/lib/libast/include/regex.h b/src/lib/libast/include/regex.h new file mode 100644 index 0000000..8b357fe --- /dev/null +++ b/src/lib/libast/include/regex.h @@ -0,0 +1,248 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +/* + * regex library interface + */ + +#ifdef _AST_STD_I +#define _REGEX_H -1 +#define regex_t int +#define regmatch_t int +#endif +#ifndef _REGEX_H +#define _REGEX_H 1 +#undef regex_t +#undef regmatch_t + +#include <ast_common.h> +#include <ast_wchar.h> + +#define REG_VERSION 20100930L + +/* regcomp flags */ + +#define REG_AUGMENTED 0x00000001 /* enable ! & < > */ +#define REG_EXTENDED 0x00000002 /* enable ( | ) */ +#define REG_ICASE 0x00000004 /* ignore case in match */ +#define REG_NEWLINE 0x00000008 /* ^/$ match embedded \n */ +#define REG_NOSUB 0x00000010 /* don't report subexp matches */ +#define REG_SHELL 0x00000020 /* shell pattern syntax */ + +/* nonstandard regcomp flags */ + +#define REG_LEFT 0x00000100 /* implicit ^... */ +#define REG_LITERAL 0x00000200 /* no operators */ +#define REG_MINIMAL 0x00000400 /* minimal match */ +#define REG_NULL 0x00000800 /* allow null patterns */ +#define REG_RIGHT 0x00001000 /* implicit ...$ */ +#define REG_LENIENT 0x00002000 /* look the other way */ +#define REG_ESCAPE 0x00004000 /* \ escapes delimiter in [...] */ +#define REG_FIRST 0x00008000 /* first match found will do */ +#define REG_MULTIPLE 0x00010000 /* multiple \n sep patterns */ +#define REG_DISCIPLINE 0x00020000 /* regex_t.re_disc is valid */ +#define REG_SPAN 0x00040000 /* . matches \n */ +#define REG_COMMENT 0x00080000 /* ignore pattern space & #...\n*/ +#define REG_MULTIREF 0x00100000 /* multiple digit backrefs */ +#define REG_MUSTDELIM 0x08000000 /* all delimiters required */ +#define REG_DELIMITED 0x10000000 /* pattern[0] is delimiter */ +#define REG_CLASS_ESCAPE 0x80000000 /* \ escapes in [...] */ + +#define REG_SHELL_DOT 0x00200000 /* explicit leading . match */ +#define REG_SHELL_ESCAPED 0x00400000 /* \ not special */ +#define REG_SHELL_GROUP 0x20000000 /* (|&) inside [@|&](...) only */ +#define REG_SHELL_PATH 0x00800000 /* explicit / match */ + +#define REG_REGEXP 0x40000000 /* <regexp.h> compatibility */ + +/* regexec flags */ + +#define REG_NOTBOL 0x00000040 /* ^ is not a special char */ +#define REG_NOTEOL 0x00000080 /* $ is not a special char */ + +/* nonstandard regexec flags */ + +#define REG_INVERT 0x01000000 /* invert regrexec match sense */ +#define REG_STARTEND 0x02000000 /* subject==match[0].rm_{so,eo} */ +#define REG_ADVANCE 0x04000000 /* advance match[0].rm_{so,eo} */ + +/* regalloc flags */ + +#define REG_NOFREE 0x00000001 /* don't free */ + +/* regsub flags */ + +#define REG_SUB_ALL 0x00000001 /* substitute all occurrences */ +#define REG_SUB_LOWER 0x00000002 /* substitute to lower case */ +#define REG_SUB_UPPER 0x00000004 /* substitute to upper case */ +#define REG_SUB_PRINT 0x00000010 /* internal no-op */ +#define REG_SUB_NUMBER 0x00000020 /* internal no-op */ +#define REG_SUB_STOP 0x00000040 /* internal no-op */ +#define REG_SUB_WRITE 0x00000080 /* internal no-op */ +#define REG_SUB_LAST 0x00000100 /* last substitution option */ +#define REG_SUB_FULL 0x00000200 /* fully delimited */ +#define REG_SUB_USER 0x00001000 /* first user flag bit */ + +/* regex error codes */ + +#define REG_ENOSYS (-1) /* not supported */ +#define REG_NOMATCH 1 /* regexec didn't match */ +#define REG_BADPAT 2 /* invalid regular expression */ +#define REG_ECOLLATE 3 /* invalid collation element */ +#define REG_ECTYPE 4 /* invalid character class */ +#define REG_EESCAPE 5 /* trailing \ in pattern */ +#define REG_ESUBREG 6 /* invalid \digit backreference */ +#define REG_EBRACK 7 /* [...] imbalance */ +#define REG_EPAREN 8 /* \(...\) or (...) imbalance */ +#define REG_EBRACE 9 /* \{...\} or {...} imbalance */ +#define REG_BADBR 10 /* invalid {...} digits */ +#define REG_ERANGE 11 /* invalid [...] range endpoint */ +#define REG_ESPACE 12 /* out of space */ +#define REG_BADRPT 13 /* unary op not preceded by re */ +#define REG_ENULL 14 /* empty subexpr in pattern */ +#define REG_ECOUNT 15 /* re component count overflow */ +#define REG_BADESC 16 /* invalid \char escape */ +#define REG_VERSIONID 17 /* version id (pseudo error) */ +#define REG_EFLAGS 18 /* flags conflict */ +#define REG_EDELIM 19 /* invalid or omitted delimiter */ +#define REG_PANIC 20 /* unrecoverable internal error */ + +struct regex_s; typedef struct regex_s regex_t; +struct regdisc_s; typedef struct regdisc_s regdisc_t; + +typedef int (*regclass_t)(int); +typedef uint32_t regflags_t; +typedef int regoff_t; +typedef int (*regerror_t)(const regex_t*, regdisc_t*, int, ...); +typedef void* (*regcomp_t)(const regex_t*, const char*, size_t, regdisc_t*); +typedef int (*regexec_t)(const regex_t*, void*, const char*, size_t, const char*, size_t, char**, regdisc_t*); +typedef void* (*regresize_t)(void*, void*, size_t); +typedef int (*regrecord_t)(void*, const char*, size_t); + +typedef struct regmatch_s +{ + regoff_t rm_so; /* offset of start */ + regoff_t rm_eo; /* offset of end */ +} regmatch_t; + +typedef struct regsub_s +{ + regflags_t re_flags; /* regsubcomp() flags */ + char* re_buf; /* regsubexec() output buffer */ + size_t re_len; /* re_buf length */ + int re_min; /* regsubcomp() min matches */ +#ifdef _REG_SUB_PRIVATE_ + _REG_SUB_PRIVATE_ +#endif +} regsub_t; + +struct regdisc_s +{ + unsigned long re_version; /* discipline version */ + regflags_t re_flags; /* discipline flags */ + regerror_t re_errorf; /* error function */ + int re_errorlevel; /* errorf level */ + regresize_t re_resizef; /* alloc/free function */ + void* re_resizehandle;/* resizef handle */ + regcomp_t re_compf; /* (?{...}) compile function */ + regexec_t re_execf; /* (?{...}) execute function */ + unsigned char* re_map; /* external to native ccode map */ +}; + +typedef struct regstat_s +{ + regflags_t re_flags; /* REG_* */ + ssize_t re_min; /* min anchored match length */ + ssize_t re_max; /* max anchored match length */ + ssize_t re_record; /* regrexec() match length */ + regflags_t re_info; /* REG_* info */ +} regstat_t; + +struct regex_s +{ + size_t re_nsub; /* number of subexpressions */ + struct reglib_s*re_info; /* library private info */ + size_t re_npat; /* number of pattern chars used */ + regdisc_t* re_disc; /* REG_DISCIPLINE discipline */ + regsub_t* re_sub; /* regsubcomp() data */ +}; + +#define reginit(disc) (memset(disc,0,sizeof(*(disc))),(disc)->re_version=REG_VERSION) + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int regcomp(regex_t*, const char*, regflags_t); +extern size_t regerror(int, const regex_t*, char*, size_t); +extern int regexec(const regex_t*, const char*, size_t, regmatch_t*, regflags_t); +extern void regfree(regex_t*); + +/* nonstandard hooks */ + +#define _REG_cache 1 /* have regcache() */ +#define _REG_class 1 /* have regclass() */ +#define _REG_collate 1 /* have regcollate(), regclass() */ +#define _REG_comb 1 /* have regcomb() */ +#define _REG_decomp 1 /* have regdecomp() */ +#define _REG_dup 1 /* have regdup() */ +#define _REG_fatal 1 /* have regfatal(), regfatalpat() */ +#define _REG_ncomp 1 /* have regncomp() */ +#define _REG_nexec 1 /* have regnexec() */ +#define _REG_rexec 1 /* have regrexec(), regrecord() */ +#define _REG_stat 1 /* have regstat() */ +#define _REG_subcomp 1 /* have regsubcomp(), regsubexec() */ + +extern regclass_t regclass(const char*, char**); +extern int regaddclass(const char*, regclass_t); +extern int regcollate(const char*, char**, char*, size_t, wchar_t*); +extern int regcomb(regex_t*, regex_t*); +extern size_t regdecomp(regex_t*, regflags_t, char*, size_t); +extern int regdup(regex_t*, regex_t*); +extern int regncomp(regex_t*, const char*, size_t, regflags_t); +extern int regnexec(const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t); +extern void regfatal(regex_t*, int, int); +extern void regfatalpat(regex_t*, int, int, const char*); +extern int regrecord(const regex_t*); +extern int regrexec(const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t, int, void*, regrecord_t); +extern regstat_t* regstat(const regex_t*); + +extern regex_t* regcache(const char*, regflags_t, int*); + +extern int regsubcomp(regex_t*, const char*, const regflags_t*, int, regflags_t); +extern int regsubexec(const regex_t*, const char*, size_t, regmatch_t*); +extern int regsubflags(regex_t*, const char*, char**, int, const regflags_t*, int*, regflags_t*); +extern void regsubfree(regex_t*); + +/* obsolete hooks */ + +#ifndef _SFIO_H +struct _sfio_s; +#endif + +extern void regalloc(void*, regresize_t, regflags_t); +extern int regsub(const regex_t*, struct _sfio_s*, const char*, const char*, size_t, regmatch_t*, regflags_t); + +#undef extern + +#endif diff --git a/src/lib/libast/include/sfdisc.h b/src/lib/libast/include/sfdisc.h new file mode 100644 index 0000000..b48eb43 --- /dev/null +++ b/src/lib/libast/include/sfdisc.h @@ -0,0 +1,70 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * AT&T Research + * + * sfio discipline interface definitions + */ + +#ifndef _SFDISC_H +#define _SFDISC_H + +#include <ast.h> + +#define SFDCEVENT(a,b,n) ((((a)-'A'+1)<<11)^(((b)-'A'+1)<<6)^(n)) + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +#define SFSK_DISCARD SFDCEVENT('S','K',1) + +/* + * %(...) printf support + */ + +typedef int (*Sf_key_lookup_t)(void*, Sffmt_t*, const char*, char**, Sflong_t*); +typedef char* (*Sf_key_convert_t)(void*, Sffmt_t*, const char*, char*, Sflong_t); + +extern int sfkeyprintf(Sfio_t*, void*, const char*, Sf_key_lookup_t, Sf_key_convert_t); +extern int sfkeyprintf_20000308(Sfio_t*, void*, const char*, Sf_key_lookup_t, Sf_key_convert_t); + +/* + * pure sfio read and/or write disciplines + */ + +extern int sfdcdio(Sfio_t*, size_t); +extern int sfdcdos(Sfio_t*); +extern int sfdcfilter(Sfio_t*, const char*); +extern int sfdcmore(Sfio_t*, const char*, int, int); +extern int sfdcprefix(Sfio_t*, const char*); +extern int sfdcseekable(Sfio_t*); +extern int sfdcslow(Sfio_t*); +extern int sfdctee(Sfio_t*, Sfio_t*); +extern int sfdcunion(Sfio_t*, Sfio_t**, int); + +extern Sfio_t* sfdcsubstream(Sfio_t*, Sfio_t*, Sfoff_t, Sfoff_t); + +#undef extern + +#endif diff --git a/src/lib/libast/include/sfio.h b/src/lib/libast/include/sfio.h new file mode 100644 index 0000000..1e3ede5 --- /dev/null +++ b/src/lib/libast/include/sfio.h @@ -0,0 +1,457 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#ifndef _SFIO_H +#define _SFIO_H 1 + +#define SFIO_VERSION 20090915L + +/* Public header file for the sfio library +** +** Written by Kiem-Phong Vo +*/ + +typedef struct _sfio_s Sfio_t; +typedef struct _sfdisc_s Sfdisc_t; + +#if defined(_AST_STD_H) || defined(_PACKAGE_ast) && defined(_SFIO_PRIVATE) +#include <ast_std.h> +#else +#include <ast_common.h> +#endif /* _PACKAGE_ast */ + +/* Sfoff_t should be large enough for largest file address */ +#define Sfoff_t intmax_t +#define Sflong_t intmax_t +#define Sfulong_t uintmax_t +#define Sfdouble_t _ast_fltmax_t + +typedef ssize_t (*Sfread_f)_ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*)); +typedef ssize_t (*Sfwrite_f)_ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*)); +typedef Sfoff_t (*Sfseek_f)_ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*)); +typedef int (*Sfexcept_f)_ARG_((Sfio_t*, int, Void_t*, Sfdisc_t*)); +typedef int (*Sfwalk_f)_ARG_((Sfio_t*, Void_t*)); + +/* discipline structure */ +struct _sfdisc_s +{ Sfread_f readf; /* read function */ + Sfwrite_f writef; /* write function */ + Sfseek_f seekf; /* seek function */ + Sfexcept_f exceptf; /* to handle exceptions */ + Sfdisc_t* disc; /* the continuing discipline */ +}; + +#include <sfio_s.h> + +/* formatting environment */ +typedef struct _sffmt_s Sffmt_t; +typedef int (*Sffmtext_f)_ARG_((Sfio_t*, Void_t*, Sffmt_t*)); +typedef int (*Sffmtevent_f)_ARG_((Sfio_t*, int, Void_t*, Sffmt_t*)); +struct _sffmt_s +{ long version;/* version of this structure */ + Sffmtext_f extf; /* function to process arguments */ + Sffmtevent_f eventf; /* process events */ + + char* form; /* format string to stack */ + va_list args; /* corresponding arg list */ + + int fmt; /* format character */ + ssize_t size; /* object size */ + int flags; /* formatting flags */ + int width; /* width of field */ + int precis; /* precision required */ + int base; /* conversion base */ + + char* t_str; /* type string */ + ssize_t n_str; /* length of t_str */ + + Void_t* mbs; /* multibyte state for format string */ + + Void_t* none; /* unused for now */ +}; +#define sffmtversion(fe,type) \ + ((type) ? ((fe)->version = SFIO_VERSION) : (fe)->version) + +#define SFFMT_SSHORT 000000010 /* 'hh' flag, char */ +#define SFFMT_TFLAG 000000020 /* 't' flag, ptrdiff_t */ +#define SFFMT_ZFLAG 000000040 /* 'z' flag, size_t */ + +#define SFFMT_LEFT 000000100 /* left-justification */ +#define SFFMT_SIGN 000000200 /* must have a sign */ +#define SFFMT_BLANK 000000400 /* if not signed, prepend a blank */ +#define SFFMT_ZERO 000001000 /* zero-padding on the left */ +#define SFFMT_ALTER 000002000 /* alternate formatting */ +#define SFFMT_THOUSAND 000004000 /* thousand grouping */ +#define SFFMT_SKIP 000010000 /* skip assignment in scanf() */ +#define SFFMT_SHORT 000020000 /* 'h' flag */ +#define SFFMT_LONG 000040000 /* 'l' flag */ +#define SFFMT_LLONG 000100000 /* 'll' flag */ +#define SFFMT_LDOUBLE 000200000 /* 'L' flag */ +#define SFFMT_VALUE 000400000 /* value is returned */ +#define SFFMT_ARGPOS 001000000 /* getting arg for $ patterns */ +#define SFFMT_IFLAG 002000000 /* 'I' flag */ +#define SFFMT_JFLAG 004000000 /* 'j' flag, intmax_t */ +#define SFFMT_CENTER 010000000 /* '=' flag, center justification */ +#define SFFMT_CHOP 020000000 /* chop long string values from left */ +#define SFFMT_SET 037777770 /* flags settable on calling extf */ + +/* for sfmutex() call */ +#define SFMTX_LOCK 0 /* up mutex count */ +#define SFMTX_TRYLOCK 1 /* try to up mutex count */ +#define SFMTX_UNLOCK 2 /* down mutex count */ +#define SFMTX_CLRLOCK 3 /* clear mutex count */ + +/* various constants */ +#ifndef NULL +#define NULL 0 +#endif +#ifndef EOF +#define EOF (-1) +#endif +#ifndef SEEK_SET +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +/* bits for various types of files */ +#define SF_READ 0000001 /* open for reading */ +#define SF_WRITE 0000002 /* open for writing */ +#define SF_STRING 0000004 /* a string stream */ +#define SF_APPENDWR 0000010 /* file is in append mode only */ +#define SF_MALLOC 0000020 /* buffer is malloc-ed */ +#define SF_LINE 0000040 /* line buffering */ +#define SF_SHARE 0000100 /* stream with shared file descriptor */ +#define SF_EOF 0000200 /* eof was detected */ +#define SF_ERROR 0000400 /* an error happened */ +#define SF_STATIC 0001000 /* a stream that cannot be freed */ +#define SF_IOCHECK 0002000 /* call exceptf before doing IO */ +#define SF_PUBLIC 0004000 /* SF_SHARE and follow physical seek */ +#define SF_MTSAFE 0010000 /* need thread safety */ +#define SF_WHOLE 0020000 /* preserve wholeness of sfwrite/sfputr */ +#define SF_IOINTR 0040000 /* return on interrupts */ +#define SF_WCWIDTH 0100000 /* wcwidth display stream */ + +#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */ +#define SF_SETS 0177163 /* flags passable to sfset() */ + +#ifndef _SF_NO_OBSOLETE +#define SF_BUFCONST 0400000 /* unused flag - for compatibility only */ +#endif + +/* for sfgetr/sfreserve to hold a record */ +#define SF_LOCKR 0000010 /* lock record, stop access to stream */ +#define SF_LASTR 0000020 /* get the last incomplete record */ + +/* exception events: SF_NEW(0), SF_READ(1), SF_WRITE(2) and the below */ +#define SF_SEEK 3 /* seek error */ +#define SF_CLOSING 4 /* when stream is about to be closed */ +#define SF_DPUSH 5 /* when discipline is being pushed */ +#define SF_DPOP 6 /* when discipline is being popped */ +#define SF_DPOLL 7 /* see if stream is ready for I/O */ +#define SF_DBUFFER 8 /* buffer not empty during push or pop */ +#define SF_SYNC 9 /* announcing start/end synchronization */ +#define SF_PURGE 10 /* a sfpurge() call was issued */ +#define SF_FINAL 11 /* closing is done except stream free */ +#define SF_READY 12 /* a polled stream is ready */ +#define SF_LOCKED 13 /* stream is in a locked state */ +#define SF_ATEXIT 14 /* process is exiting */ +#define SF_EVENT 100 /* start of user-defined events */ + +/* for stack and disciplines */ +#define SF_POPSTACK ((Sfio_t*)0) /* pop the stream stack */ +#define SF_POPDISC ((Sfdisc_t*)0) /* pop the discipline stack */ + +/* for the notify function and discipline exception */ +#define SF_NEW 0 /* new stream */ +#define SF_SETFD (-1) /* about to set the file descriptor */ +#define SF_MTACCESS (-2) /* starting a multi-threaded stream */ + +#define SF_BUFSIZE 8192 /* default buffer size */ +#define SF_UNBOUND (-1) /* unbounded buffer size */ + +/* namespace incursion workarounds -- migrate to the new names */ +#if !_mac_SF_APPEND +#define SF_APPEND SF_APPENDWR /* BSDI sys/stat.h */ +#endif +#if !_mac_SF_CLOSE +#define SF_CLOSE SF_CLOSING /* AIX sys/socket.h */ +#endif + +_BEGIN_EXTERNS_ + +#if _BLD_sfio && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_sfio && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern ssize_t _Sfi; +extern ssize_t _Sfmaxr; + +/* standard in/out/err streams */ +extern Sfio_t* sfstdin; +extern Sfio_t* sfstdout; +extern Sfio_t* sfstderr; + +#if _UWIN +#undef extern +#endif + +extern Sfio_t _Sfstdin; +extern Sfio_t _Sfstdout; +extern Sfio_t _Sfstderr; + +#undef extern + +#if _BLD_sfio && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Sfio_t* sfnew _ARG_((Sfio_t*, Void_t*, size_t, int, int)); +extern Sfio_t* sfopen _ARG_((Sfio_t*, const char*, const char*)); +extern Sfio_t* sfpopen _ARG_((Sfio_t*, const char*, const char*)); +extern Sfio_t* sfstack _ARG_((Sfio_t*, Sfio_t*)); +extern Sfio_t* sfswap _ARG_((Sfio_t*, Sfio_t*)); +extern Sfio_t* sftmp _ARG_((size_t)); +extern int sfwalk _ARG_((Sfwalk_f, Void_t*, int)); +extern int sfpurge _ARG_((Sfio_t*)); +extern int sfpoll _ARG_((Sfio_t**, int, int)); +extern Void_t* sfreserve _ARG_((Sfio_t*, ssize_t, int)); +extern int sfresize _ARG_((Sfio_t*, Sfoff_t)); +extern int sfsync _ARG_((Sfio_t*)); +extern int sfclrlock _ARG_((Sfio_t*)); +extern Void_t* sfsetbuf _ARG_((Sfio_t*, Void_t*, size_t)); +extern Sfdisc_t* sfdisc _ARG_((Sfio_t*,Sfdisc_t*)); +extern int sfraise _ARG_((Sfio_t*, int, Void_t*)); +extern int sfnotify _ARG_((void(*)(Sfio_t*, int, void*))); +extern int sfset _ARG_((Sfio_t*, int, int)); +extern int sfsetfd _ARG_((Sfio_t*, int)); +extern Sfio_t* sfpool _ARG_((Sfio_t*, Sfio_t*, int)); +extern ssize_t sfread _ARG_((Sfio_t*, Void_t*, size_t)); +extern ssize_t sfwrite _ARG_((Sfio_t*, const Void_t*, size_t)); +extern Sfoff_t sfmove _ARG_((Sfio_t*, Sfio_t*, Sfoff_t, int)); +extern int sfclose _ARG_((Sfio_t*)); +extern Sfoff_t sftell _ARG_((Sfio_t*)); +extern Sfoff_t sfseek _ARG_((Sfio_t*, Sfoff_t, int)); +extern ssize_t sfputr _ARG_((Sfio_t*, const char*, int)); +extern char* sfgetr _ARG_((Sfio_t*, int, int)); +extern ssize_t sfnputc _ARG_((Sfio_t*, int, size_t)); +extern int sfungetc _ARG_((Sfio_t*, int)); +extern int sfprintf _ARG_((Sfio_t*, const char*, ...)); +extern char* sfprints _ARG_((const char*, ...)); +extern ssize_t sfaprints _ARG_((char**, const char*, ...)); +extern ssize_t sfsprintf _ARG_((char*, size_t, const char*, ...)); +extern ssize_t sfvsprintf _ARG_((char*, size_t, const char*, va_list)); +extern ssize_t sfvasprints _ARG_((char**, const char*, va_list)); +extern int sfvprintf _ARG_((Sfio_t*, const char*, va_list)); +extern int sfscanf _ARG_((Sfio_t*, const char*, ...)); +extern int sfsscanf _ARG_((const char*, const char*, ...)); +extern int sfvsscanf _ARG_((const char*, const char*, va_list)); +extern int sfvscanf _ARG_((Sfio_t*, const char*, va_list)); + +/* mutex locking for thread-safety */ +extern int sfmutex _ARG_((Sfio_t*, int)); + +/* io functions with discipline continuation */ +extern ssize_t sfrd _ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*)); +extern ssize_t sfwr _ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*)); +extern Sfoff_t sfsk _ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*)); +extern ssize_t sfpkrd _ARG_((int, Void_t*, size_t, int, long, int)); + +/* portable handling of primitive types */ +extern int sfdlen _ARG_((Sfdouble_t)); +extern int sfllen _ARG_((Sflong_t)); +extern int sfulen _ARG_((Sfulong_t)); + +extern int sfputd _ARG_((Sfio_t*, Sfdouble_t)); +extern int sfputl _ARG_((Sfio_t*, Sflong_t)); +extern int sfputu _ARG_((Sfio_t*, Sfulong_t)); +extern int sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t)); +extern int sfputc _ARG_((Sfio_t*, int)); + +extern Sfdouble_t sfgetd _ARG_((Sfio_t*)); +extern Sflong_t sfgetl _ARG_((Sfio_t*)); +extern Sfulong_t sfgetu _ARG_((Sfio_t*)); +extern Sfulong_t sfgetm _ARG_((Sfio_t*, Sfulong_t)); +extern int sfgetc _ARG_((Sfio_t*)); + +extern int _sfputd _ARG_((Sfio_t*, Sfdouble_t)); +extern int _sfputl _ARG_((Sfio_t*, Sflong_t)); +extern int _sfputu _ARG_((Sfio_t*, Sfulong_t)); +extern int _sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t)); +extern int _sfflsbuf _ARG_((Sfio_t*, int)); + +extern int _sffilbuf _ARG_((Sfio_t*, int)); + +extern int _sfdlen _ARG_((Sfdouble_t)); +extern int _sfllen _ARG_((Sflong_t)); +extern int _sfulen _ARG_((Sfulong_t)); + +/* miscellaneous function analogues of fast in-line functions */ +extern Sfoff_t sfsize _ARG_((Sfio_t*)); +extern int sfclrerr _ARG_((Sfio_t*)); +extern int sfeof _ARG_((Sfio_t*)); +extern int sferror _ARG_((Sfio_t*)); +extern int sffileno _ARG_((Sfio_t*)); +extern int sfstacked _ARG_((Sfio_t*)); +extern ssize_t sfvalue _ARG_((Sfio_t*)); +extern ssize_t sfslen _ARG_((void)); +extern ssize_t sfmaxr _ARG_((ssize_t, int)); + +#undef extern +_END_EXTERNS_ + +/* coding long integers in a portable and compact fashion */ +#define SF_SBITS 6 +#define SF_UBITS 7 +#define SF_BBITS 8 +#define SF_SIGN (1 << SF_SBITS) +#define SF_MORE (1 << SF_UBITS) +#define SF_BYTE (1 << SF_BBITS) +#define SF_U1 SF_MORE +#define SF_U2 (SF_U1*SF_U1) +#define SF_U3 (SF_U2*SF_U1) +#define SF_U4 (SF_U3*SF_U1) + +#if __cplusplus +#define _SF_(f) (f) +#else +#define _SF_(f) ((Sfio_t*)(f)) +#endif + +#define __sf_putd(f,v) (_sfputd(_SF_(f),(Sfdouble_t)(v))) +#define __sf_putl(f,v) (_sfputl(_SF_(f),(Sflong_t)(v))) +#define __sf_putu(f,v) (_sfputu(_SF_(f),(Sfulong_t)(v))) +#define __sf_putm(f,v,m) (_sfputm(_SF_(f),(Sfulong_t)(v),(Sfulong_t)(m))) + +#define __sf_putc(f,c) (_SF_(f)->_next >= _SF_(f)->_endw ? \ + _sfflsbuf(_SF_(f),(int)((unsigned char)(c))) : \ + (int)(*_SF_(f)->_next++ = (unsigned char)(c)) ) +#define __sf_getc(f) (_SF_(f)->_next >= _SF_(f)->_endr ? _sffilbuf(_SF_(f),0) : \ + (int)(*_SF_(f)->_next++) ) + +#define __sf_dlen(v) (_sfdlen((Sfdouble_t)(v)) ) +#define __sf_llen(v) (_sfllen((Sflong_t)(v)) ) +#define __sf_ulen(v) ((Sfulong_t)(v) < SF_U1 ? 1 : (Sfulong_t)(v) < SF_U2 ? 2 : \ + (Sfulong_t)(v) < SF_U3 ? 3 : (Sfulong_t)(v) < SF_U4 ? 4 : 5) + +#define __sf_fileno(f) (_SF_(f)->_file) +#define __sf_eof(f) (_SF_(f)->_flags&SF_EOF) +#define __sf_error(f) (_SF_(f)->_flags&SF_ERROR) +#define __sf_clrerr(f) (_SF_(f)->_flags &= ~(SF_ERROR|SF_EOF)) +#define __sf_stacked(f) (_SF_(f)->_push != (Sfio_t*)0) +#define __sf_value(f) (_SF_(f)->_val) +#define __sf_slen() (_Sfi) +#define __sf_maxr(n,s) ((s)?((_Sfi=_Sfmaxr),(_Sfmaxr=(n)),_Sfi):_Sfmaxr) + +#if defined(__INLINE__) && !_BLD_sfio + +__INLINE__ int sfputd(Sfio_t* f, Sfdouble_t v) { return __sf_putd(f,v); } +__INLINE__ int sfputl(Sfio_t* f, Sflong_t v) { return __sf_putl(f,v); } +__INLINE__ int sfputu(Sfio_t* f, Sfulong_t v) { return __sf_putu(f,v); } +__INLINE__ int sfputm(Sfio_t* f, Sfulong_t v, Sfulong_t m) + { return __sf_putm(f,v,m); } + +__INLINE__ int sfputc(Sfio_t* f, int c) { return __sf_putc(f,c); } +__INLINE__ int sfgetc(Sfio_t* f) { return __sf_getc(f); } + +__INLINE__ int sfdlen(Sfdouble_t v) { return __sf_dlen(v); } +__INLINE__ int sfllen(Sflong_t v) { return __sf_llen(v); } +__INLINE__ int sfulen(Sfulong_t v) { return __sf_ulen(v); } + +__INLINE__ int sffileno(Sfio_t* f) { return __sf_fileno(f); } +__INLINE__ int sfeof(Sfio_t* f) { return __sf_eof(f); } +__INLINE__ int sferror(Sfio_t* f) { return __sf_error(f); } +__INLINE__ int sfclrerr(Sfio_t* f) { return __sf_clrerr(f); } +__INLINE__ int sfstacked(Sfio_t* f) { return __sf_stacked(f); } +__INLINE__ ssize_t sfvalue(Sfio_t* f) { return __sf_value(f); } +__INLINE__ ssize_t sfslen() { return __sf_slen(); } +__INLINE__ ssize_t sfmaxr(ssize_t n, int s) { return __sf_maxr(n,s); } + +#else + +#define sfputd(f,v) ( __sf_putd((f),(v)) ) +#define sfputl(f,v) ( __sf_putl((f),(v)) ) +#define sfputu(f,v) ( __sf_putu((f),(v)) ) +#define sfputm(f,v,m) ( __sf_putm((f),(v),(m)) ) + +#define sfputc(f,c) ( __sf_putc((f),(c)) ) +#define sfgetc(f) ( __sf_getc(f) ) + +#define sfdlen(v) ( __sf_dlen(v) ) +#define sfllen(v) ( __sf_llen(v) ) +#define sfulen(v) ( __sf_ulen(v) ) + +#define sffileno(f) ( __sf_fileno(f) ) +#define sfeof(f) ( __sf_eof(f) ) +#define sferror(f) ( __sf_error(f) ) +#define sfclrerr(f) ( __sf_clrerr(f) ) +#define sfstacked(f) ( __sf_stacked(f) ) +#define sfvalue(f) ( __sf_value(f) ) +#define sfslen() ( __sf_slen() ) +#define sfmaxr(n,s) ( __sf_maxr(n,s) ) + +#endif /*__INLINE__*/ + +#ifndef _SFSTR_H /* GSF's string manipulation stuff */ +#define _SFSTR_H 1 + +#define sfstropen() sfnew(0, 0, -1, -1, SF_READ|SF_WRITE|SF_STRING) +#define sfstrclose(f) sfclose(f) + +#define sfstrseek(f,p,m) \ + ( (m) == SEEK_SET ? \ + (((p) < 0 || (p) > (f)->_size) ? (char*)0 : \ + (char*)((f)->_next = (f)->_data+(p)) ) \ + : (m) == SEEK_CUR ? \ + ((f)->_next += (p), \ + (((f)->_next < (f)->_data || (f)->_next > (f)->_data+(f)->_size) ? \ + ((f)->_next -= (p), (char*)0) : (char*)(f)->_next ) ) \ + : (m) == SEEK_END ? \ + ( ((p) > 0 || (f)->_size+(p) < 0) ? (char*)0 : \ + (char*)((f)->_next = (f)->_data+(f)->_size+(p)) ) \ + : (char*)0 \ + ) + +#define sfstrsize(f) ((f)->_size) +#define sfstrtell(f) ((f)->_next - (f)->_data) +#define sfstrpend(f) ((f)->_size - sfstrtell()) +#define sfstrbase(f) ((char*)(f)->_data) + +#define sfstruse(f) \ + (sfputc((f),0) < 0 ? (char*)0 : (char*)((f)->_next = (f)->_data) \ + ) + +#define sfstrrsrv(f,n) \ + (sfreserve((f),(n),SF_WRITE|SF_LOCKR), sfwrite((f),(f)->_next,0), \ + ((f)->_next+(n) <= (f)->_data+(f)->_size ? (char*)(f)->_next : (char*)0) \ + ) + +#define sfstrbuf(f,b,n,m) \ + (sfsetbuf((f),(b),(n)), ((f)->_flags |= (m) ? SF_MALLOC : 0), \ + ((f)->_data == (unsigned char*)(b) ? 0 : -1) \ + ) + +#endif /* _SFSTR_H */ + +#endif /* _SFIO_H */ diff --git a/src/lib/libast/include/sfio_s.h b/src/lib/libast/include/sfio_s.h new file mode 100644 index 0000000..0fb33de --- /dev/null +++ b/src/lib/libast/include/sfio_s.h @@ -0,0 +1,51 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#ifndef _SFIO_S_H +#define _SFIO_S_H 1 + +/* + * sfio file structure used by sfio and the stdio source compatibility library + */ + +#if !defined(_SFHDR_H) && defined(_SFIO_H) && SFIO_VERSION < 20020214L +#define _data data +#define _endb endb +#define _next next +#endif + +struct _sfio_s +{ unsigned char* _next; /* next position to read/write from */ + unsigned char* _endw; /* end of write buffer */ + unsigned char* _endr; /* end of read buffer */ + unsigned char* _endb; /* end of buffer */ + struct _sfio_s* _push; /* the stream that was pushed on */ + unsigned short _flags; /* type of stream */ + short _file; /* file descriptor */ + unsigned char* _data; /* base of data buffer */ + ssize_t _size; /* buffer size */ + ssize_t _val; /* values or string lengths */ +#ifdef _SFIO_PRIVATE + _SFIO_PRIVATE +#endif +}; + +#endif diff --git a/src/lib/libast/include/sfio_t.h b/src/lib/libast/include/sfio_t.h new file mode 100644 index 0000000..9ff54a8 --- /dev/null +++ b/src/lib/libast/include/sfio_t.h @@ -0,0 +1,126 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#ifndef _SFIO_T_H +#define _SFIO_T_H 1 + +/* This header file is for library writers who need to know certain +** internal info concerning the full Sfio_t structure. Including this +** file means that you agree to track closely with sfio development +** in case its internal architecture is changed. +** +** Written by Kiem-Phong Vo +*/ + +/* the parts of Sfio_t private to sfio functions */ +#define _SFIO_PRIVATE \ + Sfoff_t extent; /* current file size */ \ + Sfoff_t here; /* current physical location */ \ + unsigned char getr; /* the last sfgetr separator */ \ + unsigned char tiny[1];/* for unbuffered read stream */ \ + unsigned short bits; /* private flags */ \ + unsigned int mode; /* current io mode */ \ + struct _sfdisc_s* disc; /* discipline */ \ + struct _sfpool_s* pool; /* the pool containing this */ \ + struct _sfrsrv_s* rsrv; /* reserved buffer */ \ + struct _sfproc_s* proc; /* coprocess id, etc. */ \ + Void_t* mutex; /* mutex for thread-safety */ \ + Void_t* stdio; /* stdio FILE if any */ \ + Sfoff_t lpos; /* last seek position */ \ + size_t iosz; /* preferred size for I/O */ \ + size_t blksz; /* preferred block size */ \ + Void_t* fill[1];/* modest expansion */ + +#include "sfio.h" + +/* mode bit to indicate that the structure hasn't been initialized */ +#define SF_INIT 0000004 +#define SF_DCDOWN 00010000 + +/* short-hand for common stream types */ +#define SF_RDWR (SF_READ|SF_WRITE) +#define SF_RDSTR (SF_READ|SF_STRING) +#define SF_WRSTR (SF_WRITE|SF_STRING) +#define SF_RDWRSTR (SF_RDWR|SF_STRING) + +/* for static initialization of an Sfio_t structure */ +#define SFNEW(data,size,file,type,disc,mutex) \ + { (unsigned char*)(data), /* next */ \ + (unsigned char*)(data), /* endw */ \ + (unsigned char*)(data), /* endr */ \ + (unsigned char*)(data), /* endb */ \ + (Sfio_t*)0, /* push */ \ + (unsigned short)((type)&SF_FLAGS), /* flags */ \ + (short)(file), /* file */ \ + (unsigned char*)(data), /* data */ \ + (ssize_t)(size), /* size */ \ + (ssize_t)(-1), /* val */ \ + (Sfoff_t)0, /* extent */ \ + (Sfoff_t)0, /* here */ \ + 0, /* getr */ \ + {0}, /* tiny */ \ + 0, /* bits */ \ + (unsigned int)(((type)&(SF_RDWR))|SF_INIT), /* mode */ \ + (struct _sfdisc_s*)(disc), /* disc */ \ + (struct _sfpool_s*)0, /* pool */ \ + (struct _sfrsrv_s*)0, /* rsrv */ \ + (struct _sfproc_s*)0, /* proc */ \ + (mutex), /* mutex */ \ + (Void_t*)0, /* stdio */ \ + (Sfoff_t)0, /* lpos */ \ + (size_t)0 /* iosz */ \ + } + +/* function to clear an Sfio_t structure */ +#define SFCLEAR(f,mtx) \ + ( (f)->next = (unsigned char*)0, /* next */ \ + (f)->endw = (unsigned char*)0, /* endw */ \ + (f)->endr = (unsigned char*)0, /* endr */ \ + (f)->endb = (unsigned char*)0, /* endb */ \ + (f)->push = (Sfio_t*)0, /* push */ \ + (f)->flags = (unsigned short)0, /* flags */ \ + (f)->file = -1, /* file */ \ + (f)->data = (unsigned char*)0, /* data */ \ + (f)->size = (ssize_t)(-1), /* size */ \ + (f)->val = (ssize_t)(-1), /* val */ \ + (f)->extent = (Sfoff_t)(-1), /* extent */ \ + (f)->here = (Sfoff_t)0, /* here */ \ + (f)->getr = 0, /* getr */ \ + (f)->tiny[0] = 0, /* tiny */ \ + (f)->bits = 0, /* bits */ \ + (f)->mode = 0, /* mode */ \ + (f)->disc = (struct _sfdisc_s*)0, /* disc */ \ + (f)->pool = (struct _sfpool_s*)0, /* pool */ \ + (f)->rsrv = (struct _sfrsrv_s*)0, /* rsrv */ \ + (f)->proc = (struct _sfproc_s*)0, /* proc */ \ + (f)->mutex = (mtx), /* mutex */ \ + (f)->stdio = (Void_t*)0, /* stdio */ \ + (f)->lpos = (Sfoff_t)0, /* lpos */ \ + (f)->iosz = (size_t)0 /* iosz */ \ + ) + +/* expose next stream inside discipline function; state saved in int f */ +#define SFDCNEXT(sp,f) (((f)=(sp)->bits&SF_DCDOWN),(sp)->bits|=SF_DCDOWN) + +/* restore SFDCNEXT() state from int f */ +#define SFDCPREV(sp,f) ((f)?(0):((sp)->bits&=~SF_DCDOWN)) + +#endif /* _SFIO_T_H */ diff --git a/src/lib/libast/include/shcmd.h b/src/lib/libast/include/shcmd.h new file mode 100644 index 0000000..16acdac --- /dev/null +++ b/src/lib/libast/include/shcmd.h @@ -0,0 +1,112 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +/* + * ksh builtin command api + */ + +#ifndef _SHCMD_H +#define _SHCMD_H 1 + +#ifndef AST_PLUGIN_VERSION +#define AST_PLUGIN_VERSION(v) (v) +#endif +#define SH_PLUGIN_VERSION AST_PLUGIN_VERSION(20111111L) + +#if __STDC__ +#define SHLIB(m) unsigned long plugin_version(void) { return SH_PLUGIN_VERSION; } +#else +#define SHLIB(m) unsigned long plugin_version() { return SH_PLUGIN_VERSION; } +#endif + +#ifndef SH_VERSION +# define Shell_t void +#endif +#ifndef NV_DEFAULT +# define Namval_t void +#endif + +#undef Shbltin_t +struct Shbltin_s; +typedef struct Shbltin_s Shbltin_t; + +#ifdef _SHTABLE_H /* pre-ksh93u+ -- obsolete */ +typedef int (*Shbltin_f)(int, char**, void*); +#else +typedef int (*Shbltin_f)(int, char**, Shbltin_t*); +#endif /* _SHTABLE_H */ + +struct Shbltin_s +{ + Shell_t* shp; + void* ptr; + int version; + int (*shrun)(int, char**); + int (*shtrap)(const char*, int); + void (*shexit)(int); + Namval_t* (*shbltin)(const char*, Shbltin_f, void*); + unsigned char notify; + unsigned char sigset; + unsigned char nosfio; + Namval_t* bnode; + Namval_t* vnode; + char* data; + int flags; + char* (*shgetenv)(const char*); + char* (*shsetenv)(const char*); + int invariant; +}; + +#if defined(SH_VERSION) || defined(_SH_PRIVATE) +# undef Shell_t +# undef Namval_t +#else +# define sh_context(c) ((Shbltin_t*)(c)) +# define sh_run(c, ac, av) ((c)?(*sh_context(c)->shrun)(ac,av):-1) +# define sh_system(c,str) ((c)?(*sh_context(c)->shtrap)(str,0):system(str)) +# define sh_exit(c,n) ((c)?(*sh_context(c)->shexit)(n):exit(n)) +# define sh_checksig(c) ((c) && sh_context(c)->sigset) +# define sh_builtin(c,n,f,p) ((c)?(*sh_context(c)->shbltin)(n,(Shbltin_f)(f),sh_context(p)):0) +# if defined(SFIO_VERSION) || defined(_AST_H) +# define LIB_INIT(c) +# else +# define LIB_INIT(c) ((c) && (sh_context(c)->nosfio = 1)) +# endif +# ifndef _CMD_H +# ifndef ERROR_NOTIFY +# define ERROR_NOTIFY 1 +# endif +# define cmdinit(ac,av,c,cat,flg) do { if((ac)<=0) return(0); \ + (sh_context(c)->notify = ((flg)&ERROR_NOTIFY)?1:0);} while(0) +# endif +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int astintercept(Shbltin_t*, int); + +#undef extern + +#endif diff --git a/src/lib/libast/include/stack.h b/src/lib/libast/include/stack.h new file mode 100644 index 0000000..593a08c --- /dev/null +++ b/src/lib/libast/include/stack.h @@ -0,0 +1,83 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * homogenous stack routine definitions + */ + +#ifndef _STACK_H +#define _STACK_H + +typedef struct stacktable* STACK; /* stack pointer */ +typedef struct stackposition STACKPOS; /* stack position */ + +struct stackblock /* stack block cell */ +{ + void** stack; /* actual stack */ + struct stackblock* prev; /* previous block in list */ + struct stackblock* next; /* next block in list */ +}; + +struct stackposition /* stack position */ +{ + struct stackblock* block; /* current block pointer */ + int index; /* index within current block */ +}; + +struct stacktable /* stack information */ +{ + struct stackblock* blocks; /* stack table blocks */ + void* error; /* error return value */ + int size; /* size of each block */ + STACKPOS position; /* current stack position */ +}; + +/* + * map old names to new + */ + +#define mkstack stackalloc +#define rmstack stackfree +#define clrstack stackclear +#define getstack stackget +#define pushstack stackpush +#define popstack stackpop +#define posstack stacktell + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern STACK stackalloc(int, void*); +extern void stackfree(STACK); +extern void stackclear(STACK); +extern void* stackget(STACK); +extern int stackpush(STACK, void*); +extern int stackpop(STACK); +extern void stacktell(STACK, int, STACKPOS*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/stak.h b/src/lib/libast/include/stak.h new file mode 100644 index 0000000..ee34773 --- /dev/null +++ b/src/lib/libast/include/stak.h @@ -0,0 +1,55 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * David Korn + * AT&T Research + * + * Interface definitions for a stack-like storage library + * + */ + +#ifndef _STAK_H +#define _STAK_H + +#include <stk.h> + +#define Stak_t Sfio_t +#define staksp stkstd +#define STAK_SMALL STK_SMALL + +#define stakptr(n) stkptr(stkstd,n) +#define staktell() stktell(stkstd) +#define stakputc(c) sfputc(stkstd,(c)) +#define stakwrite(b,n) sfwrite(stkstd,(b),(n)) +#define stakputs(s) (sfputr(stkstd,(s),0),--stkstd->_next) +#define stakseek(n) stkseek(stkstd,n) +#define stakcreate(n) stkopen(n) +#define stakinstall(s,f) stkinstall(s,f) +#define stakdelete(s) stkclose(s) +#define staklink(s) stklink(s) +#define stakalloc(n) stkalloc(stkstd,n) +#define stakcopy(s) stkcopy(stkstd,s) +#define stakset(c,n) stkset(stkstd,c,n) +#define stakfreeze(n) stkfreeze(stkstd,n) + +#endif diff --git a/src/lib/libast/include/stk.h b/src/lib/libast/include/stk.h new file mode 100644 index 0000000..851e408 --- /dev/null +++ b/src/lib/libast/include/stk.h @@ -0,0 +1,78 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * David Korn + * AT&T Research + * + * Interface definitions for a stack-like storage library + * + */ + +#ifndef _STK_H +#define _STK_H + +#include <sfio.h> + +#define _Stk_data _Stak_data + +#define stkstd (&_Stk_data) + +#define Stk_t Sfio_t + +#define STK_SMALL 1 /* small stkopen stack */ +#define STK_NULL 2 /* return NULL on overflow */ + +#define stkptr(sp,n) ((char*)((sp)->_data)+(n)) +#define stktop(sp) ((char*)(sp)->_next) +#define stktell(sp) ((sp)->_next-(sp)->_data) +#define stkseek(sp,n) ((n)==0?(char*)((sp)->_next=(sp)->_data):_stkseek(sp,n)) + +#if _BLD_ast && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Sfio_t _Stk_data; + +#undef extern + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Stk_t* stkopen(int); +extern Stk_t* stkinstall(Stk_t*, char*(*)(int)); +extern int stkclose(Stk_t*); +extern int stklink(Stk_t*); +extern char* stkalloc(Stk_t*, size_t); +extern char* stkcopy(Stk_t*, const char*); +extern char* stkset(Stk_t*, char*, size_t); +extern char* _stkseek(Stk_t*, ssize_t); +extern char* stkfreeze(Stk_t*, size_t); +extern int stkon(Stk_t*, char*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/swap.h b/src/lib/libast/include/swap.h new file mode 100644 index 0000000..03a81f4 --- /dev/null +++ b/src/lib/libast/include/swap.h @@ -0,0 +1,53 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * integral representation conversion support definitions + * supports sizeof(integral_type)<=sizeof(intmax_t) + */ + +#ifndef _SWAP_H +#define _SWAP_H + +#include <ast_common.h> + +#define int_swap _ast_intswap + +#define SWAP_MAX 8 + +#define SWAPOP(n) (((n)&int_swap)^(n)) + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern void* swapmem(int, const void*, void*, size_t); +extern intmax_t swapget(int, const void*, int); +extern void* swapput(int, void*, int, intmax_t); +extern int swapop(const void*, const void*, int); + +#undef extern + +#endif diff --git a/src/lib/libast/include/tar.h b/src/lib/libast/include/tar.h new file mode 100644 index 0000000..847d6c6 --- /dev/null +++ b/src/lib/libast/include/tar.h @@ -0,0 +1,118 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Standard Archive Format + * USTAR - Uniform Standard Tape ARchive + */ + +#ifndef _TAR_H +#define _TAR_H + +#define TBLOCK 512 +#define NAMSIZ 100 +#define PFXSIZ 155 + +#define TMODLEN 8 +#define TUIDLEN 8 +#define TGIDLEN 8 +#define TSIZLEN 12 +#define TMTMLEN 12 +#define TCKSLEN 8 + +#define TMAGIC "ustar" /* ustar and a null */ +#define TMAGLEN 6 +#define TVERSION "00" /* 00 and no null */ +#define TVERSLEN 2 +#define TUNMLEN 32 +#define TGNMLEN 32 +#define TDEVLEN 8 + +/* + * values used in typeflag field + */ + +#define REGTYPE '0' /* regular file */ +#define AREGTYPE 0 /* alternate REGTYPE */ +#define LNKTYPE '1' /* hard link */ +#define SYMTYPE '2' /* soft link */ +#define CHRTYPE '3' /* character special */ +#define BLKTYPE '4' /* block special */ +#define DIRTYPE '5' /* directory */ +#define FIFOTYPE '6' /* FIFO special */ +#define CONTTYPE '7' /* reserved */ +#define SOKTYPE '8' /* socket */ +#define EXTTYPE 'x' /* extended header */ +#define GLBTYPE 'g' /* global extended header */ +#define LLNKTYPE 'K' /* long link path */ +#define LREGTYPE 'L' /* long file path */ +#define VERTYPE 'V' /* version */ + +/* + * bits used in mode field + */ + +#define TSUID 04000 /* set uid on exec */ +#define TSGID 02000 /* set gid on exec */ +#define TSVTX 01000 /* sticky bit -- reserved */ + +/* + * file permissions + */ + +#define TUREAD 00400 /* read by owner */ +#define TUWRITE 00200 /* write by owner */ +#define TUEXEC 00100 /* execute by owner */ +#define TGREAD 00040 /* read by group */ +#define TGWRITE 00020 /* execute by group */ +#define TGEXEC 00010 /* write by group */ +#define TOREAD 00004 /* read by other */ +#define TOWRITE 00002 /* write by other */ +#define TOEXEC 00001 /* execute by other */ + +struct header +{ + char name[NAMSIZ]; + char mode[TMODLEN]; + char uid[TUIDLEN]; + char gid[TGIDLEN]; + char size[TSIZLEN]; + char mtime[TMTMLEN]; + char chksum[TCKSLEN]; + char typeflag; + char linkname[NAMSIZ]; + char magic[TMAGLEN]; + char version[TVERSLEN]; + char uname[TUNMLEN]; + char gname[TGNMLEN]; + char devmajor[TDEVLEN]; + char devminor[TDEVLEN]; + char prefix[PFXSIZ]; +}; + +union hblock +{ + char dummy[TBLOCK]; + struct header dbuf; +}; + +#endif diff --git a/src/lib/libast/include/times.h b/src/lib/libast/include/times.h new file mode 100644 index 0000000..c0c458d --- /dev/null +++ b/src/lib/libast/include/times.h @@ -0,0 +1,54 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * -last clock_t,time_t interface definitions plus + * + * <ast.h> + * <time.h> + * <sys/time.h> + * <sys/times.h> + */ + +#ifndef _TIMES_H +#define _TIMES_H + +#include <ast.h> + +#undef _TIMES_H +#include <ast_time.h> +#ifndef _TIMES_H +#define _TIMES_H +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int touch(const char*, time_t, time_t, int); + +#undef extern + +#endif diff --git a/src/lib/libast/include/tm.h b/src/lib/libast/include/tm.h new file mode 100644 index 0000000..bbd5980 --- /dev/null +++ b/src/lib/libast/include/tm.h @@ -0,0 +1,192 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * time conversion support definitions + */ + +#ifndef _TM_H +#define _TM_H + +#define TM_VERSION 20070319L + +#include <ast.h> +#include <times.h> + +#undef daylight + +#define tmset(z) tminit(z) +#define tmisleapyear(y) (!((y)%4)&&(((y)%100)||!((((y)<1900)?((y)+1900):(y))%400))) + +#define TM_ADJUST (1<<0) /* local doesn't do leap secs */ +#define TM_LEAP (1<<1) /* do leap seconds */ +#define TM_UTC (1<<2) /* universal coordinated ref */ + +#define TM_PEDANTIC (1<<3) /* pedantic date parse */ +#define TM_DATESTYLE (1<<4) /* date(1) style mmddHHMMccyy */ +#define TM_SUBSECOND (1<<5) /* <something>%S => ...%S.%P */ + +#define TM_DST (-60) /* default minutes for DST */ +#define TM_LOCALZONE (25 * 60) /* use local time zone offset */ +#define TM_UTCZONE (26 * 60) /* UTC "time zone" */ +#define TM_MAXLEAP 1 /* max leap secs per leap */ +#define TM_WINDOW 69 /* century windowing guard year */ + +/* + * these indices must agree with tm_dform[] + */ + +#define TM_MONTH_ABBREV 0 +#define TM_MONTH 12 +#define TM_DAY_ABBREV 24 +#define TM_DAY 31 +#define TM_TIME 38 +#define TM_DATE 39 +#define TM_DEFAULT 40 +#define TM_MERIDIAN 41 + +#define TM_UT 43 +#define TM_DT 47 +#define TM_SUFFIXES 51 +#define TM_PARTS 55 +#define TM_HOURS 62 +#define TM_DAYS 66 +#define TM_LAST 69 +#define TM_THIS 72 +#define TM_NEXT 75 +#define TM_EXACT 78 +#define TM_NOISE 81 +#define TM_ORDINAL 85 +#define TM_DIGITS 95 +#define TM_CTIME 105 +#define TM_DATE_1 106 +#define TM_INTERNATIONAL 107 +#define TM_RECENT 108 +#define TM_DISTANT 109 +#define TM_MERIDIAN_TIME 110 +#define TM_ERA 111 +#define TM_ERA_DATE 112 +#define TM_ERA_TIME 113 +#define TM_ERA_DEFAULT 114 +#define TM_ERA_YEAR 115 +#define TM_ORDINALS 116 +#define TM_FINAL 126 +#define TM_WORK 129 + +#define TM_NFORM 132 + +typedef struct /* leap second info */ +{ + time_t time; /* the leap second event */ + int total; /* inclusive total since epoch */ +} Tm_leap_t; + +typedef struct /* time zone info */ +{ + char* type; /* type name */ + char* standard; /* standard time name */ + char* daylight; /* daylight or summertime name */ + short west; /* minutes west of GMT */ + short dst; /* add to tz.west for DST */ +} Tm_zone_t; + +typedef struct /* tm library readonly data */ +{ + char** format; /* default TM_* format strings */ + unsigned char* lex; /* format lex type classes */ + char* digit; /* output digits */ + short* days; /* days in month i */ + short* sum; /* days in months before i */ + Tm_leap_t* leap; /* leap second table */ + Tm_zone_t* zone; /* alternate timezone table */ +} Tm_data_t; + +typedef struct /* tm library global info */ +{ + char* deformat; /* TM_DEFAULT override */ + int flags; /* flags */ + char** format; /* current format strings */ + Tm_zone_t* date; /* timezone from last tmdate() */ + Tm_zone_t* local; /* local timezone */ + Tm_zone_t* zone; /* current timezone */ +} Tm_info_t; + +typedef struct Tm_s +{ + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; + uint32_t tm_nsec; + Tm_zone_t* tm_zone; +} Tm_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Tm_data_t* _tm_datap_; +extern Tm_info_t* _tm_infop_; + +#define tm_data (*_tm_datap_) +#define tm_info (*_tm_infop_) + +#undef extern + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern time_t tmdate(const char*, char**, time_t*); +extern int tmequiv(Tm_t*); +extern Tm_t* tmfix(Tm_t*); +extern char* tmfmt(char*, size_t, const char*, time_t*); +extern char* tmform(char*, const char*, time_t*); +extern int tmgoff(const char*, char**, int); +extern void tminit(Tm_zone_t*); +extern time_t tmleap(time_t*); +extern int tmlex(const char*, char**, char**, int, char**, int); +extern char** tmlocale(void); +extern Tm_t* tmmake(time_t*); +extern char* tmpoff(char*, size_t, const char*, int, int); +extern time_t tmscan(const char*, char**, const char*, char**, time_t*, long); +extern int tmsleep(time_t, time_t); +extern time_t tmtime(Tm_t*, int); +extern Tm_zone_t* tmtype(const char*, char**); +extern int tmweek(Tm_t*, int, int, int); +extern int tmword(const char*, char**, const char*, char**, int); +extern Tm_zone_t* tmzone(const char*, char**, const char*, int*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/tok.h b/src/lib/libast/include/tok.h new file mode 100644 index 0000000..f898218 --- /dev/null +++ b/src/lib/libast/include/tok.h @@ -0,0 +1,47 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * token stream interface definitions + */ + +#ifndef _TOK_H +#define _TOK_H + +#include <ast.h> + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Sfio_t* tokline(const char*, int, int*); +extern int tokscan(char*, char**, const char*, ...); +extern char* tokopen(char*, int); +extern void tokclose(char*); +extern char* tokread(char*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/usage.h b/src/lib/libast/include/usage.h new file mode 100644 index 0000000..c1ba317 --- /dev/null +++ b/src/lib/libast/include/usage.h @@ -0,0 +1,37 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +/* + * error catalog and usage defaults + */ + +#ifndef _USAGE_H +#define _USAGE_H + +#ifndef ERROR_CATALOG +#define ERROR_CATALOG 0 +#endif + +#ifndef USAGE_LICENSE +#define USAGE_LICENSE "[-license?THIS IS AN UNLICENSED COPY]" +#endif + +#endif diff --git a/src/lib/libast/include/vdb.h b/src/lib/libast/include/vdb.h new file mode 100644 index 0000000..e647215 --- /dev/null +++ b/src/lib/libast/include/vdb.h @@ -0,0 +1,46 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * virtual db file directory entry constants + */ + +#ifndef VDB_MAGIC + +#define VDB_MAGIC "vdb" + +#define VDB_DIRECTORY "DIRECTORY" +#define VDB_UNION "UNION" +#define VDB_DATE "DATE" +#define VDB_MODE "MODE" + +#define VDB_DELIMITER ';' +#define VDB_IGNORE '_' +#define VDB_FIXED 10 +#define VDB_LENGTH ((int)sizeof(VDB_DIRECTORY)+2*(VDB_FIXED+1)) +#define VDB_OFFSET ((int)sizeof(VDB_DIRECTORY)) +#define VDB_SIZE (VDB_OFFSET+VDB_FIXED+1) + +#endif diff --git a/src/lib/libast/include/vecargs.h b/src/lib/libast/include/vecargs.h new file mode 100644 index 0000000..548c0b4 --- /dev/null +++ b/src/lib/libast/include/vecargs.h @@ -0,0 +1,45 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * vector argument interface definitions + */ + +#ifndef _VECARGS_H +#define _VECARGS_H + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int vecargs(char**, int*, char***); +extern char** vecfile(const char*); +extern void vecfree(char**, int); +extern char** vecload(char*); +extern char** vecstring(const char*); + +#undef extern + +#endif diff --git a/src/lib/libast/include/vmalloc.h b/src/lib/libast/include/vmalloc.h new file mode 100644 index 0000000..4825143 --- /dev/null +++ b/src/lib/libast/include/vmalloc.h @@ -0,0 +1,335 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#ifndef _VMALLOC_H +#define _VMALLOC_H 1 + +/* Public header file for the virtual malloc package. +** +** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/1994. +*/ + +#define VMALLOC_VERSION 20110808L + +#if _PACKAGE_ast +#include <ast_std.h> +#else +#include <ast_common.h> +#endif + +typedef struct _vmalloc_s Vmalloc_t; +typedef struct _vmstat_s Vmstat_t; +typedef struct _vmdisc_s Vmdisc_t; +typedef struct _vmethod_s Vmethod_t; +typedef struct _vmdata_s Vmdata_t; +typedef Void_t* (*Vmemory_f)_ARG_((Vmalloc_t*, Void_t*, size_t, size_t, Vmdisc_t*)); +typedef int (*Vmexcept_f)_ARG_((Vmalloc_t*, int, Void_t*, Vmdisc_t*)); + +struct _vmstat_s +{ int n_busy; /* number of busy blocks */ + int n_free; /* number of free blocks */ + size_t s_busy; /* total amount of busy space */ + size_t s_free; /* total amount of free space */ + size_t m_busy; /* largest busy piece */ + size_t m_free; /* largest free piece */ + int n_seg; /* number of segments */ + size_t extent; /* total size of region */ + int n_region; /* #parallel regions (Vmregion) */ + int n_open; /* #calls that finds open reg */ + int n_lock; /* #calls where reg was locked */ + int n_probe; /* #probes to find a region */ + int mode; /* region mode bits */ +}; + +struct _vmdisc_s +{ Vmemory_f memoryf; /* memory manipulator */ + Vmexcept_f exceptf; /* exception handler */ + size_t round; /* rounding requirement */ + size_t size; /* actual size of discipline */ +}; + +struct _vmethod_s +{ Void_t* (*allocf)_ARG_((Vmalloc_t*,size_t,int)); + Void_t* (*resizef)_ARG_((Vmalloc_t*,Void_t*,size_t,int,int)); + int (*freef)_ARG_((Vmalloc_t*,Void_t*,int)); + long (*addrf)_ARG_((Vmalloc_t*,Void_t*,int)); + long (*sizef)_ARG_((Vmalloc_t*,Void_t*,int)); + int (*compactf)_ARG_((Vmalloc_t*,int)); + Void_t* (*alignf)_ARG_((Vmalloc_t*,size_t,size_t,int)); + unsigned short meth; +}; + +struct _vmalloc_s +{ Vmethod_t meth; /* method for allocation */ + char* file; /* file name */ + int line; /* line number */ + char* func; /* calling function */ + Vmdisc_t* disc; /* discipline to get space */ + Vmdata_t* data; /* the real region data */ + Vmalloc_t* next; /* linked list of regions */ +}; + +#define VM_TRUST 0000000 /* obsolete */ +#define VM_TRACE 0000001 /* generate traces of calls */ +#define VM_DBCHECK 0000002 /* check for boundary overwrite */ +#define VM_DBABORT 0000004 /* abort on any warning */ +#define VM_SHARE 0000010 /* sharable across processes */ +#define VM_MEMORYF 0000020 /* vm was allocated by memoryf */ +#define VM_FLAGS 0000017 /* user-settable flags */ + +#define VM_MTBEST 0000100 /* Vmbest method */ +#define VM_MTPOOL 0000200 /* Vmpool method */ +#define VM_MTLAST 0000400 /* Vmlast method */ +#define VM_MTDEBUG 0001000 /* Vmdebug method */ +#define VM_MTPROFILE 0002000 /* Vmdebug method */ +#define VM_METHODS 0003700 /* available allocation methods */ + +#define VM_RSCOPY 0000001 /* copy old contents */ +#define VM_RSMOVE 0000002 /* old contents is moveable */ +#define VM_RSZERO 0000004 /* clear new space */ + +/* exception types */ +#define VM_OPEN 1 /* region being opened */ +#define VM_ENDOPEN 2 /* end of region opening */ +#define VM_CLOSE 3 /* announce being closed */ +#define VM_ENDCLOSE 4 /* end of region closing */ +#define VM_DISC 5 /* discipline being changed */ +#define VM_NOMEM 6 /* can't obtain memory */ +#define VM_BADADDR (-1) /* currently a no-op */ + +/* for application-specific data in shared/persistent regions */ +#define VM_MMGET 0 /* get data value (void*) */ +#define VM_MMSET 1 /* set data value (void*) */ +#define VM_MMADD 2 /* add data value (long) */ + +_BEGIN_EXTERNS_ /* public data */ +#if _BLD_vmalloc && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_vmalloc && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Vmethod_t* Vmbest; /* best allocation */ +extern Vmethod_t* Vmlast; /* last-block allocation */ +extern Vmethod_t* Vmpool; /* pool allocation */ +extern Vmethod_t* Vmdebug; /* allocation with debugging */ +extern Vmethod_t* Vmprofile; /* profiling memory usage */ + +extern Vmdisc_t* Vmdcsystem; /* get memory from the OS */ +extern Vmdisc_t* Vmdcheap; /* get memory from Vmheap */ +extern Vmdisc_t* Vmdcsbrk; /* like Vmdcsystem - legacy use */ + +extern Vmalloc_t _Vmheap; /* heap region - use with care! */ +extern Vmalloc_t* Vmheap; /* = &_Vmheap - safe to use */ +extern Vmalloc_t* Vmregion; /* malloc region */ + +#undef extern +_END_EXTERNS_ + +_BEGIN_EXTERNS_ /* public functions */ +#if _BLD_vmalloc && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Vmalloc_t* vmopen _ARG_(( Vmdisc_t*, Vmethod_t*, int )); +extern int vmclose _ARG_(( Vmalloc_t* )); +extern int vmclear _ARG_(( Vmalloc_t* )); +extern int vmcompact _ARG_(( Vmalloc_t* )); + +extern Vmdisc_t* vmdisc _ARG_(( Vmalloc_t*, Vmdisc_t* )); + +extern Vmalloc_t* vmmopen _ARG_(( char*, int, ssize_t )); +extern Void_t* vmmvalue _ARG_(( Vmalloc_t*, int, Void_t*, int )); +extern void vmmrelease _ARG_(( Vmalloc_t*, int )); +extern Void_t* vmmaddress _ARG_(( size_t )); + +extern Void_t* vmalloc _ARG_(( Vmalloc_t*, size_t )); +extern Void_t* vmalign _ARG_(( Vmalloc_t*, size_t, size_t )); +extern Void_t* vmresize _ARG_(( Vmalloc_t*, Void_t*, size_t, int )); +extern Void_t* vmgetmem _ARG_(( Vmalloc_t*, Void_t*, size_t )); +extern int vmfree _ARG_(( Vmalloc_t*, Void_t* )); + +extern long vmaddr _ARG_(( Vmalloc_t*, Void_t* )); +extern long vmsize _ARG_(( Vmalloc_t*, Void_t* )); + +extern Vmalloc_t* vmregion _ARG_(( Void_t* )); +extern Void_t* vmsegment _ARG_(( Vmalloc_t*, Void_t* )); +extern int vmset _ARG_(( Vmalloc_t*, int, int )); + +extern Void_t* vmdbwatch _ARG_(( Void_t* )); +extern int vmdbcheck _ARG_(( Vmalloc_t* )); +extern int vmdebug _ARG_(( int )); + +extern int vmprofile _ARG_(( Vmalloc_t*, int )); + +extern int vmtrace _ARG_(( int )); +extern int vmtrbusy _ARG_((Vmalloc_t*)); + +extern int vmstat _ARG_((Vmalloc_t*, Vmstat_t*)); + +extern int vmwalk _ARG_((Vmalloc_t*, + int(*)(Vmalloc_t*,Void_t*,size_t,Vmdisc_t*,Void_t*), Void_t*)); +extern char* vmstrdup _ARG_((Vmalloc_t*, const char*)); + +#if !defined(_BLD_vmalloc) && !defined(_AST_STD_H) && \ + !defined(__stdlib_h) && !defined(__STDLIB_H) && \ + !defined(_STDLIB_INCLUDED) && !defined(_INC_STDLIB) +extern Void_t* malloc _ARG_(( size_t )); +extern Void_t* realloc _ARG_(( Void_t*, size_t )); +extern void free _ARG_(( Void_t* )); +extern void cfree _ARG_(( Void_t* )); +extern Void_t* calloc _ARG_(( size_t, size_t )); +extern Void_t* memalign _ARG_(( size_t, size_t )); +extern Void_t* valloc _ARG_(( size_t )); +#endif +extern int setregmax _ARG_(( int )); + +#undef extern +_END_EXTERNS_ + +/* to coerce any value to a Vmalloc_t*, make ANSI happy */ +#define _VM_(vm) ((Vmalloc_t*)(vm)) + +/* enable recording of where a call originates from */ +#ifdef VMFL + +#if defined(__FILE__) +#define _VMFILE_(vm) (_VM_(vm)->file = (char*)__FILE__) +#else +#define _VMFILE_(vm) (_VM_(vm)->file = (char*)0) +#endif + +#if defined(__LINE__) +#define _VMLINE_(vm) (_VM_(vm)->line = __LINE__) +#else +#define _VMLINE_(vm) (_VM_(vm)->line = 0) +#endif + +#if defined(__FUNCTION__) +#define _VMFUNC_(vm) (_VM_(vm)->func = (char*)__FUNCTION__) +#else +#define _VMFUNC_(vm) (_VM_(vm)->func = (char*)0) +#endif + +#define _VMFL_(vm) (_VMFILE_(vm), _VMLINE_(vm), _VMFUNC_(vm)) + +#define vmalloc(vm,sz) (_VMFL_(vm), \ + (*(_VM_(vm)->meth.allocf))((vm),(sz),0) ) +#define vmresize(vm,d,sz,type) (_VMFL_(vm), \ + (*(_VM_(vm)->meth.resizef))\ + ((vm),(Void_t*)(d),(sz),(type),0) ) +#define vmfree(vm,d) (_VMFL_(vm), \ + (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d),0) ) +#define vmalign(vm,sz,align) (_VMFL_(vm), \ + (*(_VM_(vm)->meth.alignf))((vm),(sz),(align),0) ) + +#undef malloc +#undef realloc +#undef calloc +#undef free +#undef memalign +#undef valloc + +#if _map_malloc + +#define malloc(s) (_VMFL_(Vmregion), _ast_malloc((size_t)(s)) ) +#define realloc(d,s) (_VMFL_(Vmregion), _ast_realloc((Void_t*)(d),(size_t)(s)) ) +#define calloc(n,s) (_VMFL_(Vmregion), _ast_calloc((size_t)n, (size_t)(s)) ) +#define free(d) (_VMFL_(Vmregion), _ast_free((Void_t*)(d)) ) +#define memalign(a,s) (_VMFL_(Vmregion), _ast_memalign((size_t)(a),(size_t)(s)) ) +#define valloc(s) (_VMFL_(Vmregion), _ast_valloc((size_t)(s) ) + +#else + +#if !_std_malloc + +#if __STD_C || defined(__STDPP__) || defined(__GNUC__) + +#define malloc(s) (_VMFL_(Vmregion), malloc((size_t)(s)) ) +#define realloc(d,s) (_VMFL_(Vmregion), realloc((Void_t*)(d),(size_t)(s)) ) +#define calloc(n,s) (_VMFL_(Vmregion), calloc((size_t)n, (size_t)(s)) ) +#define free(d) (_VMFL_(Vmregion), free((Void_t*)(d)) ) +#define memalign(a,s) (_VMFL_(Vmregion), memalign((size_t)(a),(size_t)(s)) ) +#define valloc(s) (_VMFL_(Vmregion), valloc((size_t)(s) ) +#ifndef strdup +#define strdup(s) ( _VMFL_(Vmregion), (strdup)((char*)(s)) ) +#endif + +#else + +#define _VMNM_(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f +#define malloc(s) (_VMFL_(Vmregion), _VMNM_(mallo,/,*,*,/,c)\ + ((size_t)(s)) ) +#define realloc(d,s) (_VMFL_(Vmregion), _VMNM_(reallo,/,*,*,/,c)\ + ((Void_t*)(d),(size_t)(s)) ) +#define calloc(n,s) (_VMFL_(Vmregion), _VMNM_(callo,/,*,*,/,c)\ + ((size_t)n, (size_t)(s)) ) +#define free(d) (_VMFL_(Vmregion), _VMNM_(fre,/,*,*,/,e)((Void_t*)(d)) ) +#define memalign(a,s) (_VMFL_(Vmregion), _VMNM_(memalig,/,*,*,/,n)\ + ((size_t)(a),(size_t)(s)) ) +#define valloc(s) (_VMFL_(Vmregion), _VMNM_(vallo,/,*,*,/,c)\ + ((size_t)(s) ) +#ifndef strdup +#define strdup(s) ( _VMFL_(Vmregion), _VMNM_(strdu,/,*,*,/,p)\ + ((char*)(s)) ) +#endif + +#endif /*__STD_C || defined(__STDPP__) || defined(__GNUC__)*/ + +#define cfree(d) free(d) + +#endif /*!_std_malloc*/ + +#endif /*_map_malloc*/ + +#endif /*VMFL*/ + +/* non-debugging/profiling allocation calls */ +#ifndef vmalloc +#define vmalloc(vm,sz) (*(_VM_(vm)->meth.allocf))((vm),(sz),0) +#endif + +#ifndef vmresize +#define vmresize(vm,d,sz,type) (*(_VM_(vm)->meth.resizef))\ + ((vm),(Void_t*)(d),(sz),(type),0) +#endif + +#ifndef vmfree +#define vmfree(vm,d) (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d),0) +#endif + +#ifndef vmalign +#define vmalign(vm,sz,align) (*(_VM_(vm)->meth.alignf))((vm),(sz),(align),0) +#endif + +#define vmaddr(vm,addr) (*(_VM_(vm)->meth.addrf))((vm),(Void_t*)(addr),0) +#define vmsize(vm,addr) (*(_VM_(vm)->meth.sizef))((vm),(Void_t*)(addr),0) +#define vmcompact(vm) (*(_VM_(vm)->meth.compactf))((vm),0) +#define vmoldof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \ + (VM_RSMOVE) ) +#define vmnewof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \ + (VM_RSMOVE|VM_RSCOPY|VM_RSZERO) ) + +#define vmdata(vm) ((Void_t*)(_VM_(vm)->data) ) +#define vmlocked(vm) (*((unsigned int*)(_VM_(vm)->data)) ) + +#endif /* _VMALLOC_H */ diff --git a/src/lib/libast/include/wait.h b/src/lib/libast/include/wait.h new file mode 100644 index 0000000..0dff619 --- /dev/null +++ b/src/lib/libast/include/wait.h @@ -0,0 +1,98 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* David Korn <dgk@research.att.com> * +* Phong Vo <kpv@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped +/* + * ast POSIX wait/exit support + */ + +#ifndef _WAIT_H +#define _WAIT_H + +#include <ast.h> +#include <ast_wait.h> + +#if _sys_wait +#if defined(__STDPP__directive) && defined(__STDPP__hide) +__STDPP__directive pragma pp:hide wait waitpid +#else +#define wait ______wait +#define waitpid ______waitpid +#endif +#include <sys/wait.h> +#if defined(__STDPP__directive) && defined(__STDPP__hide) +__STDPP__directive pragma pp:nohide wait waitpid +#else +#undef wait +#undef waitpid +#endif +#endif + +#ifndef WNOHANG +#define WNOHANG 1 +#endif + +#ifndef WUNTRACED +#define WUNTRACED 2 +#endif + +#if !_ok_wif +#undef WIFEXITED +#undef WEXITSTATUS +#undef WIFSIGNALED +#undef WTERMSIG +#undef WIFSTOPPED +#undef WSTOPSIG +#undef WTERMCORE +#endif + +#ifndef WIFEXITED +#define WIFEXITED(x) (!((x)&((1<<(EXIT_BITS-1))-1))) +#endif + +#ifndef WEXITSTATUS +#define WEXITSTATUS(x) (((x)>>EXIT_BITS)&((1<<EXIT_BITS)-1)) +#endif + +#ifndef WIFSIGNALED +#define WIFSIGNALED(x) (((x)&((1<<(EXIT_BITS-1))-1))!=0) +#endif + +#ifndef WTERMSIG +#define WTERMSIG(x) ((x)&((1<<(EXIT_BITS-1))-1)) +#endif + +#ifndef WIFSTOPPED +#define WIFSTOPPED(x) (((x)&((1<<EXIT_BITS)-1))==((1<<(EXIT_BITS-1))-1)) +#endif + +#ifndef WSTOPSIG +#define WSTOPSIG(x) WEXITSTATUS(x) +#endif + +#ifndef WTERMCORE +#define WTERMCORE(x) ((x)&(1<<(EXIT_BITS-1))) +#endif + +extern pid_t wait(int*); +extern pid_t waitpid(pid_t, int*, int); + +#endif |