Newer
Older
* unixtime that returns current time in epoch format.
*
* Copyright (C) 2020 iopsys Software Solutions AB. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#define _GNU_SOURCE
#include "ubus_api_validator.h"
#include <dirent.h>
#include <json-validator.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct global_args_t {
char *path;
const char *dir_path;
} global_args;
static const char *opt_string = "f:d:t:h";
static void show_usage(char *application_name) {
fprintf(stdout,
"\nUsage: %s: <options> \n"
"Options: \n"
" -t Timeout for ubus call in seconds\n"
" -d directory with json files \n"
" -h help\n\n",
application_name);
}
static void parse_command_line_args(int argc, char *argv[]) {
int opt;
break;
case 'd':
case 't':
set_ubus_timeout(atoi(optarg));
break;
case 'h':
show_usage(argv[0]);
exit(EXIT_SUCCESS);
default:
show_usage(argv[0]);
exit(EXIT_FAILURE);
break;
}
}
}
int main(int argc, char *argv[]) {
perror("schema_validator_init failed");
return EXIT_FAILURE;
}
perror("ubus registration succesfull");
return EXIT_FAILURE;
if (global_args.path == NULL && global_args.dir_path != NULL) {
// printf("\n working with directory: %s \n ", global_args.dir_path);
while ((dir = readdir(d)) != NULL) {
char *res;
char *format;
if (strlastchar(global_args.dir_path, '/') == 0)
format = "%s%s";
else
format = "%s/%s";
rv = asprintf(&res, format, global_args.dir_path, dir->d_name);
fprintf(stderr, "asprintf() failed: insufficient memory!\n");
return EXIT_FAILURE;
}
if (dir->d_type == DT_REG) {
}
closedir(d);
} else {
perror("directory error \n");
return EXIT_FAILURE;
} else if (global_args.path == NULL && global_args.dir_path == NULL) {
validate_path("./json/ubus.json");