diff options
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/config.c b/src/config.c index df9816e..8250749 100644 --- a/src/config.c +++ b/src/config.c | |||
@@ -137,25 +137,25 @@ safe_file_name (char *file_name) | |||
137 | { | 137 | { |
138 | file_name[0] = '/'; | 138 | file_name[0] = '/'; |
139 | file_name[1] = 0; | 139 | file_name[1] = 0; |
140 | } | 140 | } |
141 | 141 | ||
142 | return file_name; | 142 | return file_name; |
143 | } | 143 | } |
144 | 144 | ||
145 | /* Same as safe_file_name, but returns an allocated copy. */ | 145 | /* Same as safe_file_name, but returns an allocated copy. */ |
146 | char * | 146 | char * |
147 | safe_file_name_alloc (const char *file_name) | 147 | safe_file_name_alloc (const char *file_name) |
148 | { | 148 | { |
149 | char *s = xstrdup (file_name); | 149 | char *s = grecs_strdup (file_name); |
150 | char *ns = safe_file_name (s); | 150 | char *ns = safe_file_name (s); |
151 | if (!ns) | 151 | if (!ns) |
152 | free (s); | 152 | free (s); |
153 | return ns; | 153 | return ns; |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | static struct keyword event_tab[] = { | 157 | static struct keyword event_tab[] = { |
158 | { "success", ev_success }, | 158 | { "success", ev_success }, |
159 | { "bad-ownership", ev_bad_ownership }, | 159 | { "bad-ownership", ev_bad_ownership }, |
160 | { "bad-directive-signature", ev_bad_directive_signature }, | 160 | { "bad-directive-signature", ev_bad_directive_signature }, |
161 | { "bad-detached-signature", ev_bad_detached_signature }, | 161 | { "bad-detached-signature", ev_bad_detached_signature }, |
@@ -540,70 +540,70 @@ cb_sql_host (enum grecs_callback_command cmd, | |||
540 | char *p; | 540 | char *p; |
541 | 541 | ||
542 | if (assert_string_arg (locus, cmd, value)) | 542 | if (assert_string_arg (locus, cmd, value)) |
543 | return 1; | 543 | return 1; |
544 | 544 | ||
545 | p = strchr (value->v.string, ':'); | 545 | p = strchr (value->v.string, ':'); |
546 | if (p) | 546 | if (p) |
547 | { | 547 | { |
548 | /* FIXME: Modifies constant string */ | 548 | /* FIXME: Modifies constant string */ |
549 | *p++ = 0; | 549 | *p++ = 0; |
550 | if (p[0] == '/') | 550 | if (p[0] == '/') |
551 | { | 551 | { |
552 | pconn->socket = xstrdup (p); | 552 | pconn->socket = grecs_strdup (p); |
553 | pconn->host = xstrdup ("localhost"); | 553 | pconn->host = grecs_strdup ("localhost"); |
554 | } | 554 | } |
555 | else | 555 | else |
556 | { | 556 | { |
557 | char *end; | 557 | char *end; |
558 | unsigned long n = strtoul (p, &end, 10); | 558 | unsigned long n = strtoul (p, &end, 10); |
559 | if (*end) | 559 | if (*end) |
560 | { | 560 | { |
561 | grecs_error (locus, 0, _("invalid port number (near %s)"), end); | 561 | grecs_error (locus, 0, _("invalid port number (near %s)"), end); |
562 | return 0; | 562 | return 0; |
563 | } | 563 | } |
564 | if (n == 0 || n > USHRT_MAX) | 564 | if (n == 0 || n > USHRT_MAX) |
565 | { | 565 | { |
566 | grecs_error (locus, 0, _("port number out of range 1..%d"), | 566 | grecs_error (locus, 0, _("port number out of range 1..%d"), |
567 | USHRT_MAX); | 567 | USHRT_MAX); |
568 | return 0; | 568 | return 0; |
569 | } | 569 | } |
570 | pconn->port = n; | 570 | pconn->port = n; |
571 | /* Save host name */ | 571 | /* Save host name */ |
572 | pconn->host = xstrdup (value->v.string); | 572 | pconn->host = grecs_strdup (value->v.string); |
573 | } | 573 | } |
574 | } | 574 | } |
575 | else | 575 | else |
576 | pconn->host = xstrdup (value->v.string); | 576 | pconn->host = grecs_strdup (value->v.string); |
577 | return 0; | 577 | return 0; |
578 | } | 578 | } |
579 | 579 | ||
580 | static int | 580 | static int |
581 | cb_sql (enum grecs_callback_command cmd, | 581 | cb_sql (enum grecs_callback_command cmd, |
582 | grecs_locus_t *locus, | 582 | grecs_locus_t *locus, |
583 | void *varptr, | 583 | void *varptr, |
584 | grecs_value_t *value, | 584 | grecs_value_t *value, |
585 | void *cb_data) | 585 | void *cb_data) |
586 | { | 586 | { |
587 | struct sqlconn *pconn; | 587 | struct sqlconn *pconn; |
588 | void **pdata = cb_data; | 588 | void **pdata = cb_data; |
589 | 589 | ||
590 | switch (cmd) { | 590 | switch (cmd) { |
591 | case grecs_callback_section_begin: | 591 | case grecs_callback_section_begin: |
592 | if (!value || value->type != GRECS_TYPE_STRING) | 592 | if (!value || value->type != GRECS_TYPE_STRING) |
593 | { | 593 | { |
594 | grecs_error(locus, 0, _("tag must be a string")); | 594 | grecs_error(locus, 0, _("tag must be a string")); |
595 | return 0; | 595 | return 0; |
596 | } | 596 | } |
597 | pconn = xzalloc (sizeof (*pconn)); | 597 | pconn = grecs_zalloc (sizeof (*pconn)); |
598 | pconn->ident = strdup (value->v.string); | 598 | pconn->ident = strdup (value->v.string); |
599 | *pdata = pconn; | 599 | *pdata = pconn; |
600 | break; | 600 | break; |
601 | 601 | ||
602 | case grecs_callback_section_end: | 602 | case grecs_callback_section_end: |
603 | pconn = *pdata; | 603 | pconn = *pdata; |
604 | sql_register_conn (pconn); | 604 | sql_register_conn (pconn); |
605 | free (pconn); | 605 | free (pconn); |
606 | *pdata = NULL; | 606 | *pdata = NULL; |
607 | break; | 607 | break; |
608 | 608 | ||
609 | case grecs_callback_set_value: | 609 | case grecs_callback_set_value: |
@@ -887,25 +887,25 @@ static struct grecs_keyword notify_event_kw[] = { | |||
887 | static int | 887 | static int |
888 | cb_notify_event (enum grecs_callback_command cmd, | 888 | cb_notify_event (enum grecs_callback_command cmd, |
889 | grecs_locus_t *locus, | 889 | grecs_locus_t *locus, |
890 | void *varptr, | 890 | void *varptr, |
891 | grecs_value_t *value, | 891 | grecs_value_t *value, |
892 | void *cb_data) | 892 | void *cb_data) |
893 | { | 893 | { |
894 | struct notification *ntf; | 894 | struct notification *ntf; |
895 | void **pdata = cb_data; | 895 | void **pdata = cb_data; |
896 | 896 | ||
897 | switch (cmd) { | 897 | switch (cmd) { |
898 | case grecs_callback_section_begin: | 898 | case grecs_callback_section_begin: |
899 | ntf = xzalloc (sizeof (*ntf)); | 899 | ntf = grecs_zalloc (sizeof (*ntf)); |
900 | *pdata = ntf; | 900 | *pdata = ntf; |
901 | break; | 901 | break; |
902 | 902 | ||
903 | case grecs_callback_section_end: | 903 | case grecs_callback_section_end: |
904 | ntf = *pdata; | 904 | ntf = *pdata; |
905 | if (!ntf->msg) | 905 | if (!ntf->msg) |
906 | grecs_error (locus, 0, _("missing message definition")); | 906 | grecs_error (locus, 0, _("missing message definition")); |
907 | else | 907 | else |
908 | { | 908 | { |
909 | struct notification **p = (struct notification **) varptr; | 909 | struct notification **p = (struct notification **) varptr; |
910 | ntf->next = *p; | 910 | ntf->next = *p; |
911 | *p = ntf; | 911 | *p = ntf; |
@@ -975,34 +975,34 @@ cb_dictionary_params (enum grecs_callback_command cmd, | |||
975 | size = grecs_list_size (value->v.list); | 975 | size = grecs_list_size (value->v.list); |
976 | if (size == 0) | 976 | if (size == 0) |
977 | { | 977 | { |
978 | meth->parmc = 0; | 978 | meth->parmc = 0; |
979 | meth->parmv = NULL; | 979 | meth->parmv = NULL; |
980 | } | 980 | } |
981 | else | 981 | else |
982 | { | 982 | { |
983 | int i; | 983 | int i; |
984 | struct grecs_list_entry *ep; | 984 | struct grecs_list_entry *ep; |
985 | 985 | ||
986 | meth->parmc = size; | 986 | meth->parmc = size; |
987 | meth->parmv = xcalloc (size + 1, sizeof (meth->parmv[0])); | 987 | meth->parmv = grecs_calloc (size + 1, sizeof (meth->parmv[0])); |
988 | 988 | ||
989 | for (i = 0, ep = value->v.list->head; ep; ep = ep->next, i++) | 989 | for (i = 0, ep = value->v.list->head; ep; ep = ep->next, i++) |
990 | { | 990 | { |
991 | const grecs_value_t *vp = ep->data; | 991 | const grecs_value_t *vp = ep->data; |
992 | 992 | ||
993 | if (assert_string_arg (locus, cmd, vp)) | 993 | if (assert_string_arg (locus, cmd, vp)) |
994 | break; | 994 | break; |
995 | 995 | ||
996 | meth->parmv[i] = xstrdup (vp->v.string); | 996 | meth->parmv[i] = grecs_strdup (vp->v.string); |
997 | } | 997 | } |
998 | meth->parmv[i] = NULL; | 998 | meth->parmv[i] = NULL; |
999 | } | 999 | } |
1000 | return 0; | 1000 | return 0; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | static struct grecs_keyword dictionary_kw[] = { | 1003 | static struct grecs_keyword dictionary_kw[] = { |
1004 | { "type", N_("type"), N_("Dictionary type"), | 1004 | { "type", N_("type"), N_("Dictionary type"), |
1005 | grecs_type_string, NULL, offsetof(struct dictionary, type), | 1005 | grecs_type_string, NULL, offsetof(struct dictionary, type), |
1006 | cb_dictionary_type }, | 1006 | cb_dictionary_type }, |
1007 | { "query", N_("string"), N_("Query template"), | 1007 | { "query", N_("string"), N_("Query template"), |
1008 | grecs_type_string, NULL, offsetof(struct dictionary, query) }, | 1008 | grecs_type_string, NULL, offsetof(struct dictionary, query) }, |
@@ -1150,26 +1150,26 @@ cb_spool (enum grecs_callback_command cmd, | |||
1150 | struct spool *spool; | 1150 | struct spool *spool; |
1151 | void **pdata = cb_data; | 1151 | void **pdata = cb_data; |
1152 | int rc, ec, i; | 1152 | int rc, ec, i; |
1153 | 1153 | ||
1154 | switch (cmd) | 1154 | switch (cmd) |
1155 | { | 1155 | { |
1156 | case grecs_callback_section_begin: | 1156 | case grecs_callback_section_begin: |
1157 | if (!value || value->type != GRECS_TYPE_STRING) | 1157 | if (!value || value->type != GRECS_TYPE_STRING) |