1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
/*
* VUOS: view OS project
* Copyright (C) 2017 Renzo Davoli <renzo@cs.unibo.it>, Antonio Cardace <anto.cardace@gmail.com>
* VirtualSquare team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 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, see <http://www.gnu.org/licenses/>.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <libgen.h>
#include <getopt.h>
#include <vulib.h>
static char *progname;
void usage()
{
fprintf(stderr,
"Usage:\n"
" %s OPTIONS\n"
" OPTIONS:\n"
" -h --help: print this help message\n\n", progname);
exit(2);
}
static const char *short_options = "p";
static const struct option long_options[] = {
{"help",0,0,'h'},
{0,0,0,0}
};
int main(int argc, char *argv[])
{
int c;
progname = basename(argv[0]);
size_t bufsize;
if (vu_check() < 0) {
fprintf(stderr,"This is a VUOS command."
"It works only inside a vuos virtual namespace\n");
usage();
}
while (1) {
c=getopt_long(argc, argv,
short_options, long_options, NULL);
if (c == -1) break;
switch (c) {
case 'h': usage();
break;
}
}
if (argc - optind > 0)
usage();
if ((bufsize = vu_lsmod(NULL, 0)) > 0) {
char buf[bufsize];
if (vu_lsmod(buf, bufsize) < 0)
perror(progname);
else
printf("%s", buf);
}
return 0;
}
|