1 /**
2  * Copyright 2006 Christian Liesch
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /**
18  * @file
19  *
20  * @Author christian liesch <liesch@gmx.ch>
21  *
22  * Interface of the HTTP Test Tool util.
23  */
24 
25 #ifndef HTTEST_UTIL_H
26 #define HTTEST_UTIL_H
27 
28 #include "store.h"
29 
30 #define swap16(x) \
31   ((((x) & 0x00ffU) << 8)| \
32    (((x) & 0xff00U) >> 8))
33 
34 #define swap32(x) \
35   ((((x) & 0x000000ffUL) << 24)| \
36    (((x) & 0x0000ff00UL) <<  8)| \
37    (((x) & 0x00ff0000UL) >>  8)| \
38    (((x) & 0xff000000UL) >> 24))
39 
40 #define swap64(x) \
41   ((((x) & 0xff00000000000000ULL) >> 56)| \
42    (((x) & 0x00ff000000000000ULL) >> 40)| \
43    (((x) & 0x0000ff0000000000ULL) >> 24)| \
44    (((x) & 0x000000ff00000000ULL) >>  8)| \
45    (((x) & 0x00000000ff000000ULL) <<  8)| \
46    (((x) & 0x0000000000ff0000ULL) << 24)| \
47    (((x) & 0x000000000000ff00ULL) << 40)| \
48    (((x) & 0x00000000000000ffULL) << 56))
49 
50 #if APR_IS_BIGENDIAN
51 # define ntlm_hton16(x) swap16(x)
52 # define ntlm_hton32(x) swap32(x)
53 # define ntlm_hton64(x) swap64(x)
54 # define ntlm_ntoh16(x) swap16(x)
55 # define ntlm_ntoh32(x) swap32(x)
56 # define ntlm_ntoh64(x) swap64(x)
57 #else
58 # define ntlm_hton16(x) (x)
59 # define ntlm_hton32(x) (x)
60 # define ntlm_hton64(x) (x)
61 # define ntlm_ntoh16(x) (x)
62 # define ntlm_ntoh32(x) (x)
63 # define ntlm_ntoh64(x) (x)
64 #endif
65 
66 char *my_unescape(char *string, char **last);
67 apr_table_t *my_table_deep_copy(apr_pool_t *p, apr_table_t *orig);
68 apr_table_t *my_table_swallow_copy(apr_pool_t *p, apr_table_t *orig);
69 char *my_status_str(apr_pool_t * p, apr_status_t rc);
70 void copyright(const char *progname);
71 const char *filename(apr_pool_t *pool, const char *path);
72 char x2c(const char *what);
73 void my_get_args(char *line, store_t *params, apr_pool_t *pool);
74 apr_status_t my_tokenize_to_argv(const char *arg_str, char ***argv_out,
75                                  apr_pool_t *pool, int with_quotes);
76 #endif
77