root/src/common/nullpo.c @ 1

Revision 1, 2.3 kB (checked in by jinshiro, 17 years ago)
RevLine 
[1]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
11static void nullpo_info_core(const char *file, int line, const char *func, 
12                             const char *fmt, va_list ap);
13
14/*======================================
15 * Nullƒ`ƒFƒbƒN ‹y‚Ñ î•ño—Í
16 *--------------------------------------*/
17int 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
31int 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‚µŒü‚¯ƒ‰ƒbƒp)
43 *--------------------------------------*/
44void 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
54void 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 *--------------------------------------*/
63static 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‚µ‚œ‚©Šm”F
83                        if (fmt[strlen(fmt)-1] != '\n')
84                                ShowMessage("\n");
85                }
86        }
87        ShowMessage("--- end nullpo info ----------------------------------------\n");
88       
89        // ‚±‚±‚ç‚ÅnullpoƒƒO‚ðƒtƒ@ƒCƒ‹‚ɏ‘‚«o‚¹‚œ‚ç
90        // ‚܂Ƃ߂Ēño‚Å‚«‚é‚ȂƎv‚Á‚Ä‚¢‚œ‚èB
91}
Note: See TracBrowser for help on using the browser.