comparison kk-data-provider.c @ 181:c96f5f64c946

Armonize configuration file path construction in KK data provider
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Fri, 21 Feb 2014 18:42:29 +0100
parents 5b4b7f37bd3b
children bc980095a24d
comparison
equal deleted inserted replaced
180:8faada7e4faf 181:c96f5f64c946
4 #include <userint.h> 4 #include <userint.h>
5 #include <formatio.h> 5 #include <formatio.h>
6 #include <utility.h> 6 #include <utility.h>
7 #include <inifile.h> 7 #include <inifile.h>
8 8
9 #include "config.h"
9 #include "data-provider.h" 10 #include "data-provider.h"
10 #include "KKFX80E.h" 11 #include "KKFX80E.h"
11 12
12 #define CONFIGFILE "FXAnalyse.ini"
13 #define DEFAULT_PORT "COM4:115200" 13 #define DEFAULT_PORT "COM4:115200"
14 #define DEFAULT_NCHAN 4 14 #define DEFAULT_NCHAN 4
15 #define TIMEOUT 1 /* seconds */ 15 #define TIMEOUT 1 /* seconds */
16 16
17 #define strneq(a, b, len) (strncmp((a), (b), (len)) == 0) 17 #define strneq(a, b, len) (strncmp((a), (b), (len)) == 0)
26 char port[256]; 26 char port[256];
27 27
28 /* get main thread id to post messages to it */ 28 /* get main thread id to post messages to it */
29 mainThreadId = CmtGetMainThreadID(); 29 mainThreadId = CmtGetMainThreadID();
30 30
31 /* construct configuration file path */ 31 /* configuration file path */
32 char pathname[MAX_PATHNAME_LEN]; 32 char path[MAX_PATHNAME_LEN];
33 char project[MAX_PATHNAME_LEN]; 33 GetIniFilePath(path);
34 GetProjectDir(project);
35 MakePathname(project, CONFIGFILE, pathname);
36 34
37 /* load configuration file */ 35 /* load configuration file */
38 IniText configuration = Ini_New(TRUE); 36 IniText configuration = Ini_New(TRUE);
39 Ini_ReadFromFile(configuration, pathname); 37 Ini_ReadFromFile(configuration, path);
40 38
41 /* get serial port name configuration */ 39 /* get serial port name configuration */
42 rv = Ini_GetStringIntoBuffer(configuration, "KK", "port", port, sizeof(port)); 40 rv = Ini_GetStringIntoBuffer(configuration, "KK", "port", port, sizeof(port));
43 if (! rv) 41 if (! rv)
44 strncpy(port, DEFAULT_PORT, sizeof(port)); 42 strncpy(port, DEFAULT_PORT, sizeof(port));
45 43
46 /* channels number */ 44 /* channel number */
47 rv = Ini_GetInt(configuration, "KK", "nchan", &nchan); 45 rv = Ini_GetInt(configuration, "KK", "nchan", &nchan);
48 if (! rv) 46 if (! rv)
49 nchan = DEFAULT_NCHAN; 47 nchan = DEFAULT_NCHAN;
50 48
51 /* free */ 49 /* free */