1 | // Copyright (c) Athena Dev Teams - Licensed under GNU GPL |
---|
2 | // For more information, see LICENCE in the main folder |
---|
3 | |
---|
4 | #include <stdio.h> |
---|
5 | #include <stdarg.h> |
---|
6 | #include <string.h> |
---|
7 | #include "nullpo.h" |
---|
8 | #include "../common/showmsg.h" |
---|
9 | // #include "logs.h" // zεÄÝé |
---|
10 | |
---|
11 | static void nullpo_info_core(const char *file, int line, const char *func, |
---|
12 | const char *fmt, va_list ap); |
---|
13 | |
---|
14 | /*====================================== |
---|
15 | * Null`FbN yÑ îñoÍ |
---|
16 | *--------------------------------------*/ |
---|
17 | int nullpo_chk_f(const char *file, int line, const char *func, const void *target, |
---|
18 | const char *fmt, ...) |
---|
19 | { |
---|
20 | va_list ap; |
---|
21 | |
---|
22 | if (target != NULL) |
---|
23 | return 0; |
---|
24 | |
---|
25 | va_start(ap, fmt); |
---|
26 | nullpo_info_core(file, line, func, fmt, ap); |
---|
27 | va_end(ap); |
---|
28 | return 1; |
---|
29 | } |
---|
30 | |
---|
31 | int nullpo_chk(const char *file, int line, const char *func, const void *target) |
---|
32 | { |
---|
33 | if (target != NULL) |
---|
34 | return 0; |
---|
35 | |
---|
36 | nullpo_info_core(file, line, func, NULL, NULL); |
---|
37 | return 1; |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | /*====================================== |
---|
42 | * nullpoîñoÍ(OÄoµü¯bp) |
---|
43 | *--------------------------------------*/ |
---|
44 | void nullpo_info_f(const char *file, int line, const char *func, |
---|
45 | const char *fmt, ...) |
---|
46 | { |
---|
47 | va_list ap; |
---|
48 | |
---|
49 | va_start(ap, fmt); |
---|
50 | nullpo_info_core(file, line, func, fmt, ap); |
---|
51 | va_end(ap); |
---|
52 | } |
---|
53 | |
---|
54 | void nullpo_info(const char *file, int line, const char *func) |
---|
55 | { |
---|
56 | nullpo_info_core(file, line, func, NULL, NULL); |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | /*====================================== |
---|
61 | * nullpoîñoÍ(Main) |
---|
62 | *--------------------------------------*/ |
---|
63 | static void nullpo_info_core(const char *file, int line, const char *func, |
---|
64 | const char *fmt, va_list ap) |
---|
65 | { |
---|
66 | if (file == NULL) |
---|
67 | file = "??"; |
---|
68 | |
---|
69 | func = |
---|
70 | func == NULL ? "unknown": |
---|
71 | func[0] == '\0' ? "unknown": |
---|
72 | func; |
---|
73 | |
---|
74 | ShowMessage("--- nullpo info --------------------------------------------\n"); |
---|
75 | ShowMessage("%s:%d: in func `%s'\n", file, line, func); |
---|
76 | if (fmt != NULL) |
---|
77 | { |
---|
78 | if (fmt[0] != '\0') |
---|
79 | { |
---|
80 | vprintf(fmt, ap); |
---|
81 | |
---|
82 | // ÅãÉüsµœ©mF |
---|
83 | if (fmt[strlen(fmt)-1] != '\n') |
---|
84 | ShowMessage("\n"); |
---|
85 | } |
---|
86 | } |
---|
87 | ShowMessage("--- end nullpo info ----------------------------------------\n"); |
---|
88 | |
---|
89 | // ±±çÅnullpoOðt@CÉ«o¹œç |
---|
90 | // ÜÆßÄñoÅ«éÈÆvÁÄ¢œèB |
---|
91 | } |
---|