Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
blog:x68_launcher_2 [2020/08/22 20:16] – [data.c / data.h] john | blog:x68_launcher_2 [2020/08/23 19:20] (current) – [Control Flow (a simple main.c)] john | ||
---|---|---|---|
Line 347: | Line 347: | ||
**Output** | **Output** | ||
- | * gamedata_t * | + | * gamedata_t *gamedata |
**Description** | **Description** | ||
+ | |||
+ | The function takes the head item of the // | ||
+ | |||
+ | We use this function to find a gamedata object when we only know a game ID. Once we have a games gamedata object, we can then use it to look up the additional metadata, since the gamedata object tells us whether it has that additional data file, and where it is located on the filesystem. | ||
**Example** | **Example** | ||
+ | |||
+ | <code " | ||
+ | int gameid; | ||
+ | gamedata_t *gamedata_head = NULL; | ||
+ | |||
+ | gameid = 23; | ||
+ | |||
+ | // Assuming the gamedata list is already populated... | ||
+ | // Keep a record of the head of the list | ||
+ | gamedata_head = gamedata; | ||
+ | |||
+ | // Return the node which matches the given gameid | ||
+ | gamedata = getGameid(gameid); | ||
+ | |||
+ | if (gamedata != NULL){ | ||
+ | | ||
+ | } | ||
+ | </ | ||
---- | ---- | ||
Line 366: | Line 388: | ||
**Description** | **Description** | ||
+ | |||
+ | This function loops over all items of the gamedata list, from the current position, until it reaches the end (defined as being the node where the //next// pointer is NULL). We use this to determine where to add a new item to the list. | ||
**Example** | **Example** | ||
+ | |||
+ | This is __only__ currently called within the // | ||
+ | |||
+ | <code " | ||
+ | gamedata = getLastGamedata(gamedata); | ||
+ | gamedata-> | ||
+ | gamedata-> | ||
+ | gamedata-> | ||
+ | strcpy(gamedata-> | ||
+ | strcpy(gamedata-> | ||
+ | gamedata-> | ||
+ | gamedata-> | ||
+ | </ | ||
---- | ---- | ||
Line 382: | Line 419: | ||
**Description** | **Description** | ||
+ | |||
+ | Works much the same as the getLastGamedata() function in that it traverses the image list from the current position until it finds the end (determined by the //next// value being NULL). | ||
**Example** | **Example** | ||
+ | |||
+ | This function is only called within getImageList() within data.c, and is used to build the list of image/ | ||
+ | |||
+ | <code " | ||
+ | imagefile = getLastImage(imagefile); | ||
+ | imagefile-> | ||
+ | strcpy(imagefile-> | ||
+ | imagefile-> | ||
+ | </ | ||
---- | ---- | ||
Line 398: | Line 446: | ||
**Description** | **Description** | ||
+ | |||
+ | Behaves the same as // | ||
**Example** | **Example** | ||
+ | |||
+ | __Not currently used.__ | ||
---- | ---- | ||
- | === int removeGamedata() === | + | === removeGamedata() === |
**Input** | **Input** | ||
Line 513: | Line 565: | ||
---- | ---- | ||
- | === int getLaunchdata() === | + | === getLaunchdata() === |
- | gamedata_t *gamedata, launchdat_t *launchdat | + | **Input** |
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | **Output** | ||
+ | |||
+ | * int | ||
+ | |||
+ | **Description** | ||
+ | |||
+ | **Example** | ||
---- | ---- | ||
- | === static int configHandler() === | + | === configHandler() === |
- | void* user, const char* section, const char* name, const char* value | + | **Input** |
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | **Output** | ||
+ | |||
+ | * static int | ||
+ | |||
+ | **Description** | ||
+ | |||
+ | **Example** | ||
---- | ---- | ||
- | === int getIni() === | + | === getIni() === |
- | config_t *config, int verbose | + | **Input** |
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | **Output** | ||
+ | |||
+ | * int | ||
+ | |||
+ | **Description** | ||
+ | |||
+ | **Example** | ||
---- | ---- | ||
- | === int getImageList() === | + | === getImageList() === |
- | launchdat_t *launchdat, imagefile_t *imagefile | + | **Input** |
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | **Output** | ||
+ | |||
+ | * int | ||
+ | |||
+ | **Description** | ||
+ | |||
+ | **Example** | ||
---- | ---- | ||
- | === int getDirList() === | + | === getDirList() === |
- | config_t *config, gamedir_t *gamedir, int verbose | + | **Input** |
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | **Output** | ||
+ | |||
+ | * int | ||
+ | |||
+ | **Description** | ||
+ | |||
+ | **Example** | ||
---- | ---- | ||
Line 547: | Line 657: | ||
* https:// | * https:// | ||
* https:// | * https:// | ||
+ | |||
+ | The ini parsing library is a drop-in component from https:// | ||
+ | |||
+ | The entire contents of __ini.c__ and __ini.h__ are from that project, only modified to disable or enable certain functionality. | ||
+ | |||
+ | The ini parsing functions are used only by a small number of calls within __data.c__, they are not directly called by any other code within the application. | ||
==== Example Configuration ==== | ==== Example Configuration ==== | ||
+ | |||
+ | The configuration file for the application is (by default, via a constant in //data.h//) named __launcher.txt__ and is searched for in the same directory as the launcher application itself. A hardcoded path is not defined. | ||
+ | |||
+ | The contents of an example config file could look as follows | ||
< | < | ||
[default] | [default] | ||
verbose=1 | verbose=1 | ||
+ | savedirs=0 | ||
gamedirs=A: | gamedirs=A: | ||
</ | </ | ||
+ | |||
+ | At a minimum the '// | ||
==== Control Flow (a simple main.c) ==== | ==== Control Flow (a simple main.c) ==== | ||
Line 566: | Line 689: | ||
gamedata_t *gamedata_head = NULL; // Constant pointer to the start of the gamedata list | gamedata_t *gamedata_head = NULL; // Constant pointer to the start of the gamedata list | ||
- | // Create a new empty gamedata entry | + | // Create a new empty gamedata entry which will hold all of |
+ | // the games that we find | ||
gamedata = (gamedata_t *) malloc(sizeof(gamedata_t)); | gamedata = (gamedata_t *) malloc(sizeof(gamedata_t)); | ||
gamedata-> | gamedata-> | ||
- | // Parse the gamedirs that are set | + | // Create a new gamedir list to hold the game search directories |
+ | // which are extracted from the application config file | ||
gamedir = (gamedir_t *) malloc(sizeof(gamedir_t)); | gamedir = (gamedir_t *) malloc(sizeof(gamedir_t)); | ||
gamedir-> | gamedir-> | ||
- | // Create an instance of a config data | + | // Create an instance of a config data, which will be filled |
+ | // by parsing the application config ini file | ||
config = (config_t *) malloc(sizeof(config_t)); | config = (config_t *) malloc(sizeof(config_t)); | ||
config-> | config-> |