int main(int argc, char *const *argv) { int c; int rv; char *node_id_file = getenv("CK_NODE_ID_FILE"); ckl_conf_t *conf = calloc(1, sizeof(ckl_conf_t)); curl_global_init(CURL_GLOBAL_ALL); if(node_id_file == NULL) { node_id_file = "/var/lib/cloudkick-agent/node_id"; } while ((c = getopt(argc, argv, "f:")) != -1) { switch (c) { case 'f': node_id_file = optarg; break; } } rv = ckl_conf_init(conf); if (rv < 0) { ckl_error_out("conf_init failed"); } FILE *fp = fopen(node_id_file, "r"); if (fp == NULL) { ckl_error_out("couldn't open node_id file"); } char node_id[128]; char *p = NULL; p = fgets(node_id, sizeof(node_id), fp); fclose(fp); do_motd(conf, node_id); ckl_conf_free(conf); curl_global_cleanup(); return rv; }
int main(int argc, char *const *argv) { int mode = MODE_SEND_MSG; int c; int rv; const char *detail = NULL; const char *usermsg = NULL; ckl_conf_t *conf = calloc(1, sizeof(ckl_conf_t)); curl_global_init(CURL_GLOBAL_ALL); while ((c = getopt(argc, argv, "hVslm:d:")) != -1) { switch (c) { case 'V': show_version(); break; case 'h': show_help(); break; case 'l': mode = MODE_LIST; break; case 'd': mode = MODE_DETAIL; detail = optarg; break; case 'm': usermsg = optarg; break; case 's': conf->script_mode = 1; break; case '?': ckl_error_out("See -h for correct options"); break; } } rv = ckl_conf_init(conf); if (rv < 0) { ckl_error_out("conf_init failed"); } switch (mode) { case MODE_SEND_MSG: rv = do_send_msg(conf, usermsg); break; case MODE_LIST: rv = do_list(conf); break; case MODE_DETAIL: rv = do_detail(conf, detail); break; } ckl_conf_free(conf); curl_global_cleanup(); return rv; }