service: constify struct service fields
[project/mdnsd.git] / service.c
index 9d3f084..9eb620e 100644 (file)
--- a/service.c
+++ b/service.c
@@ -46,8 +46,8 @@ struct service {
 
        time_t t;
 
-       char *service;
-       char *daemon;
+       const char *service;
+       const char *daemon;
        const uint8_t *txt;
        int txt_len;
        int port;
@@ -70,8 +70,8 @@ char *hostname = NULL;
 static char *sdudp =  "_services._dns-sd._udp.local";
 static char *sdtcp =  "_services._dns-sd._tcp.local";
 
-char*
-service_name(char *domain)
+char *
+service_name(const char *domain)
 {
        static char buffer[256];
 
@@ -84,7 +84,7 @@ static void
 service_send_ptr(struct uloop_fd *u, struct service *s)
 {
        unsigned char buffer[MAX_NAME_LEN];
-       char *host = service_name(s->service);
+       const char *host = service_name(s->service);
        int len = dn_comp(host, buffer, MAX_NAME_LEN, NULL, NULL);
 
        if (len < 1)
@@ -94,7 +94,7 @@ service_send_ptr(struct uloop_fd *u, struct service *s)
 }
 
 static void
-service_send_ptr_c(struct uloop_fd *u, char *host)
+service_send_ptr_c(struct uloop_fd *u, const char *host)
 {
        unsigned char buffer[MAX_NAME_LEN];
        int len = dn_comp(host, buffer, MAX_NAME_LEN, NULL, NULL);
@@ -173,7 +173,7 @@ service_reply_a(struct uloop_fd *u, int type)
 }
 
 void
-service_reply(struct uloop_fd *u, char *match)
+service_reply(struct uloop_fd *u, const char *match)
 {
        struct service *s;
 
@@ -209,7 +209,7 @@ service_reply(struct uloop_fd *u, char *match)
 }
 
 void
-service_announce_services(struct uloop_fd *u, char *service)
+service_announce_services(struct uloop_fd *u, const char *service)
 {
        struct service *s;
        int tcp = 1;
@@ -280,10 +280,8 @@ service_load(char *path)
                                continue;
 
                        s->port = blobmsg_get_u32(_tb[SERVICE_PORT]);
-                       s->service = d_service;
-                       s->daemon = d_daemon;
-                       strcpy(s->service, blobmsg_name(cur));
-                       strcpy(s->daemon, gl.gl_pathv[i]);
+                       s->service = strcpy(d_service, blobmsg_name(cur));
+                       s->daemon = strcpy(d_daemon, gl.gl_pathv[i]);
                        s->avl.key = s->service;
                        s->active = 1;
                        s->t = 0;