void send_command (const char *command) { GError *error = NULL; ccnet_client_send_cmd (applet->sync_client, command, &error); if (error) { applet_warning ("Failed to send command %s: %s\n", command, error->message); } }
/* This would also stop seaf-server & other components */ static void stop_ccnet_server () { seaf_message ("shutting down ccnet-server ...\n"); GError *error = NULL; ccnet_client_send_cmd (ctl->sync_client, "shutdown", &error); try_kill_process(PID_CCNET); try_kill_process(PID_SERVER); try_kill_process(PID_SEAFDAV); }
gboolean ccnet_register_service_sync (CcnetClient *client, const char *service, const char *group) { char buf[512]; GError *error = NULL; snprintf (buf, 512, "register-service %s %s", service, group); ccnet_client_send_cmd (client, buf, &error); if (error) { ccnet_warning ("Bad response for register service %s: %d %s", service, error->code, error->message); return FALSE; } return TRUE; }
static int add_client (int argc, char **argv) { char buf[128]; GError *error = NULL; if (argc != 1) { fputs ("add-client <peer-id>\n", stderr); return -1; } /* argv[0] is user_id */ snprintf (buf, 128, "set-client %s", argv[0]); ccnet_client_send_cmd (client, buf, &error); if (error) { fprintf (stderr, "Error: %s\n", error->message); return -1; } return 0; }
static int add_master (int argc, char **argv) { char *c; char buf[1024]; GError *error = NULL; if (argc < 1) { fputs ("add-master [--id <peer-id>] [--addr <peer-addr:port>]\n", stderr); return -1; } c = ccnet_util_strjoin_n (" ", argc, argv); snprintf (buf, 1024, "add-master %s", c); ccnet_client_send_cmd (client, buf, &error); if (error) { fprintf (stderr, "Error: %s\n", error->message); return -1; } return 0; }
static int redirect_peer (int argc, char **argv) { char buf[1024]; GError *error = NULL; if (argc != 2) { fputs ("redirect-peer <peer_id> <to_id>\n", stderr); return -1; } if (!peer_id_valid(argv[0]) || !peer_id_valid(argv[1])) { fputs ("Invalid peer id\n", stderr); return -1; } snprintf (buf, 1024, "redirect-peer %s %s", argv[0], argv[1]); ccnet_client_send_cmd (client, buf, &error); if (error) { fprintf (stderr, "Error: %s\n", error->message); return -1; } return 0; }