summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-11-13 11:50:54 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-11-13 11:50:54 (GMT)
commit9e009c4b1128352c6039d25b39213fd480e9b055 (patch)
treee1495ef4ada6f8e092e20bc474195719f1b2b4aa /plugins/utils.c
parent9728dcad931d1c442a6d8e3e6765e2d9870600d1 (diff)
downloadmonitoring-plugins-9e009c4b1128352c6039d25b39213fd480e9b055.tar.gz
remove call_getopt and asprintf
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@190 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c67
1 files changed, 0 insertions, 67 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index bf1d204..5dc6cfd 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -50,7 +50,6 @@ void strip (char *);
50char *strscpy (char *dest, const char *src); 50char *strscpy (char *dest, const char *src);
51char *strscat (char *dest, const char *src); 51char *strscat (char *dest, const char *src);
52char *strnl (char *str); 52char *strnl (char *str);
53char *ssprintf (char *str, const char *fmt, ...);
54char *strpcpy (char *dest, const char *src, const char *str); 53char *strpcpy (char *dest, const char *src, const char *str);
55char *strpcat (char *dest, const char *src, const char *str); 54char *strpcat (char *dest, const char *src, const char *str);
56 55
@@ -496,72 +495,6 @@ strnl (char *str)
496 495
497/****************************************************************************** 496/******************************************************************************
498 * 497 *
499 * Does a formatted print to a string variable
500 *
501 * Given a pointer destination string, which may or may not already
502 * hold some text, and a source string with additional text (possibly
503 * NULL or empty), returns a pointer to a string that cntains the
504 * results of the specified formatted print
505 *
506 * Example:
507 *
508 * char *str=NULL;
509 * str = ssprintf(str,"%d %s",1,"string");
510 *
511 *****************************************************************************/
512
513char *
514ssprintf (char *ptr, const char *fmt, ...)
515{
516 va_list ap;
517 int nchars;
518 size_t size;
519 char *str = NULL;
520
521 if (str == NULL) {
522 str = malloc (TXTBLK);
523 if (str == NULL)
524 terminate (STATE_UNKNOWN, "malloc failed in ssprintf");
525 size = TXTBLK;
526 }
527 else
528 size = max (strlen (str), TXTBLK);
529
530 va_start (ap, fmt);
531
532 while (1) {
533
534 nchars = vsnprintf (str, size, fmt, ap);
535
536 if (nchars > -1)
537 if (nchars < (int) size) {
538 va_end (ap);
539 str[nchars] = '\0';
540 if (ptr)
541 free (ptr);
542 return str;
543 }
544 else {
545 size = (size_t) (nchars + 1);
546 }
547
548 else
549 size *= 2;
550
551 str = realloc (str, size);
552
553 if (str == NULL)
554 terminate (STATE_UNKNOWN, "realloc failed in ssprintf");
555 }
556
557}
558
559
560
561
562
563/******************************************************************************
564 *
565 * Like strscpy, except only the portion of the source string up to 498 * Like strscpy, except only the portion of the source string up to
566 * the provided delimiter is copied. 499 * the provided delimiter is copied.
567 * 500 *