12 #include <gnutls/gnutls.h>
19 int debug_default
= 2;
20 int SkipCertificateCheck
= 0;
21 const char *certificate_filename
= NULL
;
22 const char *tls
= "NORMAL";
24 int exists(UNUSED(const char *filename
))
28 void ProcessPendingEvents(void)
39 #include "gnutls-common.h"
40 int print_info(UNUSED(gnutls_session_t state
), UNUSED(const char* hostname
))
50 const char *sequence
[][4] = {
51 {NULL
, NULL
, NULL
, NULL
},
52 {"prefix", " hello", NULL
},
53 {"pre", "fix", " hello", NULL
},
54 {"\r\n", ")\r\n", "prefix", NULL
},
55 {NULL
, NULL
, NULL
, NULL
},
58 /* trick tlscomm into believing it can read. */
59 ssize_t
read(int s
, void *buf
, size_t buflen
)
61 int val
= indices
[s
]++;
63 if (sequence
[s
][val
] == NULL
) {
64 indices
[s
]--; /* make it stay */
67 strncpy(buf
, sequence
[s
][val
], buflen
);
68 printf("read: %s\n", sequence
[s
][val
]);
69 return (strlen(sequence
[s
][val
]));
74 select(int nfds
, fd_set
* r
,
75 fd_set
* w
__attribute__ ((unused
)),
76 fd_set
* x
__attribute__ ((unused
)),
77 struct timeval
*tv
__attribute__ ((unused
)))
81 for (i
= 0; i
< nfds
; i
++) {
82 if (FD_ISSET(i
, r
) && sequence
[i
][indices
[i
]] != NULL
) {
96 struct connection_state
{
99 /*@null@ */ void *tls_state
;
100 /*@null@ */ void *xcred
;
101 char unprocessed
[BUF_SIZE
];
102 void *pc
; /* mailbox handle for debugging messages */
106 main(int argc
__attribute__ ((unused
)), char **argv
107 __attribute__ ((unused
)))
110 struct connection_state scs
;
111 scs
.name
= strdup("test");
112 scs
.unprocessed
[0] = '\0';
114 scs
.tls_state
= NULL
;
118 for (scs
.sd
= 1; sequence
[scs
.sd
][0] != NULL
; scs
.sd
++) {
119 memset(scs
.unprocessed
, 0, BUF_SIZE
);
120 printf("%d\n", tlscomm_expect(&scs
, "prefix", buf
, 255));