aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2022-03-08 20:08:05 -0900
committerDavid M. Syzdek <david@syzdek.net>2022-03-08 20:08:05 -0900
commit26a231f23b9ad8b7c152269558b2c5e870cbd294 (patch)
tree8f405992d47fdce88e0a7af1ed087281758a12ab /src
parent6c0fd226b65ae2663483e0f3b64b898e5407eac3 (diff)
downloadtinyrad-26a231f23b9ad8b7c152269558b2c5e870cbd294.tar.gz
tinyrad-26a231f23b9ad8b7c152269558b2c5e870cbd294.tar.bz2
tinyrad-26a231f23b9ad8b7c152269558b2c5e870cbd294.tar.xz
tinyrad-26a231f23b9ad8b7c152269558b2c5e870cbd294.zip
tinyrad: removing my_file_readline()
Diffstat (limited to 'src')
-rw-r--r--src/tinyrad.c61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/tinyrad.c b/src/tinyrad.c
index ab43d01..c396686 100644
--- a/src/tinyrad.c
+++ b/src/tinyrad.c
@@ -111,12 +111,6 @@ my_file_close(
111 MyFile * fb ); 111 MyFile * fb );
112 112
113 113
114int
115my_file_readline(
116 unsigned opts,
117 MyFile * fb );
118
119
120void 114void
121my_usage( void ); 115my_usage( void );
122 116
@@ -304,61 +298,6 @@ my_file_close(
304} 298}
305 299
306 300
307int
308my_file_readline(
309 unsigned opts,
310 MyFile * fb )
311{
312 size_t offset;
313 size_t pos;
314 size_t size;
315 ssize_t rc;
316
317 assert(fb != 0);
318
319 // adjusts beginning of line
320 fb->bol = ((fb->eol)) ? &fb->eol[1] : fb->buff;
321
322 // look for end line
323 if ((fb->eol = strchr(fb->bol, '\n')) != NULL)
324 {
325 fb->eol[0] = '\0';
326 return(1);
327 };
328
329 // shift buffer
330 offset = (size_t)(fb->bol = fb->buff);
331 for(pos = 0; ((pos+offset) < fb->len); pos++)
332 fb->buff[pos] = fb->buff[pos+offset];
333 fb->buff[pos] = '\0';
334 fb->len -= offset;
335
336 // attempt to fill buffer
337 size = sizeof(fb->buff) - fb->len - 1;
338 if ((rc = read(fb->fd, &fb->buff[fb->len], size)) == -1)
339 {
340 trutils_error(opts, NULL, "%s: %s", fb->filename, strerror(errno));
341 return(-1);
342 };
343 fb->len += (size_t)rc;
344 fb->buff[fb->len] = '\0';
345 fb->bol = fb->buff;
346 if (!(fb->len))
347 return(0);
348
349 // look for end line
350 if ((fb->eol = strchr(fb->bol, '\n')) != NULL)
351 {
352 fb->eol[0] = '\0';
353 return(1);
354 };
355
356 fb->eol = &fb->bol[strlen(fb->bol)];
357
358 return(0);
359}
360
361
362void my_usage(void) 301void my_usage(void)
363{ 302{
364 printf("Usage: %s [OPTIONS] url\n", PROGRAM_NAME); 303 printf("Usage: %s [OPTIONS] url\n", PROGRAM_NAME);