da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/***********************************************************************
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* This software is part of the ast package *
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner* Copyright (c) 1982-2010 AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* and is licensed under the *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Common Public License, Version 1.0 *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin* by AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* A copy of the License is available at *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Information and Software Systems Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* AT&T Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Florham Park NJ *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* David Korn <dgk@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin***********************************************************************/
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * This is the implementation header file for name-value pairs
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* Nodes can have all kinds of values */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin unsigned int u;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Sfdouble_t *ldp; /* for long floating point arithmetic */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin struct Ufunction *rp; /* shell user defined functions */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int (*bfp)(int,char*[],void*);/* builtin entry point function pointer */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* used for arrays */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define ARRAY_MAX (1L<<ARRAY_BITS) /* maximum number of elements in an array */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define ARRAY_INCR 32 /* number of elements to grow when array
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin bound exceeded. Must be a power of 2 */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define ARRAY_FILL (8L<<ARRAY_BITS) /* used with nv_putsub() */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define ARRAY_NOCLONE (16L<<ARRAY_BITS) /* do not clone array disc */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define ARRAY_NOCHILD (32L<<ARRAY_BITS) /* skip compound arrays */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define ARRAY_SETSUB (64L<<ARRAY_BITS) /* set subscript */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define ARRAY_NOSCOPE (128L<<ARRAY_BITS) /* top level scope only */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define ARRAY_TREE (256L<<ARRAY_BITS) /* arrays of compound vars */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* These flags are used as options to array_get() */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* This describes a user shell function node */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin off_t hoffset; /* offset into source or history file */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin char *fname; /* file name where function defined */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif /* !ARG_RAW */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* attributes of Namval_t items */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* The following attributes are for internal use */
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz#define NV_NOCHANGE (NV_EXPORT|NV_IMPORT|NV_RDONLY|NV_TAGGED|NV_NOFREE|NV_ARRAY)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define NV_ATTRIBUTES (~(NV_NOSCOPE|NV_ARRAY|NV_NOARRAY|NV_IDENT|NV_ASSIGN|NV_REF|NV_VARNAME|NV_STATIC))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define NV_PARAM NV_NODISC /* expansion use positional params */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* This following are for use with nodes which are not name-values */
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz#define NV_UNJUST 0x8000000 /* clear justify attributes */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define NV_FUNCTION (NV_RJUST|NV_FUNCT) /* value is shell function */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define NV_FPOSIX NV_LJUST /* posix function semantics */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define NV_FTMP NV_ZFILL /* function source in tmpfile */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * can modify enviornment */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define BLT_EXIT (NV_RJUST) /* exit value can be > 255 */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define BLT_NOSFIO (NV_IMPORT) /* doesn't use sfio */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define NV_OPTGET (NV_BINARY) /* function calls getopts */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define nv_isref(n) (nv_isattr((n),NV_REF|NV_TAGGED|NV_FUNCT)==NV_REF)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define nv_istable(n) (nv_isattr((n),NV_TABLE|NV_LJUST|NV_RJUST|NV_INTEGER)==NV_TABLE)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define is_abuiltin(n) (nv_isattr(n,NV_BLTIN|NV_INTEGER)==NV_BLTIN)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define is_afunction(n) (nv_isattr(n,NV_FUNCTION|NV_REF)==NV_FUNCTION)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define NV_SUBQUOTE (NV_ADD<<1) /* used with nv_endsubscript */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* NAMNOD MACROS */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* ... for attributes */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define nv_context(n) ((void*)(n)->nvfun) /* for builtins */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* The following are for name references */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* ... etc */
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner#define _nv_hasget(np) ((np)->nvfun && (np)->nvfun->disc && nv_hasget(np))
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner#define nv_isnull(np) (!(np)->nvalue.cp && (nv_isattr(np,NV_SHORT|NV_INTEGER)!=(NV_SHORT|NV_INTEGER)) && !_nv_hasget(np))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* ... for arrays */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinextern int nv_arraysettype(Namval_t*, Namval_t*,const char*,int);
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainzextern void nv_setlist(struct argnod*, int, Namval_t*);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinextern struct argnod* nv_onlist(struct argnod*, const char*);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern char *nv_dirnext(void*);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern void nv_dirclose(void*);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern void nv_attribute(Namval_t*, Sfio_t*, char*, int);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern Namval_t *nv_bfsearch(const char*, Dt_t*, Namval_t**, char**);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern Namval_t *nv_mount(Namval_t*, const char *name, Dt_t*);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern Namval_t *nv_arraychild(Namval_t*, Namval_t*, int);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern int nv_compare(Dt_t*, Void_t*, Void_t*, Dtdisc_t*);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinextern void nv_outnode(Namval_t*,Sfio_t*, int, int);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern char nv_local;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinextern const char *nv_discnames[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_subscript[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_nullset[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_notset[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_noparent[];
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinextern const char e_notelem[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_readonly[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_badfield[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_restricted[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_ident[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_varname[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_noalias[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_noarray[];
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinextern const char e_notenum[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_aliname[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_badexport[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_badref[];
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainzextern const char e_badsubscript[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_noref[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_selfref[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_envmarker[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_badlocale[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_loop[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_redef[];
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinextern const char e_required[];
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinextern const char e_badappend[];
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinextern const char e_unknowntype[];
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainzextern const char e_globalref[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif /* _NV_PRIVATE */