summaryrefslogtreecommitdiff
path: root/toxrtp/tests/test_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxrtp/tests/test_helper.c')
-rw-r--r--toxrtp/tests/test_helper.c83
1 files changed, 0 insertions, 83 deletions
diff --git a/toxrtp/tests/test_helper.c b/toxrtp/tests/test_helper.c
deleted file mode 100644
index 526b6b38..00000000
--- a/toxrtp/tests/test_helper.c
+++ /dev/null
@@ -1,83 +0,0 @@
1/* test_helper.c
2 *
3 * Tests support. !Red!
4 *
5 *
6 * Copyright (C) 2013 Tox project All Rights Reserved.
7 *
8 * This file is part of Tox.
9 *
10 * Tox is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * Tox is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25#include "test_helper.h"
26
27#include <string.h>
28#include <stdlib.h>
29
30arg_t* parse_args ( int argc, char* argv[] )
31{
32 arg_t* _list = calloc(sizeof(arg_t), 1);
33 _list->next = _list->prev = NULL;
34
35 arg_t* it = _list;
36
37 size_t val;
38 for ( val = 0; val < argc; val ++ ) {
39 it->value = argv[val];
40
41 if ( val < argc - 1 ) { /* just about to end */
42 it->next = calloc(sizeof(arg_t), 1);
43 it->next->prev = it;
44 it = it->next;
45 it->next = NULL;
46 }
47 }
48
49 return _list;
50}
51
52int find_arg_simple ( arg_t* _head, const char* _id )
53{
54 arg_t* it = _head;
55
56 int i;
57 for ( i = 1; it != NULL; it = it->next ) {
58 if ( strcmp ( _id, it->value ) == 0 ) {
59 return i;
60 }
61
62 i++;
63 }
64
65 return FAILURE;
66}
67
68const char* find_arg_duble ( arg_t* _head, const char* _id )
69{
70 arg_t* _it;
71 for ( _it = _head; _it != NULL; _it = _it->next ) {
72 if ( strcmp ( _id, _it->value ) == 0 ) {
73 if ( _it->next && _it->next->value[0] != '-' ) { /* exclude option */
74 return _it->next->value;
75 } else {
76 return NULL;
77 }
78 }
79 }
80
81 return NULL;
82}
83