mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
indentation
This commit is contained in:
+232
-172
@@ -33,7 +33,7 @@ static int verbose = 0; /* verbose level (0-1)*/
|
||||
|
||||
struct str_with_len
|
||||
{
|
||||
const char * const str;
|
||||
const char *const str;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
@@ -46,17 +46,22 @@ struct data_unit1
|
||||
};
|
||||
|
||||
static const struct data_unit1 data_units1[] = {
|
||||
{D_STR_W_LEN("1234567890!@~%&$@#{}[]\\/!?`."),
|
||||
{0x1c, 0x68, 0xc2, 0xe5, 0x1f, 0x63, 0xc9, 0x5f, 0x17, 0xab, 0x1f, 0x20, 0x8b, 0x86, 0x39, 0x57}},
|
||||
{D_STR_W_LEN("Simple string."),
|
||||
{0xf1, 0x2b, 0x7c, 0xad, 0xa0, 0x41, 0xfe, 0xde, 0x4e, 0x68, 0x16, 0x63, 0xb4, 0x60, 0x5d, 0x78}},
|
||||
{D_STR_W_LEN("abcdefghijklmnopqrstuvwxyz"),
|
||||
{0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b}},
|
||||
{D_STR_W_LEN("zyxwvutsrqponMLKJIHGFEDCBA"),
|
||||
{0x05, 0x61, 0x3a, 0x6b, 0xde, 0x75, 0x3a, 0x45, 0x91, 0xa8, 0x81, 0xb0, 0xa7, 0xe2, 0xe2, 0x0e}},
|
||||
{D_STR_W_LEN("abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA"
|
||||
"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA"),
|
||||
{0xaf, 0xab, 0xc7, 0xe9, 0xe7, 0x17, 0xbe, 0xd6, 0xc0, 0x0f, 0x78, 0x8c, 0xde, 0xdd, 0x11, 0xd1}},
|
||||
{D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`."),
|
||||
{0x1c, 0x68, 0xc2, 0xe5, 0x1f, 0x63, 0xc9, 0x5f, 0x17, 0xab, 0x1f, 0x20,
|
||||
0x8b, 0x86, 0x39, 0x57}},
|
||||
{D_STR_W_LEN ("Simple string."),
|
||||
{0xf1, 0x2b, 0x7c, 0xad, 0xa0, 0x41, 0xfe, 0xde, 0x4e, 0x68, 0x16, 0x63,
|
||||
0xb4, 0x60, 0x5d, 0x78}},
|
||||
{D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz"),
|
||||
{0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c,
|
||||
0xca, 0x67, 0xe1, 0x3b}},
|
||||
{D_STR_W_LEN ("zyxwvutsrqponMLKJIHGFEDCBA"),
|
||||
{0x05, 0x61, 0x3a, 0x6b, 0xde, 0x75, 0x3a, 0x45, 0x91, 0xa8, 0x81, 0xb0,
|
||||
0xa7, 0xe2, 0xe2, 0x0e}},
|
||||
{D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA"
|
||||
"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA"),
|
||||
{0xaf, 0xab, 0xc7, 0xe9, 0xe7, 0x17, 0xbe, 0xd6, 0xc0, 0x0f, 0x78, 0x8c,
|
||||
0xde, 0xdd, 0x11, 0xd1}},
|
||||
};
|
||||
|
||||
static const size_t units1_num = sizeof(data_units1) / sizeof(data_units1[0]);
|
||||
@@ -74,85 +79,134 @@ struct data_unit2
|
||||
};
|
||||
|
||||
static const struct data_unit2 data_units2[] = {
|
||||
{ { {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
|
||||
117, 118, 119, 120, 121, 122}, 26},/* a..z ASCII sequence */
|
||||
{0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b}
|
||||
},
|
||||
{ { {65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
|
||||
65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
|
||||
65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65
|
||||
}, 72 },/* 'A' x 72 times */
|
||||
{0x24, 0xa5, 0xef, 0x36, 0x82, 0x80, 0x3a, 0x06, 0x2f, 0xea, 0xad, 0xad, 0x76, 0xda, 0xbd, 0xa8}
|
||||
},
|
||||
{ { {19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
|
||||
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
|
||||
68, 69, 70, 71, 72, 73}, 55},/* 19..73 sequence */
|
||||
{0x6d, 0x2e, 0x6e, 0xde, 0x5d, 0x64, 0x6a, 0x17, 0xf1, 0x09, 0x2c, 0xac, 0x19, 0x10, 0xe3, 0xd6}
|
||||
},
|
||||
{ { {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
||||
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
|
||||
57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69}, 63},/* 7..69 sequence */
|
||||
{0x88, 0x13, 0x48, 0x47, 0x73, 0xaa, 0x92, 0xf2, 0xc9, 0xdd, 0x69, 0xb3, 0xac, 0xf4, 0xba, 0x6e}
|
||||
},
|
||||
{ { {38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
|
||||
62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
|
||||
87, 88, 89, 90, 91, 92}, 55},/* 38..92 sequence */
|
||||
{0x80, 0xf0, 0x05, 0x7e, 0xa2, 0xf7, 0xc8, 0x43, 0x12, 0xd3, 0xb1, 0x61, 0xab, 0x52, 0x3b, 0xaf}
|
||||
},
|
||||
{ { {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
|
||||
28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
|
||||
53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72},
|
||||
{ { {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
|
||||
112, 113, 114, 115, 116,
|
||||
117, 118, 119, 120, 121, 122}, 26}, /* a..z ASCII sequence */
|
||||
{0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c,
|
||||
0xca, 0x67, 0xe1, 0x3b}},
|
||||
{ { {65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
|
||||
65, 65, 65, 65, 65, 65,
|
||||
65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
|
||||
65, 65, 65, 65, 65, 65,
|
||||
65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
|
||||
65, 65, 65, 65, 65, 65}, 72 },/* 'A' x 72 times */
|
||||
{0x24, 0xa5, 0xef, 0x36, 0x82, 0x80, 0x3a, 0x06, 0x2f, 0xea, 0xad, 0xad,
|
||||
0x76, 0xda, 0xbd, 0xa8}},
|
||||
{ { {19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
|
||||
37, 38, 39, 40, 41, 42,
|
||||
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
|
||||
61, 62, 63, 64, 65, 66, 67,
|
||||
68, 69, 70, 71, 72, 73}, 55}, /* 19..73 sequence */
|
||||
{0x6d, 0x2e, 0x6e, 0xde, 0x5d, 0x64, 0x6a, 0x17, 0xf1, 0x09, 0x2c, 0xac,
|
||||
0x19, 0x10, 0xe3, 0xd6}},
|
||||
{ { {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
|
||||
26, 27, 28, 29, 30, 31,
|
||||
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
|
||||
50, 51, 52, 53, 54, 55, 56,
|
||||
57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69}, 63}, /* 7..69 sequence */
|
||||
{0x88, 0x13, 0x48, 0x47, 0x73, 0xaa, 0x92, 0xf2, 0xc9, 0xdd, 0x69, 0xb3,
|
||||
0xac, 0xf4, 0xba, 0x6e}},
|
||||
{ { {38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
|
||||
56, 57, 58, 59, 60, 61,
|
||||
62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
|
||||
80, 81, 82, 83, 84, 85, 86,
|
||||
87, 88, 89, 90, 91, 92}, 55}, /* 38..92 sequence */
|
||||
{0x80, 0xf0, 0x05, 0x7e, 0xa2, 0xf7, 0xc8, 0x43, 0x12, 0xd3, 0xb1, 0x61,
|
||||
0xab, 0x52, 0x3b, 0xaf}},
|
||||
{ { {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||
21, 22, 23, 24, 25, 26, 27,
|
||||
28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
|
||||
46, 47, 48, 49, 50, 51, 52,
|
||||
53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
|
||||
71, 72},
|
||||
72},/* 1..72 sequence */
|
||||
{0xc3, 0x28, 0xc5, 0xad, 0xc9, 0x26, 0xa9, 0x99, 0x95, 0x4a, 0x5e, 0x25, 0x50, 0x34, 0x51, 0x73}
|
||||
},
|
||||
{ { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
|
||||
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
|
||||
77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
|
||||
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
|
||||
121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
|
||||
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
|
||||
161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
|
||||
181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
|
||||
201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220,
|
||||
221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240,
|
||||
241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}, 256}, /* 0..255 sequence */
|
||||
{0xe2, 0xc8, 0x65, 0xdb, 0x41, 0x62, 0xbe, 0xd9, 0x63, 0xbf, 0xaa, 0x9e, 0xf6, 0xac, 0x18, 0xf0}
|
||||
},
|
||||
{ { {199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180,
|
||||
179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160,
|
||||
159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140,
|
||||
139}, 61}, /* 199..139 sequence */
|
||||
{0xbb, 0x3f, 0xdb, 0x4a, 0x96, 0x03, 0x36, 0x37, 0x38, 0x78, 0x5e, 0x44, 0xbf, 0x3a, 0x85, 0x51}
|
||||
},
|
||||
{ { {255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236,
|
||||
235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216,
|
||||
215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196,
|
||||
195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176,
|
||||
175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156,
|
||||
155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136,
|
||||
135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116,
|
||||
115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95,
|
||||
94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70,
|
||||
69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45,
|
||||
44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20,
|
||||
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, 255}, /* 255..1 sequence */
|
||||
{0x52, 0x21, 0xa5, 0x83, 0x4f, 0x38, 0x7c, 0x73, 0xba, 0x18, 0x22, 0xb1, 0xf9, 0x7e, 0xae, 0x8b}
|
||||
},
|
||||
{ { {41, 35, 190, 132, 225, 108, 214, 174, 82, 144, 73, 241, 241, 187, 233, 235, 179, 166, 219, 60, 135,
|
||||
12, 62, 153, 36, 94, 13, 28, 6, 183, 71, 222, 179, 18, 77, 200, 67, 187, 139, 166, 31, 3, 90, 125, 9,
|
||||
56, 37, 31, 93, 212, 203, 252, 150, 245, 69, 59, 19, 13, 137, 10, 28, 219, 174, 50, 32, 154, 80, 238,
|
||||
64, 120, 54, 253, 18, 73, 50, 246, 158, 125, 73, 220, 173, 79, 20, 242, 68, 64, 102, 208, 107, 196,
|
||||
48, 183, 50, 59, 161, 34, 246, 34, 145, 157, 225, 139, 31, 218, 176, 202, 153, 2, 185, 114, 157, 73,
|
||||
44, 128, 126, 197, 153, 213, 233, 128, 178, 234, 201, 204, 83, 191, 103, 214, 191, 20, 214, 126, 45,
|
||||
220, 142, 102, 131, 239, 87, 73, 97, 255, 105, 143, 97, 205, 209, 30, 157, 156, 22, 114, 114, 230,
|
||||
29, 240, 132, 79, 74, 119, 2, 215, 232, 57, 44, 83, 203, 201, 18, 30, 51, 116, 158, 12, 244, 213,
|
||||
212, 159, 212, 164, 89, 126, 53, 207, 50, 34, 244, 204, 207, 211, 144, 45, 72, 211, 143, 117, 230,
|
||||
217, 29, 42, 229, 192, 247, 43, 120, 129, 135, 68, 14, 95, 80, 0, 212, 97, 141, 190, 123, 5, 21, 7,
|
||||
59, 51, 130, 31, 24, 112, 146, 218, 100, 84, 206, 177, 133, 62, 105, 21, 248, 70, 106, 4, 150, 115,
|
||||
14, 217, 22, 47, 103, 104, 212, 247, 74, 74, 208, 87, 104}, 255}, /* pseudo-random data */
|
||||
{0x55, 0x61, 0x2c, 0xeb, 0x29, 0xee, 0xa8, 0xb2, 0xf6, 0x10, 0x7b, 0xc1, 0x5b, 0x0f, 0x01, 0x95}
|
||||
}
|
||||
{0xc3, 0x28, 0xc5, 0xad, 0xc9, 0x26, 0xa9, 0x99, 0x95, 0x4a, 0x5e, 0x25,
|
||||
0x50, 0x34, 0x51, 0x73}},
|
||||
{ { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||
21, 22, 23, 24, 25, 26,
|
||||
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
|
||||
45, 46, 47, 48, 49, 50, 51,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
|
||||
70, 71, 72, 73, 74, 75, 76,
|
||||
77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
|
||||
95, 96, 97, 98, 99, 100,
|
||||
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
|
||||
115, 116, 117, 118, 119, 120,
|
||||
121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
|
||||
135, 136, 137, 138, 139, 140,
|
||||
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
|
||||
155, 156, 157, 158, 159, 160,
|
||||
161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
|
||||
175, 176, 177, 178, 179, 180,
|
||||
181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
|
||||
195, 196, 197, 198, 199, 200,
|
||||
201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214,
|
||||
215, 216, 217, 218, 219, 220,
|
||||
221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234,
|
||||
235, 236, 237, 238, 239, 240,
|
||||
241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
|
||||
255}, 256}, /* 0..255 sequence */
|
||||
{0xe2, 0xc8, 0x65, 0xdb, 0x41, 0x62, 0xbe, 0xd9, 0x63, 0xbf, 0xaa, 0x9e,
|
||||
0xf6, 0xac, 0x18, 0xf0}},
|
||||
{ { {199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186,
|
||||
185, 184, 183, 182, 181, 180,
|
||||
179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166,
|
||||
165, 164, 163, 162, 161, 160,
|
||||
159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146,
|
||||
145, 144, 143, 142, 141, 140,
|
||||
139}, 61}, /* 199..139 sequence */
|
||||
{0xbb, 0x3f, 0xdb, 0x4a, 0x96, 0x03, 0x36, 0x37, 0x38, 0x78, 0x5e, 0x44,
|
||||
0xbf, 0x3a, 0x85, 0x51}},
|
||||
{ { {255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242,
|
||||
241, 240, 239, 238, 237, 236,
|
||||
235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222,
|
||||
221, 220, 219, 218, 217, 216,
|
||||
215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202,
|
||||
201, 200, 199, 198, 197, 196,
|
||||
195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182,
|
||||
181, 180, 179, 178, 177, 176,
|
||||
175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162,
|
||||
161, 160, 159, 158, 157, 156,
|
||||
155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142,
|
||||
141, 140, 139, 138, 137, 136,
|
||||
135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122,
|
||||
121, 120, 119, 118, 117, 116,
|
||||
115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102,
|
||||
101, 100, 99, 98, 97, 96, 95,
|
||||
94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77,
|
||||
76, 75, 74, 73, 72, 71, 70,
|
||||
69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52,
|
||||
51, 50, 49, 48, 47, 46, 45,
|
||||
44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27,
|
||||
26, 25, 24, 23, 22, 21, 20,
|
||||
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, 255}, /* 255..1 sequence */
|
||||
{0x52, 0x21, 0xa5, 0x83, 0x4f, 0x38, 0x7c, 0x73, 0xba, 0x18, 0x22, 0xb1,
|
||||
0xf9, 0x7e, 0xae, 0x8b}},
|
||||
{ { {41, 35, 190, 132, 225, 108, 214, 174, 82, 144, 73, 241, 241, 187, 233,
|
||||
235, 179, 166, 219, 60, 135,
|
||||
12, 62, 153, 36, 94, 13, 28, 6, 183, 71, 222, 179, 18, 77, 200, 67, 187,
|
||||
139, 166, 31, 3, 90, 125, 9,
|
||||
56, 37, 31, 93, 212, 203, 252, 150, 245, 69, 59, 19, 13, 137, 10, 28,
|
||||
219, 174, 50, 32, 154, 80, 238,
|
||||
64, 120, 54, 253, 18, 73, 50, 246, 158, 125, 73, 220, 173, 79, 20, 242,
|
||||
68, 64, 102, 208, 107, 196,
|
||||
48, 183, 50, 59, 161, 34, 246, 34, 145, 157, 225, 139, 31, 218, 176, 202,
|
||||
153, 2, 185, 114, 157, 73,
|
||||
44, 128, 126, 197, 153, 213, 233, 128, 178, 234, 201, 204, 83, 191, 103,
|
||||
214, 191, 20, 214, 126, 45,
|
||||
220, 142, 102, 131, 239, 87, 73, 97, 255, 105, 143, 97, 205, 209, 30,
|
||||
157, 156, 22, 114, 114, 230,
|
||||
29, 240, 132, 79, 74, 119, 2, 215, 232, 57, 44, 83, 203, 201, 18, 30, 51,
|
||||
116, 158, 12, 244, 213,
|
||||
212, 159, 212, 164, 89, 126, 53, 207, 50, 34, 244, 204, 207, 211, 144,
|
||||
45, 72, 211, 143, 117, 230,
|
||||
217, 29, 42, 229, 192, 247, 43, 120, 129, 135, 68, 14, 95, 80, 0, 212,
|
||||
97, 141, 190, 123, 5, 21, 7,
|
||||
59, 51, 130, 31, 24, 112, 146, 218, 100, 84, 206, 177, 133, 62, 105, 21,
|
||||
248, 70, 106, 4, 150, 115,
|
||||
14, 217, 22, 47, 103, 104, 212, 247, 74, 74, 208, 87, 104}, 255}, /* pseudo-random data */
|
||||
{0x55, 0x61, 0x2c, 0xeb, 0x29, 0xee, 0xa8, 0xb2, 0xf6, 0x10, 0x7b, 0xc1,
|
||||
0x5b, 0x0f, 0x01, 0x95}}
|
||||
};
|
||||
|
||||
static const size_t units2_num = sizeof(data_units2) / sizeof(data_units2[0]);
|
||||
@@ -171,17 +225,17 @@ static const size_t units2_num = sizeof(data_units2) / sizeof(data_units2[0]);
|
||||
*/
|
||||
static void
|
||||
bin2hex (const uint8_t *bin,
|
||||
size_t len,
|
||||
char *hex)
|
||||
size_t len,
|
||||
char *hex)
|
||||
{
|
||||
while (len-- > 0)
|
||||
{
|
||||
unsigned int b1, b2;
|
||||
b1 = (*bin >> 4) & 0xf;
|
||||
*hex++ = (char)((b1 > 9) ? (b1 + 'A' - 10) : (b1 + '0'));
|
||||
b2 = *bin++ & 0xf;
|
||||
*hex++ = (char)((b2 > 9) ? (b2 + 'A' - 10) : (b2 + '0'));
|
||||
}
|
||||
{
|
||||
unsigned int b1, b2;
|
||||
b1 = (*bin >> 4) & 0xf;
|
||||
*hex++ = (char) ((b1 > 9) ? (b1 + 'A' - 10) : (b1 + '0'));
|
||||
b2 = *bin++ & 0xf;
|
||||
*hex++ = (char) ((b2 > 9) ? (b2 + 'A' - 10) : (b2 + '0'));
|
||||
}
|
||||
*hex = 0;
|
||||
}
|
||||
|
||||
@@ -192,26 +246,28 @@ check_result (const char *test_name,
|
||||
const uint8_t calcualted[MD5_DIGEST_SIZE],
|
||||
const uint8_t expected[MD5_DIGEST_SIZE])
|
||||
{
|
||||
int failed = memcmp(calcualted, expected, MD5_DIGEST_SIZE);
|
||||
int failed = memcmp (calcualted, expected, MD5_DIGEST_SIZE);
|
||||
check_num++; /* Print 1-based numbers */
|
||||
if (failed)
|
||||
{
|
||||
char calc_str[MD5_DIGEST_STRING_LENGTH];
|
||||
char expc_str[MD5_DIGEST_STRING_LENGTH];
|
||||
bin2hex(calcualted, MD5_DIGEST_SIZE, calc_str);
|
||||
bin2hex(expected, MD5_DIGEST_SIZE, expc_str);
|
||||
fprintf (stderr, "FAILED: %s check %u: calculated digest %s, expected digest %s.\n",
|
||||
test_name, check_num, calc_str, expc_str);
|
||||
fflush (stderr);
|
||||
}
|
||||
{
|
||||
char calc_str[MD5_DIGEST_STRING_LENGTH];
|
||||
char expc_str[MD5_DIGEST_STRING_LENGTH];
|
||||
bin2hex (calcualted, MD5_DIGEST_SIZE, calc_str);
|
||||
bin2hex (expected, MD5_DIGEST_SIZE, expc_str);
|
||||
fprintf (stderr,
|
||||
"FAILED: %s check %u: calculated digest %s, expected digest %s.\n",
|
||||
test_name, check_num, calc_str, expc_str);
|
||||
fflush (stderr);
|
||||
}
|
||||
else if (verbose)
|
||||
{
|
||||
char calc_str[MD5_DIGEST_STRING_LENGTH];
|
||||
bin2hex(calcualted, MD5_DIGEST_SIZE, calc_str);
|
||||
printf ("PASSED: %s check %u: calculated digest %s match expected digest.\n",
|
||||
test_name, check_num, calc_str);
|
||||
fflush (stdout);
|
||||
}
|
||||
{
|
||||
char calc_str[MD5_DIGEST_STRING_LENGTH];
|
||||
bin2hex (calcualted, MD5_DIGEST_SIZE, calc_str);
|
||||
printf (
|
||||
"PASSED: %s check %u: calculated digest %s match expected digest.\n",
|
||||
test_name, check_num, calc_str);
|
||||
fflush (stdout);
|
||||
}
|
||||
return failed ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -222,106 +278,110 @@ check_result (const char *test_name,
|
||||
|
||||
/* Calculated MD5 as one pass for whole data */
|
||||
static int
|
||||
test1_str(void)
|
||||
test1_str (void)
|
||||
{
|
||||
unsigned int i;
|
||||
int num_failed = 0;
|
||||
for (i = 0; i < units1_num; i++)
|
||||
{
|
||||
struct MD5Context ctx;
|
||||
uint8_t digest[MD5_DIGEST_SIZE];
|
||||
|
||||
MHD_MD5Init (&ctx);
|
||||
MHD_MD5Update (&ctx, (const uint8_t*)data_units1[i].str_l.str, data_units1[i].str_l.len);
|
||||
MHD_MD5Final (&ctx, digest);
|
||||
num_failed += check_result (__FUNCTION__, i, digest,
|
||||
data_units1[i].digest);
|
||||
}
|
||||
for (i = 0; i < units1_num; i++)
|
||||
{
|
||||
struct MD5Context ctx;
|
||||
uint8_t digest[MD5_DIGEST_SIZE];
|
||||
|
||||
MHD_MD5Init (&ctx);
|
||||
MHD_MD5Update (&ctx, (const uint8_t*) data_units1[i].str_l.str,
|
||||
data_units1[i].str_l.len);
|
||||
MHD_MD5Final (&ctx, digest);
|
||||
num_failed += check_result (__FUNCTION__, i, digest,
|
||||
data_units1[i].digest);
|
||||
}
|
||||
return num_failed;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
test1_bin(void)
|
||||
test1_bin (void)
|
||||
{
|
||||
unsigned int i;
|
||||
int num_failed = 0;
|
||||
|
||||
for (i = 0; i < units2_num; i++)
|
||||
{
|
||||
struct MD5Context ctx;
|
||||
uint8_t digest[MD5_DIGEST_SIZE];
|
||||
|
||||
MHD_MD5Init (&ctx);
|
||||
MHD_MD5Update (&ctx, data_units2[i].bin_l.bin, data_units2[i].bin_l.len);
|
||||
MHD_MD5Final (&ctx, digest);
|
||||
num_failed += check_result (__FUNCTION__, i, digest,
|
||||
data_units2[i].digest);
|
||||
}
|
||||
for (i = 0; i < units2_num; i++)
|
||||
{
|
||||
struct MD5Context ctx;
|
||||
uint8_t digest[MD5_DIGEST_SIZE];
|
||||
|
||||
MHD_MD5Init (&ctx);
|
||||
MHD_MD5Update (&ctx, data_units2[i].bin_l.bin, data_units2[i].bin_l.len);
|
||||
MHD_MD5Final (&ctx, digest);
|
||||
num_failed += check_result (__FUNCTION__, i, digest,
|
||||
data_units2[i].digest);
|
||||
}
|
||||
return num_failed;
|
||||
}
|
||||
|
||||
|
||||
/* Calculated MD5 as two iterations for whole data */
|
||||
static int
|
||||
test2_str(void)
|
||||
test2_str (void)
|
||||
{
|
||||
unsigned int i;
|
||||
int num_failed = 0;
|
||||
|
||||
for (i = 0; i < units1_num; i++)
|
||||
{
|
||||
struct MD5Context ctx;
|
||||
uint8_t digest[MD5_DIGEST_SIZE];
|
||||
size_t part_s = data_units1[i].str_l.len / 4;
|
||||
{
|
||||
struct MD5Context ctx;
|
||||
uint8_t digest[MD5_DIGEST_SIZE];
|
||||
size_t part_s = data_units1[i].str_l.len / 4;
|
||||
|
||||
MHD_MD5Init (&ctx);
|
||||
MHD_MD5Update (&ctx, (const uint8_t*)data_units1[i].str_l.str, part_s);
|
||||
MHD_MD5Update (&ctx, (const uint8_t*)data_units1[i].str_l.str + part_s, data_units1[i].str_l.len - part_s);
|
||||
MHD_MD5Final (&ctx, digest);
|
||||
num_failed += check_result (__FUNCTION__, i, digest,
|
||||
data_units1[i].digest);
|
||||
}
|
||||
MHD_MD5Init (&ctx);
|
||||
MHD_MD5Update (&ctx, (const uint8_t*) data_units1[i].str_l.str, part_s);
|
||||
MHD_MD5Update (&ctx, (const uint8_t*) data_units1[i].str_l.str + part_s,
|
||||
data_units1[i].str_l.len - part_s);
|
||||
MHD_MD5Final (&ctx, digest);
|
||||
num_failed += check_result (__FUNCTION__, i, digest,
|
||||
data_units1[i].digest);
|
||||
}
|
||||
return num_failed;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
test2_bin(void)
|
||||
test2_bin (void)
|
||||
{
|
||||
unsigned int i;
|
||||
int num_failed = 0;
|
||||
|
||||
for (i = 0; i < units2_num; i++)
|
||||
{
|
||||
struct MD5Context ctx;
|
||||
uint8_t digest[MD5_DIGEST_SIZE];
|
||||
size_t part_s = data_units2[i].bin_l.len * 2 / 3;
|
||||
|
||||
MHD_MD5Init (&ctx);
|
||||
MHD_MD5Update (&ctx, data_units2[i].bin_l.bin, part_s);
|
||||
MHD_MD5Update (&ctx, data_units2[i].bin_l.bin + part_s, data_units2[i].bin_l.len - part_s);
|
||||
MHD_MD5Final (&ctx, digest);
|
||||
num_failed += check_result (__FUNCTION__, i, digest,
|
||||
data_units2[i].digest);
|
||||
}
|
||||
for (i = 0; i < units2_num; i++)
|
||||
{
|
||||
struct MD5Context ctx;
|
||||
uint8_t digest[MD5_DIGEST_SIZE];
|
||||
size_t part_s = data_units2[i].bin_l.len * 2 / 3;
|
||||
|
||||
MHD_MD5Init (&ctx);
|
||||
MHD_MD5Update (&ctx, data_units2[i].bin_l.bin, part_s);
|
||||
MHD_MD5Update (&ctx, data_units2[i].bin_l.bin + part_s,
|
||||
data_units2[i].bin_l.len - part_s);
|
||||
MHD_MD5Final (&ctx, digest);
|
||||
num_failed += check_result (__FUNCTION__, i, digest,
|
||||
data_units2[i].digest);
|
||||
}
|
||||
return num_failed;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char * argv[])
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int num_failed = 0;
|
||||
(void)has_in_name; /* Mute compiler warning. */
|
||||
if (has_param(argc, argv, "-v") || has_param(argc, argv, "--verbose"))
|
||||
(void) has_in_name; /* Mute compiler warning. */
|
||||
if (has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose"))
|
||||
verbose = 1;
|
||||
|
||||
num_failed += test1_str();
|
||||
num_failed += test1_bin();
|
||||
num_failed += test1_str ();
|
||||
num_failed += test1_bin ();
|
||||
|
||||
num_failed += test2_str();
|
||||
num_failed += test2_bin();
|
||||
num_failed += test2_str ();
|
||||
num_failed += test2_bin ();
|
||||
|
||||
return num_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
+323
-309
@@ -82,7 +82,7 @@ enum tls_tool use_tls_tool;
|
||||
*/
|
||||
static pid_t
|
||||
gnutlscli_connect (int *sock,
|
||||
uint16_t port)
|
||||
uint16_t port)
|
||||
{
|
||||
pid_t chld;
|
||||
int sp[2];
|
||||
@@ -95,11 +95,11 @@ gnutlscli_connect (int *sock,
|
||||
return -1;
|
||||
chld = fork ();
|
||||
if (0 != chld)
|
||||
{
|
||||
*sock = sp[1];
|
||||
MHD_socket_close_chk_ (sp[0]);
|
||||
return chld;
|
||||
}
|
||||
{
|
||||
*sock = sp[1];
|
||||
MHD_socket_close_chk_ (sp[0]);
|
||||
return chld;
|
||||
}
|
||||
MHD_socket_close_chk_ (sp[1]);
|
||||
(void) close (0);
|
||||
(void) close (1);
|
||||
@@ -109,34 +109,34 @@ gnutlscli_connect (int *sock,
|
||||
abort ();
|
||||
MHD_socket_close_chk_ (sp[0]);
|
||||
if (TLS_CLI_GNUTLS == use_tls_tool)
|
||||
{
|
||||
snprintf (destination,
|
||||
sizeof(destination),
|
||||
"%u",
|
||||
(unsigned int) port);
|
||||
execlp ("gnutls-cli",
|
||||
"gnutls-cli",
|
||||
"--insecure",
|
||||
"-p",
|
||||
destination,
|
||||
"127.0.0.1",
|
||||
(char *) NULL);
|
||||
}
|
||||
{
|
||||
snprintf (destination,
|
||||
sizeof(destination),
|
||||
"%u",
|
||||
(unsigned int) port);
|
||||
execlp ("gnutls-cli",
|
||||
"gnutls-cli",
|
||||
"--insecure",
|
||||
"-p",
|
||||
destination,
|
||||
"127.0.0.1",
|
||||
(char *) NULL);
|
||||
}
|
||||
else if (TLS_CLI_OPENSSL == use_tls_tool)
|
||||
{
|
||||
snprintf (destination,
|
||||
sizeof(destination),
|
||||
"127.0.0.1:%u",
|
||||
(unsigned int) port);
|
||||
execlp ("openssl",
|
||||
"openssl",
|
||||
"s_client",
|
||||
"-connect",
|
||||
destination,
|
||||
"-verify",
|
||||
"1",
|
||||
(char *) NULL);
|
||||
}
|
||||
{
|
||||
snprintf (destination,
|
||||
sizeof(destination),
|
||||
"127.0.0.1:%u",
|
||||
(unsigned int) port);
|
||||
execlp ("openssl",
|
||||
"openssl",
|
||||
"s_client",
|
||||
"-connect",
|
||||
destination,
|
||||
"-verify",
|
||||
"1",
|
||||
(char *) NULL);
|
||||
}
|
||||
_exit (1);
|
||||
}
|
||||
#endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */
|
||||
@@ -192,16 +192,16 @@ struct wr_socket
|
||||
* @return created socket on success, NULL otherwise
|
||||
*/
|
||||
static struct wr_socket *
|
||||
wr_create_plain_sckt(void)
|
||||
wr_create_plain_sckt (void)
|
||||
{
|
||||
struct wr_socket *s = malloc(sizeof(struct wr_socket));
|
||||
struct wr_socket *s = malloc (sizeof(struct wr_socket));
|
||||
if (NULL == s)
|
||||
return NULL;
|
||||
s->t = wr_plain;
|
||||
s->fd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (MHD_INVALID_SOCKET != s->fd)
|
||||
return s;
|
||||
free(s);
|
||||
free (s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -211,40 +211,44 @@ wr_create_plain_sckt(void)
|
||||
* @return created socket on success, NULL otherwise
|
||||
*/
|
||||
static struct wr_socket *
|
||||
wr_create_tls_sckt(void)
|
||||
wr_create_tls_sckt (void)
|
||||
{
|
||||
#ifdef HTTPS_SUPPORT
|
||||
struct wr_socket *s = malloc(sizeof(struct wr_socket));
|
||||
struct wr_socket *s = malloc (sizeof(struct wr_socket));
|
||||
if (NULL == s)
|
||||
return NULL;
|
||||
s->t = wr_tls;
|
||||
s->tls_connected = 0;
|
||||
s->fd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (MHD_INVALID_SOCKET != s->fd)
|
||||
{
|
||||
if (GNUTLS_E_SUCCESS == gnutls_init (&(s->tls_s), GNUTLS_CLIENT))
|
||||
{
|
||||
if (GNUTLS_E_SUCCESS == gnutls_init (&(s->tls_s), GNUTLS_CLIENT))
|
||||
if (GNUTLS_E_SUCCESS == gnutls_set_default_priority (s->tls_s))
|
||||
{
|
||||
if (GNUTLS_E_SUCCESS == gnutls_certificate_allocate_credentials (
|
||||
&(s->tls_crd)))
|
||||
{
|
||||
if (GNUTLS_E_SUCCESS == gnutls_set_default_priority (s->tls_s))
|
||||
{
|
||||
if (GNUTLS_E_SUCCESS == gnutls_certificate_allocate_credentials (&(s->tls_crd)))
|
||||
{
|
||||
if (GNUTLS_E_SUCCESS == gnutls_credentials_set (s->tls_s, GNUTLS_CRD_CERTIFICATE, s->tls_crd))
|
||||
{
|
||||
#if GNUTLS_VERSION_NUMBER+0 >= 0x030109
|
||||
gnutls_transport_set_int (s->tls_s, (int)(s->fd));
|
||||
if (GNUTLS_E_SUCCESS == gnutls_credentials_set (s->tls_s,
|
||||
GNUTLS_CRD_CERTIFICATE,
|
||||
s->tls_crd))
|
||||
{
|
||||
#if GNUTLS_VERSION_NUMBER + 0 >= 0x030109
|
||||
gnutls_transport_set_int (s->tls_s, (int) (s->fd));
|
||||
#else /* GnuTLS before 3.1.9 */
|
||||
gnutls_transport_set_ptr (s->tls_s, (gnutls_transport_ptr_t)(intptr_t)(s->fd));
|
||||
gnutls_transport_set_ptr (s->tls_s,
|
||||
(gnutls_transport_ptr_t) (intptr_t) (s->fd));
|
||||
#endif /* GnuTLS before 3.1.9 */
|
||||
return s;
|
||||
}
|
||||
gnutls_certificate_free_credentials (s->tls_crd);
|
||||
}
|
||||
}
|
||||
gnutls_deinit (s->tls_s);
|
||||
return s;
|
||||
}
|
||||
gnutls_certificate_free_credentials (s->tls_crd);
|
||||
}
|
||||
(void)MHD_socket_close_ (s->fd);
|
||||
}
|
||||
gnutls_deinit (s->tls_s);
|
||||
}
|
||||
free(s);
|
||||
(void) MHD_socket_close_ (s->fd);
|
||||
}
|
||||
free (s);
|
||||
#endif /* HTTPS_SUPPORT */
|
||||
return NULL;
|
||||
}
|
||||
@@ -257,9 +261,9 @@ wr_create_tls_sckt(void)
|
||||
* @return created socket on success, NULL otherwise
|
||||
*/
|
||||
static struct wr_socket *
|
||||
wr_create_from_plain_sckt(MHD_socket plain_sk)
|
||||
wr_create_from_plain_sckt (MHD_socket plain_sk)
|
||||
{
|
||||
struct wr_socket *s = malloc(sizeof(struct wr_socket));
|
||||
struct wr_socket *s = malloc (sizeof(struct wr_socket));
|
||||
|
||||
if (NULL == s)
|
||||
return NULL;
|
||||
@@ -277,9 +281,9 @@ wr_create_from_plain_sckt(MHD_socket plain_sk)
|
||||
* @return zero on success, -1 otherwise.
|
||||
*/
|
||||
static int
|
||||
wr_connect(struct wr_socket *s,
|
||||
const struct sockaddr *addr,
|
||||
int length)
|
||||
wr_connect (struct wr_socket *s,
|
||||
const struct sockaddr *addr,
|
||||
int length)
|
||||
{
|
||||
if (0 != connect (s->fd, addr, length))
|
||||
return -1;
|
||||
@@ -287,15 +291,15 @@ wr_connect(struct wr_socket *s,
|
||||
return 0;
|
||||
#ifdef HTTPS_SUPPORT
|
||||
if (wr_tls == s->t)
|
||||
{
|
||||
/* Do not try handshake here as
|
||||
* it require processing on MHD side and
|
||||
* when testing with "external" polling,
|
||||
* test will call MHD processing only
|
||||
* after return from wr_connect(). */
|
||||
s->tls_connected = 0;
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
/* Do not try handshake here as
|
||||
* it require processing on MHD side and
|
||||
* when testing with "external" polling,
|
||||
* test will call MHD processing only
|
||||
* after return from wr_connect(). */
|
||||
s->tls_connected = 0;
|
||||
return 0;
|
||||
}
|
||||
#endif /* HTTPS_SUPPORT */
|
||||
return -1;
|
||||
}
|
||||
@@ -303,7 +307,7 @@ wr_connect(struct wr_socket *s,
|
||||
#ifdef HTTPS_SUPPORT
|
||||
/* Only to be called from wr_send() and wr_recv() ! */
|
||||
static bool
|
||||
wr_handshake(struct wr_socket *s)
|
||||
wr_handshake (struct wr_socket *s)
|
||||
{
|
||||
int res = gnutls_handshake (s->tls_s);
|
||||
if (GNUTLS_E_SUCCESS == res)
|
||||
@@ -332,22 +336,22 @@ wr_send (struct wr_socket *s,
|
||||
size_t len)
|
||||
{
|
||||
if (wr_plain == s->t)
|
||||
return MHD_send_(s->fd, buf, len);
|
||||
return MHD_send_ (s->fd, buf, len);
|
||||
#ifdef HTTPS_SUPPORT
|
||||
if (wr_tls == s->t)
|
||||
{
|
||||
ssize_t ret;
|
||||
if (!s->tls_connected && !wr_handshake (s))
|
||||
return -1;
|
||||
{
|
||||
ssize_t ret;
|
||||
if (! s->tls_connected && ! wr_handshake (s))
|
||||
return -1;
|
||||
|
||||
ret = gnutls_record_send (s->tls_s, buf, len);
|
||||
if (ret > 0)
|
||||
return ret;
|
||||
if (GNUTLS_E_AGAIN == ret)
|
||||
MHD_socket_set_error_ (MHD_SCKT_EAGAIN_);
|
||||
else
|
||||
MHD_socket_set_error_ (MHD_SCKT_ECONNABORTED_); /* hard error */
|
||||
}
|
||||
ret = gnutls_record_send (s->tls_s, buf, len);
|
||||
if (ret > 0)
|
||||
return ret;
|
||||
if (GNUTLS_E_AGAIN == ret)
|
||||
MHD_socket_set_error_ (MHD_SCKT_EAGAIN_);
|
||||
else
|
||||
MHD_socket_set_error_ (MHD_SCKT_ECONNABORTED_); /* hard error */
|
||||
}
|
||||
#endif /* HTTPS_SUPPORT */
|
||||
return -1;
|
||||
}
|
||||
@@ -371,19 +375,19 @@ wr_recv (struct wr_socket *s,
|
||||
return MHD_recv_ (s->fd, buf, len);
|
||||
#ifdef HTTPS_SUPPORT
|
||||
if (wr_tls == s->t)
|
||||
{
|
||||
ssize_t ret;
|
||||
if (!s->tls_connected && !wr_handshake (s))
|
||||
return -1;
|
||||
{
|
||||
ssize_t ret;
|
||||
if (! s->tls_connected && ! wr_handshake (s))
|
||||
return -1;
|
||||
|
||||
ret = gnutls_record_recv (s->tls_s, buf, len);
|
||||
if (ret > 0)
|
||||
return ret;
|
||||
if (GNUTLS_E_AGAIN == ret)
|
||||
MHD_socket_set_error_ (MHD_SCKT_EAGAIN_);
|
||||
else
|
||||
MHD_socket_set_error_ (MHD_SCKT_ECONNABORTED_); /* hard error */
|
||||
}
|
||||
ret = gnutls_record_recv (s->tls_s, buf, len);
|
||||
if (ret > 0)
|
||||
return ret;
|
||||
if (GNUTLS_E_AGAIN == ret)
|
||||
MHD_socket_set_error_ (MHD_SCKT_EAGAIN_);
|
||||
else
|
||||
MHD_socket_set_error_ (MHD_SCKT_ECONNABORTED_); /* hard error */
|
||||
}
|
||||
#endif /* HTTPS_SUPPORT */
|
||||
return -1;
|
||||
}
|
||||
@@ -397,13 +401,13 @@ wr_recv (struct wr_socket *s,
|
||||
static int
|
||||
wr_close (struct wr_socket *s)
|
||||
{
|
||||
int ret = (MHD_socket_close_(s->fd)) ? 0 : -1;
|
||||
int ret = (MHD_socket_close_ (s->fd)) ? 0 : -1;
|
||||
#ifdef HTTPS_SUPPORT
|
||||
if (wr_tls == s->t)
|
||||
{
|
||||
gnutls_deinit (s->tls_s);
|
||||
gnutls_certificate_free_credentials (s->tls_crd);
|
||||
}
|
||||
{
|
||||
gnutls_deinit (s->tls_s);
|
||||
gnutls_certificate_free_credentials (s->tls_crd);
|
||||
}
|
||||
#endif /* HTTPS_SUPPORT */
|
||||
free (s);
|
||||
return ret;
|
||||
@@ -447,7 +451,7 @@ notify_completed_cb (void *cls,
|
||||
void **con_cls,
|
||||
enum MHD_RequestTerminationCode toe)
|
||||
{
|
||||
pthread_t* ppth = *con_cls;
|
||||
pthread_t*ppth = *con_cls;
|
||||
|
||||
(void) cls;
|
||||
(void) connection; /* Unused. Silent compiler warning. */
|
||||
@@ -455,7 +459,7 @@ notify_completed_cb (void *cls,
|
||||
(toe != MHD_REQUEST_TERMINATED_CLIENT_ABORT) &&
|
||||
(toe != MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN) )
|
||||
abort ();
|
||||
if (! pthread_equal (**((pthread_t**)con_cls),
|
||||
if (! pthread_equal (**((pthread_t**) con_cls),
|
||||
pthread_self ()))
|
||||
abort ();
|
||||
if (NULL != ppth)
|
||||
@@ -486,7 +490,7 @@ log_cb (void *cls,
|
||||
abort ();
|
||||
ppth = malloc (sizeof (pthread_t));
|
||||
if (NULL == ppth)
|
||||
abort();
|
||||
abort ();
|
||||
*ppth = pthread_self ();
|
||||
return (void *) ppth;
|
||||
}
|
||||
@@ -578,20 +582,20 @@ send_all (struct wr_socket *sock,
|
||||
|
||||
make_blocking (wr_fd (sock));
|
||||
for (off = 0; off < len; off += ret)
|
||||
{
|
||||
ret = wr_send (sock,
|
||||
&text[off],
|
||||
len - off);
|
||||
if (0 > ret)
|
||||
{
|
||||
ret = wr_send (sock,
|
||||
&text[off],
|
||||
len - off);
|
||||
if (0 > ret)
|
||||
{
|
||||
if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()))
|
||||
{
|
||||
ret = 0;
|
||||
continue;
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()))
|
||||
{
|
||||
ret = 0;
|
||||
continue;
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -611,36 +615,36 @@ recv_hdr (struct wr_socket *sock)
|
||||
next = '\r';
|
||||
i = 0;
|
||||
while (i < 4)
|
||||
{
|
||||
ret = wr_recv (sock,
|
||||
&c,
|
||||
1);
|
||||
if (0 > ret)
|
||||
{
|
||||
ret = wr_recv (sock,
|
||||
&c,
|
||||
1);
|
||||
if (0 > ret)
|
||||
{
|
||||
if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()))
|
||||
continue;
|
||||
abort ();
|
||||
}
|
||||
if (0 == ret)
|
||||
if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()))
|
||||
continue;
|
||||
if (c == next)
|
||||
{
|
||||
i++;
|
||||
if (next == '\r')
|
||||
next = '\n';
|
||||
else
|
||||
next = '\r';
|
||||
continue;
|
||||
}
|
||||
if (c == '\r')
|
||||
{
|
||||
i = 1;
|
||||
next = '\n';
|
||||
continue;
|
||||
}
|
||||
i = 0;
|
||||
next = '\r';
|
||||
abort ();
|
||||
}
|
||||
if (0 == ret)
|
||||
continue;
|
||||
if (c == next)
|
||||
{
|
||||
i++;
|
||||
if (next == '\r')
|
||||
next = '\n';
|
||||
else
|
||||
next = '\r';
|
||||
continue;
|
||||
}
|
||||
if (c == '\r')
|
||||
{
|
||||
i = 1;
|
||||
next = '\n';
|
||||
continue;
|
||||
}
|
||||
i = 0;
|
||||
next = '\r';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -655,22 +659,22 @@ recv_all (struct wr_socket *sock,
|
||||
|
||||
make_blocking (wr_fd (sock));
|
||||
for (off = 0; off < len; off += ret)
|
||||
{
|
||||
ret = wr_recv (sock,
|
||||
&buf[off],
|
||||
len - off);
|
||||
if (0 > ret)
|
||||
{
|
||||
ret = wr_recv (sock,
|
||||
&buf[off],
|
||||
len - off);
|
||||
if (0 > ret)
|
||||
{
|
||||
if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()))
|
||||
{
|
||||
ret = 0;
|
||||
continue;
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()))
|
||||
{
|
||||
ret = 0;
|
||||
continue;
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
if (0 != strncmp (text, buf, len))
|
||||
abort();
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
@@ -856,7 +860,7 @@ ahc_upgrade (void *cls,
|
||||
|
||||
if (NULL == *con_cls)
|
||||
abort ();
|
||||
if (! pthread_equal (**((pthread_t**)con_cls), pthread_self ()))
|
||||
if (! pthread_equal (**((pthread_t**) con_cls), pthread_self ()))
|
||||
abort ();
|
||||
resp = MHD_create_response_for_upgrade (&upgrade_cb,
|
||||
NULL);
|
||||
@@ -887,37 +891,37 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
|
||||
struct timeval tv;
|
||||
|
||||
while (! done)
|
||||
{
|
||||
FD_ZERO (&rs);
|
||||
FD_ZERO (&ws);
|
||||
FD_ZERO (&es);
|
||||
max_fd = -1;
|
||||
to = 1000;
|
||||
{
|
||||
FD_ZERO (&rs);
|
||||
FD_ZERO (&ws);
|
||||
FD_ZERO (&es);
|
||||
max_fd = -1;
|
||||
to = 1000;
|
||||
|
||||
if (MHD_YES !=
|
||||
MHD_get_fdset (daemon,
|
||||
if (MHD_YES !=
|
||||
MHD_get_fdset (daemon,
|
||||
&rs,
|
||||
&ws,
|
||||
&es,
|
||||
&max_fd))
|
||||
abort ();
|
||||
(void) MHD_get_timeout (daemon,
|
||||
&to);
|
||||
if (1000 < to)
|
||||
to = 1000;
|
||||
tv.tv_sec = to / 1000;
|
||||
tv.tv_usec = 1000 * (to % 1000);
|
||||
if (0 > MHD_SYS_select_ (max_fd + 1,
|
||||
&rs,
|
||||
&ws,
|
||||
&es,
|
||||
&tv))
|
||||
abort ();
|
||||
MHD_run_from_select (daemon,
|
||||
&rs,
|
||||
&ws,
|
||||
&es,
|
||||
&max_fd))
|
||||
abort ();
|
||||
(void) MHD_get_timeout (daemon,
|
||||
&to);
|
||||
if (1000 < to)
|
||||
to = 1000;
|
||||
tv.tv_sec = to / 1000;
|
||||
tv.tv_usec = 1000 * (to % 1000);
|
||||
if (0 > MHD_SYS_select_ (max_fd + 1,
|
||||
&rs,
|
||||
&ws,
|
||||
&es,
|
||||
&tv))
|
||||
abort ();
|
||||
MHD_run_from_select (daemon,
|
||||
&rs,
|
||||
&ws,
|
||||
&es);
|
||||
}
|
||||
&es);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_POLL
|
||||
@@ -930,7 +934,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
|
||||
static void
|
||||
run_mhd_poll_loop (struct MHD_Daemon *daemon)
|
||||
{
|
||||
(void)daemon; /* Unused. Silent compiler warning. */
|
||||
(void) daemon; /* Unused. Silent compiler warning. */
|
||||
abort (); /* currently not implementable with existing MHD API */
|
||||
}
|
||||
#endif /* HAVE_POLL */
|
||||
@@ -956,28 +960,28 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
|
||||
MHD_DAEMON_INFO_EPOLL_FD);
|
||||
ep = di->listen_fd;
|
||||
while (! done)
|
||||
{
|
||||
FD_ZERO (&rs);
|
||||
to = 1000;
|
||||
{
|
||||
FD_ZERO (&rs);
|
||||
to = 1000;
|
||||
|
||||
FD_SET (ep, &rs);
|
||||
(void) MHD_get_timeout (daemon,
|
||||
&to);
|
||||
if (1000 < to)
|
||||
to = 1000;
|
||||
tv.tv_sec = to / 1000;
|
||||
tv.tv_usec = 1000 * (to % 1000);
|
||||
ret = select (ep + 1,
|
||||
&rs,
|
||||
NULL,
|
||||
NULL,
|
||||
&tv);
|
||||
if ( (-1 == ret) &&
|
||||
(EAGAIN != errno) &&
|
||||
(EINTR != errno) )
|
||||
abort ();
|
||||
MHD_run (daemon);
|
||||
}
|
||||
FD_SET (ep, &rs);
|
||||
(void) MHD_get_timeout (daemon,
|
||||
&to);
|
||||
if (1000 < to)
|
||||
to = 1000;
|
||||
tv.tv_sec = to / 1000;
|
||||
tv.tv_usec = 1000 * (to % 1000);
|
||||
ret = select (ep + 1,
|
||||
&rs,
|
||||
NULL,
|
||||
NULL,
|
||||
&tv);
|
||||
if ( (-1 == ret) &&
|
||||
(EAGAIN != errno) &&
|
||||
(EINTR != errno) )
|
||||
abort ();
|
||||
MHD_run (daemon);
|
||||
}
|
||||
}
|
||||
#endif /* EPOLL_SUPPORT */
|
||||
|
||||
@@ -1030,25 +1034,32 @@ test_upgrade (int flags,
|
||||
|
||||
if (! test_tls)
|
||||
d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE,
|
||||
MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT) ?
|
||||
0 : 1090,
|
||||
NULL, NULL,
|
||||
&ahc_upgrade, NULL,
|
||||
MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
|
||||
MHD_OPTION_NOTIFY_COMPLETED, ¬ify_completed_cb, NULL,
|
||||
MHD_OPTION_NOTIFY_CONNECTION, ¬ify_connection_cb, NULL,
|
||||
MHD_OPTION_THREAD_POOL_SIZE, pool,
|
||||
MHD_OPTION_END);
|
||||
#ifdef HTTPS_SUPPORT
|
||||
else
|
||||
d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE | MHD_USE_TLS,
|
||||
MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT) ?
|
||||
0 : 1090,
|
||||
MHD_is_feature_supported (
|
||||
MHD_FEATURE_AUTODETECT_BIND_PORT) ?
|
||||
0 : 1090,
|
||||
NULL, NULL,
|
||||
&ahc_upgrade, NULL,
|
||||
MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
|
||||
MHD_OPTION_NOTIFY_COMPLETED, ¬ify_completed_cb, NULL,
|
||||
MHD_OPTION_NOTIFY_CONNECTION, ¬ify_connection_cb, NULL,
|
||||
MHD_OPTION_NOTIFY_COMPLETED, ¬ify_completed_cb,
|
||||
NULL,
|
||||
MHD_OPTION_NOTIFY_CONNECTION, ¬ify_connection_cb,
|
||||
NULL,
|
||||
MHD_OPTION_THREAD_POOL_SIZE, pool,
|
||||
MHD_OPTION_END);
|
||||
#ifdef HTTPS_SUPPORT
|
||||
else
|
||||
d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE
|
||||
| MHD_USE_TLS,
|
||||
MHD_is_feature_supported (
|
||||
MHD_FEATURE_AUTODETECT_BIND_PORT) ?
|
||||
0 : 1090,
|
||||
NULL, NULL,
|
||||
&ahc_upgrade, NULL,
|
||||
MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
|
||||
MHD_OPTION_NOTIFY_COMPLETED, ¬ify_completed_cb,
|
||||
NULL,
|
||||
MHD_OPTION_NOTIFY_CONNECTION, ¬ify_connection_cb,
|
||||
NULL,
|
||||
MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem,
|
||||
MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem,
|
||||
MHD_OPTION_THREAD_POOL_SIZE, pool,
|
||||
@@ -1065,65 +1076,65 @@ test_upgrade (int flags,
|
||||
if ( (NULL == dinfo) ||
|
||||
(0 == dinfo->port) )
|
||||
abort ();
|
||||
if (!test_tls || TLS_LIB_GNUTLS == use_tls_tool)
|
||||
{
|
||||
sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt ();
|
||||
if (NULL == sock)
|
||||
abort ();
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons (dinfo->port);
|
||||
sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
|
||||
if (0 != wr_connect (sock,
|
||||
(struct sockaddr *) &sa,
|
||||
sizeof (sa)))
|
||||
abort ();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID)
|
||||
MHD_socket tls_fork_sock;
|
||||
uint16_t port;
|
||||
|
||||
/* make address sanitizer happy */
|
||||
memcpy (&port,
|
||||
dinfo /* ->port */,
|
||||
sizeof (port));
|
||||
if (-1 == (pid = gnutlscli_connect (&tls_fork_sock,
|
||||
port)))
|
||||
{
|
||||
MHD_stop_daemon (d);
|
||||
return 4;
|
||||
}
|
||||
|
||||
sock = wr_create_from_plain_sckt (tls_fork_sock);
|
||||
if (NULL == sock)
|
||||
abort ();
|
||||
#else /* !HTTPS_SUPPORT || !HAVE_FORK || !HAVE_WAITPID */
|
||||
if (! test_tls ||(TLS_LIB_GNUTLS == use_tls_tool))
|
||||
{
|
||||
sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt ();
|
||||
if (NULL == sock)
|
||||
abort ();
|
||||
#endif /* !HTTPS_SUPPORT || !HAVE_FORK || !HAVE_WAITPID */
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons (dinfo->port);
|
||||
sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
|
||||
if (0 != wr_connect (sock,
|
||||
(struct sockaddr *) &sa,
|
||||
sizeof (sa)))
|
||||
abort ();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID)
|
||||
MHD_socket tls_fork_sock;
|
||||
uint16_t port;
|
||||
|
||||
/* make address sanitizer happy */
|
||||
memcpy (&port,
|
||||
dinfo /* ->port */,
|
||||
sizeof (port));
|
||||
if (-1 == (pid = gnutlscli_connect (&tls_fork_sock,
|
||||
port)))
|
||||
{
|
||||
MHD_stop_daemon (d);
|
||||
return 4;
|
||||
}
|
||||
|
||||
sock = wr_create_from_plain_sckt (tls_fork_sock);
|
||||
if (NULL == sock)
|
||||
abort ();
|
||||
#else /* !HTTPS_SUPPORT || !HAVE_FORK || !HAVE_WAITPID */
|
||||
abort ();
|
||||
#endif /* !HTTPS_SUPPORT || !HAVE_FORK || !HAVE_WAITPID */
|
||||
}
|
||||
|
||||
if (0 != pthread_create (&pt_client,
|
||||
NULL,
|
||||
&run_usock_client,
|
||||
sock))
|
||||
abort ();
|
||||
if (0 == (flags & MHD_USE_INTERNAL_POLLING_THREAD) )
|
||||
{
|
||||
enum MHD_FLAG flags;
|
||||
{
|
||||
enum MHD_FLAG flags;
|
||||
|
||||
/* make address sanitizer happy */
|
||||
memcpy (&flags,
|
||||
real_flags /* ->flags */,
|
||||
sizeof (flags));
|
||||
run_mhd_loop (d, flags);
|
||||
}
|
||||
/* make address sanitizer happy */
|
||||
memcpy (&flags,
|
||||
real_flags /* ->flags */,
|
||||
sizeof (flags));
|
||||
run_mhd_loop (d, flags);
|
||||
}
|
||||
pthread_join (pt_client,
|
||||
NULL);
|
||||
pthread_join (pt,
|
||||
NULL);
|
||||
#if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID)
|
||||
if (test_tls && TLS_LIB_GNUTLS != use_tls_tool)
|
||||
if (test_tls &&(TLS_LIB_GNUTLS != use_tls_tool))
|
||||
waitpid (pid, NULL, 0);
|
||||
#endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */
|
||||
MHD_stop_daemon (d);
|
||||
@@ -1139,56 +1150,56 @@ main (int argc,
|
||||
int res;
|
||||
|
||||
use_tls_tool = TLS_CLI_NO_TOOL;
|
||||
test_tls = has_in_name(argv[0], "_tls");
|
||||
test_tls = has_in_name (argv[0], "_tls");
|
||||
|
||||
verbose = 1;
|
||||
if (has_param(argc, argv, "-q") ||
|
||||
has_param(argc, argv, "--quiet"))
|
||||
if (has_param (argc, argv, "-q") ||
|
||||
has_param (argc, argv, "--quiet"))
|
||||
verbose = 0;
|
||||
|
||||
if (test_tls)
|
||||
{
|
||||
{
|
||||
#ifdef HTTPS_SUPPORT
|
||||
if (has_param(argc, argv, "--use-gnutls-cli"))
|
||||
use_tls_tool = TLS_CLI_GNUTLS;
|
||||
else if (has_param(argc, argv, "--use-openssl"))
|
||||
use_tls_tool = TLS_CLI_OPENSSL;
|
||||
else if (has_param(argc, argv, "--use-gnutls-lib"))
|
||||
use_tls_tool = TLS_LIB_GNUTLS;
|
||||
if (has_param (argc, argv, "--use-gnutls-cli"))
|
||||
use_tls_tool = TLS_CLI_GNUTLS;
|
||||
else if (has_param (argc, argv, "--use-openssl"))
|
||||
use_tls_tool = TLS_CLI_OPENSSL;
|
||||
else if (has_param (argc, argv, "--use-gnutls-lib"))
|
||||
use_tls_tool = TLS_LIB_GNUTLS;
|
||||
#if defined(HAVE_FORK) && defined(HAVE_WAITPID)
|
||||
else if (0 == system ("gnutls-cli --version 1> /dev/null 2> /dev/null"))
|
||||
use_tls_tool = TLS_CLI_GNUTLS;
|
||||
else if (0 == system ("openssl version 1> /dev/null 2> /dev/null"))
|
||||
use_tls_tool = TLS_CLI_OPENSSL;
|
||||
else if (0 == system ("gnutls-cli --version 1> /dev/null 2> /dev/null"))
|
||||
use_tls_tool = TLS_CLI_GNUTLS;
|
||||
else if (0 == system ("openssl version 1> /dev/null 2> /dev/null"))
|
||||
use_tls_tool = TLS_CLI_OPENSSL;
|
||||
#endif /* HAVE_FORK && HAVE_WAITPID */
|
||||
else
|
||||
use_tls_tool = TLS_LIB_GNUTLS; /* Should be available as MHD use it. */
|
||||
if (verbose)
|
||||
{
|
||||
switch (use_tls_tool)
|
||||
{
|
||||
case TLS_CLI_GNUTLS:
|
||||
printf ("GnuTLS-CLI will be used for testing.\n");
|
||||
break;
|
||||
case TLS_CLI_OPENSSL:
|
||||
printf ("Command line version of OpenSSL will be used for testing.\n");
|
||||
break;
|
||||
case TLS_LIB_GNUTLS:
|
||||
printf ("GnuTLS library will be used for testing.\n");
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
if ( (TLS_LIB_GNUTLS == use_tls_tool) &&
|
||||
(GNUTLS_E_SUCCESS != gnutls_global_init()) )
|
||||
else
|
||||
use_tls_tool = TLS_LIB_GNUTLS; /* Should be available as MHD use it. */
|
||||
if (verbose)
|
||||
{
|
||||
switch (use_tls_tool)
|
||||
{
|
||||
case TLS_CLI_GNUTLS:
|
||||
printf ("GnuTLS-CLI will be used for testing.\n");
|
||||
break;
|
||||
case TLS_CLI_OPENSSL:
|
||||
printf ("Command line version of OpenSSL will be used for testing.\n");
|
||||
break;
|
||||
case TLS_LIB_GNUTLS:
|
||||
printf ("GnuTLS library will be used for testing.\n");
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
if ( (TLS_LIB_GNUTLS == use_tls_tool) &&
|
||||
(GNUTLS_E_SUCCESS != gnutls_global_init ()) )
|
||||
abort ();
|
||||
|
||||
#else /* ! HTTPS_SUPPORT */
|
||||
fprintf (stderr, "HTTPS support was disabled by configure.\n");
|
||||
return 77;
|
||||
fprintf (stderr, "HTTPS support was disabled by configure.\n");
|
||||
return 77;
|
||||
#endif /* ! HTTPS_SUPPORT */
|
||||
}
|
||||
}
|
||||
|
||||
/* run tests */
|
||||
if (verbose)
|
||||
@@ -1229,7 +1240,8 @@ main (int argc,
|
||||
#endif
|
||||
|
||||
/* Test thread-per-connection */
|
||||
res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION,
|
||||
res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD
|
||||
| MHD_USE_THREAD_PER_CONNECTION,
|
||||
0);
|
||||
error_count += res;
|
||||
if (res)
|
||||
@@ -1239,7 +1251,8 @@ main (int argc,
|
||||
else if (verbose)
|
||||
printf ("PASSED: Upgrade with thread per connection.\n");
|
||||
|
||||
res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION,
|
||||
res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD
|
||||
| MHD_USE_THREAD_PER_CONNECTION,
|
||||
0);
|
||||
error_count += res;
|
||||
if (res)
|
||||
@@ -1249,7 +1262,8 @@ main (int argc,
|
||||
else if (verbose)
|
||||
printf ("PASSED: Upgrade with thread per connection and 'auto'.\n");
|
||||
#ifdef HAVE_POLL
|
||||
res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL,
|
||||
res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD
|
||||
| MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL,
|
||||
0);
|
||||
error_count += res;
|
||||
if (res)
|
||||
@@ -1341,7 +1355,7 @@ main (int argc,
|
||||
error_count);
|
||||
#ifdef HTTPS_SUPPORT
|
||||
if (test_tls && (TLS_LIB_GNUTLS == use_tls_tool))
|
||||
gnutls_global_deinit();
|
||||
gnutls_global_deinit ();
|
||||
#endif /* HTTPS_SUPPORT */
|
||||
return error_count != 0; /* 0 == pass */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user