mkerror.c
2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo.
$RCSfile: mkerror.c,v $
$Revision: 1.1.1.1 $
$Date: 2002/05/02 03:28:44 $
*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo.
: header,v : 1.2 : 1998/09/17 05:17:19 ---------------------------------------------------------------------*/
#include <stdlib.h>
#ifdef WIN32
#define DEV_U64_DATA "PARTNER-N64"
#else
#include <sys/u64gio.h>
#endif
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <ultrahost.h>
#ifndef WIN32 /* { */
#include <unistd.h>
#endif /* } */
#include "sub.h"
char NULLSTR[]={24,0};
FILE *fp,*fp2;
#define s q
#define sb2(x,y) sbYes(ddd(x),y,0,0)
#define sb3(x,y,z) sbYes(x,y,z,0)
void sbErrStop2(FILE * p , char * str);
int
sbYes(int x,int y,int z,int k)
{
return x+y+z+k;
}
void
putLong(s32 val)
{
u8 buf[4];
buf[0] = ( val >> 24 ) & 0xFF;
buf[1] = ( val >> 16 ) & 0xFF;
buf[2] = ( val >> 8 ) & 0xFF;
buf[3] = ( val >> 0 ) & 0xFF;
fwrite(buf,sizeof(char),4,fp);
}
char bigbuf[512][1024];
int main(int argc, char **argv)
{
int c1,c2,i;
char *t1 ,*t2;
char buf[1024],_err_no[512],_err_mes[1024];
long err_num;
int count=0;
for(i=0;i<512;i++) bigbuf[i][0]=0;
sbGetOpts(argv,argc,"h0o:");
if( TGTPYAS == 1 )
{
t1 = TGTPYA[0] ;
t2 = (char *)OPTIA[1];
}
else
{
printf("mkerror error.fmt [-o output file]");
exit(0);
}
fp = sbOpen( t1 ,"r");
count=0;
for(;;)
{
if( feof(fp) ) break;
if( fgets(buf,1024,fp) == NULL )
if( ferror(fp) ) sbErrStop("read error");
else break;
if( sbSplit(buf,'\t',_err_no, _err_mes ) != 2 )
sbErrStop2(fp,"format error");
err_num = strtol( _err_no ,NULL ,10 );
if( err_num > 511 || err_num <= 0 )
sbErrStop2(fp,"format error");
sprintf( bigbuf[err_num],"%s",_err_mes);
++count;
}
sbClose(fp);
fp2 = (t2 == NULSTR) ? sbOpen( "oserr.h" ,"w") : sbOpen( t2 ,"w");
fputs("char NULSTR[1] = {0};\n",fp2);
fputs("char *__os_error_message[]={\n",fp2);
fputs("NULSTR,\n",fp2);
i=0;
do
{
if( ++i > 511 ) break;
if(bigbuf[i][0])
{
fputs(bigbuf[i],fp2);
fputs(",",fp2);
count--;
}
else
{
fputs("NULSTR,\n",fp2);
}
}
while(count>0);
fputs("NULSTR };\n",fp2);
sbClose(fp2);
return(0);
}
void
sbErrStop2(FILE * p , char * str)
{
sbClose(p);
sbErrStop(str);
}