diff options
Diffstat (limited to 'src/sledjchisl')
-rw-r--r-- | src/sledjchisl/sledjchisl.c | 65 |
1 files changed, 20 insertions, 45 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 62eb928..5d85669 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c | |||
@@ -1204,9 +1204,7 @@ simList *getSims() | |||
1204 | struct dirtree *new = dirtree_add_node(0, path, 0); | 1204 | struct dirtree *new = dirtree_add_node(0, path, 0); |
1205 | int i, j; | 1205 | int i, j; |
1206 | 1206 | ||
1207 | ourSims = xmalloc(sizeof(simList)); | 1207 | ourSims = xzalloc(sizeof(simList)); |
1208 | memset(ourSims, 0, sizeof(simList)); | ||
1209 | |||
1210 | ourSims->byTab = qtreetbl(0); | 1208 | ourSims->byTab = qtreetbl(0); |
1211 | new->extra = (long) ourSims; | 1209 | new->extra = (long) ourSims; |
1212 | dirtree_handle_callback(new, filterSims); | 1210 | dirtree_handle_callback(new, filterSims); |
@@ -1256,7 +1254,6 @@ simList *getSims() | |||
1256 | d("Reading .ini file %s", path); | 1254 | d("Reading .ini file %s", path); |
1257 | ini = qconfig_parse_file(NULL, path, '='); | 1255 | ini = qconfig_parse_file(NULL, path, '='); |
1258 | 1256 | ||
1259 | ini->putstr(ini, "INI FILE", name); | ||
1260 | /* | 1257 | /* |
1261 | [Region] | 1258 | [Region] |
1262 | Location = "1,1" | 1259 | Location = "1,1" |
@@ -1266,15 +1263,14 @@ ini->putstr(ini, "INI FILE", name); | |||
1266 | [Network] | 1263 | [Network] |
1267 | http_listener_port = 9007 | 1264 | http_listener_port = 9007 |
1268 | */ | 1265 | */ |
1269 | simd->name = qstrunchar(ini->getstr(ini, "Region.RegionName", false), '"', '"'); | 1266 | simd->name = qstrunchar(ini->getstr(ini, "Region.RegionName", true), '"', '"'); |
1270 | simd->UUID = qstrunchar(ini->getstr(ini, "Region.RegionUUID", false), '"', '"'); | 1267 | simd->UUID = qstrunchar(ini->getstr(ini, "Region.RegionUUID", true), '"', '"'); |
1271 | simd->regionType = qstrunchar(ini->getstr(ini, "Region.RegionType", false), '"', '"'); | 1268 | simd->regionType = qstrunchar(ini->getstr(ini, "Region.RegionType", true), '"', '"'); |
1272 | simd->sizeX = getIntFromIni(ini, "Region.SizeX"); | 1269 | simd->sizeX = getIntFromIni(ini, "Region.SizeX"); |
1273 | simd->sizeY = getIntFromIni(ini, "Region.SizeY"); | 1270 | simd->sizeY = getIntFromIni(ini, "Region.SizeY"); |
1274 | simd->sizeZ = getIntFromIni(ini, "Region.SizeZ"); | 1271 | simd->sizeZ = getIntFromIni(ini, "Region.SizeZ"); |
1275 | simd->tab = name; | 1272 | simd->tab = name; |
1276 | ini->put(ini, "SIM DATA", simd, sizeof(simData)); | 1273 | ourSims->byTab->put(ourSims->byTab, name, simd, sizeof(simData)); |
1277 | ourSims->byTab->put(ourSims->byTab, name, ini, sizeof(qlisttbl_t)); | ||
1278 | 1274 | ||
1279 | if ((!qfile_exist(newPath))) | 1275 | if ((!qfile_exist(newPath))) |
1280 | { | 1276 | { |
@@ -1310,7 +1306,7 @@ ini->putstr(ini, "INI FILE", name); | |||
1310 | } | 1306 | } |
1311 | free(cmd); | 1307 | free(cmd); |
1312 | } | 1308 | } |
1313 | free(ini); | 1309 | ini->free(ini); |
1314 | free(newPath); | 1310 | free(newPath); |
1315 | free(path); | 1311 | free(path); |
1316 | } | 1312 | } |
@@ -1358,10 +1354,8 @@ void freeSimList(simList *sims) | |||
1358 | { | 1354 | { |
1359 | char *name = qmemdup(obj.name, obj.namesize); // keep the name | 1355 | char *name = qmemdup(obj.name, obj.namesize); // keep the name |
1360 | size_t namesize = obj.namesize; // for removal argument | 1356 | size_t namesize = obj.namesize; // for removal argument |
1361 | qlisttbl_t *ini = (qlisttbl_t *) obj.data; | ||
1362 | if (NULL != ini) | ||
1363 | { | 1357 | { |
1364 | simData *simd = ini->get(ini, "SIM DATA", NULL, false); | 1358 | simData *simd = (simData *) obj.data; |
1365 | 1359 | ||
1366 | if (NULL != simd) | 1360 | if (NULL != simd) |
1367 | { | 1361 | { |
@@ -1372,16 +1366,8 @@ void freeSimList(simList *sims) | |||
1372 | free(simd->estate); | 1366 | free(simd->estate); |
1373 | free(simd->owner); | 1367 | free(simd->owner); |
1374 | free(simd->paneID); | 1368 | free(simd->paneID); |
1375 | free(simd); | ||
1376 | } | 1369 | } |
1377 | // TODO - this leaks memory, but it's a bug in qLibc. Send the bug fix upstream. | ||
1378 | // It either leaks, or frees twice. Pffft | ||
1379 | // ini->clear(ini); | ||
1380 | // ini->free(ini); | ||
1381 | // free(ini); | ||
1382 | ; | ||
1383 | } | 1370 | } |
1384 | |||
1385 | sims->byTab->remove_by_obj(sims->byTab, obj.name, obj.namesize); // remove | 1371 | sims->byTab->remove_by_obj(sims->byTab, obj.name, obj.namesize); // remove |
1386 | obj = sims->byTab->find_nearest(sims->byTab, name, namesize, false); // rewind one step back | 1372 | obj = sims->byTab->find_nearest(sims->byTab, name, namesize, false); // rewind one step back |
1387 | free(name); // clean up | 1373 | free(name); // clean up |
@@ -7859,14 +7845,12 @@ fcgiDone: | |||
7859 | 7845 | ||
7860 | if ((strcmp("number", obj1.name) != 0) && (strcmp("panes", obj1.name) != 0) && (strcmp("type", obj1.name) != 0)) | 7846 | if ((strcmp("number", obj1.name) != 0) && (strcmp("panes", obj1.name) != 0) && (strcmp("type", obj1.name) != 0)) |
7861 | { | 7847 | { |
7862 | char *sim = q1->v.s; | 7848 | simData *simd = ourSims->byTab->get(ourSims->byTab, q1->v.s, NULL, false); |
7863 | qlisttbl_t *ini = ourSims->byTab->get(ourSims->byTab, sim, NULL, false); | ||
7864 | 7849 | ||
7865 | if (NULL == ini) | 7850 | if (NULL == simd) |
7866 | E("Sim %s not found in ini list!", sim); | 7851 | E("Sim %s not found in ini list!", q1->v.s); |
7867 | else | 7852 | else |
7868 | { | 7853 | { |
7869 | simData *simd = ini->get(ini, "SIM DATA", NULL, false); | ||
7870 | char *path = xmprintf("%s/%s.shini", scEtc, simd->tab); | 7854 | char *path = xmprintf("%s/%s.shini", scEtc, simd->tab); |
7871 | char *newPath = xmprintf("%s/sim%d/%s.ini", scTemp, count, simd->tab); // Coz OpenSim. | 7855 | char *newPath = xmprintf("%s/sim%d/%s.ini", scTemp, count, simd->tab); // Coz OpenSim. |
7872 | char *cmd; | 7856 | char *cmd; |
@@ -7999,15 +7983,12 @@ fcgiDone: | |||
7999 | 7983 | ||
8000 | if ((strcmp("number", obj1.name) != 0) && (strcmp("panes", obj1.name) != 0) && (strcmp("type", obj1.name) != 0)) | 7984 | if ((strcmp("number", obj1.name) != 0) && (strcmp("panes", obj1.name) != 0) && (strcmp("type", obj1.name) != 0)) |
8001 | { | 7985 | { |
8002 | char *sim = q1->v.s; | 7986 | simData *simd = ourSims->byTab->get(ourSims->byTab, q1->v.s, NULL, false); |
8003 | qlisttbl_t *ini = ourSims->byTab->get(ourSims->byTab, sim, NULL, false); | ||
8004 | 7987 | ||
8005 | if (NULL == ini) | 7988 | if (NULL == simd) |
8006 | E("Sim %s not found in ini list!", sim); | 7989 | E("Sim %s not found in ini list!", q1->v.s); |
8007 | else | 7990 | else |
8008 | { | 7991 | { |
8009 | simData *simd = ini->get(ini, "SIM DATA", NULL, false); | ||
8010 | |||
8011 | simd->window = window; | 7992 | simd->window = window; |
8012 | simd->pane = pane; | 7993 | simd->pane = pane; |
8013 | 7994 | ||
@@ -8074,15 +8055,12 @@ fcgiDone: | |||
8074 | 8055 | ||
8075 | if ((strcmp("number", obj1.name) != 0) && (strcmp("panes", obj1.name) != 0) && (strcmp("type", obj1.name) != 0)) | 8056 | if ((strcmp("number", obj1.name) != 0) && (strcmp("panes", obj1.name) != 0) && (strcmp("type", obj1.name) != 0)) |
8076 | { | 8057 | { |
8077 | char *sim = q1->v.s; | 8058 | simData *simd = ourSims->byTab->get(ourSims->byTab, q1->v.s, NULL, false); |
8078 | qlisttbl_t *ini = ourSims->byTab->get(ourSims->byTab, sim, NULL, false); | ||
8079 | 8059 | ||
8080 | if (NULL == ini) | 8060 | if (NULL == simd) |
8081 | E("Sim %s not found in ini list!", sim); | 8061 | E("Sim %s not found in ini list!", 5); |
8082 | else | 8062 | else |
8083 | { | 8063 | { |
8084 | simData *simd = ini->get(ini, "SIM DATA", NULL, false); | ||
8085 | |||
8086 | // Check if only doing a single sim. | 8064 | // Check if only doing a single sim. |
8087 | int cont = FALSE; | 8065 | int cont = FALSE; |
8088 | if (NULL != target) | 8066 | if (NULL != target) |
@@ -8091,7 +8069,7 @@ fcgiDone: | |||
8091 | snprintf(toybuf, sizeof(toybuf), "%s.shini", simd->tab); | 8069 | snprintf(toybuf, sizeof(toybuf), "%s.shini", simd->tab); |
8092 | if | 8070 | if |
8093 | ( | 8071 | ( |
8094 | (strcmp(target, sim) == 0) || | 8072 | (strcmp(target, q1->v.s) == 0) || |
8095 | (strcmp(target, simd->name) == 0) || | 8073 | (strcmp(target, simd->name) == 0) || |
8096 | (strcmp(target, simd->tab) == 0) || | 8074 | (strcmp(target, simd->tab) == 0) || |
8097 | (strcmp(target, toybuf) == 0) | 8075 | (strcmp(target, toybuf) == 0) |
@@ -8278,15 +8256,12 @@ fcgiDone: | |||
8278 | 8256 | ||
8279 | if ((strcmp("number", obj1.name) != 0) && (strcmp("panes", obj1.name) != 0) && (strcmp("type", obj1.name) != 0)) | 8257 | if ((strcmp("number", obj1.name) != 0) && (strcmp("panes", obj1.name) != 0) && (strcmp("type", obj1.name) != 0)) |
8280 | { | 8258 | { |
8281 | char *sim = q1->v.s; | 8259 | simData *simd = ourSims->byTab->get(ourSims->byTab, q1->v.s, NULL, false); |
8282 | qlisttbl_t *ini = ourSims->byTab->get(ourSims->byTab, sim, NULL, false); | ||
8283 | 8260 | ||
8284 | if (NULL == ini) | 8261 | if (NULL == simd) |
8285 | E("Sim %s not found in ini list!", sim); | 8262 | E("Sim %s not found in ini list!", q1->v.s); |
8286 | else | 8263 | else |
8287 | { | 8264 | { |
8288 | simData *simd = ini->get(ini, "SIM DATA", NULL, false); | ||
8289 | |||
8290 | // NOTE - these sleeps are guesses, seems to work on my super desktop during testing. | 8265 | // NOTE - these sleeps are guesses, seems to work on my super desktop during testing. |
8291 | while (checkSimIsRunning(simd->tab)) | 8266 | while (checkSimIsRunning(simd->tab)) |
8292 | usleep(100000); | 8267 | usleep(100000); |