Use getopt_long() to reject flags w/usage output
This commit is contained in:
parent
bb118be462
commit
cc530fcccc
1 changed files with 11 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -36,6 +37,10 @@ static void usage(int argc, char **argv, const char *message, ...) {
|
|||
int main(int argc, char **argv) {
|
||||
patty_client *client;
|
||||
|
||||
struct option opts[] = {
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
uint8_t buf[4096];
|
||||
ssize_t readlen;
|
||||
|
||||
|
@ -45,6 +50,12 @@ int main(int argc, char **argv) {
|
|||
|
||||
struct stat st;
|
||||
|
||||
int ch;
|
||||
|
||||
if ((ch = getopt_long(argc, argv, "", opts, NULL)) >= 0) {
|
||||
usage(argc, argv, NULL);
|
||||
}
|
||||
|
||||
if (argc < 2) {
|
||||
usage(argc, argv, "Not enough arguments provided");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue