Definition in file printf-stdarg.c.
#include <sys/reent.h>
#include <stdarg.h>
Go to the source code of this file.
Defines | |
#define | PAD_RIGHT 1 |
#define | PAD_ZERO 2 |
#define | PRINT_BUF_LEN 12 |
#define | putchar(c) print_dbg_char(c) |
Functions | |
int | fprintf (__FILE *stream, const char *format,...) |
static void | printchar (char **str, int c) |
static int | printi (char **out, int i, int b, int sg, int width, int pad, int letbase) |
int | printk (const char *format,...) |
int | printk_va (char **out, const char *format, va_list args) |
static int | prints (char **out, const char *string, int width, int pad) |
int | sprintf (char *out, const char *format,...) |
#define PAD_RIGHT 1 |
#define PAD_ZERO 2 |
#define PRINT_BUF_LEN 12 |
#define putchar | ( | c | ) | print_dbg_char(c) |
int fprintf | ( | __FILE * | stream, | |
const char * | format, | |||
... | ||||
) |
static void printchar | ( | char ** | str, | |
int | c | |||
) | [static] |
Definition at line 77 of file printf-stdarg.c.
References putchar.
Referenced by printi(), printk_va(), and prints().
00078 { 00079 extern int putchar(int c); 00080 00081 if (str) { 00082 **str = c; 00083 ++(*str); 00084 } 00085 else (void)putchar(c); 00086 }
static int printi | ( | char ** | out, | |
int | i, | |||
int | b, | |||
int | sg, | |||
int | width, | |||
int | pad, | |||
int | letbase | |||
) | [static] |
Definition at line 124 of file printf-stdarg.c.
References PAD_ZERO, PRINT_BUF_LEN, printchar(), and prints().
Referenced by printk_va().
00125 { 00126 char print_buf[PRINT_BUF_LEN]; 00127 register char *s; 00128 register int t, neg = 0, pc = 0; 00129 register unsigned int u = i; 00130 00131 if (i == 0) { 00132 print_buf[0] = '0'; 00133 print_buf[1] = '\0'; 00134 return prints (out, print_buf, width, pad); 00135 } 00136 00137 if (sg && b == 10 && i < 0) { 00138 neg = 1; 00139 u = -i; 00140 } 00141 00142 s = print_buf + PRINT_BUF_LEN-1; 00143 *s = '\0'; 00144 00145 while (u) { 00146 t = u % b; 00147 if( t >= 10 ) 00148 t += letbase - '0' - 10; 00149 *--s = t + '0'; 00150 u /= b; 00151 } 00152 00153 if (neg) { 00154 if( width && (pad & PAD_ZERO) ) { 00155 printchar (out, '-'); 00156 ++pc; 00157 --width; 00158 } 00159 else { 00160 *--s = '-'; 00161 } 00162 } 00163 00164 return pc + prints (out, s, width, pad); 00165 }
int printk | ( | const char * | format, | |
... | ||||
) |
Definition at line 240 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(), fw_download_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(), join_argv(), main(), ping_recv(), print_network(), print_network_list(), print_stats(), set_wep_key_cb(), set_wpa_key_cb(), 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().
00241 { 00242 va_list args; 00243 00244 va_start( args, format ); 00245 return printk_va( 0, format, args ); 00246 }
int printk_va | ( | char ** | out, | |
const char * | format, | |||
va_list | args | |||
) |
Definition at line 171 of file printf-stdarg.c.
References PAD_RIGHT, PAD_ZERO, printchar(), printi(), prints(), and width.
Referenced by printk(), and sprintf().
00172 { 00173 register int width, pad; 00174 register int pc = 0; 00175 char scr[2]; 00176 00177 for (; *format != 0; ++format) { 00178 if (*format == '%') { 00179 ++format; 00180 width = pad = 0; 00181 if (*format == '\0') break; 00182 if (*format == '%') goto out; 00183 if (*format == '-') { 00184 ++format; 00185 pad = PAD_RIGHT; 00186 } 00187 while (*format == '0') { 00188 ++format; 00189 pad |= PAD_ZERO; 00190 } 00191 for ( ; *format >= '0' && *format <= '9'; ++format) { 00192 width *= 10; 00193 width += *format - '0'; 00194 } 00195 if( *format == 's' ) { 00196 register char *s = (char *)va_arg( args, int ); 00197 pc += prints (out, s?s:"(null)", width, pad); 00198 continue; 00199 } 00200 if( *format == 'd' ) { 00201 pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a'); 00202 continue; 00203 } 00204 if( *format == 'p' ) { 00205 pad = 8; 00206 pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a'); 00207 continue; 00208 } 00209 if( *format == 'x' ) { 00210 pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a'); 00211 continue; 00212 } 00213 if( *format == 'X' ) { 00214 pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A'); 00215 continue; 00216 } 00217 if( *format == 'u' ) { 00218 pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a'); 00219 continue; 00220 } 00221 if( *format == 'c' ) { 00222 /* char are converted to int then pushed on the stack */ 00223 scr[0] = (char)va_arg( args, int ); 00224 scr[1] = '\0'; 00225 pc += prints (out, scr, width, pad); 00226 continue; 00227 } 00228 } 00229 else { 00230 out: 00231 printchar (out, *format); 00232 ++pc; 00233 } 00234 } 00235 if (out) **out = '\0'; 00236 va_end( args ); 00237 return pc; 00238 }
static int prints | ( | char ** | out, | |
const char * | string, | |||
int | width, | |||
int | pad | |||
) | [static] |
Definition at line 91 of file printf-stdarg.c.
References PAD_RIGHT, PAD_ZERO, and printchar().
Referenced by printi(), and printk_va().
00092 { 00093 register int pc = 0, padchar = ' '; 00094 00095 if (width > 0) { 00096 register int len = 0; 00097 register const char *ptr; 00098 for (ptr = string; *ptr; ++ptr) ++len; 00099 if (len >= width) width = 0; 00100 else width -= len; 00101 if (pad & PAD_ZERO) padchar = '0'; 00102 } 00103 if (!(pad & PAD_RIGHT)) { 00104 for ( ; width > 0; --width) { 00105 printchar (out, padchar); 00106 ++pc; 00107 } 00108 } 00109 for ( ; *string ; ++string) { 00110 printchar (out, *string); 00111 ++pc; 00112 } 00113 for ( ; width > 0; --width) { 00114 printchar (out, padchar); 00115 ++pc; 00116 } 00117 00118 return pc; 00119 }
int sprintf | ( | char * | out, | |
const char * | format, | |||
... | ||||
) |
Definition at line 248 of file printf-stdarg.c.
References printk_va().
00249 { 00250 va_list args; 00251 00252 va_start( args, format ); 00253 return printk_va( &out, format, args ); 00254 }