#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <bsd/string.h>
#include <stdint.h>
#include <strings.h>
#include "main.h"
static void
print_usage(char *prog_name)
{
printf("Usage: %s [-h] -b brokers -s services\n"
" -b NUM Number of brokers\n"
" -s NUM Number of services per broker\n"
" -h Display the help information\n",
prog_name);
}
int
parse_args(int argc, char **argv)
{
struct option lgopts[] = {{NULL, 0, 0, 0}};
int opt, option_index, val;
app->num_brokers = NUM_DEFAULT_BROKERS;
app->num_services = NUM_DEFAULT_SERVICES;
for (;;) {
opt = getopt_long(argc, argv, "hb:s:", lgopts, &option_index);
if (opt == EOF)
break;
switch (opt) {
case 'h':
print_usage(argv[0]);
return -1;
case 'b':
val = atoi(optarg);
app->num_brokers = val;
else {
printf("Number of brokers (%d) invalid\n", val);
return -1;
}
break;
case 's':
val = atoi(optarg);
app->num_services = val;
else {
printf("Number of services (%d) is invalid\n", val);
return -1;
}
break;
default:
print_usage(argv[0]);
printf("Invalid command option (%c)\n", opt);
return -1;
}
}
return 0;
}
#define IBROKER_MAX_COUNT
#define IBROKER_MAX_SERVICES