1N/A
1N/A/* : : generated by proto : : */
1N/A/***********************************************************************
1N/A* *
1N/A* This software is part of the ast package *
1N/A* Copyright (c) 1982-2011 AT&T Intellectual Property *
1N/A* and is licensed under the *
1N/A* Common Public License, Version 1.0 *
1N/A* by AT&T Intellectual Property *
1N/A* *
1N/A* A copy of the License is available at *
1N/A* http://www.opensource.org/licenses/cpl1.0.txt *
1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
1N/A* *
1N/A* Information and Software Systems Research *
1N/A* AT&T Research *
1N/A* Florham Park NJ *
1N/A* *
1N/A* David Korn <dgk@research.att.com> *
1N/A* *
1N/A***********************************************************************/
1N/A
1N/A#ifndef NV_DEFAULT
1N/A#if !defined(__PROTO__)
1N/A#include <prototyped.h>
1N/A#endif
1N/A#if !defined(__LINKAGE__)
1N/A#define __LINKAGE__ /* 2004-08-11 transition */
1N/A#endif
1N/A
1N/A/*
1N/A * David Korn
1N/A * AT&T Labs
1N/A *
1N/A * Interface definitions of structures for name-value pairs
1N/A * These structures are used for named variables, functions and aliases
1N/A *
1N/A */
1N/A
1N/A
1N/A#include <ast.h>
1N/A#include <cdt.h>
1N/A#include <option.h>
1N/A
1N/A/* for compatibility with old hash library */
1N/A#define Hashtab_t Dt_t
1N/A#define HASH_BUCKET 1
1N/A#define HASH_NOSCOPE 2
1N/A#define HASH_SCOPE 4
1N/A#define hashscope(x) dtvnext(x)
1N/A
1N/Atypedef struct Namval Namval_t;
1N/Atypedef struct Namfun Namfun_t;
1N/Atypedef struct Namdisc Namdisc_t;
1N/Atypedef struct Nambfun Nambfun_t;
1N/Atypedef struct Namarray Namarr_t;
1N/Atypedef struct Namdecl Namdecl_t;
1N/A
1N/A/*
1N/A * This defines the template for nodes that have their own assignment
1N/A * and or lookup functions
1N/A */
1N/Astruct Namdisc
1N/A{
1N/A size_t dsize;
1N/A void (*putval) __PROTO__((Namval_t*, const char*, int, Namfun_t*));
1N/A char *(*getval) __PROTO__((Namval_t*, Namfun_t*));
1N/A Sfdouble_t (*getnum) __PROTO__((Namval_t*, Namfun_t*));
1N/A char *(*setdisc) __PROTO__((Namval_t*, const char*, Namval_t*, Namfun_t*));
1N/A Namval_t *(*createf) __PROTO__((Namval_t*, const char*, int, Namfun_t*));
1N/A Namfun_t *(*clonef) __PROTO__((Namval_t*, Namval_t*, int, Namfun_t*));
1N/A char *(*namef) __PROTO__((Namval_t*, Namfun_t*));
1N/A Namval_t *(*nextf) __PROTO__((Namval_t*, Dt_t*, Namfun_t*));
1N/A Namval_t *(*typef) __PROTO__((Namval_t*, Namfun_t*));
1N/A int (*readf) __PROTO__((Namval_t*, Sfio_t*, int, Namfun_t*));
1N/A int (*writef) __PROTO__((Namval_t*, Sfio_t*, int, Namfun_t*));
1N/A};
1N/A
1N/Astruct Namfun
1N/A{
1N/A const Namdisc_t *disc;
1N/A char nofree;
1N/A unsigned char subshell;
1N/A unsigned short dsize;
1N/A Namfun_t *next;
1N/A char *last;
1N/A Namval_t *type;
1N/A};
1N/A
1N/Astruct Nambfun
1N/A{
1N/A Namfun_t fun;
1N/A int num;
1N/A const char **bnames;
1N/A Namval_t *bltins[1];
1N/A};
1N/A
1N/A/* This is an array template header */
1N/Astruct Namarray
1N/A{
1N/A Namfun_t hdr;
1N/A long nelem; /* number of elements */
1N/A __V_ *(*fun) __PROTO__((Namval_t*,const char*,int)); /* associative arrays */
1N/A __V_ *fixed; /* for fixed sized arrays */
1N/A Dt_t *table; /* for subscripts */
1N/A __V_ *scope; /* non-zerp when scoped */
1N/A};
1N/A
1N/A/* The context pointer for declaration command */
1N/Astruct Namdecl
1N/A{
1N/A Namval_t *tp; /* point to type */
1N/A const char *optstring;
1N/A __V_ *optinfof;
1N/A};
1N/A
1N/A/* attributes of name-value node attribute flags */
1N/A
1N/A#define NV_DEFAULT 0
1N/A/* This defines the attributes for an attributed name-value pair node */
1N/Astruct Namval
1N/A{
1N/A Dtlink_t nvlink; /* space for cdt links */
1N/A char *nvname; /* pointer to name of the node */
1N/A unsigned short nvflag; /* attributes */
1N/A unsigned short nvsize; /* size or base */
1N/A#ifdef _NV_PRIVATE
1N/A _NV_PRIVATE
1N/A#else
1N/A Namfun_t *nvfun;
1N/A char *nvalue;
1N/A char *nvprivate;
1N/A#endif /* _NV_PRIVATE */
1N/A};
1N/A
1N/A#define NV_CLASS ".sh.type"
1N/A#define NV_DATA "_" /* special class or instance variable */
1N/A#define NV_MINSZ (sizeof(struct Namval)-sizeof(Dtlink_t)-sizeof(char*))
1N/A#define nv_namptr(p,n) ((Namval_t*)((char*)(p)+(n)*NV_MINSZ-sizeof(Dtlink_t)))
1N/A
1N/A/* The following attributes are for internal use */
1N/A#define NV_NOFREE 0x200 /* don't free the space when releasing value */
1N/A#define NV_ARRAY 0x400 /* node is an array */
1N/A#define NV_REF 0x4000 /* reference bit */
1N/A#define NV_TABLE 0x800 /* node is a dictionary table */
1N/A#define NV_IMPORT 0x1000 /* value imported from environment */
1N/A#define NV_MINIMAL NV_IMPORT /* node does not contain all fields */
1N/A
1N/A#define NV_INTEGER 0x2 /* integer attribute */
1N/A/* The following attributes are valid only when NV_INTEGER is off */
1N/A#define NV_LTOU 0x4 /* convert to uppercase */
1N/A#define NV_UTOL 0x8 /* convert to lowercase */
1N/A#define NV_ZFILL 0x10 /* right justify and fill with leading zeros */
1N/A#define NV_RJUST 0x20 /* right justify and blank fill */
1N/A#define NV_LJUST 0x40 /* left justify and blank fill */
1N/A#define NV_BINARY 0x100 /* fixed size data buffer */
1N/A#define NV_RAW NV_LJUST /* used only with NV_BINARY */
1N/A#define NV_HOST (NV_RJUST|NV_LJUST) /* map to host filename */
1N/A
1N/A/* The following attributes do not effect the value */
1N/A#define NV_RDONLY 0x1 /* readonly bit */
1N/A#define NV_EXPORT 0x2000 /* export bit */
1N/A#define NV_TAGGED 0x8000 /* user define tag bit */
1N/A
1N/A/* The following are used with NV_INTEGER */
1N/A#define NV_SHORT (NV_RJUST) /* when integers are not long */
1N/A#define NV_LONG (NV_UTOL) /* for long long and long double */
1N/A#define NV_UNSIGN (NV_LTOU) /* for unsigned quantities */
1N/A#define NV_DOUBLE (NV_INTEGER|NV_ZFILL) /* for floating point */
1N/A#define NV_EXPNOTE (NV_LJUST) /* for scientific notation */
1N/A#define NV_HEXFLOAT (NV_LTOU) /* for C99 base16 float notation */
1N/A
1N/A/* options for nv_open */
1N/A
1N/A#define NV_APPEND 0x10000 /* append value */
1N/A#define NV_MOVE 0x8000000 /* for use with nv_clone */
1N/A#define NV_ADD 8
1N/A /* add node if not found */
1N/A#define NV_ASSIGN NV_NOFREE /* assignment is possible */
1N/A#define NV_NOASSIGN 0 /* backward compatibility */
1N/A#define NV_NOARRAY 0x200000 /* array name not possible */
1N/A#define NV_IARRAY 0x400000 /* for indexed array */
1N/A#define NV_NOREF NV_REF /* don't follow reference */
1N/A#define NV_IDENT 0x80 /* name must be identifier */
1N/A#define NV_VARNAME 0x20000 /* name must be ?(.)id*(.id) */
1N/A#define NV_NOADD 0x40000 /* do not add node */
1N/A#define NV_NOSCOPE 0x80000 /* look only in current scope */
1N/A#define NV_NOFAIL 0x100000 /* return 0 on failure, no msg */
1N/A#define NV_NODISC NV_IDENT /* ignore disciplines */
1N/A
1N/A#define NV_FUNCT NV_IDENT /* option for nv_create */
1N/A#define NV_BLTINOPT NV_ZFILL /* mark builtins in libcmd */
1N/A
1N/A#define NV_PUBLIC (~(NV_NOSCOPE|NV_ASSIGN|NV_IDENT|NV_VARNAME|NV_NOADD))
1N/A
1N/A/* numeric types */
1N/A#define NV_INT16P (NV_LJUST|NV_SHORT|NV_INTEGER)
1N/A#define NV_INT16 (NV_SHORT|NV_INTEGER)
1N/A#define NV_UINT16 (NV_UNSIGN|NV_SHORT|NV_INTEGER)
1N/A#define NV_UINT16P (NV_LJUSTNV_UNSIGN|NV_SHORT|NV_INTEGER)
1N/A#define NV_INT32 (NV_INTEGER)
1N/A#define NV_UNT32 (NV_UNSIGN|NV_INTEGER)
1N/A#define NV_INT64 (NV_LONG|NV_INTEGER)
1N/A#define NV_UINT64 (NV_UNSIGN|NV_LONG|NV_INTEGER)
1N/A#define NV_FLOAT (NV_SHORT|NV_DOUBLE)
1N/A#define NV_LDOUBLE (NV_LONG|NV_DOUBLE)
1N/A
1N/A/* name-value pair macros */
1N/A#define nv_isattr(np,f) ((np)->nvflag & (f))
1N/A#define nv_onattr(n,f) ((n)->nvflag |= (f))
1N/A#define nv_offattr(n,f) ((n)->nvflag &= ~(f))
1N/A#define nv_isarray(np) (nv_isattr((np),NV_ARRAY))
1N/A
1N/A/* The following are operations for associative arrays */
1N/A#define NV_AINIT 1 /* initialize */
1N/A#define NV_AFREE 2 /* free array */
1N/A#define NV_ANEXT 3 /* advance to next subscript */
1N/A#define NV_ANAME 4 /* return subscript name */
1N/A#define NV_ADELETE 5 /* delete current subscript */
1N/A#define NV_AADD 6 /* add subscript if not found */
1N/A#define NV_ACURRENT 7 /* return current subscript Namval_t* */
1N/A#define NV_ASETSUB 8 /* set current subscript */
1N/A
1N/A/* The following are for nv_disc */
1N/A#define NV_FIRST 1
1N/A#define NV_LAST 2
1N/A#define NV_POP 3
1N/A#define NV_CLONE 4
1N/A
1N/A/* The following are operations for nv_putsub() */
1N/A#define ARRAY_BITS 22
1N/A#define ARRAY_ADD (1L<<ARRAY_BITS) /* add subscript if not found */
1N/A#define ARRAY_SCAN (2L<<ARRAY_BITS) /* For ${array[@]} */
1N/A#define ARRAY_UNDEF (4L<<ARRAY_BITS) /* For ${array} */
1N/A
1N/A
1N/A/* These are disciplines provided by the library for use with nv_discfun */
1N/A#define NV_DCADD 0 /* used to add named disciplines */
1N/A#define NV_DCRESTRICT 1 /* variable that are restricted in rsh */
1N/A
1N/A#if defined(__EXPORT__) && defined(_DLL)
1N/A# ifdef _BLD_shell
1N/A#undef __MANGLE__
1N/A#define __MANGLE__ __LINKAGE__ __EXPORT__
1N/A# else
1N/A#undef __MANGLE__
1N/A#define __MANGLE__ __LINKAGE__ __IMPORT__
1N/A# endif /* _BLD_shell */
1N/A#endif /* _DLL */
1N/A/* prototype for array interface*/
1N/Aextern __MANGLE__ Namarr_t *nv_arrayptr __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ Namarr_t *nv_setarray __PROTO__((Namval_t*,__V_*(*)(Namval_t*,const char*,int)));
1N/Aextern __MANGLE__ int nv_arraynsub __PROTO__((Namarr_t*));
1N/Aextern __MANGLE__ __V_ *nv_associative __PROTO__((Namval_t*,const char*,int));
1N/Aextern __MANGLE__ int nv_aindex __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ int nv_nextsub __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ char *nv_getsub __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ Namval_t *nv_putsub __PROTO__((Namval_t*, char*, long));
1N/Aextern __MANGLE__ Namval_t *nv_opensub __PROTO__((Namval_t*));
1N/A
1N/A/* name-value pair function prototypes */
1N/Aextern __MANGLE__ int nv_adddisc __PROTO__((Namval_t*, const char**, Namval_t**));
1N/Aextern __MANGLE__ int nv_clone __PROTO__((Namval_t*, Namval_t*, int));
1N/Aextern __MANGLE__ void nv_close __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ __V_ *nv_context __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ Namval_t *nv_create __PROTO__((const char*, Dt_t*, int,Namfun_t*));
1N/Aextern __MANGLE__ void nv_delete __PROTO__((Namval_t*, Dt_t*, int));
1N/Aextern __MANGLE__ Dt_t *nv_dict __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ Sfdouble_t nv_getn __PROTO__((Namval_t*, Namfun_t*));
1N/Aextern __MANGLE__ Sfdouble_t nv_getnum __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ char *nv_getv __PROTO__((Namval_t*, Namfun_t*));
1N/Aextern __MANGLE__ char *nv_getval __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ Namfun_t *nv_hasdisc __PROTO__((Namval_t*, const Namdisc_t*));
1N/Aextern __MANGLE__ int nv_isnull __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ Namfun_t *nv_isvtree __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ Namval_t *nv_lastdict __PROTO__((void));
1N/Aextern __MANGLE__ Namval_t *nv_mkinttype __PROTO__((char*, size_t, int, const char*, Namdisc_t*));
1N/Aextern __MANGLE__ void nv_newattr __PROTO__((Namval_t*,unsigned,int));
1N/Aextern __MANGLE__ void nv_newtype __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ Namval_t *nv_open __PROTO__((const char*,Dt_t*,int));
1N/Aextern __MANGLE__ void nv_putval __PROTO__((Namval_t*,const char*,int));
1N/Aextern __MANGLE__ void nv_putv __PROTO__((Namval_t*,const char*,int,Namfun_t*));
1N/Aextern __MANGLE__ int nv_rename __PROTO__((Namval_t*,int));
1N/Aextern __MANGLE__ int nv_scan __PROTO__((Dt_t*,void(*)(Namval_t*,__V_*),__V_*,int,int));
1N/Aextern __MANGLE__ char *nv_setdisc __PROTO__((Namval_t*,const char*,Namval_t*,Namfun_t*));
1N/Aextern __MANGLE__ void nv_setref __PROTO__((Namval_t*, Dt_t*,int));
1N/Aextern __MANGLE__ int nv_settype __PROTO__((Namval_t*, Namval_t*, int));
1N/Aextern __MANGLE__ void nv_setvec __PROTO__((Namval_t*,int,int,char*[]));
1N/Aextern __MANGLE__ void nv_setvtree __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ int nv_setsize __PROTO__((Namval_t*,int));
1N/Aextern __MANGLE__ Namfun_t *nv_disc __PROTO__((Namval_t*,Namfun_t*,int));
1N/Aextern __MANGLE__ void nv_unset __PROTO__((Namval_t*)); /*obsolete */
1N/Aextern __MANGLE__ void _nv_unset __PROTO__((Namval_t*,int));
1N/Aextern __MANGLE__ Namval_t *nv_search __PROTO__((const char *, Dt_t*, int));
1N/Aextern __MANGLE__ char *nv_name __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ Namval_t *nv_type __PROTO__((Namval_t*));
1N/Aextern __MANGLE__ void nv_addtype __PROTO__((Namval_t*,const char*, Optdisc_t*, size_t));
1N/Aextern __MANGLE__ const Namdisc_t *nv_discfun __PROTO__((int));
1N/A
1N/A#ifdef _DLL
1N/A#undef __MANGLE__
1N/A#define __MANGLE__ __LINKAGE__
1N/A#endif /* _DLL */
1N/A
1N/A#define nv_unset(np) _nv_unset(np,0)
1N/A#define nv_size(np) nv_setsize((np),-1)
1N/A#define nv_stack(np,nf) nv_disc(np,nf,0)
1N/A
1N/A#if 0
1N/A/*
1N/A * The names of many functions were changed in early '95
1N/A * Here is a mapping to the old names
1N/A */
1N/A# define nv_istype(np) nv_isattr(np)
1N/A# define nv_newtype(np) nv_newattr(np)
1N/A# define nv_namset(np,a,b) nv_open(np,a,b)
1N/A# define nv_free(np) nv_unset(np,0)
1N/A# define nv_settype(np,a,b,c) nv_setdisc(np,a,b,c)
1N/A# define nv_search(np,a,b) nv_open(np,a,((b)?0:NV_NOADD))
1N/A# define settype setdisc
1N/A#endif
1N/A
1N/A#endif /* NV_DEFAULT */