#INSTALL_PROGRAM = $(INSTALL)
LIBDNS_SOURCES=rdata.c util.c rr.c packet.c
-LIBDNS_HEADERS=rdata.h prototype.h rr.h packet.h util.h \
-error.h
+LIBDNS_HEADERS=rdata.h prototype.h rr.h packet.h util.h error.h
LIBDNS_OBJECTS=$(LIBDNS_SOURCES:.c=.o)
ALL_SOURCES=run-test0.c $(LIBDNS_SOURCES)
enum ldns_enum_status_type
{
- EEMPTY_LABEL = 1 * __X,
- EDDD_OVERFLOW = 2 * __X
+ LDNS_E_OK = 0,
+ LDNS_E_EMPTY_LABEL = 1 * __X,
+ LDNS_E_DDD_OVERFLOW = 2 * __X
};
-typedef enum ldns_enum_status_type ldns_t_status;
+typedef enum ldns_enum_status_type ldns_status_type;
#endif /* _ERROR_H */
#include <config.h>
#include <ldns/rdata.h>
+#include <ldns/error.h>
#include "util.h"
-#include "error.h"
/* Access functions
* do this as functions to get type checking
/**
* remove \DDD, \[space] and other escapes from the input
* See RFC 1035, section 5.1
- * Return the lenght of the string or a negative error
+ * Return the length of the string or a negative error
* code
*/
-ldns_t_status
-_ldns_octet(char *word)
+ldns_status_type
+_ldns_octet(char *word, size_t *length)
{
char *s; char *p;
- unsigned int length = 0;
+ *length = 0;
for (s = p = word; *s != '\0'; s++,p++) {
switch (*s) {
case '.':
if (s[1] == '.') {
fprintf(stderr,"Empty label");
- return EEMPTY_LABEL;
+ return LDNS_E_EMPTY_LABEL;
}
*p = *s;
- length++;
+ *length++;
break;
case '\\':
if ('0' <= s[1] && s[1] <= '9' &&
/* this also handles \0 */
s += 3;
*p = val;
- length++;
+ *length++;
} else {
- fprintf(stderr,"ASCII \\DDD overflow");
+ return LDNS_E_DDD_OVERFLOW;
}
} else {
/* an espaced character, like \<space> ?
* remove the '\' keep the rest */
*p = *++s;
- length++;
+ *length++;
}
break;
case '\"':
* the string */
*p = *++s; /* skip it */
- length++;
+ *length++;
/* I'm not sure if this is needed in libdns... MG */
if ( *s == '\0' ) {
/* ok, it was the last one */
- *p = '\0'; return length;
+ *p = '\0';
+ return LDNS_E_OK;
}
break;
default:
*p = *s;
- length++;
+ *length++;
break;
}
}
*p = '\0';
- return length;
+ return LDNS_E_OK;
}