aboutsummaryrefslogtreecommitdiff
path: root/src/zonefile.c
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2021-09-19 16:20:12 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2021-09-19 16:20:12 +0200
commit1a30093457b4f50a5c28fd8923007fc0e657ba09 (patch)
treeaa8b7b4c5e825fd514127194389677364998f12f /src/zonefile.c
parent1fde26df00673cf863435ae0db7c9edb24593987 (diff)
downloaddns-1a30093457b4f50a5c28fd8923007fc0e657ba09.tar.gz
zonefile
Diffstat (limited to 'src/zonefile.c')
-rw-r--r--src/zonefile.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/zonefile.c b/src/zonefile.c
index 3f00212..13a2a34 100644
--- a/src/zonefile.c
+++ b/src/zonefile.c
@@ -6,27 +6,39 @@
#include "zonefile.h"
-int zonefile_parse_line(database_t *_database, char *_line) {
+int zonefile_string_split(char* _parts[], ssize_t _max, char* _str, char _delim) {
unsigned int i, o, start;
- char *parts[5];
-
- /* Does this work? */
- memset(&parts, 0, sizeof(parts));
start = 0;
- for ( i=0; i < 4; i++ ) {
- for ( o=start; _line[o] && _line[o] != ' '; o++ );
+ for ( i=0; i < _max; i++ ) {
+ for ( o=start; _str[o] && _str[o] != ' '; o++ );
- parts[i] = &_line[start];
+ _parts[i] = &_str[start];
- if(!_line[o])
+ if(!_str[o])
break;
- _line[o] = '\0';
+ _str[o] = '\0';
start = o+1;
}
+ return (int)i + 1;
+}
+
+int zonefile_parse_line(database_t *_database, char *_line) {
+ char *parts[5];
+ int parts_len;
+
+ /* Does this work? */
+ memset(&parts, 0, sizeof(parts));
+
+ parts_len = zonefile_string_split(parts, 4, _line, ' ');
+ if (parts_len != 4) {
+ LOGPRINTF(_LOG_ERROR, "Incomplete");
+ return -1;
+ }
+
/* parts is the first 5 space-seperated parts of _line */
return -1;
@@ -44,11 +56,13 @@ int zonefile_to_database (database_t *_database, char* _file) {
return -1;
}
+ DEBUG("Parsing zonefile %s", _file)
+
while(!feof(zfile)) {
line_cnt ++;
line_len = getline(&line, 0, zfile);
- /* getline includes the line break. ONLY UNIX!! */
+ /* getline includes the line break. ONLY UNIX ENDINGS!! */
if( line[line_len - 2] == '\n' )
line[line_len - 2] = '\0';