Kaynağa Gözat

More changes...

master
ebeveyn
işleme
4a68e16148
2 değiştirilmiş dosya ile 37 ekleme ve 13 silme
  1. +35
    -13
      xtandard.c
  2. +2
    -0
      xtandard.h

+ 35
- 13
xtandard.c Dosyayı Görüntüle

@@ -18,6 +18,8 @@ char * program_license = NULL;
int argument_count = 0;
char * * argument_nick = NULL;
char * * argument_name = NULL;
char * argument_input = NULL;
char * argument_output = NULL;
void (* * argument_function) (void) = NULL;

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 (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_count;

argument_nick [argument_count] = allocate (string_length (nick) + 1);
argument_name [argument_count] = allocate (string_length (name) + 1);
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));

string_copy (argument_nick [argument_count], nick);
string_copy (argument_name [argument_count], name);
argument_nick [argument_count - 1] = allocate (string_length (nick) + 1);
argument_name [argument_count - 1] = allocate (string_length (name) + 1);

argument_function [argument_count] = function;
string_copy (argument_nick [argument_count - 1], nick);
string_copy (argument_name [argument_count - 1], name);

++argument_count;
argument_function [argument_count - 1] = function;
}

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)) {
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) {
if ((string_compare (array [index_a], argument_nick [index_b]) != 0)
|| (string_compare (array [index_a], argument_name [index_b]) != 0)) {
if ((string_compare (array [index_a], "-h") != 0) || (string_compare (array [index_a], "--help") != 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] ();
echo ("Executing: "); echo (argument_name [index_b]); echo ("\n");
break;
}
}
}


+ 2
- 0
xtandard.h Dosyayı Görüntüle

@@ -60,6 +60,8 @@ extern char * program_license;
extern int argument_count;
extern char * * argument_nick;
extern char * * argument_name;
extern char * argument_input;
extern char * argument_output;
extern void (* * argument_function) (void);

extern int file_list_active;


Yükleniyor…
İptal
Kaydet