- Timestamp:
- Jun 30, 2002, 4:58:09 PM (23 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 507d5aa
- Parents:
- 262422c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
util.c
r1aee7d9 r1c6c4d3 28 28 strcpy(buff, " (-/-) "); 29 29 } else { 30 s printf(buff, " (%i/%i/%i) ", owl_global_get_curmsg(&g)+1,30 snprintf(buff, 1024, " (%i/%i/%i) ", owl_global_get_curmsg(&g)+1, 31 31 owl_view_get_size(v), 32 32 owl_messagelist_get_size(ml)); … … 62 62 getyx(sepwin, y, x); 63 63 wmove(sepwin, y, x+2); 64 s printf(buff, " right: %i ", owl_global_get_rightshift(&g));64 snprintf(buff, 1024, " right: %i ", owl_global_get_rightshift(&g)); 65 65 waddstr(sepwin, buff); 66 66 } … … 316 316 } 317 317 318 /* allocates memory and returns the string or null. 319 * caller must free the string. 320 * from Linux sprintf man page. 321 */ 322 char *owl_sprintf(const char *fmt, ...) { 323 int n, size = 100; 324 char *p; 325 va_list ap; 326 if ((p = owl_malloc (size)) == NULL) 327 return NULL; 328 while (1) { 329 /* Try to print in the allocated space. */ 330 va_start(ap, fmt); 331 n = vsnprintf (p, size, fmt, ap); 332 va_end(ap); 333 /* If that worked, return the string. */ 334 if (n > -1 && n < size) 335 return p; 336 /* Else try again with more space. */ 337 if (n > -1) /* glibc 2.1 */ 338 size = n+1; /* precisely what is needed */ 339 else /* glibc 2.0 */ 340 size *= 2; /* twice the old size */ 341 if ((p = owl_realloc (p, size)) == NULL) 342 return NULL; 343 } 344 } 345 318 346 char *pretty_sender(char *in) { 319 347 char *out, *ptr; … … 331 359 332 360 char *long_sender(char *in) { 333 char * out, *ptr;361 char *ptr; 334 362 335 363 /* the caller must free the return */ 336 out=owl_malloc(strlen(in)+100); 337 strcpy(out, in); 338 ptr=strchr(out, '@'); 339 if (ptr) return(out); 340 sprintf(out, "%s@%s", out, ZGetRealm()); 341 return(out); 364 if (NULL != (ptr=strchr(in, '@'))) { 365 return owl_strdup(in); 366 } else { 367 return owl_sprintf("%s@%s", in, ZGetRealm()); 368 } 342 369 } 343 370
Note: See TracChangeset
for help on using the changeset viewer.