summaryrefslogtreecommitdiffstats
path: root/lib/utils/stdio_helpers.c
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-11-15 15:29:24 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2010-11-15 15:29:24 +0100
commit2cf0d770b66b6c6ce50af2767f575db552cd784c (patch)
tree56ba70257c94add690ddaa8b0ec961c6964a146e /lib/utils/stdio_helpers.c
parent2169959c6ba2d77512b8b39366a4d3e476931b4a (diff)
move inc/ and lib/ to src/. No code changes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'lib/utils/stdio_helpers.c')
-rw-r--r--lib/utils/stdio_helpers.c69
1 files changed, 0 insertions, 69 deletions
diff --git a/lib/utils/stdio_helpers.c b/lib/utils/stdio_helpers.c
deleted file mode 100644
index 81cf5d75..00000000
--- a/lib/utils/stdio_helpers.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Utility routines.
- *
- * Copyright (C) 2001 Matt Krai
- * Copyright (C) 2004 Erik Andersen <andersen@codepoet.org>
- * Copyright (C) 2005, 2006 Rob Landley <rob@landley.net>
- * Copyright (C) 2010 ABRT Team
- *
- * Licensed under GPLv2 or later, see file LICENSE in this source tree.
- */
-#include "abrtlib.h"
-
-//TODO: add sanitizing upper limit (e.g 64K, 1M, or configurable).
-//This is why we don't use GNU's getline: it doesn't have
-//any upper sanity bound on line size.
-
-static char *xmalloc_fgets_internal(FILE *file, int *sizep)
-{
- unsigned idx = 0;
- char *linebuf = NULL;
-
- while (1) {
- char *r;
-
- linebuf = xrealloc(linebuf, idx + 0x100);
- r = fgets(&linebuf[idx], 0x100, file);
- if (!r) {
- /* need to terminate the line */
- linebuf[idx] = '\0';
- break;
- }
-
- /* stupid. fgets knows the len, it should report it somehow */
- unsigned len = strlen(&linebuf[idx]);
-
- idx += len;
- if (len < 0xff || linebuf[idx - 1] == '\n')
- break; /* we found \n or EOF */
- }
-
- *sizep = idx;
-
- if (!idx) {
- /* The very first fgets returned NULL. It's EOF (or error) */
- free(linebuf);
- linebuf = NULL;
- }
- return linebuf;
-}
-
-char *xmalloc_fgets(FILE *file)
-{
- int sz;
- char *r = xmalloc_fgets_internal(file, &sz);
- if (!r)
- return r;
- return xrealloc(r, sz + 1);
-}
-
-char *xmalloc_fgetline(FILE *file)
-{
- int sz;
- char *r = xmalloc_fgets_internal(file, &sz);
- if (!r)
- return r;
- if (r[sz - 1] == '\n')
- r[--sz] = '\0';
- return xrealloc(r, sz + 1);
-}