@@ -197,7 +197,6 @@ loadFile_returnData TigerLoadFile(char *pubpath, char *cachepath) {
197
197
pubfile = fopen (pubpath , "r" );
198
198
cachefile = fopen (cachepath , "w" );
199
199
if (!cachefile ) {
200
- perror (cachepath );
201
200
return (loadFile_returnData ){0 };
202
201
}
203
202
@@ -231,21 +230,33 @@ loadFile_returnData TigerLoadFile(char *pubpath, char *cachepath) {
231
230
return data ;
232
231
}
233
232
233
+ char * defaulthandlertxt [] = {
234
+ [400 ] = "Sorry, but your request could not be understood." ,
235
+ [401 ] = "Sorry, but you are not authorized to view this resource." ,
236
+ [403 ] = "Sorry, but you are forbidden from viewing this resource." ,
237
+ [404 ] = "Sorry, but the requested resource could not be found." ,
238
+ [410 ] = "Sorry, but the requested resource is not and will never be available again." ,
239
+ [418 ] = "Sorry, but this server only brews tea. The server is a teapot." ,
240
+ [451 ] = "Sorry, but the requested resource is not available due to legal reasons." ,
241
+ [500 ] = "Sorry, but the server had a stroke trying to figure out what to do." ,
242
+ [503 ] = "Sorry, but the server is overloaded and cannot handle the request." ,
243
+ [505 ] = "Sorry, but your HTTP Version was not supported." ,
244
+ };
245
+
234
246
void TigerErrorHandler (int status , char * response , RequestData reqdata , char * rootpath ) {;
235
247
sprintf (response , "HTTP/1.0 %d %s\nServer: Tiger/" TIGER_VERS "\r\n\r\n" , status , httpcodes [status ]);
236
- char * filename = malloc (9 ); //<status>.html
237
- sprintf (filename , "%03d.html" , status );
238
-
239
- void * tmp1 , * tmp2 ;
248
+ char filename [BUFSIZ ]; //<status>.html
249
+ sprintf (filename , "/%03d.html" , status );
240
250
241
- loadFile_returnData data = TigerLoadFile (tmp1 = combine (rootpath , "/public/404.html" ), tmp2 = combine (rootpath , "/public/404.html" ));
251
+ char public_path [BUFSIZ ];
252
+ char cache_path [BUFSIZ ];
253
+
254
+ loadFile_returnData data = TigerLoadFile (public_path , cache_path );
255
+
242
256
if (errno ) {
243
- printf ( "E%d %s " , errno , reqdata . path );
244
- return ( loadFile_returnData ){ 0 } ;
257
+ //can't access error handler
258
+ sprintf ( response , "%s<html><body>%s</body></html>" , response , defaulthandlertxt [ status ]) ;
245
259
}
246
-
247
- free (tmp1 );
248
- free (tmp2 );
249
260
}
250
261
251
262
int TigerCallPHP (char * source_path , char * output_path , RequestData data , loadFile_returnData * output ) {
0 commit comments