More changes...
This commit is contained in:
parent
5e27b78e2b
commit
4a68e16148
54
xtandard.c
54
xtandard.c
@ -18,6 +18,8 @@ char * program_license = NULL;
|
|||||||
int argument_count = 0;
|
int argument_count = 0;
|
||||||
char * * argument_nick = NULL;
|
char * * argument_nick = NULL;
|
||||||
char * * argument_name = NULL;
|
char * * argument_name = NULL;
|
||||||
|
char * argument_input = NULL;
|
||||||
|
char * argument_output = NULL;
|
||||||
void (* * argument_function) (void) = NULL;
|
void (* * argument_function) (void) = NULL;
|
||||||
|
|
||||||
int file_list_active = 0;
|
int file_list_active = 0;
|
||||||
@ -154,33 +156,53 @@ void argument_define (char * nick, char * name, void (* function) (void)) {
|
|||||||
fatal_failure (name == NULL, "argument_define: Failed to define an argument, name is null pointer.");
|
fatal_failure (name == NULL, "argument_define: Failed to define an argument, name is null pointer.");
|
||||||
fatal_failure (function == NULL, "argument_define: Failed to define an argument, function is null pointer.");
|
fatal_failure (function == NULL, "argument_define: Failed to define an argument, function is null pointer.");
|
||||||
|
|
||||||
argument_nick = reallocate (argument_nick, (argument_count + 1) * (int) sizeof (* argument_nick));
|
|
||||||
argument_name = reallocate (argument_name, (argument_count + 1) * (int) sizeof (* argument_name));
|
|
||||||
argument_function = reallocate (argument_function, (argument_count + 1) * (int) sizeof (* argument_function));
|
|
||||||
|
|
||||||
argument_nick [argument_count] = allocate (string_length (nick) + 1);
|
|
||||||
argument_name [argument_count] = allocate (string_length (name) + 1);
|
|
||||||
|
|
||||||
string_copy (argument_nick [argument_count], nick);
|
|
||||||
string_copy (argument_name [argument_count], name);
|
|
||||||
|
|
||||||
argument_function [argument_count] = function;
|
|
||||||
|
|
||||||
++argument_count;
|
++argument_count;
|
||||||
|
|
||||||
|
argument_nick = reallocate (argument_nick, argument_count * (int) sizeof (* argument_nick));
|
||||||
|
argument_name = reallocate (argument_name, argument_count * (int) sizeof (* argument_name));
|
||||||
|
argument_function = reallocate (argument_function, argument_count * (int) sizeof (* argument_function));
|
||||||
|
|
||||||
|
argument_nick [argument_count - 1] = allocate (string_length (nick) + 1);
|
||||||
|
argument_name [argument_count - 1] = allocate (string_length (name) + 1);
|
||||||
|
|
||||||
|
string_copy (argument_nick [argument_count - 1], nick);
|
||||||
|
string_copy (argument_name [argument_count - 1], name);
|
||||||
|
|
||||||
|
argument_function [argument_count - 1] = function;
|
||||||
}
|
}
|
||||||
|
|
||||||
void argument_select (int count, char * * array) {
|
void argument_select (int count, char * * array) {
|
||||||
int index_a, index_b;
|
int index_a = 0;
|
||||||
|
int index_b = 0;
|
||||||
|
|
||||||
if ((count == 1) || (array == NULL)) {
|
if ((count == 1) || (array == NULL)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (index_a = 0; index_a != count; ++index_a) {
|
for (index_a = 1; index_a != count; ++index_a) {
|
||||||
for (index_b = 0; index_b != argument_count; ++index_b) {
|
for (index_b = 0; index_b != argument_count; ++index_b) {
|
||||||
if ((string_compare (array [index_a], argument_nick [index_b]) != 0)
|
if ((string_compare (array [index_a], "-h") != 0) || (string_compare (array [index_a], "--help") != 0)) {
|
||||||
|| (string_compare (array [index_a], argument_name [index_b]) != 0)) {
|
echo ("Printing help...\n");
|
||||||
|
for (index_b = 0; index_b != argument_count; ++index_b) {
|
||||||
|
echo ("\t"); echo (argument_nick [index_b]);
|
||||||
|
echo (" "); echo (argument_name [index_b]);
|
||||||
|
echo ("\n");
|
||||||
|
}
|
||||||
|
fatal_failure (1, "Help printed, terminating...");
|
||||||
|
} else if ((string_compare (array [index_a], "-i") != 0) || (string_compare (array [index_a], "--input") != 0)) {
|
||||||
|
++index_a;
|
||||||
|
argument_input = array [index_a];
|
||||||
|
echo ("Selecting input: "); echo (argument_input); echo ("\n");
|
||||||
|
break;
|
||||||
|
} else if ((string_compare (array [index_a], "-o") != 0) || (string_compare (array [index_a], "--output") != 0)) {
|
||||||
|
++index_a;
|
||||||
|
argument_output = array [index_a];
|
||||||
|
echo ("Selecting output: "); echo (argument_output); echo ("\n");
|
||||||
|
break;
|
||||||
|
} else if ((string_compare (array [index_a], argument_nick [index_b]) != 0) || (string_compare (array [index_a], argument_name [index_b]) != 0)) {
|
||||||
argument_function [index_b] ();
|
argument_function [index_b] ();
|
||||||
|
echo ("Executing: "); echo (argument_name [index_b]); echo ("\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,8 @@ extern char * program_license;
|
|||||||
extern int argument_count;
|
extern int argument_count;
|
||||||
extern char * * argument_nick;
|
extern char * * argument_nick;
|
||||||
extern char * * argument_name;
|
extern char * * argument_name;
|
||||||
|
extern char * argument_input;
|
||||||
|
extern char * argument_output;
|
||||||
extern void (* * argument_function) (void);
|
extern void (* * argument_function) (void);
|
||||||
|
|
||||||
extern int file_list_active;
|
extern int file_list_active;
|
||||||
|
Loading…
Reference in New Issue
Block a user