/* ============== = = SCRIPT_GetDoubleString = ============== */ void SCRIPT_GetDoubleString ( int32 scripthandle, char * sectionname, char * entryname, char * dest1, char * dest2 ) { scriptnode_t *cur; /* STUBBED("GetDoubleString"); */ if (scripthandle == -1) return; cur = script_headnode[scripthandle]; cur = SCRIPT_findinchildren (cur, sectionname); cur = SCRIPT_findinchildren (cur, entryname); if (cur != NULL && cur->type == SCRIPTFLAG_TWOSTRING) { strcpy (dest1, cur->data.string[0]); strcpy (dest2, cur->data.string[1]); #ifdef DEBUG_SCRIPLIB printf ("GetDoubleString: value for %s:%s is %s %s\n", sectionname, entryname, dest1, dest2); #endif } }
/* ============== = = SCRIPT_GetNumber = ============== */ boolean SCRIPT_GetNumber ( int32 scripthandle, char * sectionname, char * entryname, int32 * number ) { scriptnode_t *cur; /* STUBBED("GetNumber"); */ if (scripthandle == -1) return false; cur = script_headnode[scripthandle]; cur = SCRIPT_findinchildren (cur, sectionname); cur = SCRIPT_findinchildren (cur, entryname); if (cur != NULL && cur->type == SCRIPTFLAG_DECIMAL) { *number = cur->data.number; #ifdef DEBUG_SCRIPLIB printf ("GetNumber: value for %s:%s is %ld\n", sectionname, entryname, *number); #endif } return (cur != NULL) ? true : false; }
/* ============== = = SCRIPT_GetFloat = ============== */ boolean SCRIPT_GetFloat ( int32 scripthandle, char * sectionname, char * entryname, float * floatnumber ) { scriptnode_t *cur; if (scripthandle == -1) return false; cur = script_headnode[scripthandle]; cur = SCRIPT_findinchildren (cur, sectionname); cur = SCRIPT_findinchildren (cur, entryname); if (cur != NULL && cur->type == SCRIPTFLAG_FLOAT) { *floatnumber = cur->data.floatnumber; #ifdef DEBUG_SCRIPLIB printf ("GetFloat: value for %s:%s is %f\n", sectionname, entryname, *number); #endif } return (cur != NULL) ? true : false; }
/* ============== = = SCRIPT_PutNumber = ============== */ void SCRIPT_PutNumber ( int32 scripthandle, char * sectionname, char * entryname, int32 number, boolean hexadecimal, boolean defaultvalue ) { /* DDOI - I don't know what "defaultvalue" is for so it's ignored */ scriptnode_t *head; scriptnode_t *section; scriptnode_t *node; if(scripthandle >= MAX_SCRIPTS || scripthandle < 0) return; head = script_headnode[scripthandle]; /* We're screwed if there's no head */ if (head == NULL) return; section = SCRIPT_findinchildren (head, sectionname); if (section == NULL) { /* Add the section if it does not exist */ section = SCRIPT_constructnode (); section->type = SCRIPTFLAG_CATEGORY; section->key = SCRIPT_copystring (sectionname); SCRIPT_addchild (head, section); } node = SCRIPT_findinchildren (section, entryname); if (node == NULL) { /* Add the section if it does not exist */ node = SCRIPT_constructnode (); node->key = SCRIPT_copystring (entryname); SCRIPT_addchild (section, node); } if (hexadecimal) node->type = SCRIPTFLAG_HEX; else node->type = SCRIPTFLAG_DECIMAL; node->data.number = number; }
/* ============== = = SCRIPT_PutDoubleString = ============== */ void SCRIPT_PutDoubleString ( int32 scripthandle, char * sectionname, char * entryname, char * string1, char * string2 ) { scriptnode_t *head; scriptnode_t *section; scriptnode_t *node; if(scripthandle >= MAX_SCRIPTS || scripthandle < 0) return; head = script_headnode[scripthandle]; /* We're screwed if there's no head */ if (head == NULL) return; section = SCRIPT_findinchildren (head, sectionname); if (section == NULL) { /* Add the section if it does not exist */ section = SCRIPT_constructnode (); section->type = SCRIPTFLAG_CATEGORY; section->key = SCRIPT_copystring (sectionname); SCRIPT_addchild (head, section); } node = SCRIPT_findinchildren (section, entryname); if (node == NULL) { /* Add the section if it does not exist */ node = SCRIPT_constructnode (); node->type = SCRIPTFLAG_TWOSTRING; node->key = SCRIPT_copystring (entryname); SCRIPT_addchild (section, node); } else { free (node->data.string[0]); free (node->data.string[1]); } node->data.string[0] = SCRIPT_copystring (string1); node->data.string[1] = SCRIPT_copystring (string2); }
int32 SCRIPT_NumberEntries( int32 scripthandle, char * sectionname ) { scriptnode_t *node = NULL; int32 entries = 0; if(scripthandle >= MAX_SCRIPTS || scripthandle < 0) return 0; node = script_headnode[scripthandle]; node = SCRIPT_findinchildren(node, sectionname); if(!node) return 0; for(node=node->child; node ; node=node->sibling) { ++entries; } return entries; }
/* ============== = = SCRIPT_Entry = ============== */ char * SCRIPT_Entry( int32 scripthandle, char * sectionname, int32 which ) { scriptnode_t *node = NULL; int32 entrynum = 0; char * val = NULL; if(scripthandle >= MAX_SCRIPTS || scripthandle < 0) return ""; node = script_headnode[scripthandle]; node = SCRIPT_findinchildren(node,sectionname); if(!node) return ""; for(node=node->child; node ; node=node->sibling, ++entrynum) { if(entrynum == which) { val = node->key; break; } } return val; }