Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=firepl.git;a=commitdiff;h=21687343720ca38639345e421398a106a9a85c3a

commit 21687343720ca38639345e421398a106a9a85c3a
Author: James Buren <[email protected]>
Date:   Sat Apr 28 23:42:41 2012 -0500

add getline function to dsb

diff --git a/dsb.c b/dsb.c
index d961ec5..6b2adde 100644
--- a/dsb.c
+++ b/dsb.c
@@ -1,5 +1,4 @@
#include <stdlib.h>
-#include <stdio.h>
#include <stdarg.h>
#include "utility.h"
#include "dsb.h"
@@ -104,3 +103,23 @@ extern void dsb_rewind(dsb *self)

dsb_putc(self,0);
}
+
+extern const char *dsb_getline(dsb *self,FILE *file)
+{
+       int c;
+
+       assert(self);
+       assert(file);
+
+       dsb_rewind(self);
+
+       while((c = fgetc(file)) != EOF)
+       {
+               if(c == '\n')
+                       break;
+
+               dsb_putc(self,c);
+       }
+
+       return *self->str ? self->str : 0;
+}
diff --git a/dsb.h b/dsb.h
index d8a8e7d..ab48dbd 100644
--- a/dsb.h
+++ b/dsb.h
@@ -1,6 +1,7 @@
#pragma once

#include <stdbool.h>
+#include <stdio.h>

typedef struct _dsb dsb;

@@ -9,3 +10,4 @@ extern char *dsb_close(dsb *self,bool save);
extern void dsb_puts(dsb *self,...) __attribute__((__sentinel__));
extern const char *dsb_gets(const dsb *self);
extern void dsb_rewind(dsb *self);
+extern const char *dsb_getline(dsb *self,FILE *file);
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to