コード例 #1
0
ファイル: object.c プロジェクト: Prospero86/ServiceManager
void destroy_svcs_list (svc_list box)
{
    for (svc_list_iterator it = svc_list_begin (box); it != NULL;
         svc_list_iterator_next (&it))
    {
        destroy_svc (it->val);
    }
    List_destroy (box);
}
コード例 #2
0
ファイル: translate.c プロジェクト: uncled1023/ServiceManager
rpc_svc_t * svc_list_to_rpc_svc_array (svc_list box)
{
    register unsigned s_index = 0;
    rpc_svc_t * newRpc_svclist;

    if (List_count (box) == 0)
        return 0;

    newRpc_svclist = malloc (List_count (box) * sizeof (rpc_svc_t));

    for (svc_list_iterator it = svc_list_begin (box); it != NULL;
         svc_list_iterator_next (&it))
    {
        newRpc_svclist[s_index++] = svc_to_rpc_svc (it->val);
    }

    return newRpc_svclist;
}
コード例 #3
0
ファイル: svccfg.c プロジェクト: Prospero86/ServiceManager
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]);
}