comparison config.c @ 741:80a67be1770b

Initial work on Windows port
author Michael Pavone <pavone@retrodev.com>
date Tue, 01 Apr 2014 19:43:58 -0700
parents 6fc71114d145
children 2e1b3b258523
comparison
equal deleted inserted replaced
589:2dde38c1744f 741:80a67be1770b
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
11 11
12 #define MAX_NEST 30 //way more than I'll ever need 12 #define MAX_NEST 30 //way more than I'll ever need
13
14 #ifdef _WIN32
15 char * strtok_r(char * input, char * sep, char ** state)
16 {
17 if (input) {
18 *state = input;
19 }
20 char * ret = *state;
21 while (**state && **state != *sep)
22 {
23 ++*state;
24 }
25 if (**state)
26 {
27 **state = 0;
28 ++*state;
29 return ret;
30 }
31 return NULL;
32 }
33 #endif
13 34
14 tern_node * parse_config(char * config_data) 35 tern_node * parse_config(char * config_data)
15 { 36 {
16 char *state, *curline; 37 char *state, *curline;
17 char *prefix = NULL; 38 char *prefix = NULL;
98 return ret; 119 return ret;
99 } 120 }
100 121
101 tern_node * load_config() 122 tern_node * load_config()
102 { 123 {
124 #ifdef _WIN32
125 tern_node * ret = parse_config_file("default.cfg");
126 #else
103 char * exe_dir; 127 char * exe_dir;
104 char * home = getenv("HOME"); 128 char * home = getenv("HOME");
105 if (!home) { 129 if (!home) {
106 goto load_in_app_dir; 130 goto load_in_app_dir;
107 } 131 }
117 goto no_config; 141 goto no_config;
118 } 142 }
119 path = alloc_concat(exe_dir, "/default.cfg"); 143 path = alloc_concat(exe_dir, "/default.cfg");
120 ret = parse_config_file(path); 144 ret = parse_config_file(path);
121 free(path); 145 free(path);
146 #endif
122 success: 147 success:
123 if (ret) { 148 if (ret) {
124 return ret; 149 return ret;
125 } 150 }
126 no_config: 151 no_config: