1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

add new '-V' option to tools which shows the version of only and exits

This commit is contained in:
Steffen Vogel 2017-09-16 11:52:30 +02:00
parent b27a4ba652
commit d587b5a817
9 changed files with 60 additions and 38 deletions

View file

@ -46,13 +46,8 @@ struct super_node {
char *name; /**< A name of this super node. Usually the hostname. */
struct {
int argc;
char **argv;
} cli;
enum state state;
char *uri; /**< URI of configuration */
json_t *cfg; /**< JSON representation of the configuration. */
@ -66,9 +61,6 @@ struct super_node {
/** Inititalize configuration object before parsing the configuration. */
int super_node_init(struct super_node *sn);
/** Wrapper for super_node_parse() */
int super_node_parse_cli(struct super_node *sn, int argc, char *argv[]);
/** Wrapper for super_node_parse() */
int super_node_parse_uri(struct super_node *sn, const char *uri);

View file

@ -135,9 +135,12 @@
/* Forward declarations */
struct timespec;
/** Print copyright message to screen. */
/** Print copyright message to stdout. */
void print_copyright();
/** Print version to stdout. */
void print_version();
/** Normal random variate generator using the Box-Muller method
*
* @param m Mean

View file

@ -41,6 +41,13 @@ static Opal_GenAsyncParam_Ctrl params; /** String and Float parameters, provided
static pthread_mutex_t lock; /** Big Global Lock for libOpalAsync API */
int opal_register_region(int argc, char *argv[])
{
async_shmem_name = argv[1];
async_shmem_size = atoi(argv[2]);
print_shmem_name = argv[3];
}
int opal_init(struct super_node *sn)
{
int err;
@ -50,10 +57,6 @@ int opal_init(struct super_node *sn)
pthread_mutex_init(&lock, NULL);
async_shmem_name = sn->cli.argv[1];
async_shmem_size = atoi(sn->cli.argv[2]);
print_shmem_name = sn->cli.argv[3];
/* Enable the OpalPrint function. This prints to the OpalDisplay. */
err = OpalSystemCtrl_Register(print_shmem_name);
if (err != EOK)

View file

@ -169,16 +169,6 @@ int super_node_parse_uri(struct super_node *sn, const char *uri)
return 0;
}
int super_node_parse_cli(struct super_node *sn, int argc, char *argv[])
{
char *uri = (argc == 2) ? argv[1] : NULL;
sn->cli.argc = argc;
sn->cli.argv = argv;
return super_node_parse_uri(sn, uri);
}
int super_node_parse_json(struct super_node *sn, json_t *cfg)
{
int ret;

View file

@ -44,6 +44,11 @@ void print_copyright()
printf(" Steffen Vogel <StVogel@eonerc.rwth-aachen.de>\n");
}
void print_version()
{
printf("%s\n", BUILDID);
}
int version_parse(const char *s, struct version *v)
{
return sscanf(s, "%u.%u", &v->major, &v->minor) != 2;

View file

@ -30,7 +30,9 @@ void usage()
printf(" CONFIG path to a configuration file\n");
printf(" CARD name of the FPGA card\n");
printf(" OPTIONS is one or more of the following options:\n");
printf(" -d Set log level\n");
printf(" -d set log level\n");
printf(" -h show this help\n");
printf(" -V show the version of the tool\n");
printf("\n");
print_copyright();
}
@ -44,12 +46,16 @@ int main(int argc, char *argv[])
/* Parse arguments */
char c, *endptr;
while ((c = getopt(argc, argv, "d:")) != -1) {
while ((c = getopt(argc, argv, "Vd:h")) != -1) {
switch (c) {
case 'V':
print_version();
exit(EXIT_SUCCESS);
case 'd':
sn.log.level = strtoul(optarg, &endptr, 10);
goto check;
case 'h':
case '?':
default:
usage();

View file

@ -83,9 +83,10 @@ static void usage()
printf(" PARAM* a string of configuration settings for the hook\n");
printf(" OPTIONS is one or more of the following options:\n");
printf(" -f FMT the data format\n");
printf(" -h show this help\n");
printf(" -d LVL set debug level to LVL\n");
printf(" -v CNT process CNT smps at once\n");
printf(" -h show this help\n");
printf(" -V show the version of the tool\n");
printf("\n");
printf("The following hook functions are supported:\n");
@ -114,8 +115,11 @@ int main(int argc, char *argv[])
json_t *cfg_cli = json_object();
char c, *endptr;
while ((c = getopt(argc, argv, "hv:d:f:o:")) != -1) {
while ((c = getopt(argc, argv, "Vhv:d:f:o:")) != -1) {
switch (c) {
case 'V':
print_version();
exit(EXIT_SUCCESS);
case 'f':
format = optarg;
break;

View file

@ -66,7 +66,10 @@ static void quit(int signal, siginfo_t *sinfo, void *ctx)
static void usage()
{
printf("Usage: villas-node [CONFIG]\n");
printf("Usage: villas-node [OPTIONS] [CONFIG]\n");
printf(" OPTIONS is one or more of the following options:\n");
printf(" -V show the version of the tool\n");
printf(" -h show this help\n");
printf(" CONFIG is the path to an optional configuration file\n");
printf(" if omitted, VILLASnode will start without a configuration\n");
printf(" and wait for provisioning over the web interface.\n\n");
@ -106,16 +109,28 @@ int main(int argc, char *argv[])
if (argc != 4)
usage(argv[0]);
opal_register_region(argc, argv);
char *uri = "opal-shmem.conf";
#else
if (argc == 2) {
if (!strcmp(argv[1], "-h") ||
!strcmp(argv[1], "--help"))
usage();
char c;
while ((c = getopt(argc, argv, "hV")) != -1) {
switch (c) {
case 'V':
print_version();
exit(EXIT_SUCCESS);
case 'h':
case '?':
usage();
exit(c == '?' ? EXIT_FAILURE : EXIT_SUCCESS);
}
continue;
}
else if (argc > 2)
usage();
char *uri = argc == optind + 1 ? argv[optind] : NULL;
#endif
info("This is VILLASnode %s (built on %s, %s)", CLR_BLD(CLR_YEL(BUILDID)),
CLR_BLD(CLR_MAG(__DATE__)), CLR_BLD(CLR_MAG(__TIME__)));
@ -134,7 +149,7 @@ int main(int argc, char *argv[])
if (ret)
error("Failed to initialize super node");
ret = super_node_parse_cli(&sn, argc, argv);
ret = super_node_parse_uri(&sn, uri);
if (ret)
error("Failed to parse command line arguments");

View file

@ -99,7 +99,8 @@ static void usage()
printf(" -r only read data from node and write it to stdout\n");
printf(" -t NUM terminate after NUM seconds\n");
printf(" -L NUM terminate after NUM samples sent\n");
printf(" -l NUM terminate after NUM samples received\n\n");
printf(" -l NUM terminate after NUM samples received\n");
printf(" -V show the version of the tool\n\n");
print_copyright();
}
@ -216,8 +217,11 @@ int main(int argc, char *argv[])
json_t *cfg_cli = json_object();
char c, *endptr;
while ((c = getopt(argc, argv, "hxrsd:l:L:t:f:o:")) != -1) {
while ((c = getopt(argc, argv, "Vhxrsd:l:L:t:f:o:")) != -1) {
switch (c) {
case 'V':
print_version();
exit(EXIT_SUCCESS);
case 'f':
format = optarg;
break;