First project skeleton attempt
This commit is contained in:
parent
c7e998ac1f
commit
f124022b78
@ -2,13 +2,47 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
extern int optind;
|
||||||
#include <libutils/libutils.h>
|
#include <libutils/libutils.h>
|
||||||
|
|
||||||
|
|
||||||
/* usage */
|
/* configure */
|
||||||
static int usage(void)
|
static int _configure_config(Config * config);
|
||||||
|
static int _configure(char const * directory)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s", "Usage: configure\n");
|
Config * config;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
if(chdir(directory) != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s", "configure: ");
|
||||||
|
perror(directory);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if((config = config_new()) == NULL)
|
||||||
|
return 2;
|
||||||
|
if(config_load(config, "project.conf") == 0)
|
||||||
|
res = _configure_config(config);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res = 3;
|
||||||
|
fprintf(stderr, "%s", "configure: could not open project file\n");
|
||||||
|
}
|
||||||
|
config_delete(config);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _configure_config(Config * config)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* usage */
|
||||||
|
static int _usage(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s", "Usage: configure [directory]\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,12 +51,18 @@ static int usage(void)
|
|||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
Config * config;
|
Config * config;
|
||||||
|
int o;
|
||||||
|
|
||||||
if(argc != 1)
|
while((o = getopt(argc, argv, "h")) != -1)
|
||||||
return usage();
|
{
|
||||||
/* if((config = config_new("project.conf")) == NULL) */
|
switch(o)
|
||||||
if((config = config_new()) == NULL)
|
{
|
||||||
return 2;
|
case 'h':
|
||||||
config_delete(config);
|
case '?':
|
||||||
return 0;
|
return _usage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(argc - optind > 2)
|
||||||
|
return _usage();
|
||||||
|
return _configure(argc - optind == 1 ? argv[argc - 1] : ".");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user