diff options
author | onefang | 2021-07-30 14:01:59 +1000 |
---|---|---|
committer | onefang | 2021-07-30 14:01:59 +1000 |
commit | 396931b65b0e689c32c087fa63e176b558d64b8a (patch) | |
tree | 90e7c07a46b48bd6c3843b66f071a7c87431100e /src/sledjchisl/sledjchisl.c | |
parent | Fix up web start at end. (diff) | |
download | opensim-SC-396931b65b0e689c32c087fa63e176b558d64b8a.zip opensim-SC-396931b65b0e689c32c087fa63e176b558d64b8a.tar.gz opensim-SC-396931b65b0e689c32c087fa63e176b558d64b8a.tar.bz2 opensim-SC-396931b65b0e689c32c087fa63e176b558d64b8a.tar.xz |
Start of getting the details from sims.lua when we get the other sims stuff.
Diffstat (limited to 'src/sledjchisl/sledjchisl.c')
-rw-r--r-- | src/sledjchisl/sledjchisl.c | 88 |
1 files changed, 87 insertions, 1 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 9834834..5c79138 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c | |||
@@ -1020,10 +1020,11 @@ struct _simList | |||
1020 | { | 1020 | { |
1021 | int len, num; | 1021 | int len, num; |
1022 | char **sims; | 1022 | char **sims; |
1023 | qtreetbl_t *byTab; | 1023 | qtreetbl_t *byTab, *simsLua; |
1024 | }; | 1024 | }; |
1025 | simList *ourSims = NULL; | 1025 | simList *ourSims = NULL; |
1026 | 1026 | ||
1027 | |||
1027 | static int getIntFromIni(qlisttbl_t *ini, char *name) | 1028 | static int getIntFromIni(qlisttbl_t *ini, char *name) |
1028 | { | 1029 | { |
1029 | int ret; | 1030 | int ret; |
@@ -1088,6 +1089,44 @@ static int filterInis(struct dirtree *node) | |||
1088 | return 0; | 1089 | return 0; |
1089 | } | 1090 | } |
1090 | 1091 | ||
1092 | // Get the details from all the .ini or .shini sim files. | ||
1093 | // Creates the .shini and sims.lua files if it's an old install. | ||
1094 | // TODO - read the .shini and sims.lua if they exist. | ||
1095 | /* | ||
1096 | ourSims shall be - | ||
1097 | int len, num; | ||
1098 | char **sims; | ||
1099 | qtreetbl_t *byTab, *simsLua; | ||
1100 | |||
1101 | byTab has the short name as the key, simData as the value. | ||
1102 | Iterate through it looking for target sims if specified in the sledjchisl arguments. | ||
1103 | Which can be short name, long name, foo.shini file name. | ||
1104 | Though short name is a direct lookup, and "foo.shini" we can strip off the .shini and direct lookup the short name. | ||
1105 | So only need to iterate if it's a long name. | ||
1106 | Keep in mind the argument might be a user name for IAR backups. Or perhaps a UUID. | ||
1107 | |||
1108 | **sims will be in sims.lua order, and maybe include a pointer to the simData. | ||
1109 | We really only need to iterate through this at full start up and reverse iterate through it at full shutdown. | ||
1110 | So just the tab names in the correct order is fine. | ||
1111 | |||
1112 | |||
1113 | if sims.lua doesn't exist | ||
1114 | create blank one | ||
1115 | else | ||
1116 | read it | ||
1117 | loop through old config/sim* | ||
1118 | if it's not a *.shini file | ||
1119 | read *.ini | ||
1120 | create *.shini | ||
1121 | write *.shini | ||
1122 | else | ||
1123 | read the *.shini file | ||
1124 | add *.shini to ourSims | ||
1125 | if it's not in sims.lua, add it to unsorted | ||
1126 | write sims.lua if it changed | ||
1127 | reorder **sims | ||
1128 | |||
1129 | */ | ||
1091 | simList *getSims() | 1130 | simList *getSims() |
1092 | { | 1131 | { |
1093 | if (NULL != ourSims) return ourSims; | 1132 | if (NULL != ourSims) return ourSims; |
@@ -1114,6 +1153,53 @@ simList *getSims() | |||
1114 | int fd = -1; | 1153 | int fd = -1; |
1115 | size_t l = strlen(tnm); | 1154 | size_t l = strlen(tnm); |
1116 | 1155 | ||
1156 | ourSims->simsLua = Lua2tree(file, "sims"); | ||
1157 | |||
1158 | fprintf(stderr, "DEBUG simsLua table\n"); | ||
1159 | qtreetbl_obj_t obj0; | ||
1160 | |||
1161 | memset((void*)&obj0, 0, sizeof(obj0)); // must be cleared before call | ||
1162 | ourSims->simsLua->lock(ourSims->simsLua); // lock it when thread condition is expected | ||
1163 | while(ourSims->simsLua->getnext(ourSims->simsLua, &obj0, false) == true) | ||
1164 | { | ||
1165 | fprintf(stderr, "%s\n", obj0.name); | ||
1166 | qLua *q0 = obj0.data; | ||
1167 | |||
1168 | switch (q0->type) | ||
1169 | { | ||
1170 | case LUA_TBOOLEAN : {fprintf(stderr, " %s = %d\n", obj0.name, q0->v.b); break;} | ||
1171 | case LUA_TINTEGER : {fprintf(stderr, " %s = %d\n", obj0.name, q0->v.i); break;} | ||
1172 | case LUA_TNUMBER : {fprintf(stderr, " %s = %f\n", obj0.name, q0->v.f); break;} | ||
1173 | case LUA_TSTRING : {fprintf(stderr, " %s = %s\n", obj0.name, q0->v.s); break;} | ||
1174 | case LUA_TTABLE : {fprintf(stderr, " %s TABLE\n", obj0.name); break;} | ||
1175 | default : {fprintf(stderr, " %s ? %s\n", obj0.name, q0->v.s); break;} | ||
1176 | } | ||
1177 | if (LUA_TTABLE == q0->type) | ||
1178 | { | ||
1179 | qtreetbl_t *t = q0->v.t; | ||
1180 | qtreetbl_obj_t obj1; | ||
1181 | |||
1182 | memset((void*)&obj1, 0, sizeof(obj1)); // must be cleared before call | ||
1183 | t->lock(t); // lock it when thread condition is expected | ||
1184 | while(t->getnext(t, &obj1, false) == true) | ||
1185 | { | ||
1186 | qLua *q1 = obj1.data; | ||
1187 | switch (q1->type) | ||
1188 | { | ||
1189 | case LUA_TBOOLEAN : {fprintf(stderr, " %s = %d\n", obj1.name, q1->v.b); break;} | ||
1190 | case LUA_TINTEGER : {fprintf(stderr, " %s = %d\n", obj1.name, q1->v.i); break;} | ||
1191 | case LUA_TNUMBER : {fprintf(stderr, " %s = %f\n", obj1.name, q1->v.f); break;} | ||
1192 | case LUA_TSTRING : {fprintf(stderr, " %s = %s\n", obj1.name, q1->v.s); break;} | ||
1193 | case LUA_TTABLE : {fprintf(stderr, " %s TABLE\n", obj1.name); break;} | ||
1194 | default : {fprintf(stderr, " %s ? %s\n", obj1.name, q1->v.s); break;} | ||
1195 | } | ||
1196 | } | ||
1197 | t->unlock(t); | ||
1198 | } | ||
1199 | } | ||
1200 | ourSims->simsLua->unlock(ourSims->simsLua); | ||
1201 | |||
1202 | |||
1117 | if (s) | 1203 | if (s) |
1118 | { | 1204 | { |
1119 | I("Creating sims %s.", file); | 1205 | I("Creating sims %s.", file); |