| 2951 | */ |
| 2952 | |
| 2953 | static void |
| 2954 | html_printf(ippeve_client_t *client, /* I - Client */ |
| 2955 | const char *format, /* I - Printf-style format string */ |
| 2956 | ...) /* I - Additional arguments as needed */ |
| 2957 | { |
| 2958 | va_list ap; /* Pointer to arguments */ |
| 2959 | const char *start; /* Start of string */ |
| 2960 | char size, /* Size character (h, l, L) */ |
| 2961 | type; /* Format type character */ |
| 2962 | int width, /* Width of field */ |
| 2963 | prec; /* Number of characters of precision */ |
| 2964 | char tformat[100], /* Temporary format string for sprintf() */ |
| 2965 | *tptr, /* Pointer into temporary format */ |
| 2966 | temp[1024]; /* Buffer for formatted numbers */ |
| 2967 | char *s; /* Pointer to string */ |
| 2968 | |
| 2969 | |
| 2970 | /* |
| 2971 | * Loop through the format string, formatting as needed... |
| 2972 | */ |
| 2973 | |
| 2974 | va_start(ap, format); |
| 2975 | start = format; |
| 2976 | |
| 2977 | while (*format) |
| 2978 | { |
| 2979 | if (*format == '%') |
| 2980 | { |
| 2981 | if (format > start) |
| 2982 | httpWrite2(client->http, start, (size_t)(format - start)); |
| 2983 | |
| 2984 | tptr = tformat; |
| 2985 | *tptr++ = *format++; |
| 2986 | |
| 2987 | if (*format == '%') |
| 2988 | { |
| 2989 | httpWrite2(client->http, "%", 1); |
| 2990 | format ++; |
| 2991 | start = format; |
| 2992 | continue; |
| 2993 | } |
| 2994 | else if (strchr(" -+#\'", *format)) |
| 2995 | *tptr++ = *format++; |
| 2996 | |
| 2997 | if (*format == '*') |
| 2998 | { |
| 2999 | /* |
| 3000 | * Get width from argument... |
| 3001 | */ |
| 3002 | |
| 3003 | format ++; |
| 3004 | width = va_arg(ap, int); |
| 3005 | |
| 3006 | snprintf(tptr, sizeof(tformat) - (size_t)(tptr - tformat), "%d", width); |
| 3007 | tptr += strlen(tptr); |
| 3008 | } |
| 3009 | else |
| 3010 | { |
no test coverage detected