add ifquery --version
This commit is contained in:
parent
86a83d9e95
commit
c189467707
5 changed files with 80 additions and 3 deletions
10
Makefile
10
Makefile
|
@ -1,5 +1,10 @@
|
||||||
|
PACKAGE_NAME := ifupdown-ng
|
||||||
|
PACKAGE_VERSION := 0.0.1
|
||||||
|
PACKAGE_BUGREPORT := https://github.com/kaniini/ifupdown-ng/issues/new
|
||||||
|
|
||||||
|
|
||||||
INTERFACES_FILE := /etc/network/interfaces
|
INTERFACES_FILE := /etc/network/interfaces
|
||||||
CFLAGS := -ggdb3 -O2 -Wall -I. -DINTERFACES_FILE=\"${INTERFACES_FILE}\"
|
CFLAGS := -ggdb3 -O2 -Wall -I. -DINTERFACES_FILE=\"${INTERFACES_FILE}\" -DPACKAGE_NAME=\"${PACKAGE_NAME}\" -DPACKAGE_VERSION=\"${PACKAGE_VERSION}\" -DPACKAGE_BUGREPORT=\"${PACKAGE_BUGREPORT}\"
|
||||||
|
|
||||||
|
|
||||||
LIBIFUPDOWN_SRC = \
|
LIBIFUPDOWN_SRC = \
|
||||||
|
@ -7,7 +12,8 @@ LIBIFUPDOWN_SRC = \
|
||||||
libifupdown/dict.c \
|
libifupdown/dict.c \
|
||||||
libifupdown/interface.c \
|
libifupdown/interface.c \
|
||||||
libifupdown/interface-file.c \
|
libifupdown/interface-file.c \
|
||||||
libifupdown/fgetline.c
|
libifupdown/fgetline.c \
|
||||||
|
libifupdown/version.c
|
||||||
|
|
||||||
LIBIFUPDOWN_OBJ = ${LIBIFUPDOWN_SRC:.c=.o}
|
LIBIFUPDOWN_OBJ = ${LIBIFUPDOWN_SRC:.c=.o}
|
||||||
LIBIFUPDOWN_LIB = libifupdown.a
|
LIBIFUPDOWN_LIB = libifupdown.a
|
||||||
|
|
|
@ -64,6 +64,8 @@ usage()
|
||||||
printf(" ifquery [options] --list\n");
|
printf(" ifquery [options] --list\n");
|
||||||
|
|
||||||
printf("\nOptions:\n");
|
printf("\nOptions:\n");
|
||||||
|
printf(" -h, --help this help\n");
|
||||||
|
printf(" -V, --version show this program's version\n");
|
||||||
printf(" -i, --interfaces FILE use FILE for interface definitions\n");
|
printf(" -i, --interfaces FILE use FILE for interface definitions\n");
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -74,6 +76,8 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lif_dict collection;
|
struct lif_dict collection;
|
||||||
struct option long_options[] = {
|
struct option long_options[] = {
|
||||||
|
{"help", no_argument, 0, 'h'},
|
||||||
|
{"version", no_argument, 0, 'V'},
|
||||||
{"interfaces", required_argument, 0, 'i'},
|
{"interfaces", required_argument, 0, 'i'},
|
||||||
{NULL, 0, 0, 0}
|
{NULL, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
@ -81,11 +85,17 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c = getopt_long(argc, argv, "i:", long_options, NULL);
|
int c = getopt_long(argc, argv, "hVi:", long_options, NULL);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'h':
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
|
case 'V':
|
||||||
|
lif_common_version();
|
||||||
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
interfaces_file = optarg;
|
interfaces_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -21,5 +21,6 @@
|
||||||
#include "libifupdown/interface.h"
|
#include "libifupdown/interface.h"
|
||||||
#include "libifupdown/interface-file.h"
|
#include "libifupdown/interface-file.h"
|
||||||
#include "libifupdown/fgetline.h"
|
#include "libifupdown/fgetline.h"
|
||||||
|
#include "libifupdown/version.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
39
libifupdown/version.c
Normal file
39
libifupdown/version.c
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* libifupdown/version.c
|
||||||
|
* Purpose: lif_common_version() header
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 Ariadne Conill <ariadne@dereferenced.org>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* This software is provided 'as is' and without any warranty, express or
|
||||||
|
* implied. In no event shall the authors be liable for any damages arising
|
||||||
|
* from the use of this software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "libifupdown/version.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
lif_common_version(void)
|
||||||
|
{
|
||||||
|
printf("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
|
||||||
|
|
||||||
|
printf("\nCopyright (c) 2020 Ariadne Conill <ariadne@dereferenced.org>\n\n");
|
||||||
|
|
||||||
|
printf("Permission to use, copy, modify, and/or distribute this software for any\n");
|
||||||
|
printf("purpose with or without fee is hereby granted, provided that the above\n");
|
||||||
|
printf("copyright notice and this permission notice appear in all copies.\n\n");
|
||||||
|
|
||||||
|
printf("This software is provided 'as is' and without any warranty, express or\n");
|
||||||
|
printf("implied. In no event shall the authors be liable for any damages arising\n");
|
||||||
|
printf("from the use of this software.\n\n");
|
||||||
|
|
||||||
|
printf("Report bugs at <%s>.\n", PACKAGE_BUGREPORT);
|
||||||
|
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
21
libifupdown/version.h
Normal file
21
libifupdown/version.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* libifupdown/version.h
|
||||||
|
* Purpose: lif_common_version() header
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 Ariadne Conill <ariadne@dereferenced.org>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* This software is provided 'as is' and without any warranty, express or
|
||||||
|
* implied. In no event shall the authors be liable for any damages arising
|
||||||
|
* from the use of this software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LIBIFUPDOWN_VERSION_H__GUARD
|
||||||
|
#define LIBIFUPDOWN_VERSION_H__GUARD
|
||||||
|
|
||||||
|
extern void lif_common_version(void);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue