0
|
1 /*
|
|
2 * miniJSS - General functions
|
|
3 * Programmed and designed by Matti 'ccr' Hamalainen
|
|
4 * (C) Copyright 2006-2007 Tecnic Software productions (TNSP)
|
|
5 */
|
|
6 #include "jss.h"
|
|
7 #include <stdarg.h>
|
|
8
|
|
9
|
|
10 /* Memory and error handling functions
|
|
11 */
|
|
12
|
|
13 BOOL jssWarningIsFatal, jssErrorIsFatal;
|
|
14
|
|
15 #ifndef JSS_LIGHT
|
|
16 void (*jssError) (int code, char * filename, int linen, char * fmt, ...);
|
|
17 void (*jssWarning) (int code, char * filename, int linen, char * fmt, ...);
|
|
18 #endif
|
|
19
|
|
20
|
|
21 void jssDefaultPrint(int code, char * filename, int linen, char * fmt)
|
|
22 {
|
|
23 fprintf(stderr, "JSS");
|
|
24 if (filename)
|
|
25 fprintf(stderr, "[%s:%i]", filename, linen);
|
|
26 fprintf(stderr, fmt);
|
|
27 if (code > 0)
|
|
28 fprintf(stderr, "(%i)", code);
|
|
29 fprintf(stderr, ": ");
|
|
30 }
|
|
31
|
|
32
|
|
33 void jssDefaultError(int code, char * filename, int linen, char * fmt, ...)
|
|
34 {
|
|
35 va_list ap;
|
|
36 jssDefaultPrint(code, filename, linen, "E");
|
|
37
|
|
38 va_start(ap, fmt);
|
|
39 vfprintf(stderr, fmt, ap);
|
|
40 va_end(ap);
|
|
41 }
|
|
42
|
|
43
|
|
44 void jssDefaultWarning(int code, char * filename, int linen, char * fmt, ...)
|
|
45 {
|
|
46 va_list ap;
|
|
47 jssDefaultPrint(code, filename, linen, "W");
|
|
48
|
|
49 va_start(ap, fmt);
|
|
50 vfprintf(stderr, fmt, ap);
|
|
51 va_end(ap);
|
|
52 }
|
|
53
|
|
54
|
|
55 /* System initialization
|
|
56 */
|
|
57 int jssInit(void)
|
|
58 {
|
|
59 // Error handling
|
|
60 jssWarningIsFatal = FALSE;
|
|
61 jssErrorIsFatal = TRUE;
|
|
62
|
|
63 #ifndef JSS_LIGHT
|
|
64 jssError = jssDefaultError;
|
|
65 jssWarning = jssDefaultWarning;
|
|
66 #endif
|
|
67
|
|
68 // Allocate global tables
|
|
69
|
|
70 return DMERR_OK;
|
|
71 }
|
|
72
|
|
73
|
|
74 /* System shutdown
|
|
75 */
|
|
76 int jssClose(void)
|
|
77 {
|
|
78 return DMERR_OK;
|
|
79 }
|