1.fp 5 CW 2.de Af 3.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2 4.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" 5.. 6.de aF 7.ie \\$3 .ft \\$1 8.el \{\ 9.ds ;G \& 10.nr ;G \\n(.f 11.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" 12\\*(;G 13.ft \\n(;G \} 14.. 15.de L 16.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 17.. 18.de LR 19.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 20.. 21.de RL 22.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 23.. 24.de EX \" start example 25.ta 1i 2i 3i 4i 5i 6i 26.PP 27.PD 0 28.ft 5 29.nf 30.. 31.de EE \" end example 32.fi 33.ft 34.PD 35.PP 36.. 37.de Tp 38.fl 39.ne 3 40.TP 41.. 42.de Ss 43.fl 44.ne 3 45.SS "\\$1" 46.. 47.ta 1.0i 2.0i 3.0i 4.0i 5.0i 48.TH ASTSA 3 49.SH NAME 50astsa \- standalone libast support 51.SH SYNOPSIS 52.EX 53#include <ast.h> 54#include <ccode.h> 55#include <error.h> 56#include <option.h> 57#include <stk.h> 58.EE 59.SH DESCRIPTION 60.B astsa 61is a standalone subset of 62.BR ast (3) 63that requires only 64.BR cdt (3) 65and 66.BR sfio (3). 67.PP 68.B <ast.h> 69includes 70.BR <ast_common.h> , 71.B <stdarg.h> 72or 73.BR <varargs.h> , 74.BR <sfio.h> , 75.BR <limits.h> , 76and 77.B <limits.h> 78and 79.B <unistd.h> 80if supported by the local system. 81.PP 82The macros and functions provided by 83.B <ast.h> 84are described below. 85The other headers are described in 86.BR ccode (3), 87.BR error (3), 88.BR optget (3), 89and 90.BR stk (3). 91.SH MACROS 92.Ss "size_t elementsof(\fIx\fP)" 93Evaluates to the number of elements in the array variable 94.IR x . 95.Ss "\fItype\fP* newof(void* old, \fItype\fP, size_t \fIelements\fP, size_t \fIextra\fP)" 96Equivalent to (\fItype\fP*)realloc((char*)\fIold\fP,sizeof(\fItype\fP)*\fIelements\fP+\fIextra\fP) 97if \fIold\fP!=0 and 98(\fItype\fP*)calloc(1,sizeof(\fItype\fP)*\fIelements\fP+\fIextra\fP) 99otherwise. 100.Ss "\fItype\fP* oldof(void* old, \fItype\fP, size_t \fIelements\fP, size_t \fIextra\fP)" 101Equivalent to (\fItype\fP*)realloc((char*)\fIold\fP,sizeof(\fItype\fP)*\fIelements\fP+\fIextra\fP) 102if \fIold\fP!=0 and 103(\fItype\fP*)malloc(1,sizeof(\fItype\fP)*\fIelements\fP+\fIextra\fP) 104otherwise. 105.Ss "size_t roundof(\fIx\fP,\fIy\fP)" 106Evaluates to \fIx\fP rounded up to the next power of 2 boundary \fIy\fP. 107.Ss "int ssizeof(\fIx\fP)" 108Equivalent to (int)sizeof(\fIx\fP). 109.Ss "int streq(\fIa\fP,\fIb\fP)" 110Equivalent to (*(\fIa\fP)==*(\fIb\fP)&&strcmp(\fIa\fP,\fIb\fP)==0). 111.Ss "int strneq(\fIa\fP,\fIb\fP,\fIn\fP)" 112Equivalent to (*(\fIa\fP)==*(\fIb\fP)&&strncmp(\fIa\fP,\fIb\fP,\fIn\fP)==0). 113.SH FUNCTIONS 114.Ss "void astwinsize(int \fIfd\fP, int* \fIplines\fP, int* \fIpcolumns\fP)" 115If \fIplines\fP!=0 then *\fIplines\fP is set to the number of lines on the 116tty device corresponding to \fIfd\fP. 117If \fIpcolumns\fP!=0 then *\fIpcolumns\fP is set to the number of columns 118on the tty device corresponding to \fIfd\fP. 119The default if \fIfd\fP is not a terminal device, or if \fIfd\fP queries fail, 120is 24 lines and 80 columns. 121.Ss "char* fmterror(int \fIerrno\fP)" 122Returns the error message text corresponding to the 123.BR errno (3) 124\fIerrno\fP. 125.Ss "char* strerror(int \fIerrno\fP)" 126Equivalent to fmterror(\fIerrno\fP). 127.Ss "int strgrpmatch(const char* \fIstring\fP, const char* \fIpattern\fP, int* \fIsub\fP, int \fInsub\fP, int \fIflags\fP)" 128Matches the null terminated \fIstring\fP against the null terminated 129.BR ksh (1) 130augmented \fIpattern\fP. 131If \fIsub\fP!=0 then \fIsub\fP[2*\fIi\fP] is set to the start offset and \fIsub\fP[2*\fIi\fP+1] is set 132to the end offset of the \fIi\fP-th parenthesized subexpression. 133\fInsub\fP is 1/2 the number of elements in \fIsub\fP. 134\fIflags\fP controls the matching: 135.Tp 136\f5STR_MAXIMAL\fP: 137Maximal match. 138The default is minimal (first) match. 139.Tp 140\f5STR_LEFT\fP: 141Implicit left anchor. 142.Tp 143\f5STR_RIGHT\fP: 144Implicit right anchor. 145.Tp 146\f5STR_ICASE\fP: 147Ignore case. 148.Tp 149\f5STR_GROUP\fP: 150(|&) inside [@|*|+{n,m}](...) only. 151.Ss "int strmatch(const char* \fIstring\fP, const char* \fIpattern\fP, int* \fIsub\fP, int \fInsub\fP, int \fIflags\fP)" 152Equivalent to strgrpmatch(\fIstring\fP,\fIpattern\fP,0,0,STR_MAXIMAL|STR_LEFT|STR_RIGHT). 153.SH "SEE ALSO" 154.BR ast (3), 155.BR ccode (3), 156.BR cdt (3), 157.BR error (3), 158.BR malloc (3), 159.BR option (3), 160.BR sfio (3), 161.BR stk (3) 162