2 // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
3 // ERROR.C - Error Handling
4 // Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
5 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
6 // Source Utilised with the Kind Permission of Landon Dyer
13 int errcnt; // Error count
14 char *err_fname; // Name of error message file
16 static char nl[] = "\n";
19 // --- Report error if not at EOL ------------------------------------------------------------------
24 error("syntax error");
29 // --- Cannot Create a File ------------------------------------------------------------------------
32 void cantcreat(char *fn) {
33 printf("cannot create: '%s'\n", fn);
38 // --- Setup for Error Message ---------------------------------------------------------------------
39 // o Create error listing file (if necessary)
40 // o Set current filename
43 void err_setup(void) {
47 if(err_fname != NULL) {
48 strcpy(fnbuf, err_fname);
50 strcpy(fnbuf, firstfname);
54 if((err_fd = open(fnbuf, _OPEN_FLAGS, _PERM_MODE)) < 0)
61 // --- Display Error Message -----------------------------------------------------------------------
69 if(listing > 0) ship_ln(s);
70 sprintf(buf, "%s[%d]: Error: %s%s", curfname, curlineno, s, nl);
72 if(err_flag) write(err_fd, buf, length);
73 else printf("%s", buf);
80 int errors(char *s, char *s1) {
86 if(listing > 0) ship_ln(buf);
87 sprintf(buf1, "%s[%d]: Error: %s%s", curfname, curlineno, buf, nl);
88 if(err_flag) write(err_fd, buf1, (LONG)strlen(buf1));
89 else printf("%s", buf1);
100 if(listing > 0) ship_ln(s);
101 sprintf(buf, "%s[%d]: Warning: %s%s", curfname, curlineno, s, nl);
102 if(err_flag) write(err_fd, buf, (LONG)strlen(buf));
103 else printf("%s", buf);
109 int warns(char *s, char *s1) {
115 if(listing > 0) ship_ln(s);
116 sprintf(buf1, "%s[%d]: Warning: %s%s", curfname, curlineno, buf, nl);
117 if(err_flag) write(err_fd, buf1, (LONG)strlen(buf1));
118 else printf("%s", buf1);
124 int warni(char *s, unsigned i) {
130 if(listing > 0) ship_ln(buf);
131 sprintf(buf1, "%s[%d]: Warning: %s%s", curfname, curlineno, buf, nl);
132 if(err_flag) write(err_fd, buf1, (LONG)strlen(buf1));
133 else printf("%s", buf1);
143 if(listing > 0) ship_ln(s);
144 sprintf(buf, "%s[%d]: Fatal: %s%s", curfname, curlineno, s, nl);
145 if(err_flag) write(err_fd, buf, (LONG)strlen(buf));
146 else printf("%s", buf);
151 int interror(int n) {
155 sprintf(buf, "%s[%d]: Internal Error Number %d%s", curfname, curlineno, n, nl);
156 if(listing > 0) ship_ln(buf);
157 if(err_flag) write(err_fd, buf, (LONG)strlen(buf));
158 else printf("%s", buf);