diff options
Diffstat (limited to 'src/pies.c')
-rw-r--r-- | src/pies.c | 115 |
1 files changed, 59 insertions, 56 deletions
@@ -132,7 +132,7 @@ int | |||
132 | config_file_remove (const char *name) | 132 | config_file_remove (const char *name) |
133 | { | 133 | { |
134 | struct grecs_list_entry *ep; | 134 | struct grecs_list_entry *ep; |
135 | 135 | ||
136 | for (ep = config_list->head; ep; ep = ep->next) | 136 | for (ep = config_list->head; ep; ep = ep->next) |
137 | { | 137 | { |
138 | struct config_file *file = ep->data; | 138 | struct config_file *file = ep->data; |
@@ -156,7 +156,7 @@ void | |||
156 | config_file_list_serialize (struct json_value *ar) | 156 | config_file_list_serialize (struct json_value *ar) |
157 | { | 157 | { |
158 | struct grecs_list_entry *ep; | 158 | struct grecs_list_entry *ep; |
159 | 159 | ||
160 | for (ep = config_list->head; ep; ep = ep->next) | 160 | for (ep = config_list->head; ep; ep = ep->next) |
161 | { | 161 | { |
162 | struct config_file *file = ep->data; | 162 | struct config_file *file = ep->data; |
@@ -327,7 +327,7 @@ action_free (struct action *act) | |||
327 | free (act->addr); | 327 | free (act->addr); |
328 | free (act->message); | 328 | free (act->message); |
329 | free (act->command); | 329 | free (act->command); |
330 | 330 | ||
331 | free (act); | 331 | free (act); |
332 | } | 332 | } |
333 | 333 | ||
@@ -359,7 +359,7 @@ create_action (struct component *comp, | |||
359 | unsigned n; | 359 | unsigned n; |
360 | const char *arg = getarg (val, i, locus); | 360 | const char *arg = getarg (val, i, locus); |
361 | size_t len = strlen (arg); | 361 | size_t len = strlen (arg); |
362 | 362 | ||
363 | if (isdigit (arg[0])) | 363 | if (isdigit (arg[0])) |
364 | { | 364 | { |
365 | char *p; | 365 | char *p; |
@@ -394,12 +394,12 @@ create_action (struct component *comp, | |||
394 | grecs_error (locus, 0, _("%s: not a return code"), arg); | 394 | grecs_error (locus, 0, _("%s: not a return code"), arg); |
395 | continue; | 395 | continue; |
396 | } | 396 | } |
397 | 397 | ||
398 | /* Alles in ordnung */ | 398 | /* Alles in ordnung */ |
399 | retv[retc++] = n; | 399 | retv[retc++] = n; |
400 | } | 400 | } |
401 | } | 401 | } |
402 | 402 | ||
403 | if (retc == 0 && !allflag) | 403 | if (retc == 0 && !allflag) |
404 | { | 404 | { |
405 | free (retv); | 405 | free (retv); |
@@ -472,18 +472,18 @@ return_code_section_parser (enum grecs_callback_command cmd, | |||
472 | grecs_error (locus, 0, _("missing tag")); | 472 | grecs_error (locus, 0, _("missing tag")); |
473 | return 1; | 473 | return 1; |
474 | } | 474 | } |
475 | 475 | ||
476 | switch (value->type) | 476 | switch (value->type) |
477 | { | 477 | { |
478 | case GRECS_TYPE_STRING: | 478 | case GRECS_TYPE_STRING: |
479 | act = create_action (comp, locus, value, 1, _get_string_arg); | 479 | act = create_action (comp, locus, value, 1, _get_string_arg); |
480 | break; | 480 | break; |
481 | 481 | ||
482 | case GRECS_TYPE_ARRAY: | 482 | case GRECS_TYPE_ARRAY: |
483 | act = create_action (comp, locus, value, | 483 | act = create_action (comp, locus, value, |
484 | value->v.arg.c, _get_array_arg); | 484 | value->v.arg.c, _get_array_arg); |
485 | break; | 485 | break; |
486 | 486 | ||
487 | case GRECS_TYPE_LIST: | 487 | case GRECS_TYPE_LIST: |
488 | count = grecs_list_size (value->v.list); | 488 | count = grecs_list_size (value->v.list); |
489 | act = create_action (comp, locus, value, count, _get_list_arg); | 489 | act = create_action (comp, locus, value, count, _get_list_arg); |
@@ -492,7 +492,7 @@ return_code_section_parser (enum grecs_callback_command cmd, | |||
492 | return 1; | 492 | return 1; |
493 | *(struct action **) cb_data = act; | 493 | *(struct action **) cb_data = act; |
494 | break; | 494 | break; |
495 | 495 | ||
496 | case grecs_callback_section_end: | 496 | case grecs_callback_section_end: |
497 | break; | 497 | break; |
498 | 498 | ||
@@ -542,7 +542,7 @@ _cb_command (enum grecs_callback_command cmd, | |||
542 | wordsplit_get_words (&ws, &comp->argc, &comp->argv); | 542 | wordsplit_get_words (&ws, &comp->argc, &comp->argv); |
543 | wordsplit_free (&ws); | 543 | wordsplit_free (&ws); |
544 | break; | 544 | break; |
545 | 545 | ||
546 | case GRECS_TYPE_ARRAY: | 546 | case GRECS_TYPE_ARRAY: |
547 | comp->argv = config_array_to_argv (value, locus, &comp->argc); | 547 | comp->argv = config_array_to_argv (value, locus, &comp->argc); |
548 | break; | 548 | break; |
@@ -702,7 +702,7 @@ _cb_redir (enum grecs_callback_command cmd, | |||
702 | {NULL} | 702 | {NULL} |
703 | }; | 703 | }; |
704 | int res; | 704 | int res; |
705 | 705 | ||
706 | switch (value->type) | 706 | switch (value->type) |
707 | { | 707 | { |
708 | case GRECS_TYPE_STRING: | 708 | case GRECS_TYPE_STRING: |
@@ -719,7 +719,7 @@ _cb_redir (enum grecs_callback_command cmd, | |||
719 | return 0; | 719 | return 0; |
720 | } | 720 | } |
721 | break; | 721 | break; |
722 | 722 | ||
723 | case GRECS_TYPE_ARRAY: | 723 | case GRECS_TYPE_ARRAY: |
724 | if (assert_grecs_value_type (locus, value->v.arg.v[0], | 724 | if (assert_grecs_value_type (locus, value->v.arg.v[0], |
725 | GRECS_TYPE_STRING)) | 725 | GRECS_TYPE_STRING)) |
@@ -739,12 +739,12 @@ _cb_redir (enum grecs_callback_command cmd, | |||
739 | if (assert_grecs_value_type (locus, value->v.arg.v[1], | 739 | if (assert_grecs_value_type (locus, value->v.arg.v[1], |
740 | GRECS_TYPE_STRING)) | 740 | GRECS_TYPE_STRING)) |
741 | return 0; | 741 | return 0; |
742 | 742 | ||
743 | switch (res) | 743 | switch (res) |
744 | { | 744 | { |
745 | case redir_null: | 745 | case redir_null: |
746 | break; | 746 | break; |
747 | 747 | ||
748 | case redir_syslog: | 748 | case redir_syslog: |
749 | if (string_to_syslog_priority (value->v.arg.v[1]->v.string, | 749 | if (string_to_syslog_priority (value->v.arg.v[1]->v.string, |
750 | &rp->v.prio)) | 750 | &rp->v.prio)) |
@@ -755,7 +755,7 @@ _cb_redir (enum grecs_callback_command cmd, | |||
755 | return 0; | 755 | return 0; |
756 | } | 756 | } |
757 | break; | 757 | break; |
758 | 758 | ||
759 | case redir_file: | 759 | case redir_file: |
760 | rp->v.file = grecs_strdup (value->v.arg.v[1]->v.string); | 760 | rp->v.file = grecs_strdup (value->v.arg.v[1]->v.string); |
761 | break; | 761 | break; |
@@ -764,17 +764,17 @@ _cb_redir (enum grecs_callback_command cmd, | |||
764 | rp->type = res; | 764 | rp->type = res; |
765 | } | 765 | } |
766 | break; | 766 | break; |
767 | 767 | ||
768 | default: | 768 | default: |
769 | grecs_error (locus, 0, _("unexpected list")); | 769 | grecs_error (locus, 0, _("unexpected list")); |
770 | } | 770 | } |
771 | 771 | ||
772 | return 0; | 772 | return 0; |
773 | } | 773 | } |
774 | 774 | ||
775 | static struct tokendef socktype_xtab[] = { | 775 | static struct tokendef socktype_xtab[] = { |
776 | { "stream", SOCK_STREAM }, | 776 | { "stream", SOCK_STREAM }, |
777 | { "dgram", SOCK_DGRAM }, | 777 | { "dgram", SOCK_DGRAM }, |
778 | { "seqpacket", SOCK_SEQPACKET }, | 778 | { "seqpacket", SOCK_SEQPACKET }, |
779 | { "raw", SOCK_RAW }, | 779 | { "raw", SOCK_RAW }, |
780 | { "rdm", SOCK_RDM }, | 780 | { "rdm", SOCK_RDM }, |
@@ -820,12 +820,14 @@ static struct tokendef modetab[] = { | |||
820 | {"nostartaccept", pies_comp_inetd}, | 820 | {"nostartaccept", pies_comp_inetd}, |
821 | {"pass-fd", pies_comp_pass_fd}, | 821 | {"pass-fd", pies_comp_pass_fd}, |
822 | {"pass", pies_comp_pass_fd}, | 822 | {"pass", pies_comp_pass_fd}, |
823 | {"startup", pies_comp_startup}, | ||
824 | {"shutdown", pies_comp_shutdown}, | ||
823 | {"boot", pies_comp_boot}, | 825 | {"boot", pies_comp_boot}, |
824 | {"bootwait", pies_comp_boot}, | 826 | {"bootwait", pies_comp_boot}, |
825 | {"powerfail", pies_comp_powerfail}, | 827 | {"powerfail", pies_comp_powerfail}, |
826 | {"powerwait", pies_comp_powerwait}, | 828 | {"powerwait", pies_comp_powerwait}, |
827 | {"powerokwait", pies_comp_powerokwait}, | 829 | {"powerokwait", pies_comp_powerokwait}, |
828 | {"ctrlaltdel", pies_comp_ctrlaltdel}, | 830 | {"ctrlaltdel", pies_comp_ctrlaltdel}, |
829 | {"ondemand", pies_comp_ondemand}, | 831 | {"ondemand", pies_comp_ondemand}, |
830 | {"sysinit", pies_comp_sysinit}, | 832 | {"sysinit", pies_comp_sysinit}, |
831 | {"powerfailnow", pies_comp_powerfailnow}, | 833 | {"powerfailnow", pies_comp_powerfailnow}, |
@@ -920,11 +922,11 @@ _cb_flags (enum grecs_callback_command cmd, | |||
920 | return 1; | 922 | return 1; |
921 | } | 923 | } |
922 | break; | 924 | break; |
923 | 925 | ||
924 | case GRECS_TYPE_LIST: | 926 | case GRECS_TYPE_LIST: |
925 | { | 927 | { |
926 | struct grecs_list_entry *ep; | 928 | struct grecs_list_entry *ep; |
927 | 929 | ||
928 | for (ep = value->v.list->head; ep; ep = ep->next) | 930 | for (ep = value->v.list->head; ep; ep = ep->next) |
929 | { | 931 | { |
930 | const grecs_value_t *vp = ep->data; | 932 | const grecs_value_t *vp = ep->data; |
@@ -939,7 +941,7 @@ _cb_flags (enum grecs_callback_command cmd, | |||
939 | } | 941 | } |
940 | } | 942 | } |
941 | break; | 943 | break; |
942 | 944 | ||
943 | case GRECS_TYPE_ARRAY: | 945 | case GRECS_TYPE_ARRAY: |
944 | grecs_error (locus, 0, _("too many arguments")); | 946 | grecs_error (locus, 0, _("too many arguments")); |
945 | return 1; | 947 | return 1; |
@@ -1228,7 +1230,7 @@ struct grecs_keyword * | |||
1228 | find_component_keyword (const char *ident) | 1230 | find_component_keyword (const char *ident) |
1229 | { | 1231 | { |
1230 | struct grecs_keyword *kwp; | 1232 | struct grecs_keyword *kwp; |
1231 | 1233 | ||
1232 | for (kwp = component_keywords; kwp->ident; kwp++) | 1234 | for (kwp = component_keywords; kwp->ident; kwp++) |
1233 | if (strcmp (kwp->ident, ident) == 0) | 1235 | if (strcmp (kwp->ident, ident) == 0) |
1234 | return kwp; | 1236 | return kwp; |
@@ -1256,7 +1258,7 @@ component_section_parser (enum grecs_callback_command cmd, | |||
1256 | comp = *(struct component **) section_data; | 1258 | comp = *(struct component **) section_data; |
1257 |