1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: misc.c |
2 | * File: misc.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1996 mj olesen <olesen@me.QueensU.CA> Queen's Univ at Kingston |
6 | * Copyright (c) 1996 mj olesen <olesen@me.QueensU.CA> Queen's Univ at Kingston |
7 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
7 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
… | |
… | |
68 | /* |
68 | /* |
69 | * Print an error message |
69 | * Print an error message |
70 | */ |
70 | */ |
71 | /* EXTPROTO */ |
71 | /* EXTPROTO */ |
72 | void |
72 | void |
|
|
73 | rxvt_vlog (const char *fmt, va_list arg_ptr) |
|
|
74 | { |
|
|
75 | char msg[1024]; |
|
|
76 | |
|
|
77 | vsnprintf (msg, sizeof msg, fmt, arg_ptr); |
|
|
78 | |
|
|
79 | if (GET_R && GET_R->log_hook) |
|
|
80 | (*GET_R->log_hook) (msg); |
|
|
81 | else |
|
|
82 | write (STDOUT_FILENO, msg, strlen (msg)); |
|
|
83 | } |
|
|
84 | |
|
|
85 | /* EXTPROTO */ |
|
|
86 | void |
73 | rxvt_print_error (const char *fmt,...) |
87 | rxvt_log (const char *fmt,...) |
74 | { |
88 | { |
75 | va_list arg_ptr; |
89 | va_list arg_ptr; |
76 | |
90 | |
77 | va_start (arg_ptr, fmt); |
91 | va_start (arg_ptr, fmt); |
78 | fprintf (stderr, RESNAME ": "); |
92 | rxvt_vlog (fmt, arg_ptr); |
79 | vfprintf (stderr, fmt, arg_ptr); |
|
|
80 | fprintf (stderr, "\n"); |
|
|
81 | va_end (arg_ptr); |
93 | va_end (arg_ptr); |
|
|
94 | } |
|
|
95 | |
|
|
96 | /* |
|
|
97 | * Print an error message |
|
|
98 | */ |
|
|
99 | /* EXTPROTO */ |
|
|
100 | void |
|
|
101 | rxvt_warn (const char *fmt,...) |
|
|
102 | { |
|
|
103 | va_list arg_ptr; |
|
|
104 | |
|
|
105 | rxvt_log ("%s: ", RESNAME); |
|
|
106 | |
|
|
107 | va_start (arg_ptr, fmt); |
|
|
108 | rxvt_vlog (fmt, arg_ptr); |
|
|
109 | va_end (arg_ptr); |
|
|
110 | } |
|
|
111 | |
|
|
112 | /* EXTPROTO */ |
|
|
113 | void |
|
|
114 | rxvt_fatal (const char *fmt,...) |
|
|
115 | { |
|
|
116 | va_list arg_ptr; |
|
|
117 | |
|
|
118 | rxvt_log ("%s: ", RESNAME); |
|
|
119 | |
|
|
120 | va_start (arg_ptr, fmt); |
|
|
121 | rxvt_vlog (fmt, arg_ptr); |
|
|
122 | va_end (arg_ptr); |
|
|
123 | |
|
|
124 | rxvt_exit_failure (); |
|
|
125 | } |
|
|
126 | |
|
|
127 | class rxvt_failure_exception rxvt_failure_exception; |
|
|
128 | |
|
|
129 | /* EXTPROTO */ |
|
|
130 | void |
|
|
131 | rxvt_exit_failure () |
|
|
132 | { |
|
|
133 | throw (rxvt_failure_exception); |
82 | } |
134 | } |
83 | |
135 | |
84 | /* |
136 | /* |
85 | * check that the first characters of S1 match S2 |
137 | * check that the first characters of S1 match S2 |
86 | * |
138 | * |