int pl02x100_init(int cm) { PL_OBJECT plugin; CM_OBJECT com; int i=0; set_crash(); /* create plugin */ if ((plugin=create_plugin())==NULL) { write_syslog(ERRLOG, 1, "Nemozem vytvorit novu polozku v registroch pre plugin 'hangman'!\n"); return 0; } strcpy(plugin->name,"Hangman"); /* Plugin Description */ strcpy(plugin->author,"Lopo"); /* Author's name */ strcpy(plugin->registration,"02-100"); /* Plugin/Author ID */ strcpy(plugin->ver,"1.3"); /* Plugin version */ strcpy(plugin->req_ver,"120"); /* OSS version required */ plugin->id = cm; /* ID used as reference */ plugin->req_userfile = 1; /* Requires user data? */ /* (no separate file required since it keeps its data in a central file, but we need to do housekeeping procedures when the user leaves, so we set this to 1 so that we are notified when a user leaves.) */ plugin->triggerable = 0; /* This plugin is triggered by the system timer, and it will automatically save the current poker data when the boards are automatically checked. */ /* create associated command */ if ((com=create_cmd())==NULL) { write_syslog(ERRLOG, 1, "Nemozem pridat prikaz do registrov pre plugin %s !\n", plugin->registration); return 0; } i++; /* Keep track of number created */ strcpy(com->command,"hangman"); /* Name of command */ com->id = plugin->id; /* Command reference ID */ com->req_lev = USER; /* Required level for cmd. */ com->comnum = i; com->plugin = plugin; /* end creating command - repeat as needed for more commands */ return i; }
int main(int argc, char *argv[]) { struct command* cmd; int fd; if (argc != 2) { help(); return 1; } cmd = create_cmd(TYPE_DEQ, 0, getuid(), 1, ++argv); printf("jid %s\n", cmd->buf); ERRORIF( (fd = open(CMD_FIFO, O_WRONLY)) < 0, "deq open fifo failed" ); ERRORIF( write(fd, cmd, CMDSIZE) < 0, "deq write failed" ); close(fd); return 0; }
int pl00x100_init(int cm) { PL_OBJECT plugin; CM_OBJECT com; int i=0; set_crash(); /* create plugin */ if ((plugin=create_plugin())==NULL) { write_syslog(ERRLOG, 1, "Unable to create new registry entry!\n"); return 0; } strcpy(plugin->name,"TalkerMagicEightBall"); /* Plugin Description */ strcpy(plugin->author,"Lopo"); /* Author's name */ strcpy(plugin->registration,"00-100"); /* Plugin/Author ID */ strcpy(plugin->ver,"1.2"); /* Plugin version */ strcpy(plugin->req_ver,"110"); /* Runtime ver required */ plugin->id = cm; /* ID used as reference */ plugin->req_userfile = 0; /* Requires user data? */ plugin->triggerable = 0; /* Can be triggered by regular speech? */ /* create associated command */ if ((com=create_cmd())==NULL) { write_syslog(ERRLOG, 1, "Unable to add command to registry!\n"); return 0; } i++; /* Keep track of number created */ strcpy(com->command,"8ball"); /* Name of command */ com->id = plugin->id; /* Command reference ID */ com->req_lev = USER; /* Required level for cmd. */ com->comnum = i; /* Per-plugin command ID */ com->plugin = plugin; /* Link to parent plugin */ /* end creating command - repeat as needed for more commands */ return i; }
struct list * read_config(const char *filename) { APP_DEBUG_FNAME; struct list *beg_cmd; struct list *beg_var; struct list *l; FILE *in; char *line; size_t len; ssize_t read_len; beg_cmd = NULL; beg_var = NULL; len = CONF_LINE_MAXLENGTH; line = alloc_string_size(len); in = fopen(filename, "r"); if (in == NULL) { ERR("fopen('%s'): %s", filename, strerr()); myabort(); } else { while ((read_len = getline(&line, &len, in)) != -1) { // remove \n from the end if (read_len > 0) line[read_len - 1] = '\0'; switch (check_line(line)) { case LINE_VARIABLE: l = malloc(sizeof (struct list)); l->next = beg_var; l->item = create_var(line, beg_var); beg_var = l; break; case LINE_COMMAND: l = malloc(sizeof (struct list)); l->next = beg_cmd; l->item = create_cmd(line, beg_var); beg_cmd = l; break; case LINE_BAD: WARN("bad line structure '%s'", line); break; case LINE_IGNORE: DEBUG("ignoring line '%s'", line); break; } l = NULL; } if (ferror(in)) WARN("ferror while reading '%s', try to continue", filename); fclose(in); print_cfg(beg_var, beg_cmd); } free(line); delete_list(&beg_var); return (beg_cmd); }
/* * prodreg_uninstall * * This routine launches an uninstaller, if the location of one is supplied. * Otherwise, it will attempt to find the uninstaller associated with a * component registered, and launch it. * * arglist The list of arguemnts to supply to the installer. * pcRoot The alternate root to use for registry operations. * criteria The component to unregister (if no pc_path supplied). * force Whether to perform uninstallation even if there are * other components which depend on the component to uninstall. * * Returns: Nothing * Side effects: Depend on the uninstaller executed. */ void prodreg_uninstall(char **arglist, const char *pcRoot, Criteria criteria, int force) { char *pc_path; Wsreg_query *pq = NULL; Wsreg_component *pws = NULL; if (wsreg_initialize(WSREG_INIT_NORMAL, pcRoot) != WSREG_SUCCESS) { fail(PRODREG_CONVERT_NEEDED_ACCESS); } if (wsreg_can_access_registry(O_RDONLY) == 0) { fail(PRODREG_CANNOT_READ); } db_open(); pq = wsreg_query_create(); if (criteria.mask & FIND_UUID) { wsreg_query_set_id(pq, criteria.uuid); if (criteria.mask & FIND_INST) { wsreg_query_set_instance(pq, criteria.instance); } else if (criteria.mask & FIND_LOCN) { wsreg_query_set_location(pq, criteria.location); } else { fail(PRODREG_BAD_SYNTAX); } } else if (criteria.mask & FIND_UNAME) { char *pc_val = NULL; wsreg_query_set_unique_name(pq, criteria.uniquename); /* * It is possible that the location value is actually an * 'id' attribute. Try this. */ pws = wsreg_get(pq); if (pws != NULL) { pc_val = wsreg_get_data(pws, "id"); if (pc_val == NULL || strcmp(pc_val, criteria.location) != 0) { pws = NULL; } } if ((pws == NULL) && (criteria.mask & FIND_LOCN)) { wsreg_query_set_location(pq, criteria.location); } } else { fail(PRODREG_BAD_SYNTAX); } if (pws == NULL) pws = wsreg_get(pq); if (pws == NULL) fail(PRODREG_UNINSTALL_IMPOSSIBLE); /* * If component is depended upon, complain & exit, unless forced. * This check is not recursive - do not check the children of the * node. */ check_dependent(0, force, pws, PRODREG_UNINSTALL_WOULD_BREAK); pc_path = wsreg_get_uninstaller(pws); if (pc_path) { char *pc, **ppc; create_cmd(pc_path, arglist, pcRoot, &pc, &ppc); #ifndef NDEBUG if (getenv("NDEBUG") == NULL) { int x; (void) printf("command for uninstall: '%s'\n", pc); (void) printf("command line arguments for uninstall:"); for (x = 0; ppc && ppc[x]; x++) { (void) printf("[%s] ", ppc[x]); } (void) printf("\n"); } #endif launch_installer(pc, ppc); /* Never returns. */ } else { fail(PRODREG_NO_UNINSTALLER); } if (pws) wsreg_free_component(pws); if (pq) wsreg_query_free(pq); db_close(); }