awk.h revision 79777a7dd0179283917bda2ba98999c382d31c2c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* awk -- common header file.
*
* Copyright 1986, 1994 by Mortice Kern Systems Inc. All rights reserved.
*
* This version uses the POSIX.2 compatible <regex.h> routines.
*
*
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include <regex.h>
#include <errno.h>
#include <locale.h>
#include <wchar.h>
#include <widec.h>
#define M_LDATA 1
#ifdef M_LDATA
#else
#endif
#if BSD
/*
* A speedup for BSD. Use their routines which are
* already optimised. Note that BSD bcopy does not
* return a value.
*/
int bcmp();
void bcopy();
#endif /* BSD */
/*
* Basic AWK internal types.
*/
typedef double REAL;
typedef long long INT;
typedef void *REGEXP;
/*
* Node in the AWK interpreter expression tree.
*/
typedef struct NODE {
union {
struct {
union {
struct {
} n_str;
} n_tun;
} n_term;
struct {
} n_op;
struct {
} n_re;
} n_un;
} NODE;
/*
* Definitions to make the node access much easier.
*/
/*
* Compress the types that are actually used in the final tree
* to save space in the intermediate file. Allows 1 byte to
* represent all types
*/
/*
* n_flags bit assignments.
*/
/*
* n_flags macros
* These work when given an argument of np->n_flags
*/
/*
* Prototype file size is defined in awksize.h
*/
/*
* Awkrun prototype default name
*/
#if defined(DOS)
#if defined(__386__)
#else
#endif
#else
#endif
/*
* This is a kludge that gets around a bug in compact & large
* models under DOS. It also makes the generated
* code faster even if there wasn't a bug. UNIX people: try
* to ignore these noisy "near" declarations.
*/
#ifndef DOS
#define near
#endif
/*
* Form of builtin symbols
* This should be a union because only one of r_ivalue
* and r_svalue is needed, but (alas) unions cannot be
* initialised.
*/
typedef struct RESERVED {
int r_type; /* Type of node */
} RESERVED;
/*
* Table of builtin functions.
*/
typedef struct RESFUNC {
int rf_type; /* FUNC || GETLINE */
} RESFUNC;
/*
* Structure holding list of open files.
*/
typedef struct OFILE {
char *f_name; /* Remembered file name */
} OFILE;
/* Global functions -- awk.y */
int yyparse(void);
/* Global functions -- awk1.c */
#ifdef __WATCOMC__
#endif
int yylex(void);
/* Global functions -- awk2.c */
void awk(void);
void dobegin(void);
/* Global functions -- awk3.c */
void fieldsplit(void);
/* Global functions -- awk4.c */
/* In awk0.c */
extern char r[];
extern char w[];
extern unsigned char inprint;
extern unsigned char funparm;
extern unsigned char splitdone;
extern wchar_t radixpoint;
extern long NIOSTREAM; /* Maximum open I/O streams */
extern char interr[];
extern char nomem[];
extern NODE *constundef;
extern NODE *varCONVFMT;
extern NODE *varENVIRON;
extern NODE *varFILENAME;
extern char *mbunconvert(wchar_t *);
extern wchar_t *mbstowcsdup(char *);
extern char *wcstombsdup(wchar_t *);
extern void awkerr(char *, ...);
/*
* The following defines the expected max length in chars of a printed number.
* This should be the longest expected size for any type of number
* ie. float, long etc. This number is used to calculate the approximate
* number of chars needed to hold the number.
*/
#ifdef M_NUMSIZE
#else
#define NUMSIZE 30
#endif
#define M_MB_L(s) L##s
#ifdef __STDC__
#define ANSI(x) x
#else
#define const
#define signed
#define volatile
#define ANSI(x) ()
#endif
/*
* Wide character version of regular expression functions.
*/
#define REGWMATCH_T int_regwmatch_t
#define REGWCOMP int_regwcomp
#define REGWEXEC int_regwexec
#define REGWFREE int_regwfree
#define REGWERROR int_regwerror
#define REGWDOSUBA int_regwdosuba
typedef struct {
int_regwmatch_t *, int);
extern void int_regwfree(REGEXP);