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 /* 239fb11590Smike_s * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 279fb11590Smike_s #ifndef _ERROR_H 289fb11590Smike_s #define _ERROR_H 299fb11590Smike_s 309fb11590Smike_s #ifdef __cplusplus 319fb11590Smike_s extern "C" { 329fb11590Smike_s #endif 339fb11590Smike_s 347c478bd9Sstevel@tonic-gate typedef int boolean; 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #define TRUE 1 377c478bd9Sstevel@tonic-gate #define FALSE 0 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #define true 1 407c478bd9Sstevel@tonic-gate #define false 0 417c478bd9Sstevel@tonic-gate /* 427c478bd9Sstevel@tonic-gate * Descriptors for the various languages we know about. 437c478bd9Sstevel@tonic-gate * If you touch these, also touch lang_table 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate #define INUNKNOWN 0 467c478bd9Sstevel@tonic-gate #define INCPP 1 477c478bd9Sstevel@tonic-gate #define INCC 2 487c478bd9Sstevel@tonic-gate #define INAS 3 497c478bd9Sstevel@tonic-gate #define INLD 4 507c478bd9Sstevel@tonic-gate #define INLINT 5 517c478bd9Sstevel@tonic-gate #define INF77 6 527c478bd9Sstevel@tonic-gate #define INPI 7 537c478bd9Sstevel@tonic-gate #define INPC 8 547c478bd9Sstevel@tonic-gate #define INFRANZ 9 557c478bd9Sstevel@tonic-gate #define INLISP 10 567c478bd9Sstevel@tonic-gate #define INVAXIMA 11 577c478bd9Sstevel@tonic-gate #define INRATFOR 12 587c478bd9Sstevel@tonic-gate #define INLEX 13 597c478bd9Sstevel@tonic-gate #define INYACC 14 607c478bd9Sstevel@tonic-gate #define INAPL 15 617c478bd9Sstevel@tonic-gate #define INMAKE 16 627c478bd9Sstevel@tonic-gate #define INRI 17 637c478bd9Sstevel@tonic-gate #define INTROFF 18 647c478bd9Sstevel@tonic-gate #define INMOD2 19 659fb11590Smike_s #define INSUNF77 20 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate extern int language; 689fb11590Smike_s 699fb11590Smike_s extern boolean notouch; 709fb11590Smike_s 717c478bd9Sstevel@tonic-gate /* 727c478bd9Sstevel@tonic-gate * We analyze each line in the error message file, and 737c478bd9Sstevel@tonic-gate * attempt to categorize it by type, as well as language. 747c478bd9Sstevel@tonic-gate * Here are the type descriptors. 757c478bd9Sstevel@tonic-gate */ 767c478bd9Sstevel@tonic-gate typedef int Errorclass; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate #define C_FIRST 0 /* first error category */ 797c478bd9Sstevel@tonic-gate #define C_UNKNOWN 0 /* must be zero */ 807c478bd9Sstevel@tonic-gate #define C_IGNORE 1 /* ignore the message; used for pi */ 817c478bd9Sstevel@tonic-gate #define C_SYNC 2 /* synchronization errors */ 827c478bd9Sstevel@tonic-gate #define C_DISCARD 3 /* touches dangerous files, so discard */ 837c478bd9Sstevel@tonic-gate #define C_NONSPEC 4 /* not specific to any file */ 847c478bd9Sstevel@tonic-gate #define C_THISFILE 5 /* specific to this file, but at no line */ 857c478bd9Sstevel@tonic-gate #define C_NULLED 6 /* refers to special func; so null */ 867c478bd9Sstevel@tonic-gate #define C_TRUE 7 /* fits into true error format */ 877c478bd9Sstevel@tonic-gate #define C_DUPL 8 /* sub class only; duplicated error message */ 887c478bd9Sstevel@tonic-gate #define C_LAST 9 /* last error category */ 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate #define SORTABLE(x) (!(NOTSORTABLE(x))) 917c478bd9Sstevel@tonic-gate #define NOTSORTABLE(x) (x <= C_NONSPEC) 927c478bd9Sstevel@tonic-gate /* 937c478bd9Sstevel@tonic-gate * Resources to count and print out the error categories 947c478bd9Sstevel@tonic-gate */ 957c478bd9Sstevel@tonic-gate extern char *class_table[]; 967c478bd9Sstevel@tonic-gate extern int class_count[]; 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate #define nunknown class_count[C_UNKNOWN] 997c478bd9Sstevel@tonic-gate #define nignore class_count[C_IGNORE] 1007c478bd9Sstevel@tonic-gate #define nsyncerrors class_count[C_SYNC] 1017c478bd9Sstevel@tonic-gate #define ndiscard class_count[C_DISCARD] 1027c478bd9Sstevel@tonic-gate #define nnonspec class_count[C_NONSPEC] 1037c478bd9Sstevel@tonic-gate #define nthisfile class_count[C_THISFILE] 1047c478bd9Sstevel@tonic-gate #define nnulled class_count[C_NULLED] 1057c478bd9Sstevel@tonic-gate #define ntrue class_count[C_TRUE] 1067c478bd9Sstevel@tonic-gate #define ndupl class_count[C_DUPL] 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* places to put the error complaints */ 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate #define TOTHEFILE 1 /* touch the file */ 1117c478bd9Sstevel@tonic-gate #define TOSTDOUT 2 /* just print them out (ho-hum) */ 1127c478bd9Sstevel@tonic-gate 113*28ab0ca4SToomas Soome extern FILE *errorfile; /* where error file comes from */ 114*28ab0ca4SToomas Soome extern FILE *queryfile; /* where the query responses from the user come from */ 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate extern char *currentfilename; 1177c478bd9Sstevel@tonic-gate extern char *processname; 1187c478bd9Sstevel@tonic-gate extern char *scriptname; 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate extern boolean query; 1217c478bd9Sstevel@tonic-gate extern boolean terse; 1229fb11590Smike_s int inquire(char *format, ...); /* inquire for yes/no */ 1239fb11590Smike_s /* 1247c478bd9Sstevel@tonic-gate * codes for inquire() to return 1257c478bd9Sstevel@tonic-gate */ 1267c478bd9Sstevel@tonic-gate #define Q_NO 1 /* 'N' */ 1277c478bd9Sstevel@tonic-gate #define Q_no 2 /* 'n' */ 1287c478bd9Sstevel@tonic-gate #define Q_YES 3 /* 'Y' */ 1297c478bd9Sstevel@tonic-gate #define Q_yes 4 /* 'y' */ 1307c478bd9Sstevel@tonic-gate 1319fb11590Smike_s int probethisfile(char *name); 1327c478bd9Sstevel@tonic-gate /* 1337c478bd9Sstevel@tonic-gate * codes for probethisfile to return 1347c478bd9Sstevel@tonic-gate */ 1357c478bd9Sstevel@tonic-gate #define F_NOTEXIST 1 1367c478bd9Sstevel@tonic-gate #define F_NOTREAD 2 1377c478bd9Sstevel@tonic-gate #define F_NOTWRITE 3 1387c478bd9Sstevel@tonic-gate #define F_TOUCHIT 4 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate /* 1417c478bd9Sstevel@tonic-gate * Describes attributes about a language 1427c478bd9Sstevel@tonic-gate */ 1439fb11590Smike_s struct lang_desc { 1447c478bd9Sstevel@tonic-gate char *lang_name; 1457c478bd9Sstevel@tonic-gate char *lang_incomment; /* one of the following defines */ 1467c478bd9Sstevel@tonic-gate char *lang_outcomment; /* one of the following defines */ 1477c478bd9Sstevel@tonic-gate }; 1487c478bd9Sstevel@tonic-gate extern struct lang_desc lang_table[]; 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate #define CINCOMMENT "/*###" 1517c478bd9Sstevel@tonic-gate #define COUTCOMMENT "%%%*/\n" 1527c478bd9Sstevel@tonic-gate #define FINCOMMENT "C###" 1537c478bd9Sstevel@tonic-gate #define FOUTCOMMENT "%%%\n" 1547c478bd9Sstevel@tonic-gate #define NEWLINE "%%%\n" 1557c478bd9Sstevel@tonic-gate #define PIINCOMMENT "(*###" 1567c478bd9Sstevel@tonic-gate #define PIOUTCOMMENT "%%%*)\n" 1577c478bd9Sstevel@tonic-gate #define LISPINCOMMENT ";###" 1587c478bd9Sstevel@tonic-gate #define ASINCOMMENT "####" 1597c478bd9Sstevel@tonic-gate #define RIINCOMMENT CINCOMMENT 1607c478bd9Sstevel@tonic-gate #define RIOUTCOMMENT COUTCOMMENT 1617c478bd9Sstevel@tonic-gate #define TROFFINCOMMENT ".\\\"###" 1627c478bd9Sstevel@tonic-gate #define TROFFOUTCOMMENT NEWLINE 1637c478bd9Sstevel@tonic-gate #define MOD2INCOMMENT "(*###" 1647c478bd9Sstevel@tonic-gate #define MOD2OUTCOMMENT "%%%*)\n" 1657c478bd9Sstevel@tonic-gate /* 1667c478bd9Sstevel@tonic-gate * Defines and resources for determing if a given line 1677c478bd9Sstevel@tonic-gate * is to be discarded because it refers to a file not to 1687c478bd9Sstevel@tonic-gate * be touched, or if the function reference is to a 1697c478bd9Sstevel@tonic-gate * function the user doesn't want recorded. 1707c478bd9Sstevel@tonic-gate */ 17109e2ab34SAndy Fiddaman #define IG_FILE1 "llib-port" 17209e2ab34SAndy Fiddaman #define IG_FILE2 "/usr/lib/llib-port" 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate #define ERRORNAME "/.errorrc" 175*28ab0ca4SToomas Soome extern int nignored; 176*28ab0ca4SToomas Soome extern char **names_ignored; 1779fb11590Smike_s /* 1787c478bd9Sstevel@tonic-gate * Structure definition for a full error 1797c478bd9Sstevel@tonic-gate */ 1807c478bd9Sstevel@tonic-gate typedef struct edesc Edesc; 1817c478bd9Sstevel@tonic-gate typedef Edesc *Eptr; 1827c478bd9Sstevel@tonic-gate 1839fb11590Smike_s struct edesc { 1849fb11590Smike_s Eptr error_next; /* linked together */ 1859fb11590Smike_s int error_lgtext; /* how many on the right hand side */ 1869fb11590Smike_s char **error_text; /* the right hand side proper */ 1879fb11590Smike_s Errorclass error_e_class; /* error category of this error */ 1889fb11590Smike_s Errorclass error_s_class; /* sub descriptor of error_e_class */ 1899fb11590Smike_s int error_language; /* the language for this error */ 1907c478bd9Sstevel@tonic-gate int error_position; /* oridinal position */ 1919fb11590Smike_s int error_line; /* discovered line number */ 1927c478bd9Sstevel@tonic-gate int error_no; /* sequence number on input */ 1937c478bd9Sstevel@tonic-gate }; 1947c478bd9Sstevel@tonic-gate /* 1957c478bd9Sstevel@tonic-gate * Resources for the true errors 1967c478bd9Sstevel@tonic-gate */ 1977c478bd9Sstevel@tonic-gate extern int nerrors; 1987c478bd9Sstevel@tonic-gate extern Eptr er_head; 1999fb11590Smike_s extern Eptr *errors; 2007c478bd9Sstevel@tonic-gate /* 2017c478bd9Sstevel@tonic-gate * Resources for each of the files mentioned 2027c478bd9Sstevel@tonic-gate */ 2037c478bd9Sstevel@tonic-gate extern int nfiles; 2049fb11590Smike_s extern Eptr **files; /* array of pointers into errors */ 205*28ab0ca4SToomas Soome extern boolean *touchedfiles; /* which files we touched */ 2067c478bd9Sstevel@tonic-gate /* 2077c478bd9Sstevel@tonic-gate * The langauge the compilation is in, as intuited from 2087c478bd9Sstevel@tonic-gate * the flavor of error messages analyzed. 2097c478bd9Sstevel@tonic-gate */ 2107c478bd9Sstevel@tonic-gate extern int langauge; 2117c478bd9Sstevel@tonic-gate extern char *currentfilename; 2127c478bd9Sstevel@tonic-gate /* 2137c478bd9Sstevel@tonic-gate * Functional forwards 2147c478bd9Sstevel@tonic-gate */ 2159fb11590Smike_s void *Calloc(int nelements, int size); 2169fb11590Smike_s char *strsave(char *instring); 2179fb11590Smike_s char lastchar(char *string); 2189fb11590Smike_s char firstchar(char *string); 2199fb11590Smike_s char next_lastchar(char *string); 2209fb11590Smike_s char **wordvsplice(int emptyhead, int wordc, char **wordv); 2219fb11590Smike_s int wordvcmp(char **wordv1, int wordc, char **wordv2); 2229fb11590Smike_s boolean persperdexplode(char *string, char **r_perd, char **r_pers); 2237c478bd9Sstevel@tonic-gate /* 2247c478bd9Sstevel@tonic-gate * Printing hacks 2257c478bd9Sstevel@tonic-gate */ 2269fb11590Smike_s char *plural(int n); 2279fb11590Smike_s char *verbform(int n); 2289fb11590Smike_s 2299fb11590Smike_s void erroradd(int errorlength, char **errorv, Errorclass errorclass, 2309fb11590Smike_s Errorclass errorsubclass); 2319fb11590Smike_s void eaterrors(int *r_errorc, Eptr **r_errorv); 2329fb11590Smike_s void wordvbuild(char *string, int *r_wordc, char ***r_wordv); 2339fb11590Smike_s void wordvprint(FILE *fyle, int wordc, char *wordv[]); 2349fb11590Smike_s void printerrors(boolean look_at_subclass, int errorc, Eptr errorv[]); 2359fb11590Smike_s void clob_last(char *string, char newstuff); 2369fb11590Smike_s void arrayify(int *e_length, Eptr **e_array, Eptr header); 2379fb11590Smike_s void getignored(char *auxname); 2389fb11590Smike_s void filenames(int nfiles, Eptr **files); 2399fb11590Smike_s void findfiles(int nerrors, Eptr *errors, int *r_nfiles, Eptr ***r_files); 2409fb11590Smike_s void onintr(int sig); 2419fb11590Smike_s boolean touchfiles(int nfiles, Eptr **files, int *r_edargc, char ***r_edargv); 2429fb11590Smike_s Errorclass discardit(Eptr errorp); 2439fb11590Smike_s char *substitute(char *string, char chold, char chnew); 2449fb11590Smike_s int position(char *string, char ch); 2459fb11590Smike_s 2469fb11590Smike_s #ifdef __cplusplus 2479fb11590Smike_s } 2489fb11590Smike_s #endif 2499fb11590Smike_s 2509fb11590Smike_s #endif /* _ERROR_H */ 251