#include <stdarg.h>
Go to the source code of this file.
Functions | |
int | printk (const char *format,...) |
int | printk_va (char **out, const char *format, va_list args) |
int printk | ( | const char * | format, | |
... | ||||
) |
Definition at line 238 of file printf-stdarg.c.
References printk_va().
Referenced by ascii_to_key(), cmd_connect(), cmd_ping(), cmd_power(), cmd_psconf(), cmd_setkey(), cmd_status(), cmd_ttcp(), console_init(), console_schedule_cmd(), gui_connect_cb(), gui_dec_scroll_cursor(), gui_del_scroll_box_item(), gui_display_infobox(), gui_inc_scroll_cursor(), gui_scan_cb(), http_accept(), http_recv(), ip_status_cb(), main(), ping_recv(), print_network(), print_network_list(), print_stats(), tcp_accept_cb(), tcp_conn_err_cb(), tcp_connect_cb(), tcp_recv_cb(), tcp_send_data(), tcp_start(), tcp_timeout_cb(), ttcp_print_stats(), ttcp_start(), udp_recv_cb(), udp_send_bytes(), udp_start(), wl_cm_conn_cb(), and wl_cm_disconn_cb().
00239 { 00240 va_list args; 00241 00242 va_start( args, format ); 00243 return printk_va( 0, format, args ); 00244 }
int printk_va | ( | char ** | out, | |
const char * | format, | |||
va_list | args | |||
) |
Definition at line 169 of file printf-stdarg.c.
References PAD_RIGHT, PAD_ZERO, printchar(), printi(), prints(), and width.
Referenced by printk(), and sprintf().
00170 { 00171 register int width, pad; 00172 register int pc = 0; 00173 char scr[2]; 00174 00175 for (; *format != 0; ++format) { 00176 if (*format == '%') { 00177 ++format; 00178 width = pad = 0; 00179 if (*format == '\0') break; 00180 if (*format == '%') goto out; 00181 if (*format == '-') { 00182 ++format; 00183 pad = PAD_RIGHT; 00184 } 00185 while (*format == '0') { 00186 ++format; 00187 pad |= PAD_ZERO; 00188 } 00189 for ( ; *format >= '0' && *format <= '9'; ++format) { 00190 width *= 10; 00191 width += *format - '0'; 00192 } 00193 if( *format == 's' ) { 00194 register char *s = (char *)va_arg( args, int ); 00195 pc += prints (out, s?s:"(null)", width, pad); 00196 continue; 00197 } 00198 if( *format == 'd' ) { 00199 pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a'); 00200 continue; 00201 } 00202 if( *format == 'p' ) { 00203 pad = 8; 00204 pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a'); 00205 continue; 00206 } 00207 if( *format == 'x' ) { 00208 pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a'); 00209 continue; 00210 } 00211 if( *format == 'X' ) { 00212 pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A'); 00213 continue; 00214 } 00215 if( *format == 'u' ) { 00216 pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a'); 00217 continue; 00218 } 00219 if( *format == 'c' ) { 00220 /* char are converted to int then pushed on the stack */ 00221 scr[0] = (char)va_arg( args, int ); 00222 scr[1] = '\0'; 00223 pc += prints (out, scr, width, pad); 00224 continue; 00225 } 00226 } 00227 else { 00228 out: 00229 printchar (out, *format); 00230 ++pc; 00231 } 00232 } 00233 if (out) **out = '\0'; 00234 va_end( args ); 00235 return pc; 00236 }