home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "socketlib.h"
-
- /*
- * Read a line from a file, junking comments
- */
- char *__socketlib_readline(FILE *file)
- {
- static char line[256];
-
- char *hash;
-
- do
- {
- /* Read a line from the file */
- if (fgets(line, 256, file) == NULL)
- return NULL;
-
- /* Format the line */
- if ((hash = strchr(line, '#')) != NULL)
- {
- /* Throw away any comments on the line */
- *hash = '\0';
- }
- else
- {
- /* Remove the newline */
- line[strlen(line) - 1] = '\0';
- }
- }
- while (strlen(line) == 0);
-
- /* Return the line */
- return line;
- }
-