Model loading
This commit is contained in:
parent
67d78dfaec
commit
2d34d38a28
24
src/cmds.c
24
src/cmds.c
|
@ -37,7 +37,7 @@ char *CmdModel(char **argv, Server_t *args)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
char temp[255];
|
char temp[255];
|
||||||
int tempsize;
|
int tempsize, id, eid;
|
||||||
Model_t *newModel;
|
Model_t *newModel;
|
||||||
|
|
||||||
buf = (char *) calloc(LINE_NUMBER, LINE_LENGTH * sizeof(char));
|
buf = (char *) calloc(LINE_NUMBER, LINE_LENGTH * sizeof(char));
|
||||||
|
@ -64,9 +64,12 @@ char *CmdModel(char **argv, Server_t *args)
|
||||||
|
|
||||||
// TODO modify model according to things in file
|
// TODO modify model according to things in file
|
||||||
|
|
||||||
strcpy(argv[2] + 5, newModel->name);
|
strcpy(newModel->name, argv[2] + 5);
|
||||||
|
|
||||||
strcat(buf, "Model created with id");
|
strcat(buf, "Model ");
|
||||||
|
tempsize = sprintf(temp, "%s", newModel->name);
|
||||||
|
strcat(buf, temp);
|
||||||
|
strcat(buf, " created with id");
|
||||||
tempsize = sprintf(temp, " %d\n", newModel->id);
|
tempsize = sprintf(temp, " %d\n", newModel->id);
|
||||||
strcat(buf, temp);
|
strcat(buf, temp);
|
||||||
goto CmdModelEnd;
|
goto CmdModelEnd;
|
||||||
|
@ -89,7 +92,20 @@ char *CmdModel(char **argv, Server_t *args)
|
||||||
if (!argv[2]) {
|
if (!argv[2]) {
|
||||||
goto loadEnd;
|
goto loadEnd;
|
||||||
}
|
}
|
||||||
// TODO get ID
|
|
||||||
|
id = (int) strtol(argv[2] + 3, NULL, 10);
|
||||||
|
|
||||||
|
if ((eid = ModelLoad(id)) < 0) {
|
||||||
|
strcat(buf, "Failed to load model id ");
|
||||||
|
tempsize = sprintf(temp, " %d\n", id);
|
||||||
|
strcat(buf, temp);
|
||||||
|
goto CmdModelEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcat(buf, "Model loaded with eid ");
|
||||||
|
tempsize = sprintf(temp, " %d\n", eid);
|
||||||
|
strcat(buf, temp);
|
||||||
|
goto CmdModelEnd;
|
||||||
loadEnd:
|
loadEnd:
|
||||||
// invalid use
|
// invalid use
|
||||||
strcat(buf, "Loads a model structure\n");
|
strcat(buf, "Loads a model structure\n");
|
||||||
|
|
|
@ -67,6 +67,8 @@ void ModelCreate(Model_t **newModel) // TODO manage deletion and empty slots
|
||||||
|
|
||||||
int ModelLoad(int id) // TODO unload !
|
int ModelLoad(int id) // TODO unload !
|
||||||
{
|
{
|
||||||
|
if (id > knownModelIndex) return -1;
|
||||||
|
|
||||||
// Creating structure for the Scheduler
|
// Creating structure for the Scheduler
|
||||||
knownModel[id]->scheduler = (Scheduler_t*) calloc(1, sizeof(Scheduler_t));
|
knownModel[id]->scheduler = (Scheduler_t*) calloc(1, sizeof(Scheduler_t));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue