started argument parsing using argp

This commit is contained in:
root committed 2026-06-22 23:16:45 +02:00
1 parent 7b1511e31a
commit 62542734b5
4 files changed
+131 -7

No files matched your search

+16 -6
View File
@@ -1,16 +1,22 @@
// external dependencies
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <argp.h>
#include <dirent.h>
#include <errno.h>
#include <linux/limits.h>
// internal dependencies
#include "log.h"
#include "arguments.h"
typedef struct dirent dirent;
// program logic
int main( int argc, char** argv )
{
( void )argc;
( void )argv;
arguments_t args;
parse_args( argc, argv, &args );
if ( 2 < argc ) return -1;
@@ -27,11 +33,15 @@ int main( int argc, char** argv )
}
DIR* directory = opendir( argument_directory );
dirent* entry;
struct dirent* entry;
if ( !directory )
{
log_error( "failed to open directory `%s`", argument_directory );
if ( ENOENT == errno )
log_error( "no directory `%s`", argument_directory );
else
log_error( "failed to open directory `%s`", argument_directory );
return -1;
}