summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2015-12-19 17:07:21 +0200
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2015-12-19 17:09:23 +0200
commit7ec33cc6bb971d1bf6789fcd656f7db9d2880fc4 (patch)
treee6a544f5656e44f31019b8ac05b58b808d877853
parent8d5ced3a60a9da551c1cc05dd856b3b507c2de53 (diff)
Import profile load from Clouseau
-rw-r--r--src/bin/edbg_checker.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/bin/edbg_checker.c b/src/bin/edbg_checker.c
new file mode 100644
index 0000000..a07fa04
--- /dev/null
+++ b/src/bin/edbg_checker.c
@@ -0,0 +1,79 @@
1#include <Eina.h>
2#include <Eet.h>
3
4#define _PROFILE_EET_ENTRY "config"
5
6typedef enum
7{
8 CLOUSEAU_PROFILE_LOCAL = 1,
9 CLOUSEAU_PROFILE_SHELL_REMOTE
10} Clouseau_Profile_Type;
11
12typedef struct
13{
14 const char *name;
15 const char *command;
16 const char *script;
17 Clouseau_Profile_Type type;
18} Clouseau_Profile;
19
20static Eet_Data_Descriptor *_profile_edd = NULL;
21
22static void
23_profile_eet_load()
24{
25 if (_profile_edd) return;
26 Eet_Data_Descriptor_Class eddc;
27
28 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Profile);
29 _profile_edd = eet_data_descriptor_stream_new(&eddc);
30
31#define CFG_ADD_BASIC(member, eet_type)\
32 EET_DATA_DESCRIPTOR_ADD_BASIC\
33 (_profile_edd, Clouseau_Profile, # member, member, eet_type)
34
35 CFG_ADD_BASIC(name, EET_T_STRING);
36 CFG_ADD_BASIC(command, EET_T_STRING);
37 CFG_ADD_BASIC(script, EET_T_STRING);
38 CFG_ADD_BASIC(type, EET_T_INT);
39
40#undef CFG_ADD_BASIC
41}
42
43static Clouseau_Profile *
44_config_load(const char *path)
45{
46 Eet_File *file = eet_open(path, EET_FILE_MODE_READ);
47 if (!file) return EINA_FALSE;
48 Clouseau_Profile *p = eet_data_read(file, _profile_edd, _PROFILE_EET_ENTRY);
49 eet_close(file);
50 return p;
51}
52
53int main(int argc, char **argv)
54{
55 int error = 1;
56 eina_init();
57 eet_init();
58 _profile_eet_load();
59 if (argc < 2)
60 {
61 fprintf(stderr, "Path to profile is required\n");
62 goto end;
63 }
64
65 const char *path = argv[1];
66
67 Clouseau_Profile *p = _config_load(path);
68 if (!p)
69 {
70 fprintf(stderr, "Incorrect path (%s) or bad contents\n", path);
71 goto end;
72 }
73 error = 0;
74end:
75 eet_shutdown();
76 eina_shutdown();
77 exit(error);
78}
79