initial commit

This commit is contained in:
2024-11-02 11:17:36 +00:00
commit f68ac974d8
14 changed files with 831 additions and 0 deletions

115
src/capture.c Normal file
View File

@@ -0,0 +1,115 @@
#include "commands.h"
#include <blue/cmd.h>
#define BUFFER_SIZE 65536
enum {
OPT_OUTPATH,
OPT_OUTPATH_PATH,
ARG_DIRECTORY,
OPT_TAGGED_DIRECTORY,
OPT_TAGGED_DIRECTORY_TAG,
OPT_TAGGED_DIRECTORY_PATH,
OPT_VERBOSE,
};
static int capture(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_CAPTURE, CMD_ROOT)
{
B_COMMAND_NAME("capture");
B_COMMAND_SHORT_NAME('Z');
B_COMMAND_DESC(
"capture one or more directories into an ec3 container. each "
"directory specified will be stored in a separate volume "
"within "
"the created container.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(capture);
B_COMMAND_HELP_OPTION();
B_COMMAND_OPTION(OPT_OUTPATH)
{
B_OPTION_SHORT_NAME('o');
B_OPTION_LONG_NAME("out");
B_OPTION_DESC("the path to save the new file to.");
B_OPTION_ARG(OPT_OUTPATH_PATH)
{
B_ARG_NAME("path");
B_ARG_NR_VALUES(1);
}
}
B_COMMAND_ARG(ARG_DIRECTORY)
{
B_ARG_NAME("directory");
B_ARG_DESC(
"a directory to add to the container. a volume "
"will be created "
"within the container to store the specified "
"directory.");
B_ARG_NR_VALUES(B_ARG_1_OR_MORE_VALUES);
}
B_COMMAND_OPTION(OPT_TAGGED_DIRECTORY)
{
B_OPTION_SHORT_NAME('D');
B_OPTION_LONG_NAME("tagged-directory");
B_OPTION_DESC(
"a file to add to the container, with an associated "
"tag. a disk "
"image will be created within the container to store "
"the specified "
"directory. the tag must be either: (a) a 64-bit "
"hexadecimal "
"number; or (b) a string of no more than 8 "
"characters.");
B_OPTION_ARG(OPT_TAGGED_DIRECTORY_TAG)
{
B_ARG_NAME("tag");
B_ARG_NR_VALUES(1);
}
B_OPTION_ARG(OPT_TAGGED_DIRECTORY_PATH)
{
B_ARG_NAME("path");
B_ARG_NR_VALUES(1);
}
}
B_COMMAND_OPTION(OPT_VERBOSE)
{
B_OPTION_SHORT_NAME('v');
B_OPTION_LONG_NAME("verbose");
B_OPTION_DESC(
"show detailed output logs. this option can be "
"specified multiple "
"times to increase the level of output.");
}
B_COMMAND_USAGE()
{
B_COMMAND_USAGE_OPT(OPT_OUTPATH);
B_COMMAND_USAGE_ARG(ARG_DIRECTORY);
}
B_COMMAND_USAGE()
{
B_COMMAND_USAGE_OPT(OPT_OUTPATH);
B_COMMAND_USAGE_OPT(OPT_TAGGED_DIRECTORY);
}
}

33
src/check-sig.c Normal file
View File

@@ -0,0 +1,33 @@
#include "commands.h"
#include <blue/cmd.h>
enum {
ARG_FILE,
};
static int check_sig(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_CHECK_SIG, CMD_ROOT)
{
B_COMMAND_NAME("check-sig");
B_COMMAND_SHORT_NAME('Y');
B_COMMAND_DESC("validate the digital signature of an ec3 file");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(check_sig);
B_COMMAND_HELP_OPTION();
B_COMMAND_ARG(ARG_FILE)
{
B_ARG_NAME("file");
B_ARG_NR_VALUES(B_ARG_1_OR_MORE_VALUES);
B_ARG_DESC("the file(s) to validate");
}
}

17
src/commands.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef COMMANDS_H_
#define COMMANDS_H_
enum command_id {
CMD_ROOT = 0,
CMD_CREATE,
CMD_WRAP,
CMD_CAPTURE,
CMD_SHELL,
CMD_EXTRACT,
CMD_GET_MANIFEST,
CMD_CHECK_SIG,
CMD_EXPLORE,
CMD_QUERY,
};
#endif

40
src/create.c Normal file
View File

@@ -0,0 +1,40 @@
#include "commands.h"
#include <blue/cmd.h>
enum {
OPT_OUTPATH,
OPT_OUTPATH_PATH,
};
static int create(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_CREATE, CMD_ROOT)
{
B_COMMAND_NAME("create");
B_COMMAND_SHORT_NAME('C');
B_COMMAND_DESC("create an ec3 file");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(create);
B_COMMAND_HELP_OPTION();
B_COMMAND_OPTION(OPT_OUTPATH)
{
B_OPTION_SHORT_NAME('o');
B_OPTION_LONG_NAME("out");
B_OPTION_DESC("the path to save the new file to");
B_OPTION_ARG(OPT_OUTPATH_PATH)
{
B_ARG_NAME("path");
B_ARG_NR_VALUES(1);
}
}
}

34
src/explore.c Normal file
View File

@@ -0,0 +1,34 @@
#include "commands.h"
#include <blue/cmd.h>
enum {
ARG_FILE,
};
static int explore(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_EXPLORE, CMD_ROOT)
{
B_COMMAND_NAME("explore");
B_COMMAND_SHORT_NAME('E');
B_COMMAND_DESC(
"start a basic shell to browse the contents of an ec3 file");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(explore);
B_COMMAND_HELP_OPTION();
B_COMMAND_ARG(ARG_FILE)
{
B_ARG_NAME("file");
B_ARG_NR_VALUES(1);
B_ARG_DESC("the file to explore");
}
}

33
src/extract.c Normal file
View File

@@ -0,0 +1,33 @@
#include "commands.h"
#include <blue/cmd.h>
enum {
ARG_FILE,
};
static int extract(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_EXTRACT, CMD_ROOT)
{
B_COMMAND_NAME("extract");
B_COMMAND_SHORT_NAME('X');
B_COMMAND_DESC("extract the contents of an ec3 file");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(extract);
B_COMMAND_HELP_OPTION();
B_COMMAND_ARG(ARG_FILE)
{
B_ARG_NAME("file");
B_ARG_NR_VALUES(B_ARG_1_OR_MORE_VALUES);
B_ARG_DESC("the file to extract");
}
}

33
src/get-manifest.c Normal file
View File

@@ -0,0 +1,33 @@
#include "commands.h"
#include <blue/cmd.h>
enum {
ARG_FILE,
};
static int get_manifest(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_GET_MANIFEST, CMD_ROOT)
{
B_COMMAND_NAME("get-manifest");
B_COMMAND_SHORT_NAME('M');
B_COMMAND_DESC("retrieve and print the manifest of an ec3 file");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(get_manifest);
B_COMMAND_HELP_OPTION();
B_COMMAND_ARG(ARG_FILE)
{
B_ARG_NAME("file");
B_ARG_NR_VALUES(1);
B_ARG_DESC("the file to query");
}
}

19
src/main.c Normal file
View File

@@ -0,0 +1,19 @@
#include "commands.h"
#include <blue/cmd.h>
#include <blue/term.h>
B_COMMAND(CMD_ROOT, B_COMMAND_INVALID_ID)
{
B_COMMAND_NAME("ec3");
B_COMMAND_DESC(
"Elastic, Compressed, Content-Addressed Container image "
"manipulation tool");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_HELP_OPTION();
}
int main(int argc, const char **argv)
{
return b_command_dispatch(CMD_ROOT, argc, argv);
}

39
src/query.c Normal file
View File

@@ -0,0 +1,39 @@
#include "commands.h"
#include <blue/cmd.h>
enum {
ARG_CONTAINER,
OPT_VERBOSE,
};
static int query(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_QUERY, CMD_ROOT)
{
B_COMMAND_NAME("query");
B_COMMAND_SHORT_NAME('Q');
B_COMMAND_DESC("query information about a container.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(query);
B_COMMAND_HELP_OPTION();
B_COMMAND_ARG(ARG_CONTAINER)
{
B_ARG_NAME("container");
B_ARG_DESC("the container to query.");
B_ARG_NR_VALUES(1);
}
B_COMMAND_USAGE()
{
B_COMMAND_USAGE_ARG(ARG_CONTAINER);
}
}

54
src/shell.c Normal file
View File

@@ -0,0 +1,54 @@
#include "commands.h"
#include <blue/cmd.h>
enum {
ARG_CONTAINER,
OPT_VERBOSE,
};
static int shell(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_SHELL, CMD_ROOT)
{
B_COMMAND_NAME("shell");
B_COMMAND_SHORT_NAME('S');
B_COMMAND_DESC(
"start a basic shell to explore the volumes within a "
"container.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(shell);
B_COMMAND_HELP_OPTION();
B_COMMAND_OPTION(OPT_VERBOSE)
{
B_OPTION_SHORT_NAME('v');
B_OPTION_LONG_NAME("verbose");
B_OPTION_DESC(
"show detailed output logs. this option can be "
"specified multiple "
"times to increase the level of output.");
}
B_COMMAND_ARG(ARG_CONTAINER)
{
B_ARG_NAME("container");
B_ARG_DESC(
"the container to explore. the container must contain "
"at least one "
"volume.");
B_ARG_NR_VALUES(1);
}
B_COMMAND_USAGE()
{
B_COMMAND_USAGE_ARG(ARG_CONTAINER);
}
}

96
src/wrap.c Normal file
View File

@@ -0,0 +1,96 @@
#include "commands.h"
#include <blue/cmd.h>
#include <stdlib.h>
enum {
OPT_OUTPATH,
OPT_OUTPATH_PATH,
ARG_FILE,
ARG_FILE_PATH,
OPT_TAGGED_FILE,
OPT_TAGGED_FILE_TAG,
OPT_TAGGED_FILE_PATH,
};
static int wrap(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_WRAP, CMD_ROOT)
{
B_COMMAND_NAME("wrap");
B_COMMAND_SHORT_NAME('W');
B_COMMAND_DESC(
"wrap one or more files into an ec3 container. each file will "
"be "
"stored in a separate blob tag within the created container.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(wrap);
B_COMMAND_HELP_OPTION();
B_COMMAND_OPTION(OPT_OUTPATH)
{
B_OPTION_SHORT_NAME('o');
B_OPTION_LONG_NAME("out");
B_OPTION_DESC("the path to save the new file to");
B_OPTION_ARG(OPT_OUTPATH_PATH)
{
B_ARG_NAME("path");
B_ARG_NR_VALUES(1);
}
}
B_COMMAND_ARG(ARG_FILE)
{
B_ARG_NAME("file");
B_ARG_DESC("a file to add to the container");
B_ARG_NR_VALUES(B_ARG_1_OR_MORE_VALUES);
}
B_COMMAND_OPTION(OPT_TAGGED_FILE)
{
B_OPTION_SHORT_NAME('I');
B_OPTION_LONG_NAME("tagged-file");
B_OPTION_DESC(
"a file to add to the container, with an associated "
"tag. "
"the tag must be either: (a) a 64-bit hexadecimal "
"number; "
"or (b) a string of no more than 8 characters.");
B_OPTION_ARG(OPT_TAGGED_FILE_TAG)
{
B_ARG_NAME("tag");
B_ARG_DESC("the tag!");
B_ARG_NR_VALUES(1);
}
B_OPTION_ARG(OPT_TAGGED_FILE_PATH)
{
B_ARG_NAME("path");
B_ARG_NR_VALUES(1);
}
}
B_COMMAND_USAGE()
{
B_COMMAND_USAGE_OPT(OPT_OUTPATH);
B_COMMAND_USAGE_ARG(ARG_FILE);
}
B_COMMAND_USAGE()
{
B_COMMAND_USAGE_OPT(OPT_OUTPATH);
B_COMMAND_USAGE_OPT(OPT_TAGGED_FILE);
}
}