Rev 6424 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
647 | andrew_pro | 1 | #include |
6412 | siemargl | 2 | #include |
647 | andrew_pro | 3 | |
6433 | siemargl | 4 | |
5 | |||
647 | andrew_pro | 6 | int fprintf(FILE* file, const char* format, ...) |
7 | { |
||
6433 | siemargl | 8 | va_list arg; |
9 | va_start (arg, format); |
||
647 | andrew_pro | 10 | |
6433 | siemargl | 11 | return vfprintf(file, format, arg); |
12 | |||
13 | } |
||
14 | |||
15 | int vfprintf ( FILE * file, const char * format, va_list arg ) |
||
16 | { |
||
17 | char *buf; |
||
18 | int printed, rc = 0; |
||
19 | |||
20 | if(!file || !format) |
||
21 | { |
||
22 | errno = E_INVALIDPTR; |
||
23 | return errno; |
||
24 | } |
||
25 | |||
26 | buf=malloc(4096*2); //8kb max |
||
27 | if(!buf) |
||
28 | { |
||
29 | errno = E_NOMEM; |
||
30 | return errno; |
||
31 | } |
||
32 | |||
647 | andrew_pro | 33 | printed=format_print(buf,8191, format,arg); |
6424 | siemargl | 34 | if (file == stderr) |
35 | debug_out_str(buf); |
||
36 | else |
||
6433 | siemargl | 37 | rc = fwrite(buf,printed,1,file); |
647 | andrew_pro | 38 | free(buf); |
39 | |||
6433 | siemargl | 40 | if (rc < 0) |
41 | return rc; |
||
42 | else |
||
43 | return(printed); |
||
647 | andrew_pro | 44 | }> |