void destroy_properties_list (prop_list box) { for (prop_list_iterator it = prop_list_begin (box); it != NULL; prop_list_iterator_next (&it)) { destroy_property (it->val); } List_destroy (box); }
rpc_property_t * property_list_to_rpc_property_array (prop_list box) { register unsigned p_index = 0; rpc_property_t * newRpc_plist; if (List_count (box) == 0) return 0; newRpc_plist = malloc (List_count (box) * sizeof (rpc_property_t)); for (prop_list_iterator it = prop_list_begin (box); it != NULL; prop_list_iterator_next (&it)) { newRpc_plist[p_index++] = property_to_rpc_property (it->val); } return newRpc_plist; }
int main (int argc, char * argv[]) { int c; extern char * optarg; extern int optind; svccfg_mode mode; if (argc < 2) { fprintf (stderr, "svccfg: expected option\n"); exit (1); } if (!strcasecmp (argv[1], "import")) mode = IMPORT; else goto mode_unknown; clnt = s16db_context_create (); optind++; switch (mode) { case IMPORT: { int is_systemd = 0; const char * manifest = 0; svc_t * newSvc; while ((c = getopt (argc, argv, "m:s")) != -1) { switch (c) { case 'm': manifest = optarg; break; case 's': is_systemd = 1; break; case '?': exit (1); break; } } if (!manifest) eerror ("import manifest mode, but no manifest specified\n"); newSvc = parse_unit (is_systemd, manifest); if (!newSvc) exit (1); int ret = s16db_svc_install (clnt, newSvc); printf ("installed manifest for service <%s> %d\n", newSvc->name, ret); // return 0; break; } } svc_list box = s16db_svc_retrieve_all (clnt); for (svc_list_iterator it = svc_list_begin (box); it != NULL; svc_list_iterator_next (&it)) { printf ("Service: %s\n", it->val->name); printf (" ID: %d\n", it->val->id); printf (" PList:\n"); for (prop_list_iterator itp = prop_list_begin (it->val->properties); itp != NULL; prop_list_iterator_next (&itp)) { printf (" %s: %s\n", itp->val->name, itp->val->value.pval_u.s); } } s16db_context_destroy (clnt); return 0; mode_unknown: fprintf (stderr, "svccfg: unknown operation: %s\n", argv[1]); }