void daemon_assert( int result, int line ) { if(!result) { fprintf(stderr, "Assertion failed on line %d, at time %s\n\t code=%d (%s)\n", line, __TIME__, errno, strerror(errno)); daemon_close(); exit( EXIT_FAILURE ); } }
int main(int argc,char *argv[]) { printf("Starting razer blackwidow chroma daemon\n"); #ifndef USE_DEBUGGING daemonize(); #endif struct razer_daemon *daemon=NULL; if(!(daemon=daemon_open())) { printf("razer_bcd: error initializing daemon\n"); return(1); } daemon_run(daemon); daemon_close(daemon); }
int main( int argc, char **argv ) { cx_t cx; memset(&cx, 0, sizeof(cx)); /* static cx_t cx; memset(&cx, 0, sizeof(cx)); cx.d_opts.ident = "fastrakd"; cx.d_opts.sched_rt = SOMATIC_D_SCHED_UI; // logger not realtime cx.opt_chan_name = "fastrak"; cx.opt_freq = -1; cx.opt_peekabot = 0; cx.opt_peekabot_host = "localhost"; cx.opt_device = "/dev/ttyS0"; cx.opt_kalman = 0; cx.opt_diag_E = 1; cx.opt_diag_Q = 250; cx.opt_diag_R = 1; */ // parse options // argp_parse (&argp, argc, argv, 0, NULL, &cx); // somatic_verbprintf_prefix="fastrak"; // somatic_verbprintf( 1, "Frequency of %d Hz\n", cx.opt_freq ); // init(&cx); daemonize("fastrakd"); int r = fastrak_init(&(cx.fk), "/dev/ttyS0" ); r = ach_open( &chan, "fastrak", NULL ); daemon_assert( ACH_OK == r, __LINE__ ); //printf("About to start\n"); run(&cx); // destroy(&cx); daemon_close(); return 0; }
int main(int argc,char *argv[]) { struct daemon_options options = parse_args(argc, argv); if(options.daemonize) { printf("Starting razer blackwidow chroma daemon as a daemon\n"); daemonize(options.pid_file); } else { printf("Starting razer blackwidow chroma daemon in the foreground\n"); if(options.pid_file != NULL) { write_pid_file(options.pid_file, getpid()); } } struct razer_daemon *daemon=NULL; if(!(daemon=daemon_open())) { printf("razer_bcd: error initializing daemon\n"); return(1); } if(options.mouse_input_file) daemon->chroma->sys_mouse_event_path = options.mouse_input_file; if(options.keyboard_input_file) daemon->chroma->sys_keyboard_event_path = options.keyboard_input_file; daemon_run(daemon); daemon_close(daemon); // Remove the PID file if we exit normally if(options.pid_file != NULL) { remove(options.pid_file); free(options.pid_file); } }
int main(int argc, char **argv) { daemon_reply reply; char *cmd; char *uuid; char *name; int val; int ver; if (argc < 2) { printf("lvmetactl dump\n"); printf("lvmetactl pv_list\n"); printf("lvmetactl vg_list\n"); printf("lvmetactl vg_lookup_name <name>\n"); printf("lvmetactl vg_lookup_uuid <uuid>\n"); printf("lvmetactl pv_lookup_uuid <uuid>\n"); printf("lvmetactl set_global_invalid 0|1\n"); printf("lvmetactl get_global_invalid\n"); printf("lvmetactl set_vg_version <uuid> <name> <version>\n"); printf("lvmetactl vg_lock_type <uuid>\n"); return -1; } cmd = argv[1]; h = lvmetad_open(NULL); if (!strcmp(cmd, "dump")) { reply = daemon_send_simple(h, "dump", "token = %s", "skip", NULL); printf("%s\n", reply.buffer.mem); } else if (!strcmp(cmd, "pv_list")) { reply = daemon_send_simple(h, "pv_list", "token = %s", "skip", NULL); printf("%s\n", reply.buffer.mem); } else if (!strcmp(cmd, "vg_list")) { reply = daemon_send_simple(h, "vg_list", "token = %s", "skip", NULL); printf("%s\n", reply.buffer.mem); } else if (!strcmp(cmd, "set_global_invalid")) { if (argc < 3) { printf("set_global_invalid 0|1\n"); return -1; } val = atoi(argv[2]); reply = daemon_send_simple(h, "set_global_info", "global_invalid = %d", val, "token = %s", "skip", NULL); print_reply(reply); } else if (!strcmp(cmd, "get_global_invalid")) { reply = daemon_send_simple(h, "get_global_info", "token = %s", "skip", NULL); printf("%s\n", reply.buffer.mem); } else if (!strcmp(cmd, "set_vg_version")) { if (argc < 5) { printf("set_vg_version <uuid> <name> <ver>\n"); return -1; } uuid = argv[2]; name = argv[3]; ver = atoi(argv[4]); if ((strlen(uuid) == 1) && (uuid[0] == '-')) uuid = NULL; if ((strlen(name) == 1) && (name[0] == '-')) name = NULL; if (uuid && name) { reply = daemon_send_simple(h, "set_vg_info", "uuid = %s", uuid, "name = %s", name, "version = %d", ver, "token = %s", "skip", NULL); } else if (uuid) { reply = daemon_send_simple(h, "set_vg_info", "uuid = %s", uuid, "version = %d", ver, "token = %s", "skip", NULL); } else if (name) { reply = daemon_send_simple(h, "set_vg_info", "name = %s", name, "version = %d", ver, "token = %s", "skip", NULL); } else { printf("name or uuid required\n"); return -1; } print_reply(reply); } else if (!strcmp(cmd, "vg_lookup_name")) { if (argc < 3) { printf("vg_lookup_name <name>\n"); return -1; } name = argv[2]; reply = daemon_send_simple(h, "vg_lookup", "name = %s", name, "token = %s", "skip", NULL); printf("%s\n", reply.buffer.mem); } else if (!strcmp(cmd, "vg_lookup_uuid")) { if (argc < 3) { printf("vg_lookup_uuid <uuid>\n"); return -1; } uuid = argv[2]; reply = daemon_send_simple(h, "vg_lookup", "uuid = %s", uuid, "token = %s", "skip", NULL); printf("%s\n", reply.buffer.mem); } else if (!strcmp(cmd, "vg_lock_type")) { struct dm_config_node *metadata; const char *lock_type; if (argc < 3) { printf("vg_lock_type <uuid>\n"); return -1; } uuid = argv[2]; reply = daemon_send_simple(h, "vg_lookup", "uuid = %s", uuid, "token = %s", "skip", NULL); /* printf("%s\n", reply.buffer.mem); */ metadata = dm_config_find_node(reply.cft->root, "metadata"); if (!metadata) { printf("no metadata\n"); goto out; } lock_type = dm_config_find_str(metadata, "metadata/lock_type", NULL); if (!lock_type) { printf("no lock_type\n"); goto out; } printf("lock_type %s\n", lock_type); } else if (!strcmp(cmd, "pv_lookup_uuid")) { if (argc < 3) { printf("pv_lookup_uuid <uuid>\n"); return -1; } uuid = argv[2]; reply = daemon_send_simple(h, "pv_lookup", "uuid = %s", uuid, "token = %s", "skip", NULL); printf("%s\n", reply.buffer.mem); } else { printf("unknown command\n"); goto out_close; } out: daemon_reply_destroy(reply); out_close: daemon_close(h); return 0; }