summaryrefslogtreecommitdiff
path: root/apps/misc.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-05-03 15:12:19 +0000
committerThomas Martitz <kugel@rockbox.org>2010-05-03 15:12:19 +0000
commit69f8e8d277f3edd02d44ac1452d9471a5fedf2f1 (patch)
tree50d9ffbad95ae31e14a6fbfb5a272deff6dd9b29 /apps/misc.c
parentb3f1eb8bbafdac59f2f532adaae97debbcf48a9b (diff)
Move read_line() further down so that it can be used in checkwps and remove checkwps' copy if it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25793 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/misc.c')
-rw-r--r--apps/misc.c74
1 files changed, 38 insertions, 36 deletions
diff --git a/apps/misc.c b/apps/misc.c
index f9c6116205..eebcc9aebc 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
+#include <errno.h>
#include "config.h"
#include "misc.h"
#include "lcd.h"
@@ -33,7 +34,6 @@
#include "lang.h"
#include "dir.h"
#include "lcd-remote.h"
-#include "errno.h"
#include "system.h"
#include "timefuncs.h"
#include "screens.h"
@@ -158,41 +158,6 @@ bool warn_on_pl_erase(void)
return true;
}
-/* Read (up to) a line of text from fd into buffer and return number of bytes
- * read (which may be larger than the number of bytes stored in buffer). If
- * an error occurs, -1 is returned (and buffer contains whatever could be
- * read). A line is terminated by a LF char. Neither LF nor CR chars are
- * stored in buffer.
- */
-int read_line(int fd, char* buffer, int buffer_size)
-{
- int count = 0;
- int num_read = 0;
-
- errno = 0;
-
- while (count < buffer_size)
- {
- unsigned char c;
-
- if (1 != read(fd, &c, 1))
- break;
-
- num_read++;
-
- if ( c == '\n' )
- break;
-
- if ( c == '\r' )
- continue;
-
- buffer[count++] = c;
- }
-
- buffer[MIN(count, buffer_size - 1)] = 0;
-
- return errno ? -1 : num_read;
-}
/* Performance optimized version of the previous function. */
int fast_readline(int fd, char *buf, int buf_size, void *parameters,
@@ -841,6 +806,43 @@ char *strip_extension(char* buffer, int buffer_size, const char *filename)
}
#endif /* !defined(__PCTOOL__) */
+/* Read (up to) a line of text from fd into buffer and return number of bytes
+ * read (which may be larger than the number of bytes stored in buffer). If
+ * an error occurs, -1 is returned (and buffer contains whatever could be
+ * read). A line is terminated by a LF char. Neither LF nor CR chars are
+ * stored in buffer.
+ */
+int read_line(int fd, char* buffer, int buffer_size)
+{
+ int count = 0;
+ int num_read = 0;
+
+ errno = 0;
+
+ while (count < buffer_size)
+ {
+ unsigned char c;
+
+ if (1 != read(fd, &c, 1))
+ break;
+
+ num_read++;
+
+ if ( c == '\n' )
+ break;
+
+ if ( c == '\r' )
+ continue;
+
+ buffer[count++] = c;
+ }
+
+ buffer[MIN(count, buffer_size - 1)] = 0;
+
+ return errno ? -1 : num_read;
+}
+
+
char* skip_whitespace(char* const str)
{
char *s = str;