diff --git a/guestfs-inspect.c b/guestfs-inspect.c index e69de29..f20b9ca 100644 --- a/guestfs-inspect.c +++ b/guestfs-inspect.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include + +#include "libguestfs-inspect.h" + +#define STREQ(a, b) (strcmp((a), (b)) == 0) + +void print_help(char *); + +int main(int argc, char **argv) { + if (argc == 1) { + print_help(argv[0]); + return EXIT_SUCCESS; + } + + char *ep = endpoint(); + zsock_t *daemon = zsock_new_req(ep); + free(ep); + + return EXIT_SUCCESS; +} + +void print_help(char *name) { + printf("Usage: %s [name] [command] \n", name); + printf("Commands:\n"); + printf(" ls \n"); + printf(" cat \n"); +} diff --git a/guestfs-inspectd.c b/guestfs-inspectd.c index 3487000..f847c2b 100644 --- a/guestfs-inspectd.c +++ b/guestfs-inspectd.c @@ -11,19 +11,9 @@ static void *worker_task(zsock_t*, char*); -char *endpoint(void); - static int compare_key_len(const void*, const void*); static int count_mountpoints(char *const *argv); -char *endpoint() { - // TODO: This should be based on GUESTFS_INSPECT_ENDPOINT, or XDG_RUNTIME_DIR if the former is not set, and default to a sensible path if neither are set. - const char* ep = "ipc:///tmp/guestfs-inspect.sock"; - char *res = malloc(strlen(ep) + 1); - strcpy(res, ep); - return res; -} - static int compare_key_len(const void *p1, const void *p2) { const char *key1 = *(char* const*) p1; const char *key2 = *(char* const*) p2; diff --git a/libguestfs-inspect.h b/libguestfs-inspect.h index b25fe12..16721c3 100644 --- a/libguestfs-inspect.h +++ b/libguestfs-inspect.h @@ -21,3 +21,11 @@ struct guestfs_inpsect_command { char name[]; }; +static char *endpoint() { + // TODO: This should be based on GUESTFS_INSPECT_ENDPOINT, or XDG_RUNTIME_DIR if the former is not set, and default to a sensible path if neither are set. + const char* ep = "ipc:///tmp/guestfs-inspect.sock"; + char *res = malloc(strlen(ep) + 1); + strcpy(res, ep); + return res; +} +