Changeset 3586
- Timestamp:
- 07/27/09 01:26:08 (4 years ago)
- Location:
- libcaca/trunk/caca
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/caca.h
r3583 r3586 26 26 27 27 #include <caca_types.h> 28 29 #if !defined(__KERNEL__) 30 # include <stdarg.h> 31 #endif 28 32 29 33 #undef __extern … … 228 232 __extern int caca_put_str(caca_canvas_t *, int, int, char const *); 229 233 __extern int caca_printf(caca_canvas_t *, int, int, char const *, ...); 234 __extern int caca_vprintf(caca_canvas_t *, int, int, char const *, va_list); 230 235 __extern int caca_clear_canvas(caca_canvas_t *); 231 236 __extern int caca_set_canvas_handle(caca_canvas_t *, int, int); -
libcaca/trunk/caca/string.c
r3583 r3586 282 282 int caca_printf(caca_canvas_t *cv, int x, int y, char const *format, ...) 283 283 { 284 va_list args; 285 int ret; 286 va_start(args, format); 287 ret = caca_vprintf(cv, x, y, format, args); 288 va_end(args); 289 return ret; 290 } 291 292 /** \brief Print a formated string (va_list version). 293 * 294 * Format a string at the given coordinates, using the default foreground 295 * and background values. The coordinates may be outside the canvas 296 * boundaries (eg. a negative Y coordinate) and the string will be cropped 297 * accordingly if it is too long. The syntax of the format string is the 298 * same as for the C vprintf() function. 299 * 300 * This function never fails. 301 * 302 * \param cv A handle to the libcaca canvas. 303 * \param x X coordinate. 304 * \param y Y coordinate. 305 * \param format The format string to print. 306 * \param ap A va_list containting the arguments to the format string. 307 * \return This function always returns 0. 308 */ 309 int caca_vprintf(caca_canvas_t *cv, int x, int y, char const *format, 310 va_list args) 311 { 284 312 char tmp[BUFSIZ]; 285 313 char *buf = tmp; 286 va_list args;287 314 288 315 if(y < 0 || y >= (int)cv->height || x >= (int)cv->width) … … 292 319 buf = malloc(cv->width - x + 1); 293 320 294 va_start(args, format);295 321 #if defined(HAVE_VSNPRINTF) 296 322 vsnprintf(buf, cv->width - x + 1, format, args); … … 299 325 #endif 300 326 buf[cv->width - x] = '\0'; 301 va_end(args);302 327 303 328 caca_put_str(cv, x, y, buf);
Note: See TracChangeset
for help on using the changeset viewer.
