summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2002-08-18 08:31:50 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2002-08-18 08:31:50 +0000
commitec57ed29c83d25bea9833944e91de67bb1d6ab11 (patch)
tree905930bd2c91a14e7db661c1808ede10e9b1179d
parent2f2e51046fd7bce7f53aa4a1796d1d5cb6428e3c (diff)
downloadgnutls-ec57ed29c83d25bea9833944e91de67bb1d6ab11.tar.gz
Added verbose option to gnutls-cli-debug.
-rw-r--r--src/tls_test-gaa.c73
-rw-r--r--src/tls_test-gaa.h6
-rw-r--r--src/tls_test.c2
-rw-r--r--src/tls_test.gaa6
4 files changed, 64 insertions, 23 deletions
diff --git a/src/tls_test-gaa.c b/src/tls_test-gaa.c
index 98a4796c29..9bf2a7467b 100644
--- a/src/tls_test-gaa.c
+++ b/src/tls_test-gaa.c
@@ -1,8 +1,9 @@
-/* File generated by GAA 1.6.1
+/* File generated by GAA 1.6.2
*/
#define GAA_NO_WIN32
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#ifndef GAA_NO_WIN32
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(WINDOWS)
@@ -10,6 +11,16 @@
#endif
#endif
+void* gaa_malloc( size_t size) {
+void* ret;
+ ret = malloc(size);
+ if (ret==NULL) {
+ fprintf(stderr, "gaa: could not allocate memory");
+ exit(1);
+ }
+ return ret;
+}
+
void __gaa_helpsingle(char short_name, char *name,
char *arg_desc, char *opt_help)
{
@@ -107,6 +118,7 @@ void gaa_help(void)
{
printf("GNU TLS debug client\nUsage: gnutls-cli-debug [options] hostname\n\n\n");
__gaa_helpsingle('p', "port", "integer ", "The port to connect to.");
+ __gaa_helpsingle('v', "verbose", "", "More verbose output");
__gaa_helpsingle('h', "help", "", "prints this help");
#line 100 "gaa.skel"
@@ -122,10 +134,12 @@ typedef struct _gaainfo gaainfo;
struct _gaainfo
{
-#line 9 "tls_test.gaa"
+#line 13 "tls_test.gaa"
char **rest_args;
-#line 8 "tls_test.gaa"
+#line 12 "tls_test.gaa"
int nrest_args;
+#line 6 "tls_test.gaa"
+ int more_info;
#line 3 "tls_test.gaa"
int pp;
@@ -182,9 +196,10 @@ int gaa_error = 0;
#define GAA_MULTIPLE_OPTION 3
#define GAA_REST 0
-#define GAA_NB_OPTION 2
+#define GAA_NB_OPTION 3
#define GAAOPTID_help 1
-#define GAAOPTID_port 2
+#define GAAOPTID_verbose 2
+#define GAAOPTID_port 3
#line 168 "gaa.skel"
@@ -254,7 +269,7 @@ if(!OK) \
num = 0; \
target = NULL; \
if ( gaa_last_non_option - gaa_index > 0) \
- target = malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
+ target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
for(; gaa_index < gaa_last_non_option; gaa_index++) \
{ \
if(gaa_arg_used[gaa_index] == 0) \
@@ -273,7 +288,7 @@ if(!OK) \
num = 0; \
target = NULL; \
if ( gaa_last_non_option - gaa_index > 0) \
- target = malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
+ target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
for(; gaa_index < gaa_last_non_option; gaa_index++) \
{ \
if(gaa_arg_used[gaa_index] == 0) \
@@ -417,11 +432,13 @@ int gaa_get_option_num(char *str, int status)
case GAA_MULTIPLE_OPTION:
#line 375 "gaa.skel"
GAA_CHECK1STR("h", GAAOPTID_help);
+ GAA_CHECK1STR("v", GAAOPTID_verbose);
#line 277 "gaa.skel"
break;
case GAA_WORD_OPTION:
GAA_CHECKSTR("help", GAAOPTID_help);
+ GAA_CHECKSTR("verbose", GAAOPTID_verbose);
GAA_CHECKSTR("port", GAAOPTID_port);
#line 281 "gaa.skel"
@@ -458,11 +475,18 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
{
case GAAOPTID_help:
OK = 0;
-#line 6 "tls_test.gaa"
+#line 9 "tls_test.gaa"
{ gaa_help(); exit(0); ;};
return GAA_OK;
break;
+ case GAAOPTID_verbose:
+ OK = 0;
+#line 7 "tls_test.gaa"
+{ gaaval->more_info = 1 ;};
+
+ return GAA_OK;
+ break;
case GAAOPTID_port:
OK = 0;
GAA_TESTMOREARGS;
@@ -475,7 +499,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
break;
case GAA_REST:
GAA_LIST_FILL(GAAREST_tmp.arg1, gaa_getstr, char*, GAAREST_tmp.size1);
-#line 10 "tls_test.gaa"
+#line 14 "tls_test.gaa"
{ gaaval->rest_args = GAAREST_tmp.arg1; gaaval->nrest_args = GAAREST_tmp.size1 ;};
return GAA_OK;
@@ -496,23 +520,26 @@ int gaa(int argc, char **argv, gaainfo *gaaval)
GAAargv = argv;
GAAargc = argc;
- opt_list = (char*) malloc(GAA_NB_OPTION + 1);
+ opt_list = (char*) gaa_malloc(GAA_NB_OPTION + 1);
+
for(i = 0; i < GAA_NB_OPTION + 1; i++)
opt_list[i] = 0;
/* initialization */
if(inited == 0)
{
-#line 12 "tls_test.gaa"
-{ gaaval->rest_args=NULL; gaaval->nrest_args=0; gaaval->pp = 443; ;};
+#line 16 "tls_test.gaa"
+{ gaaval->rest_args=NULL; gaaval->nrest_args=0; gaaval->pp = 443; gaaval->more_info = 0; ;};
}
inited = 1;
#line 438 "gaa.skel"
gaa_arg_used = NULL;
- if (argc > 0)
- gaa_arg_used = malloc(argc * sizeof(char));
+ if (argc > 0) {
+ gaa_arg_used = gaa_malloc(argc * sizeof(char));
+ }
+
for(i = 1; i < argc; i++)
gaa_arg_used[i] = 0;
for(i = 1; i < argc; i++)
@@ -624,8 +651,10 @@ int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc)
char a;
int i = 0, len = 0, newline = 0;
- if(argc == 1)
+ if(argc == 1) {
newline = 1;
+ len = 2;
+ }
if(fscanf(file,"%c", &a) != 1) return 0;
@@ -647,8 +676,10 @@ int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc)
len++;
if(fscanf(file,"%c", &a) != 1) a = ' ';
}
-
- tmp_str->str = malloc((len + 1) * sizeof(char));
+
+ len += 1;
+ tmp_str->str = gaa_malloc((len) * sizeof(char));
+
if(newline == 1)
{
tmp_str->str[0] = '-';
@@ -671,7 +702,7 @@ int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc)
tmp_str->str[i] = a;
i++;
}
- while(a != ' ' && a != 9 && a != '\n');
+ while(a != ' ' && a != 9 && a != '\n' && i < len);
tmp_str->str[i - 1] = 0;
@@ -701,7 +732,8 @@ int gaa_file(char *name, gaainfo *gaaval)
do
{
argc++;
- *tmp_str = malloc(sizeof(gaa_str_node));
+ *tmp_str = gaa_malloc(sizeof(gaa_str_node));
+
(*tmp_str)->str = NULL;
(*tmp_str)->next = NULL;
@@ -713,7 +745,8 @@ int gaa_file(char *name, gaainfo *gaaval)
if(rval == 1)
return 0;
- argv = malloc((1 + argc) * sizeof(char*));
+ argv = gaa_malloc((1 + argc) * sizeof(char*));
+
tmp_str2 = first_str;
argv[0] = "cfg";
for(i = 1; i < argc; i++)
diff --git a/src/tls_test-gaa.h b/src/tls_test-gaa.h
index 6418500ba5..fc1a63f75c 100644
--- a/src/tls_test-gaa.h
+++ b/src/tls_test-gaa.h
@@ -8,10 +8,12 @@ typedef struct _gaainfo gaainfo;
struct _gaainfo
{
-#line 9 "tls_test.gaa"
+#line 13 "tls_test.gaa"
char **rest_args;
-#line 8 "tls_test.gaa"
+#line 12 "tls_test.gaa"
int nrest_args;
+#line 6 "tls_test.gaa"
+ int more_info;
#line 3 "tls_test.gaa"
int pp;
diff --git a/src/tls_test.c b/src/tls_test.c
index 086832182c..b0b0e85c90 100644
--- a/src/tls_test.c
+++ b/src/tls_test.c
@@ -218,5 +218,7 @@ void gaa_parser(int argc, char **argv)
if (info.nrest_args==0) hostname="localhost";
else hostname = info.rest_args[0];
+ more_info = info.more_info;
+
}
diff --git a/src/tls_test.gaa b/src/tls_test.gaa
index 0e73c1d116..c1d0664a69 100644
--- a/src/tls_test.gaa
+++ b/src/tls_test.gaa
@@ -3,11 +3,15 @@ helpnode "GNU TLS debug client\nUsage: gnutls-cli-debug [options] hostname\n\n"
#int pp;
option (p, port) INT "integer" { $pp = $1 } "The port to connect to."
+#int more_info;
+option (v, verbose) { $more_info = 1 } "More verbose output"
+
option (h, help) { gaa_help(); exit(0); } "prints this help"
+
#int nrest_args;
#char **rest_args;
rest *STR "hostname" { $rest_args = $1; $nrest_args = @1 }
-init { $rest_args=NULL; $nrest_args=0; $pp = 443; }
+init { $rest_args=NULL; $nrest_args=0; $pp = 443; $more_info = 0; }