]> git.karo-electronics.de Git - mdnsd.git/commitdiff
Replaced int8_t by char for all strings
authorOle Reinhardt <ole.reinhardt@kernelconcepts.de>
Wed, 1 May 2013 16:34:01 +0000 (18:34 +0200)
committerOle Reinhardt <ole.reinhardt@kernelconcepts.de>
Wed, 1 May 2013 16:34:01 +0000 (18:34 +0200)
mdnsd.c
mdnsd.h
rfc1035.c
rfc1035.h

diff --git a/mdnsd.c b/mdnsd.c
index a04a98480414ead60309a2bd30b329396e1cc848..1ef5b85e9db3fcbc91ab2da75d3a129474231fe1 100644 (file)
--- a/mdnsd.c
+++ b/mdnsd.c
  * \return      The calculated hash value
  */
 
-static int NameHash(const int8_t *str)
+static int NameHash(const char *str)
 {
-    const uint8_t *name = (const uint8_t *)str;
+    const char *name = (const char *)str;
     uint32_t hash = 0;
     uint32_t g;
 
@@ -151,7 +151,7 @@ static int NameHash(const int8_t *str)
  *
  * \return          The next matching query or NULL
  */
-static TQuery *QueryNext(TMdnsd *mdnsd, TQuery *query, int8_t *host, int type)
+static TQuery *QueryNext(TMdnsd *mdnsd, TQuery *query, char *host, int type)
 {
     if (query == NULL) {
         query = mdnsd->queries[NameHash(host) % SPRIME];
@@ -183,7 +183,7 @@ static TQuery *QueryNext(TMdnsd *mdnsd, TQuery *query, int8_t *host, int type)
  *
  * \return          The next matching cache entry or NULL
  */
-static TCached *CachedNext(TMdnsd *mdnsd, TCached *cached, uint8_t *host, int type)
+static TCached *CachedNext(TMdnsd *mdnsd, TCached *cached, char *host, int type)
 {
     if (cached == NULL) {
         cached = mdnsd->cache[NameHash(host) % LPRIME];
@@ -214,7 +214,7 @@ static TCached *CachedNext(TMdnsd *mdnsd, TCached *cached, uint8_t *host, int ty
  *
  * \return          The next matching dns record or NULL
  */
-static TMdnsdRecord *RecordNext(TMdnsd *mdnsd, TMdnsdRecord *record, uint8_t *host, int type)
+static TMdnsdRecord *RecordNext(TMdnsd *mdnsd, TMdnsdRecord *record, char *host, int type)
 {
     if (record == NULL) {
         record = mdnsd->published[NameHash(host) % SPRIME];
@@ -813,7 +813,7 @@ void MdnsdFree(TMdnsd *mdnsd)
 }
 
 #ifdef MDNSD_DEBUG
-uint8_t *MdnsdDecodeType(uint16_t type)
+char *MdnsdDecodeType(uint16_t type)
 {
     switch (type) {
         case QTYPE_A:     return "A";
@@ -860,7 +860,7 @@ void MdnsdDumpRessource (FILE *file, DNSRESOURCE *res)
     }
 }
 
-void mdnsd_dump (FILE *file, DNSMESSAGE *msg, uint8_t *type)
+void mdnsd_dump (FILE *file, DNSMESSAGE *msg, char *type)
 {
     int idx;
 
@@ -1334,7 +1334,7 @@ out:
  *
  * \return          Maximum time after which MdnsdOutput needs to be called again
  */
-void MdnsdQuery(TMdnsd *mdnsd, uint8_t *host, int type, int (*answer)(TMdnsdAnswer *answer, void *arg), void *arg)
+void MdnsdQuery(TMdnsd *mdnsd, char *host, int type, int (*answer)(TMdnsdAnswer *answer, void *arg), void *arg)
 {
     TQuery  *query;
     TCached *current = NULL;
@@ -1388,7 +1388,7 @@ void MdnsdQuery(TMdnsd *mdnsd, uint8_t *host, int type, int (*answer)(TMdnsdAnsw
  *
  * \return          next cached answer
  */
-TMdnsdAnswer *MdnsdListCachedAnswers(TMdnsd *mdnsd, uint8_t *host, int type, TMdnsdAnswer *last)
+TMdnsdAnswer *MdnsdListCachedAnswers(TMdnsd *mdnsd, char *host, int type, TMdnsdAnswer *last)
 {
     return (TMdnsdAnswer *)CachedNext(mdnsd, (TCached *)last, host, type);
 }
@@ -1409,7 +1409,7 @@ TMdnsdAnswer *MdnsdListCachedAnswers(TMdnsd *mdnsd, uint8_t *host, int type, TMd
  *
  * \return          newly allocated share record
  */
-TMdnsdRecord *MdnsdAllocShared(TMdnsd *mdnsd, uint8_t *host, int type, uint32_t ttl)
+TMdnsdRecord *MdnsdAllocShared(TMdnsd *mdnsd, char *host, int type, uint32_t ttl)
 {
     int idx;
     TMdnsdRecord *record;
@@ -1451,7 +1451,7 @@ TMdnsdRecord *MdnsdAllocShared(TMdnsd *mdnsd, uint8_t *host, int type, uint32_t
  *
  * \return          newly allocated share record
  */
-TMdnsdRecord *MdnsdAllocUnique(TMdnsd *mdnsd, uint8_t *host, int type, uint32_t ttl, void (*conflict)(TMdnsdRecord *record, uint8_t *host, int type, void *arg), void *arg)
+TMdnsdRecord *MdnsdAllocUnique(TMdnsd *mdnsd, char *host, int type, uint32_t ttl, void (*conflict)(TMdnsdRecord *record, char *host, int type, void *arg), void *arg)
 {
     TMdnsdRecord *record;
     record = MdnsdAllocShared(mdnsd, host, type, ttl);
@@ -1517,7 +1517,7 @@ void MdnsdSetRaw(TMdnsd *mdnsd, TMdnsdRecord *record, uint8_t *data, int len)
  * \param record    The record which shall be de-listed
  * \param name      Hostname
  */
-void MdnsdSetHost(TMdnsd *mdnsd, TMdnsdRecord *record, uint8_t *name)
+void MdnsdSetHost(TMdnsd *mdnsd, TMdnsdRecord *record, char *name)
 {
     free(record->rr.rdname);
     record->rr.rdname = strdup(name);
@@ -1549,7 +1549,7 @@ void MdnsdSetIp(TMdnsd *mdnsd, TMdnsdRecord *record, struct in_addr ip)
  * \param port      TCP / UDP port number of the service
  * \param name      The canonical hostname of the machine providing the service.
  */
-void MdnsdSetSrv(TMdnsd *mdnsd, TMdnsdRecord *record, int priority, int weight, uint16_t port, uint8_t *name)
+void MdnsdSetSrv(TMdnsd *mdnsd, TMdnsdRecord *record, int priority, int weight, uint16_t port, char *name)
 {
     record->rr.srv.priority = priority;
     record->rr.srv.weight = weight;
diff --git a/mdnsd.h b/mdnsd.h
index c5cc7b4d7ba077eba4518933615eae2ed66f698b..90ae20c112c028da6c31a0b5773b3e98beb79b22 100644 (file)
--- a/mdnsd.h
+++ b/mdnsd.h
 typedef struct _mdnsda_struct  TMdnsdAnswer;
 struct _mdnsda_struct
 {
-    uint8_t *name;
+    char    *name;
     uint16_t type;
     uint32_t ttl;
     uint16_t rdlen;
-    uint8_t *rdata;
+    char    *rdata;
     struct in_addr ip; // A
     uint8_t *rdname;   // NS/CNAME/PTR/SRV
     struct {
@@ -135,7 +135,7 @@ struct _mdnsdr_struct
     TMdnsdAnswer rr;
     int8_t unique; // # of checks performed to ensure
     int    tries;
-    void  (*conflict)(TMdnsdRecord *record, uint8_t *name, int type, void *arg);
+    void  (*conflict)(TMdnsdRecord *record,char *name, int type, void *arg);
     void   *arg;
     TMdnsdRecord *next;
     TMdnsdRecord *list;
@@ -148,7 +148,7 @@ struct _mdnsdr_struct
 typedef struct _query_struct   TQuery;
 struct _query_struct
 {
-    uint8_t *name;
+    char    *name;
     int      type;
     uint32_t nexttry;
     int      tries;
@@ -223,18 +223,18 @@ int MdnsdOutput(TMdnsd *mdnsd, DNSMESSAGE *m, struct in_addr *ip, uint16_t *port
 struct timeval *MdnsdGetMaxSleepTime(TMdnsd *mdnsd);
 
 /* Qery / Answer functions */
-void MdnsdQuery(TMdnsd *mdnsd, uint8_t *host, int type, int (*answer)(TMdnsdAnswer *a, void *arg), void *arg);
-TMdnsdAnswer *MdnsdListCachedAnswers(TMdnsd *mdnsd, uint8_t *host, int type, TMdnsdAnswer *last);
+void MdnsdQuery(TMdnsd *mdnsd, char *host, int type, int (*answer)(TMdnsdAnswer *a, void *arg), void *arg);
+TMdnsdAnswer *MdnsdListCachedAnswers(TMdnsd *mdnsd, char *host, int type, TMdnsdAnswer *last);
 
 /* Publishing functions */
-TMdnsdRecord *MdnsdAllocUnique(TMdnsd *mdnsd, uint8_t *host, int type, uint32_t ttl, void (*conflict)(TMdnsdRecord *record, uint8_t *host, int type, void *arg), void *arg);
-TMdnsdRecord *MdnsdAllocShared(TMdnsd *mdnsd, uint8_t *host, int type, uint32_t ttl);
+TMdnsdRecord *MdnsdAllocUnique(TMdnsd *mdnsd, char *host, int type, uint32_t ttl, void (*conflict)(TMdnsdRecord *record, char *host, int type, void *arg), void *arg);
+TMdnsdRecord *MdnsdAllocShared(TMdnsd *mdnsd, char *host, int type, uint32_t ttl);
 void MdnsdDone(TMdnsd *mdnsd, TMdnsdRecord *record);
 
 /* These all set/update the data for the given record, nothing is published until they are called */
 void MdnsdSetRaw(TMdnsd *mdnsd, TMdnsdRecord *record, uint8_t *data, int len);
-void MdnsdSetHost(TMdnsd *mdnsd, TMdnsdRecord *record, uint8_t *name);
+void MdnsdSetHost(TMdnsd *mdnsd, TMdnsdRecord *record, char *name);
 void MdnsdSetIp(TMdnsd *mdnsd, TMdnsdRecord *record, struct in_addr ip);
-void MdnsdSetSrv(TMdnsd *mdnsd, TMdnsdRecord *record, int priority, int weight, uint16_t port, uint8_t *name);
+void MdnsdSetSrv(TMdnsd *mdnsd, TMdnsdRecord *record, int priority, int weight, uint16_t port, char *name);
 
 #endif
index 59e93d1551b6c9091851c7a9e72a4ad7369be152..4b552e074f11acee915ed018ae36c4612300cf5f 100644 (file)
--- a/rfc1035.c
+++ b/rfc1035.c
@@ -191,10 +191,10 @@ static uint16_t LabelDecompress(uint8_t *ptr)
  * \param buf   Pointer to the package data buffer
  * \param namep Pointer to the string buffer, where the label will be copied to
  */
-static void ExtractLabel(DNSMESSAGE *msg, uint8_t **buf, uint8_t **namep)
+static void ExtractLabel(DNSMESSAGE *msg, uint8_t **buf, char **namep)
 {
     uint8_t *label;
-    uint8_t *name;
+    char *name;
     int x;
 
     /* Set the name pointer to the end of the data block */
@@ -219,7 +219,7 @@ static void ExtractLabel(DNSMESSAGE *msg, uint8_t **buf, uint8_t **namep)
         }
 
         /* Copy label to the name buffer */
-        memcpy(name, label+1,*label);
+        memcpy(name, label+1, *label);
         name[*label] = '.';
 
         name  += *label + 1;
@@ -316,7 +316,7 @@ static int MatchLabel(DNSMESSAGE *msg, uint8_t *label1, uint8_t *label2)
  *
  * \return          Length of the label
  */
-static int Host2Label(DNSMESSAGE *msg, uint8_t **buf, uint8_t *name)
+static int Host2Label(DNSMESSAGE *msg, uint8_t **buf, char *name)
 {
     uint8_t  label[MAX_LABEL_SIZE];
     uint8_t *l;
@@ -612,7 +612,7 @@ void DnsParseMsg(DNSMESSAGE *msg, uint8_t *packet)
  * \param class     Query class
  * \param ttl       TTL value
  */
-static void DnsAppendRR(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t class, uint32_t ttl)
+static void DnsAppendRR(DNSMESSAGE *msg, char *name, uint16_t type, uint16_t class, uint32_t ttl)
 {
     if (msg->buf == 0) {
         /* Initialise the buffer pointer */
@@ -635,7 +635,7 @@ static void DnsAppendRR(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t
  * \param type      Query type
  * \param class     Query class
  */
-void DnsMsgAdd_qd(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t class)
+void DnsMsgAdd_qd(DNSMESSAGE *msg, char *name, uint16_t type, uint16_t class)
 {
     msg->qdcount++;
     if (msg->buf == 0) {
@@ -659,7 +659,7 @@ void DnsMsgAdd_qd(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t class)
  * \param type      Query type
  * \param class     Query class
  */
-void DnsMsgAdd_an(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t class, uint32_t ttl)
+void DnsMsgAdd_an(DNSMESSAGE *msg, char *name, uint16_t type, uint16_t class, uint32_t ttl)
 {
     msg->ancount++;
     DnsAppendRR(msg, name, type, class, ttl);
@@ -676,7 +676,7 @@ void DnsMsgAdd_an(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t class,
  * \param type      Query type
  * \param class     Query class
  */
-void DnsMsgAdd_ns(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t class, uint32_t ttl)
+void DnsMsgAdd_ns(DNSMESSAGE *msg, char *name, uint16_t type, uint16_t class, uint32_t ttl)
 {
     msg->nscount++;
     DnsAppendRR(msg, name, type, class, ttl);
@@ -691,7 +691,7 @@ void DnsMsgAdd_ns(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t class,
  * \param type      Query type
  * \param class     Query class
  */
-void DnsMsgAdd_ar(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t class, uint32_t ttl)
+void DnsMsgAdd_ar(DNSMESSAGE *msg, char *name, uint16_t type, uint16_t class, uint32_t ttl)
 {
     msg->arcount++;
     DnsAppendRR(msg, name, type, class, ttl);
@@ -717,7 +717,7 @@ void DnsMsgAdd_rdata_long(DNSMESSAGE *msg, uint32_t val)
  * \param msg       DNS message
  * \param name      Hostname
  */
-void DnsMsgAdd_rdata_name(DNSMESSAGE *msg, uint8_t *name)
+void DnsMsgAdd_rdata_name(DNSMESSAGE *msg, char *name)
 {
     uint8_t *tmp_buf = msg->buf;
     msg->buf += 2;
@@ -733,7 +733,7 @@ void DnsMsgAdd_rdata_name(DNSMESSAGE *msg, uint8_t *name)
  * \param port      TCP / UDP port number of the service
  * \param name      The canonical hostname of the machine providing the service.
  */
-void DnsMsgAdd_rdata_srv(DNSMESSAGE *msg, uint16_t priority, uint16_t weight, uint16_t port, uint8_t *name)
+void DnsMsgAdd_rdata_srv(DNSMESSAGE *msg, uint16_t priority, uint16_t weight, uint16_t port, char *name)
 {
     uint8_t *tmp_buf = msg->buf;
     msg->buf += 2;
index 8238cf4893b555746a954c06b86eed06884e36c2..f60841aefb14a30f891ca65207b509caf68406c1 100644 (file)
--- a/rfc1035.h
+++ b/rfc1035.h
  */
 typedef struct
 {
-    uint8_t *name;
+    char    *name;
     uint16_t type;
     uint16_t class;
 } DNSQUESTION;
@@ -128,7 +128,7 @@ typedef struct
  */
 typedef struct
 {
-    uint8_t *name;
+    char    *name;
     uint16_t type;
     uint16_t class;
     uint32_t ttl;
@@ -137,22 +137,22 @@ typedef struct
     union {
         struct {
             uint32_t ip;
-            uint8_t *name;
+            char *name;
         } a;
         struct {
-            uint8_t *name;
+            char *name;
         } ns;
         struct {
-            uint8_t *name;
+            char *name;
         } cname;
         struct {
-            uint8_t *name;
+            char *name;
         } ptr;
         struct {
             uint16_t priority;
             uint16_t weight;
             uint16_t port;
-            uint8_t *name;
+            char *name;
         } srv;
     } known;
 } DNSRESOURCE;
@@ -185,8 +185,8 @@ typedef struct
     DNSRESOURCE *ar;
 
     /* internal variables */
-    uint8_tbuf;
-    uint8_tlabels[MAX_LABEL];
+    uint8_t *buf;
+    uint8_t *labels[MAX_LABEL];
     int len;
     int label;
 
@@ -213,17 +213,17 @@ void DnsParseMsg(DNSMESSAGE *msg, uint8_t *packet);
 DNSMESSAGE *DnsCreateMsg(void);
 
 /* Append a question to the message buffer */
-void DnsMsgAdd_qd(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t class);
+void DnsMsgAdd_qd(DNSMESSAGE *msg, char *name, uint16_t type, uint16_t class);
 
 /* Append a resource record to the message. Call these functions in the below order. */
-void DnsMsgAdd_an(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t class, uint32_t ttl);
-void DnsMsgAdd_ns(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t class, uint32_t ttl);
-void DnsMsgAdd_ar(DNSMESSAGE *msg, uint8_t *name, uint16_t type, uint16_t class, uint32_t ttl);
+void DnsMsgAdd_an(DNSMESSAGE *msg, char *name, uint16_t type, uint16_t class, uint32_t ttl);
+void DnsMsgAdd_ns(DNSMESSAGE *msg, char *name, uint16_t type, uint16_t class, uint32_t ttl);
+void DnsMsgAdd_ar(DNSMESSAGE *msg, char *name, uint16_t type, uint16_t class, uint32_t ttl);
 
 /* Append resource data types blocks */
 void DnsMsgAdd_rdata_long(DNSMESSAGE *msg, uint32_t val);
-void DnsMsgAdd_rdata_name(DNSMESSAGE *msg, uint8_t *name);
-void DnsMsgAdd_rdata_srv(DNSMESSAGE *msg, uint16_t priority, uint16_t weight, uint16_t port, uint8_t *name);
+void DnsMsgAdd_rdata_name(DNSMESSAGE *msg, char *name);
+void DnsMsgAdd_rdata_srv(DNSMESSAGE *msg, uint16_t priority, uint16_t weight, uint16_t port, char *name);
 void DnsMsgAdd_rdata_raw(DNSMESSAGE *msg, uint8_t *rdata, uint16_t rdlength);
 
 /* Generate the message packet to be send out and return the length */