17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 23*9fb11590Smike_s * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 27*9fb11590Smike_s #ifndef _ERROR_H 28*9fb11590Smike_s #define _ERROR_H 29*9fb11590Smike_s 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 32*9fb11590Smike_s #ifdef __cplusplus 33*9fb11590Smike_s extern "C" { 34*9fb11590Smike_s #endif 35*9fb11590Smike_s 367c478bd9Sstevel@tonic-gate typedef int boolean; 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #define TRUE 1 397c478bd9Sstevel@tonic-gate #define FALSE 0 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #define true 1 427c478bd9Sstevel@tonic-gate #define false 0 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * Descriptors for the various languages we know about. 457c478bd9Sstevel@tonic-gate * If you touch these, also touch lang_table 467c478bd9Sstevel@tonic-gate */ 477c478bd9Sstevel@tonic-gate #define INUNKNOWN 0 487c478bd9Sstevel@tonic-gate #define INCPP 1 497c478bd9Sstevel@tonic-gate #define INCC 2 507c478bd9Sstevel@tonic-gate #define INAS 3 517c478bd9Sstevel@tonic-gate #define INLD 4 527c478bd9Sstevel@tonic-gate #define INLINT 5 537c478bd9Sstevel@tonic-gate #define INF77 6 547c478bd9Sstevel@tonic-gate #define INPI 7 557c478bd9Sstevel@tonic-gate #define INPC 8 567c478bd9Sstevel@tonic-gate #define INFRANZ 9 577c478bd9Sstevel@tonic-gate #define INLISP 10 587c478bd9Sstevel@tonic-gate #define INVAXIMA 11 597c478bd9Sstevel@tonic-gate #define INRATFOR 12 607c478bd9Sstevel@tonic-gate #define INLEX 13 617c478bd9Sstevel@tonic-gate #define INYACC 14 627c478bd9Sstevel@tonic-gate #define INAPL 15 637c478bd9Sstevel@tonic-gate #define INMAKE 16 647c478bd9Sstevel@tonic-gate #define INRI 17 657c478bd9Sstevel@tonic-gate #define INTROFF 18 667c478bd9Sstevel@tonic-gate #define INMOD2 19 677c478bd9Sstevel@tonic-gate #define INSUNF77 20 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate extern int language; 70*9fb11590Smike_s 71*9fb11590Smike_s extern boolean notouch; 72*9fb11590Smike_s 737c478bd9Sstevel@tonic-gate /* 747c478bd9Sstevel@tonic-gate * We analyze each line in the error message file, and 757c478bd9Sstevel@tonic-gate * attempt to categorize it by type, as well as language. 767c478bd9Sstevel@tonic-gate * Here are the type descriptors. 777c478bd9Sstevel@tonic-gate */ 787c478bd9Sstevel@tonic-gate typedef int Errorclass; 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate #define C_FIRST 0 /* first error category */ 817c478bd9Sstevel@tonic-gate #define C_UNKNOWN 0 /* must be zero */ 827c478bd9Sstevel@tonic-gate #define C_IGNORE 1 /* ignore the message; used for pi */ 837c478bd9Sstevel@tonic-gate #define C_SYNC 2 /* synchronization errors */ 847c478bd9Sstevel@tonic-gate #define C_DISCARD 3 /* touches dangerous files, so discard */ 857c478bd9Sstevel@tonic-gate #define C_NONSPEC 4 /* not specific to any file */ 867c478bd9Sstevel@tonic-gate #define C_THISFILE 5 /* specific to this file, but at no line */ 877c478bd9Sstevel@tonic-gate #define C_NULLED 6 /* refers to special func; so null */ 887c478bd9Sstevel@tonic-gate #define C_TRUE 7 /* fits into true error format */ 897c478bd9Sstevel@tonic-gate #define C_DUPL 8 /* sub class only; duplicated error message */ 907c478bd9Sstevel@tonic-gate #define C_LAST 9 /* last error category */ 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate #define SORTABLE(x) (!(NOTSORTABLE(x))) 937c478bd9Sstevel@tonic-gate #define NOTSORTABLE(x) (x <= C_NONSPEC) 947c478bd9Sstevel@tonic-gate /* 957c478bd9Sstevel@tonic-gate * Resources to count and print out the error categories 967c478bd9Sstevel@tonic-gate */ 977c478bd9Sstevel@tonic-gate extern char *class_table[]; 987c478bd9Sstevel@tonic-gate extern int class_count[]; 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate #define nunknown class_count[C_UNKNOWN] 1017c478bd9Sstevel@tonic-gate #define nignore class_count[C_IGNORE] 1027c478bd9Sstevel@tonic-gate #define nsyncerrors class_count[C_SYNC] 1037c478bd9Sstevel@tonic-gate #define ndiscard class_count[C_DISCARD] 1047c478bd9Sstevel@tonic-gate #define nnonspec class_count[C_NONSPEC] 1057c478bd9Sstevel@tonic-gate #define nthisfile class_count[C_THISFILE] 1067c478bd9Sstevel@tonic-gate #define nnulled class_count[C_NULLED] 1077c478bd9Sstevel@tonic-gate #define ntrue class_count[C_TRUE] 1087c478bd9Sstevel@tonic-gate #define ndupl class_count[C_DUPL] 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate /* places to put the error complaints */ 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate #define TOTHEFILE 1 /* touch the file */ 1137c478bd9Sstevel@tonic-gate #define TOSTDOUT 2 /* just print them out (ho-hum) */ 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate FILE *errorfile; /* where error file comes from */ 1167c478bd9Sstevel@tonic-gate FILE *queryfile; /* where the query responses from the user come from */ 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate extern char *currentfilename; 1197c478bd9Sstevel@tonic-gate extern char *processname; 1207c478bd9Sstevel@tonic-gate extern char *scriptname; 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate extern boolean query; 1237c478bd9Sstevel@tonic-gate extern boolean terse; 124*9fb11590Smike_s int inquire(char *format, ...); /* inquire for yes/no */ 1257c478bd9Sstevel@tonic-gate /* 1267c478bd9Sstevel@tonic-gate * codes for inquire() to return 1277c478bd9Sstevel@tonic-gate */ 1287c478bd9Sstevel@tonic-gate #define Q_NO 1 /* 'N' */ 1297c478bd9Sstevel@tonic-gate #define Q_no 2 /* 'n' */ 1307c478bd9Sstevel@tonic-gate #define Q_YES 3 /* 'Y' */ 1317c478bd9Sstevel@tonic-gate #define Q_yes 4 /* 'y' */ 1327c478bd9Sstevel@tonic-gate 133*9fb11590Smike_s int probethisfile(char *name); 1347c478bd9Sstevel@tonic-gate /* 1357c478bd9Sstevel@tonic-gate * codes for probethisfile to return 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate #define F_NOTEXIST 1 1387c478bd9Sstevel@tonic-gate #define F_NOTREAD 2 1397c478bd9Sstevel@tonic-gate #define F_NOTWRITE 3 1407c478bd9Sstevel@tonic-gate #define F_TOUCHIT 4 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate /* 1437c478bd9Sstevel@tonic-gate * Describes attributes about a language 1447c478bd9Sstevel@tonic-gate */ 1457c478bd9Sstevel@tonic-gate struct lang_desc { 1467c478bd9Sstevel@tonic-gate char *lang_name; 1477c478bd9Sstevel@tonic-gate char *lang_incomment; /* one of the following defines */ 1487c478bd9Sstevel@tonic-gate char *lang_outcomment; /* one of the following defines */ 1497c478bd9Sstevel@tonic-gate }; 1507c478bd9Sstevel@tonic-gate extern struct lang_desc lang_table[]; 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate #define CINCOMMENT "/*###" 1537c478bd9Sstevel@tonic-gate #define COUTCOMMENT "%%%*/\n" 1547c478bd9Sstevel@tonic-gate #define FINCOMMENT "C###" 1557c478bd9Sstevel@tonic-gate #define FOUTCOMMENT "%%%\n" 1567c478bd9Sstevel@tonic-gate #define NEWLINE "%%%\n" 1577c478bd9Sstevel@tonic-gate #define PIINCOMMENT "(*###" 1587c478bd9Sstevel@tonic-gate #define PIOUTCOMMENT "%%%*)\n" 1597c478bd9Sstevel@tonic-gate #define LISPINCOMMENT ";###" 1607c478bd9Sstevel@tonic-gate #define ASINCOMMENT "####" 1617c478bd9Sstevel@tonic-gate #define RIINCOMMENT CINCOMMENT 1627c478bd9Sstevel@tonic-gate #define RIOUTCOMMENT COUTCOMMENT 1637c478bd9Sstevel@tonic-gate #define TROFFINCOMMENT ".\\\"###" 1647c478bd9Sstevel@tonic-gate #define TROFFOUTCOMMENT NEWLINE 1657c478bd9Sstevel@tonic-gate #define MOD2INCOMMENT "(*###" 1667c478bd9Sstevel@tonic-gate #define MOD2OUTCOMMENT "%%%*)\n" 1677c478bd9Sstevel@tonic-gate /* 1687c478bd9Sstevel@tonic-gate * Defines and resources for determing if a given line 1697c478bd9Sstevel@tonic-gate * is to be discarded because it refers to a file not to 1707c478bd9Sstevel@tonic-gate * be touched, or if the function reference is to a 1717c478bd9Sstevel@tonic-gate * function the user doesn't want recorded. 1727c478bd9Sstevel@tonic-gate */ 1737c478bd9Sstevel@tonic-gate #define IG_FILE1 "llib-lc" 1747c478bd9Sstevel@tonic-gate #define IG_FILE2 "llib-port" 1757c478bd9Sstevel@tonic-gate #define IG_FILE3 "/usr/lib/llib-lc" 1767c478bd9Sstevel@tonic-gate #define IG_FILE4 "/usr/lib/llib-port" 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate #define ERRORNAME "/.errorrc" 1797c478bd9Sstevel@tonic-gate int nignored; 1807c478bd9Sstevel@tonic-gate char **names_ignored; 1817c478bd9Sstevel@tonic-gate /* 1827c478bd9Sstevel@tonic-gate * Structure definition for a full error 1837c478bd9Sstevel@tonic-gate */ 1847c478bd9Sstevel@tonic-gate typedef struct edesc Edesc; 1857c478bd9Sstevel@tonic-gate typedef Edesc *Eptr; 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate struct edesc { 1887c478bd9Sstevel@tonic-gate Eptr error_next; /* linked together */ 1897c478bd9Sstevel@tonic-gate int error_lgtext; /* how many on the right hand side */ 1907c478bd9Sstevel@tonic-gate char **error_text; /* the right hand side proper */ 1917c478bd9Sstevel@tonic-gate Errorclass error_e_class; /* error category of this error */ 1927c478bd9Sstevel@tonic-gate Errorclass error_s_class; /* sub descriptor of error_e_class */ 1937c478bd9Sstevel@tonic-gate int error_language; /* the language for this error */ 1947c478bd9Sstevel@tonic-gate int error_position; /* oridinal position */ 1957c478bd9Sstevel@tonic-gate int error_line; /* discovered line number */ 1967c478bd9Sstevel@tonic-gate int error_no; /* sequence number on input */ 1977c478bd9Sstevel@tonic-gate }; 1987c478bd9Sstevel@tonic-gate /* 1997c478bd9Sstevel@tonic-gate * Resources for the true errors 2007c478bd9Sstevel@tonic-gate */ 2017c478bd9Sstevel@tonic-gate extern int nerrors; 2027c478bd9Sstevel@tonic-gate extern Eptr er_head; 2037c478bd9Sstevel@tonic-gate extern Eptr *errors; 2047c478bd9Sstevel@tonic-gate /* 2057c478bd9Sstevel@tonic-gate * Resources for each of the files mentioned 2067c478bd9Sstevel@tonic-gate */ 2077c478bd9Sstevel@tonic-gate extern int nfiles; 2087c478bd9Sstevel@tonic-gate extern Eptr **files; /* array of pointers into errors */ 2097c478bd9Sstevel@tonic-gate boolean *touchedfiles; /* which files we touched */ 2107c478bd9Sstevel@tonic-gate /* 2117c478bd9Sstevel@tonic-gate * The langauge the compilation is in, as intuited from 2127c478bd9Sstevel@tonic-gate * the flavor of error messages analyzed. 2137c478bd9Sstevel@tonic-gate */ 2147c478bd9Sstevel@tonic-gate extern int langauge; 2157c478bd9Sstevel@tonic-gate extern char *currentfilename; 2167c478bd9Sstevel@tonic-gate /* 2177c478bd9Sstevel@tonic-gate * Functional forwards 2187c478bd9Sstevel@tonic-gate */ 219*9fb11590Smike_s void *Calloc(int nelements, int size); 220*9fb11590Smike_s char *strsave(char *instring); 221*9fb11590Smike_s char lastchar(char *string); 222*9fb11590Smike_s char firstchar(char *string); 223*9fb11590Smike_s char next_lastchar(char *string); 224*9fb11590Smike_s char **wordvsplice(int emptyhead, int wordc, char **wordv); 225*9fb11590Smike_s int wordvcmp(char **wordv1, int wordc, char **wordv2); 226*9fb11590Smike_s boolean persperdexplode(char *string, char **r_perd, char **r_pers); 2277c478bd9Sstevel@tonic-gate /* 2287c478bd9Sstevel@tonic-gate * Printing hacks 2297c478bd9Sstevel@tonic-gate */ 230*9fb11590Smike_s char *plural(int n); 231*9fb11590Smike_s char *verbform(int n); 232*9fb11590Smike_s 233*9fb11590Smike_s void erroradd(int errorlength, char **errorv, Errorclass errorclass, 234*9fb11590Smike_s Errorclass errorsubclass); 235*9fb11590Smike_s void eaterrors(int *r_errorc, Eptr **r_errorv); 236*9fb11590Smike_s void wordvbuild(char *string, int *r_wordc, char ***r_wordv); 237*9fb11590Smike_s void wordvprint(FILE *fyle, int wordc, char *wordv[]); 238*9fb11590Smike_s void printerrors(boolean look_at_subclass, int errorc, Eptr errorv[]); 239*9fb11590Smike_s void clob_last(char *string, char newstuff); 240*9fb11590Smike_s void arrayify(int *e_length, Eptr **e_array, Eptr header); 241*9fb11590Smike_s void getignored(char *auxname); 242*9fb11590Smike_s void filenames(int nfiles, Eptr **files); 243*9fb11590Smike_s void findfiles(int nerrors, Eptr *errors, int *r_nfiles, Eptr ***r_files); 244*9fb11590Smike_s void onintr(int sig); 245*9fb11590Smike_s boolean touchfiles(int nfiles, Eptr **files, int *r_edargc, char ***r_edargv); 246*9fb11590Smike_s Errorclass discardit(Eptr errorp); 247*9fb11590Smike_s char *substitute(char *string, char chold, char chnew); 248*9fb11590Smike_s int position(char *string, char ch); 249*9fb11590Smike_s 250*9fb11590Smike_s #ifdef __cplusplus 251*9fb11590Smike_s } 252*9fb11590Smike_s #endif 253*9fb11590Smike_s 254*9fb11590Smike_s #endif /* _ERROR_H */ 255