short LoadKeyTextList( void ) { KeyTextList* list; char* pathname = NULL; short result = -1; if( !g_keytext_dir ) goto Err1; if( (pathname = CheckFileExists(g_keytext_dir, CNIJLGMON2_RESFILE)) == NULL ){ if( (pathname = CheckFileExists("keytext", CNIJLGMON2_RESFILE)) == NULL ) goto Err1; } if ( (list = (KeyTextList*)malloc(sizeof(KeyTextList))) == NULL ) goto Err1; if( (list->tree = CreateTree()) == NULL ) goto Err2; if( ReadXMLFile(pathname, list->tree) != 0 ) goto Err3; g_key_keytext_list = list; result = 0; return result; Err3: FreeStringList( list->tree ); Err2: free( list ); Err1: return result; }
KeyTextList* LoadKeyTextList(gchar* filename) { KeyTextList* list; gchar* pathname = NULL; if( !g_keytext_dir || !filename ) return NULL; if( (pathname = CheckFileExists(g_keytext_dir, filename)) == NULL ) if( (pathname = CheckFileExists("keytext", filename)) == NULL ) return NULL; list = (KeyTextList*)g_malloc(sizeof(KeyTextList)); if( list != NULL ) { if( (list->tree = CreateTree()) != NULL ) { if( ReadXMLFile(pathname, list->tree) ) { return list; } FreeTree(list->tree); } g_free(list); } return NULL; }