Mercurial > audlegacy-plugins
changeset 2507:251336bee085
Cosmetic cleanups, synchronized from XMMS-SID.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 02 Apr 2008 19:53:39 +0300 |
parents | 28f3f1fc4001 |
children | 58889ccbe807 |
files | src/sid/xmms-sid.c src/sid/xmms-sid.h src/sid/xs_fileinfo.c src/sid/xs_length.c src/sid/xs_length.h src/sid/xs_md5.c src/sid/xs_md5.h src/sid/xs_player.h src/sid/xs_sidplay.h src/sid/xs_sidplay1.cc src/sid/xs_sidplay1.h src/sid/xs_sidplay2.cc src/sid/xs_sidplay2.h src/sid/xs_slsup.c src/sid/xs_slsup.h src/sid/xs_stil.c src/sid/xs_stil.h src/sid/xs_support.c src/sid/xs_support.h |
diffstat | 19 files changed, 507 insertions(+), 512 deletions(-) [+] |
line wrap: on
line diff
--- a/src/sid/xmms-sid.c Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xmms-sid.c Wed Apr 02 19:53:39 2008 +0300 @@ -27,8 +27,6 @@ #endif #include <stdarg.h> -#include <gdk/gdkkeysyms.h> - #include "xs_config.h" #include "xs_length.h" #include "xs_stil.h" @@ -54,7 +52,7 @@ /* * List of players and links to their functions */ -t_xs_player xs_playerlist[] = { +static const xs_player_t xs_playerlist[] = { #ifdef HAVE_SIDPLAY1 {XS_ENG_SIDPLAY1, xs_sidplay1_probe, @@ -77,17 +75,17 @@ #endif }; -const gint xs_nplayerlist = (sizeof(xs_playerlist) / sizeof(t_xs_player)); +static const gint xs_nplayerlist = (sizeof(xs_playerlist) / sizeof(xs_playerlist[0])); /* * Global variables */ -t_xs_status xs_status; +xs_status_t xs_status; XS_MUTEX(xs_status); static XS_THREAD_T xs_decode_thread; -static void xs_get_song_tuple_info(Tuple *pResult, t_xs_tuneinfo *pInfo, gint subTune); +static void xs_get_song_tuple_info(Tuple *pResult, xs_tuneinfo_t *pInfo, gint subTune); /* * Error messages @@ -120,7 +118,7 @@ */ void xs_reinit(void) { - gint iPlayer; + gint player; gboolean isInitialized; XSDEBUG("xs_reinit() thread = %p\n", g_thread_self()); @@ -161,31 +159,31 @@ /* Try to initialize emulator engine */ XSDEBUG("initializing emulator engine #%i...\n", xs_cfg.playerEngine); - iPlayer = 0; + player = 0; isInitialized = FALSE; - while ((iPlayer < xs_nplayerlist) && !isInitialized) { - if (xs_playerlist[iPlayer].plrIdent == xs_cfg.playerEngine) { - if (xs_playerlist[iPlayer].plrInit(&xs_status)) { + while ((player < xs_nplayerlist) && !isInitialized) { + if (xs_playerlist[player].plrIdent == xs_cfg.playerEngine) { + if (xs_playerlist[player].plrInit(&xs_status)) { isInitialized = TRUE; - xs_status.sidPlayer = (t_xs_player *) & xs_playerlist[iPlayer]; + xs_status.sidPlayer = (xs_player_t *) & xs_playerlist[player]; } } - iPlayer++; + player++; } - XSDEBUG("init#1: %s, %i\n", (isInitialized) ? "OK" : "FAILED", iPlayer); + XSDEBUG("init#1: %s, %i\n", (isInitialized) ? "OK" : "FAILED", player); - iPlayer = 0; - while ((iPlayer < xs_nplayerlist) && !isInitialized) { - if (xs_playerlist[iPlayer].plrInit(&xs_status)) { + player = 0; + while ((player < xs_nplayerlist) && !isInitialized) { + if (xs_playerlist[player].plrInit(&xs_status)) { isInitialized = TRUE; - xs_status.sidPlayer = (t_xs_player *) & xs_playerlist[iPlayer]; - xs_cfg.playerEngine = xs_playerlist[iPlayer].plrIdent; + xs_status.sidPlayer = (xs_player_t *) & xs_playerlist[player]; + xs_cfg.playerEngine = xs_playerlist[player].plrIdent; } else - iPlayer++; + player++; } - XSDEBUG("init#2: %s, %i\n", (isInitialized) ? "OK" : "FAILED", iPlayer); + XSDEBUG("init#2: %s, %i\n", (isInitialized) ? "OK" : "FAILED", player); /* Get settings back, in case the chosen emulator backend changed them */ @@ -255,28 +253,28 @@ /* * Check whether the given file is handled by this plugin */ -static gchar * xs_has_tracknumber(gchar *pcFilename) +static gchar * xs_has_tracknumber(gchar *filename) { - gchar *tmpSep = xs_strrchr(pcFilename, '?'); - if (tmpSep && g_ascii_isdigit(*(tmpSep + 1))) - return tmpSep; + gchar *sep = xs_strrchr(filename, '?'); + if (sep && g_ascii_isdigit(*(sep + 1))) + return sep; else return NULL; } -gboolean xs_get_trackinfo(const gchar *pcFilename, gchar **pcResult, gint *pTrack) +gboolean xs_get_trackinfo(const gchar *filename, gchar **result, gint *track) { - gchar *tmpSep; + gchar *sep; - *pcResult = g_strdup(pcFilename); - tmpSep = xs_has_tracknumber(*pcResult); + *result = g_strdup(filename); + sep = xs_has_tracknumber(*result); - if (tmpSep) { - *tmpSep = '\0'; - *pTrack = atoi(tmpSep + 1); + if (sep) { + *sep = '\0'; + *track = atoi(sep + 1); return TRUE; } else { - *pTrack = -1; + *track = -1; return FALSE; } } @@ -287,7 +285,7 @@ */ void xs_play_file(InputPlayback *pb) { - t_xs_tuneinfo *tmpTune; + xs_tuneinfo_t *tmpTune; gboolean audioOpen = FALSE; gint audioGot, tmpLength, subTune; gchar *tmpFilename, *audioBuffer = NULL, *oversampleBuffer = NULL, *tmpTitle; @@ -591,7 +589,7 @@ /* * Return song information Tuple */ -static void xs_get_song_tuple_info(Tuple *pResult, t_xs_tuneinfo *pInfo, gint subTune) +static void xs_get_song_tuple_info(Tuple *pResult, xs_tuneinfo_t *pInfo, gint subTune) { gchar *tmpStr, tmpStr2[64]; @@ -646,18 +644,18 @@ } -Tuple * xs_get_song_tuple(gchar *songFilename) +Tuple * xs_get_song_tuple(gchar *filename) { - Tuple *tmpResult; + Tuple *result; gchar *tmpFilename; - t_xs_tuneinfo *tmpInfo; + xs_tuneinfo_t *tmpInfo; gint tmpTune; /* Get information from URL */ - xs_get_trackinfo(songFilename, &tmpFilename, &tmpTune); + xs_get_trackinfo(filename, &tmpFilename, &tmpTune); - tmpResult = aud_tuple_new_from_filename(tmpFilename); - if (!tmpResult) { + result = aud_tuple_new_from_filename(tmpFilename); + if (!result) { g_free(tmpFilename); return NULL; } @@ -669,25 +667,25 @@ g_free(tmpFilename); if (!tmpInfo) - return tmpResult; + return result; - xs_get_song_tuple_info(tmpResult, tmpInfo, tmpTune); + xs_get_song_tuple_info(result, tmpInfo, tmpTune); xs_tuneinfo_free(tmpInfo); - return tmpResult; + return result; } -Tuple *xs_probe_for_tuple(gchar *songFilename, t_xs_file *fd) +Tuple *xs_probe_for_tuple(gchar *filename, xs_file_t *fd) { - Tuple *tmpResult; + Tuple *result; gchar *tmpFilename; - t_xs_tuneinfo *tmpInfo; + xs_tuneinfo_t *tmpInfo; gint tmpTune; assert(xs_status.sidPlayer); - if (songFilename == NULL) + if (filename == NULL) return NULL; XS_MUTEX_LOCK(xs_status); @@ -699,9 +697,9 @@ /* Get information from URL */ - xs_get_trackinfo(songFilename, &tmpFilename, &tmpTune); - tmpResult = aud_tuple_new_from_filename(tmpFilename); - if (!tmpResult) { + xs_get_trackinfo(filename, &tmpFilename, &tmpTune); + result = aud_tuple_new_from_filename(tmpFilename); + if (!result) { g_free(tmpFilename); return NULL; } @@ -713,14 +711,14 @@ g_free(tmpFilename); if (!tmpInfo) - return tmpResult; + return result; - xs_get_song_tuple_info(tmpResult, tmpInfo, tmpTune); + xs_get_song_tuple_info(result, tmpInfo, tmpTune); /* Set subtunes */ if (xs_cfg.subAutoEnable && tmpInfo->nsubTunes > 1 && tmpTune < 0) { gint i, n; - tmpResult->subtunes = g_new(gint, tmpInfo->nsubTunes); + result->subtunes = g_new(gint, tmpInfo->nsubTunes); for (n = 0, i = 1; i <= tmpInfo->nsubTunes; i++) { gboolean doAdd = FALSE; @@ -731,13 +729,13 @@ } else doAdd = TRUE; - if (doAdd) tmpResult->subtunes[n++] = i; + if (doAdd) result->subtunes[n++] = i; } - tmpResult->nsubtunes = n; + result->nsubtunes = n; } else - tmpResult->nsubtunes = 0; + result->nsubtunes = 0; xs_tuneinfo_free(tmpInfo); - return tmpResult; + return result; }
--- a/src/sid/xmms-sid.h Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xmms-sid.h Wed Apr 02 19:53:39 2008 +0300 @@ -131,9 +131,9 @@ /* Shorthands for linked lists */ -#define LPREV (pNode->pPrev) -#define LTHIS (pNode) -#define LNEXT (pNode->pNext) +#define LPREV (node->prev) +#define LTHIS (node) +#define LNEXT (node->next) /* Plugin-wide typedefs @@ -142,7 +142,7 @@ gint tuneSpeed, tuneLength; gboolean tunePlayed; -} t_xs_subtuneinfo; +} xs_subtuneinfo_t; typedef struct { @@ -157,8 +157,8 @@ dataFileLen, sidModel; gint nsubTunes, startTune; - t_xs_subtuneinfo *subTunes; -} t_xs_tuneinfo; + xs_subtuneinfo_t *subTunes; +} xs_tuneinfo_t; /* Global variables @@ -177,7 +177,7 @@ void xs_seek(InputPlayback *, gint); gint xs_get_time(InputPlayback *); Tuple * xs_get_song_tuple(gchar *); -Tuple * xs_probe_for_tuple(gchar *, t_xs_file *); +Tuple * xs_probe_for_tuple(gchar *, xs_file_t *); void xs_about(void); void xs_error(const char *, ...);
--- a/src/sid/xs_fileinfo.c Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_fileinfo.c Wed Apr 02 19:53:39 2008 +0300 @@ -33,7 +33,7 @@ static GtkWidget *xs_fileinfowin = NULL; -static t_xs_stil_node *xs_fileinfostil = NULL; +static stil_node_t *xs_fileinfostil = NULL; XS_MUTEX(xs_fileinfowin); #define LUW(x) lookup_widget(xs_fileinfowin, x) @@ -120,7 +120,7 @@ static void xs_fileinfo_subtune(GtkWidget * widget, void *data) { - t_xs_stil_subnode *tmpNode; + stil_subnode_t *tmpNode; GtkWidget *tmpText; gchar *subName, *subAuthor, *subInfo; @@ -136,14 +136,14 @@ #endif /* Get subtune information */ - tmpNode = (t_xs_stil_subnode *) data; + tmpNode = (stil_subnode_t *) data; if (!tmpNode && xs_fileinfostil) tmpNode = xs_fileinfostil->subTunes[0]; if (tmpNode) { - subName = tmpNode->pName; - subAuthor = tmpNode->pAuthor; - subInfo = tmpNode->pInfo; + subName = tmpNode->name; + subAuthor = tmpNode->author; + subInfo = tmpNode->info; } else { subName = NULL; subAuthor = NULL; @@ -167,11 +167,11 @@ } -void xs_fileinfo(gchar * pcFilename) +void xs_fileinfo(gchar * filename) { GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu; - t_xs_tuneinfo *tmpInfo; - t_xs_stil_subnode *tmpNode; + xs_tuneinfo_t *tmpInfo; + stil_subnode_t *tmpNode; gchar tmpStr[256], *tmpFilename; gint n; @@ -179,9 +179,9 @@ * no information can be found for the new file. Hmm... */ #ifdef AUDACIOUS_PLUGIN - xs_get_trackinfo(pcFilename, &tmpFilename, &n); + xs_get_trackinfo(filename, &tmpFilename, &n); #else - tmpFilename = pcFilename; + tmpFilename = filename; #endif /* Get new tune information */ @@ -220,7 +220,7 @@ /* Set the generic song information */ - tmpFilename = XS_CS_FILENAME(pcFilename); + tmpFilename = XS_CS_FILENAME(filename); gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), tmpFilename); g_free(tmpFilename); gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), tmpInfo->sidName); @@ -246,18 +246,18 @@ g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n); - if (tmpNode->pName) { - xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pName); + if (tmpNode->name) { + xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->name); isSet = TRUE; } - if (tmpNode->pTitle) { + if (tmpNode->title) { xs_pnstrcat(tmpStr, sizeof(tmpStr), - isSet ? " [*]" : tmpNode->pTitle); + isSet ? " [*]" : tmpNode->title); isSet = TRUE; } - if (tmpNode->pInfo) { + if (tmpNode->info) { xs_pnstrcat(tmpStr, sizeof(tmpStr), " [!]"); isSet = TRUE; }
--- a/src/sid/xs_length.c Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_length.c Wed Apr 02 19:53:39 2008 +0300 @@ -30,31 +30,31 @@ /* Free memory allocated for given SLDB node */ -static void xs_sldb_node_free(t_xs_sldb_node *pNode) +static void xs_sldb_node_free(sldb_node_t *node) { - if (pNode) { + if (node) { /* Nothing much to do here ... */ - g_free(pNode->sLengths); - g_free(pNode); + g_free(node->lengths); + g_free(node); } } /* Insert given node to db linked list */ -static void xs_sldb_node_insert(t_xs_sldb *db, t_xs_sldb_node *pNode) +static void xs_sldb_node_insert(xs_sldb_t *db, sldb_node_t *node) { assert(db); - if (db->pNodes) { - /* The first node's pPrev points to last node */ - LPREV = db->pNodes->pPrev; /* New node's prev = Previous last node */ - db->pNodes->pPrev->pNext = pNode; /* Previous last node's next = New node */ - db->pNodes->pPrev = pNode; /* New last node = New node */ + if (db->nodes) { + /* The first node's prev points to last node */ + LPREV = db->nodes->prev; /* New node's prev = Previous last node */ + db->nodes->prev->next = node; /* Previous last node's next = New node */ + db->nodes->prev = node; /* New last node = New node */ LNEXT = NULL; /* But next is NULL! */ } else { - db->pNodes = pNode; /* First node ... */ - LPREV = pNode; /* ... it's also last */ + db->nodes = node; /* First node ... */ + LPREV = node; /* ... it's also last */ LNEXT = NULL; /* But next is NULL! */ } } @@ -62,54 +62,54 @@ /* Parse a time-entry in SLDB format */ -static gint xs_sldb_gettime(gchar *pcStr, size_t *piPos) +static gint xs_sldb_gettime(gchar *str, size_t *pos) { - gint iResult, iTemp; + gint result, tmp; /* Check if it starts with a digit */ - if (isdigit(pcStr[*piPos])) { + if (isdigit(str[*pos])) { /* Get minutes-field */ - iResult = 0; - while (isdigit(pcStr[*piPos])) - iResult = (iResult * 10) + (pcStr[(*piPos)++] - '0'); + result = 0; + while (isdigit(str[*pos])) + result = (result * 10) + (str[(*pos)++] - '0'); - iResult *= 60; + result *= 60; /* Check the field separator char */ - if (pcStr[*piPos] == ':') { + if (str[*pos] == ':') { /* Get seconds-field */ - (*piPos)++; - iTemp = 0; - while (isdigit(pcStr[*piPos])) { - iTemp = (iTemp * 10) + (pcStr[(*piPos)++] - '0'); + (*pos)++; + tmp = 0; + while (isdigit(str[*pos])) { + tmp = (tmp * 10) + (str[(*pos)++] - '0'); } - iResult += iTemp; + result += tmp; } else - iResult = -2; + result = -2; } else - iResult = -1; + result = -1; /* Ignore and skip the possible attributes */ - while (pcStr[*piPos] && !isspace(pcStr[*piPos])) - (*piPos)++; + while (str[*pos] && !isspace(str[*pos])) + (*pos)++; - return iResult; + return result; } /* Parse one SLDB definition line, return SLDB node */ -t_xs_sldb_node * xs_sldb_read_entry(gchar *inLine) +sldb_node_t * xs_sldb_read_entry(gchar *inLine) { size_t linePos; gint i; - gboolean iOK; - t_xs_sldb_node *tmpNode; + gboolean isOK; + sldb_node_t *tmnode; /* Allocate new node */ - tmpNode = (t_xs_sldb_node *) g_malloc0(sizeof(t_xs_sldb_node)); - if (!tmpNode) { + tmnode = (sldb_node_t *) g_malloc0(sizeof(sldb_node_t)); + if (!tmnode) { xs_error("Error allocating new node. Fatal error.\n"); return NULL; } @@ -119,14 +119,14 @@ for (i = 0; i < XS_MD5HASH_LENGTH; i++, linePos += 2) { gint tmpu; sscanf(&inLine[linePos], "%2x", &tmpu); - tmpNode->md5Hash[i] = tmpu; + tmnode->md5Hash[i] = tmpu; } /* Get playtimes */ if (inLine[linePos] != 0) { if (inLine[linePos] != '=') { xs_error("'=' expected on column #%d.\n", linePos); - xs_sldb_node_free(tmpNode); + xs_sldb_node_free(tmnode); return NULL; } else { size_t tmpLen, savePos; @@ -136,52 +136,52 @@ tmpLen = strlen(inLine); /* Get number of sub-tune lengths */ - iOK = TRUE; - while ((linePos < tmpLen) && iOK) { + isOK = TRUE; + while ((linePos < tmpLen) && isOK) { xs_findnext(inLine, &linePos); if (xs_sldb_gettime(inLine, &linePos) >= 0) - tmpNode->nLengths++; + tmnode->nlengths++; else - iOK = FALSE; + isOK = FALSE; } /* Allocate memory for lengths */ - if (tmpNode->nLengths > 0) { - tmpNode->sLengths = (gint *) g_malloc0(tmpNode->nLengths * sizeof(gint)); - if (!tmpNode->sLengths) { + if (tmnode->nlengths > 0) { + tmnode->lengths = (gint *) g_malloc0(tmnode->nlengths * sizeof(gint)); + if (!tmnode->lengths) { xs_error("Could not allocate memory for node.\n"); - xs_sldb_node_free(tmpNode); + xs_sldb_node_free(tmnode); return NULL; } } else { - xs_sldb_node_free(tmpNode); + xs_sldb_node_free(tmnode); return NULL; } /* Read lengths in */ i = 0; linePos = savePos; - iOK = TRUE; - while ((linePos < tmpLen) && (i < tmpNode->nLengths) && iOK) { + isOK = TRUE; + while ((linePos < tmpLen) && (i < tmnode->nlengths) && isOK) { gint l; xs_findnext(inLine, &linePos); l = xs_sldb_gettime(inLine, &linePos); if (l >= 0) - tmpNode->sLengths[i] = l; + tmnode->lengths[i] = l; else - iOK = FALSE; + isOK = FALSE; i++; } - if (!iOK) { - xs_sldb_node_free(tmpNode); + if (!isOK) { + xs_sldb_node_free(tmnode); return NULL; } else - return tmpNode; + return tmnode; } } @@ -191,12 +191,12 @@ /* Read database to memory */ -gint xs_sldb_read(t_xs_sldb *db, const gchar *dbFilename) +gint xs_sldb_read(xs_sldb_t *db, const gchar *dbFilename) { FILE *inFile; gchar inLine[XS_BUF_SIZE]; size_t lineNum; - t_xs_sldb_node *tmpNode; + sldb_node_t *tmnode; assert(db); /* Try to open the file */ @@ -225,8 +225,8 @@ dbFilename, lineNum); } else { /* Parse and add node to db */ - if ((tmpNode = xs_sldb_read_entry(inLine)) != NULL) { - xs_sldb_node_insert(db, tmpNode); + if ((tmnode = xs_sldb_read_entry(inLine)) != NULL) { + xs_sldb_node_insert(db, tmnode); } else { xs_error("Invalid entry in SongLengthDB file '%s' line #%d!\n", dbFilename, lineNum); @@ -251,7 +251,7 @@ * negative if testHash1 < testHash2 * positive if testHash1 > testHash2 */ -static gint xs_sldb_cmphash(t_xs_md5hash testHash1, t_xs_md5hash testHash2) +static gint xs_sldb_cmphash(xs_md5hash_t testHash1, xs_md5hash_t testHash2) { gint i, d; @@ -265,54 +265,54 @@ /* Compare two nodes */ -static gint xs_sldb_cmp(const void *pNode1, const void *pNode2) +static gint xs_sldb_cmp(const void *node1, const void *node2) { /* We assume here that we never ever get NULL-pointers or similar */ return xs_sldb_cmphash( - (*(t_xs_sldb_node **) pNode1)->md5Hash, - (*(t_xs_sldb_node **) pNode2)->md5Hash); + (*(sldb_node_t **) node1)->md5Hash, + (*(sldb_node_t **) node2)->md5Hash); } /* (Re)create index */ -gint xs_sldb_index(t_xs_sldb * db) +gint xs_sldb_index(xs_sldb_t * db) { - t_xs_sldb_node *pCurr; + sldb_node_t *pCurr; size_t i; assert(db); /* Free old index */ - if (db->ppIndex) { - g_free(db->ppIndex); - db->ppIndex = NULL; + if (db->pindex) { + g_free(db->pindex); + db->pindex = NULL; } /* Get size of db */ - pCurr = db->pNodes; + pCurr = db->nodes; db->n = 0; while (pCurr) { db->n++; - pCurr = pCurr->pNext; + pCurr = pCurr->next; } /* Check number of nodes */ if (db->n > 0) { /* Allocate memory for index-table */ - db->ppIndex = (t_xs_sldb_node **) g_malloc(sizeof(t_xs_sldb_node *) * db->n); - if (!db->ppIndex) + db->pindex = (sldb_node_t **) g_malloc(sizeof(sldb_node_t *) * db->n); + if (!db->pindex) return -1; /* Get node-pointers to table */ i = 0; - pCurr = db->pNodes; + pCurr = db->nodes; while (pCurr && (i < db->n)) { - db->ppIndex[i++] = pCurr; - pCurr = pCurr->pNext; + db->pindex[i++] = pCurr; + pCurr = pCurr->next; } /* Sort the indexes */ - qsort(db->ppIndex, db->n, sizeof(t_xs_sldb_node *), xs_sldb_cmp); + qsort(db->pindex, db->n, sizeof(sldb_node_t *), xs_sldb_cmp); } return 0; @@ -321,27 +321,27 @@ /* Free a given song-length database */ -void xs_sldb_free(t_xs_sldb * db) +void xs_sldb_free(xs_sldb_t * db) { - t_xs_sldb_node *pCurr, *pNext; + sldb_node_t *pCurr, *next; if (!db) return; /* Free the memory allocated for nodes */ - pCurr = db->pNodes; + pCurr = db->nodes; while (pCurr) { - pNext = pCurr->pNext; + next = pCurr->next; xs_sldb_node_free(pCurr); - pCurr = pNext; + pCurr = next; } - db->pNodes = NULL; + db->nodes = NULL; /* Free memory allocated for index */ - if (db->ppIndex) { - g_free(db->ppIndex); - db->ppIndex = NULL; + if (db->pindex) { + g_free(db->pindex); + db->pindex = NULL; } /* Free structure */ @@ -352,8 +352,7 @@ /* Compute md5hash of given SID-file */ -typedef struct -{ +typedef struct { gchar magicID[4]; /* "PSID" / "RSID" magic identifier */ guint16 version, /* Version number */ dataOffset, /* Start of actual c64 data in file */ @@ -366,36 +365,35 @@ gchar sidName[32]; /* Descriptive text-fields, ASCIIZ */ gchar sidAuthor[32]; gchar sidCopyright[32]; -} t_xs_psidv1_header; +} psidv1_header_t; -typedef struct -{ +typedef struct { guint16 flags; /* Flags */ guint8 startPage, pageLength; guint16 reserved; -} t_xs_psidv2_header; +} psidv2_header_t; -static gint xs_get_sid_hash(const gchar *pcFilename, t_xs_md5hash hash) +static gint xs_get_sid_hash(const gchar *filename, xs_md5hash_t hash) { - t_xs_file *inFile; - t_xs_md5state inState; - t_xs_psidv1_header psidH; - t_xs_psidv2_header psidH2; + xs_file_t *inFile; + xs_md5state_t inState; + psidv1_header_t psidH; + psidv2_header_t psidH2; guint8 *songData; guint8 ib8[2], i8; - gint iIndex, iRes; + gint index, result; /* Try to open the file */ - if ((inFile = xs_fopen(pcFilename, "rb")) == NULL) + if ((inFile = xs_fopen(filename, "rb")) == NULL) return -1; /* Read PSID header in */ xs_fread(psidH.magicID, sizeof(psidH.magicID), 1, inFile); if (strncmp(psidH.magicID, "PSID", 4) && strncmp(psidH.magicID, "RSID", 4)) { xs_fclose(inFile); - xs_error("Not a PSID or RSID file '%s'\n", pcFilename); + xs_error("Not a PSID or RSID file '%s'\n", filename); return -2; } @@ -414,7 +412,7 @@ if (xs_feof(inFile) || xs_ferror(inFile)) { xs_fclose(inFile); - xs_error("Error reading SID file header from '%s'\n", pcFilename); + xs_error("Error reading SID file header from '%s'\n", filename); return -4; } @@ -433,12 +431,12 @@ songData = (guint8 *) g_malloc(XS_SIDBUF_SIZE * sizeof(guint8)); if (!songData) { xs_fclose(inFile); - xs_error("Error allocating temp data buffer for file '%s'\n", pcFilename); + xs_error("Error allocating temp data buffer for file '%s'\n", filename); return -3; } /* Read data to buffer */ - iRes = xs_fread(songData, sizeof(guint8), XS_SIDBUF_SIZE, inFile); + result = xs_fread(songData, sizeof(guint8), XS_SIDBUF_SIZE, inFile); xs_fclose(inFile); /* Initialize and start MD5-hash calculation */ @@ -446,32 +444,36 @@ if (psidH.loadAddress == 0) { /* Strip load address (2 first bytes) */ - xs_md5_append(&inState, &songData[2], iRes - 2); + xs_md5_append(&inState, &songData[2], result - 2); } else { /* Append "as is" */ - xs_md5_append(&inState, songData, iRes); + xs_md5_append(&inState, songData, result); } /* Free buffer */ g_free(songData); /* Append header data to hash */ -#define XSADDHASH(QDATAB) { ib8[0] = (QDATAB & 0xff); ib8[1] = (QDATAB >> 8); xs_md5_append(&inState, (guint8 *) &ib8, sizeof(ib8)); } +#define XSADDHASH(QDATAB) do { \ + ib8[0] = (QDATAB & 0xff); \ + ib8[1] = (QDATAB >> 8); \ + xs_md5_append(&inState, (guint8 *) &ib8, sizeof(ib8)); \ + } while (0) - XSADDHASH(psidH.initAddress) - XSADDHASH(psidH.playAddress) - XSADDHASH(psidH.nSongs) + XSADDHASH(psidH.initAddress); + XSADDHASH(psidH.playAddress); + XSADDHASH(psidH.nSongs); #undef XSADDHASH /* Append song speed data to hash */ i8 = 0; - for (iIndex = 0; (iIndex < psidH.nSongs) && (iIndex < 32); iIndex++) { - i8 = (psidH.speed & (1 << iIndex)) ? 60 : 0; + for (index = 0; (index < psidH.nSongs) && (index < 32); index++) { + i8 = (psidH.speed & (1 << index)) ? 60 : 0; xs_md5_append(&inState, &i8, sizeof(i8)); } /* Rest of songs (more than 32) */ - for (iIndex = 32; iIndex < psidH.nSongs; iIndex++) { + for (index = 32; index < psidH.nSongs; index++) { xs_md5_append(&inState, &i8, sizeof(i8)); } @@ -492,19 +494,19 @@ /* Get node from db index via binary search */ -t_xs_sldb_node *xs_sldb_get(t_xs_sldb *db, const gchar *pcFilename) +sldb_node_t *xs_sldb_get(xs_sldb_t *db, const gchar *filename) { - t_xs_sldb_node keyItem, *key, **item; + sldb_node_t keyItem, *key, **item; /* Check the database pointers */ - if (!db || !db->pNodes || !db->ppIndex) + if (!db || !db->nodes || !db->pindex) return NULL; /* Get the hash and then look up from db */ - if (xs_get_sid_hash(pcFilename, keyItem.md5Hash) == 0) { + if (xs_get_sid_hash(filename, keyItem.md5Hash) == 0) { key = &keyItem; - item = bsearch(&key, db->ppIndex, db->n, - sizeof(db->ppIndex[0]), xs_sldb_cmp); + item = bsearch(&key, db->pindex, db->n, + sizeof(db->pindex[0]), xs_sldb_cmp); if (item) return *item;
--- a/src/sid/xs_length.h Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_length.h Wed Apr 02 19:53:39 2008 +0300 @@ -10,27 +10,27 @@ /* Types */ -typedef struct _t_xs_sldb_node { - t_xs_md5hash md5Hash; /* 128-bit MD5 hash-digest */ - gint nLengths; /* Number of lengths */ - gint *sLengths; /* Lengths in seconds */ - struct _t_xs_sldb_node *pPrev, *pNext; -} t_xs_sldb_node; +typedef struct _sldb_node_t { + xs_md5hash_t md5Hash; /* 128-bit MD5 hash-digest */ + gint nlengths; /* Number of lengths */ + gint *lengths; /* Lengths in seconds */ + struct _sldb_node_t *prev, *next; +} sldb_node_t; typedef struct { - t_xs_sldb_node *pNodes, - **ppIndex; + sldb_node_t *nodes, + **pindex; size_t n; -} t_xs_sldb; +} xs_sldb_t; /* Functions */ -gint xs_sldb_read(t_xs_sldb *, const gchar *); -gint xs_sldb_index(t_xs_sldb *); -void xs_sldb_free(t_xs_sldb *); -t_xs_sldb_node * xs_sldb_get(t_xs_sldb *, const gchar *); +gint xs_sldb_read(xs_sldb_t *, const gchar *); +gint xs_sldb_index(xs_sldb_t *); +void xs_sldb_free(xs_sldb_t *); +sldb_node_t * xs_sldb_get(xs_sldb_t *, const gchar *); #ifdef __cplusplus }
--- a/src/sid/xs_md5.c Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_md5.c Wed Apr 02 19:53:39 2008 +0300 @@ -16,7 +16,7 @@ #define xs_md5_bytereverse(buf, len) /* Nothing */ #else #if G_BYTE_ORDER == G_BIG_ENDIAN -void xs_md5_bytereverse(guint8 *buf, guint l) +static void xs_md5_bytereverse(guint8 *buf, guint l) { guint32 t; do { @@ -34,7 +34,7 @@ /* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious * initialization constants. */ -void xs_md5_init(t_xs_md5state *ctx) +void xs_md5_init(xs_md5state_t *ctx) { ctx->buf[0] = 0x67452301; ctx->buf[1] = 0xefcdab89; @@ -57,7 +57,7 @@ #define MD5STEP(f, w, x, y, z, data, s) \ ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) -void xs_md5_transform(guint32 buf[4], guint32 const in[16]) +static void xs_md5_transform(guint32 buf[4], guint32 const in[16]) { register guint32 a, b, c, d; @@ -144,7 +144,7 @@ /* Update context to reflect the concatenation of another buffer full * of bytes. */ -void xs_md5_append(t_xs_md5state *ctx, const guint8 *buf, guint len) +void xs_md5_append(xs_md5state_t *ctx, const guint8 *buf, guint len) { guint32 t; @@ -157,7 +157,6 @@ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ /* Handle any leading odd-sized chunks */ - if (t) { guint8 *p = (guint8 *) ctx->in + t; @@ -172,8 +171,8 @@ buf += t; len -= t; } + /* Process data in 64-byte chunks */ - while (len >= 64) { memcpy(ctx->in, buf, 64); xs_md5_bytereverse(ctx->in, 16); @@ -183,14 +182,13 @@ } /* Handle any remaining bytes of data. */ - memcpy(ctx->in, buf, len); } /* Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ -void xs_md5_finish(t_xs_md5state *ctx, t_xs_md5hash digest) +void xs_md5_finish(xs_md5state_t *ctx, xs_md5hash_t digest) { guint count; guint8 *p;
--- a/src/sid/xs_md5.h Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_md5.h Wed Apr 02 19:53:39 2008 +0300 @@ -13,19 +13,19 @@ guint32 bits[2]; /* message length in bits, lsw first */ guint32 buf[4]; /* digest buffer */ guint8 in[64]; /* accumulate block */ -} t_xs_md5state; +} xs_md5state_t; #define XS_MD5HASH_LENGTH (16) #define XS_MD5HASH_LENGTH_CH (XS_MD5HASH_LENGTH * 2) -typedef guint8 t_xs_md5hash[XS_MD5HASH_LENGTH]; +typedef guint8 xs_md5hash_t[XS_MD5HASH_LENGTH]; /* Functions */ -void xs_md5_init(t_xs_md5state *ctx); -void xs_md5_append(t_xs_md5state *ctx, const guint8 *buf, guint len); -void xs_md5_finish(t_xs_md5state *ctx, t_xs_md5hash digest); +void xs_md5_init(xs_md5state_t *ctx); +void xs_md5_append(xs_md5state_t *ctx, const guint8 *buf, guint len); +void xs_md5_finish(xs_md5state_t *ctx, xs_md5hash_t digest); #ifdef __cplusplus
--- a/src/sid/xs_player.h Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_player.h Wed Apr 02 19:53:39 2008 +0300 @@ -8,24 +8,24 @@ extern "C" { #endif -struct t_xs_status; +struct xs_status_t; typedef struct { gint plrIdent; - gboolean (*plrProbe)(t_xs_file *); - gboolean (*plrInit)(struct t_xs_status *); - void (*plrClose)(struct t_xs_status *); - gboolean (*plrInitSong)(struct t_xs_status *); - guint (*plrFillBuffer)(struct t_xs_status *, gchar *, guint); - gboolean (*plrLoadSID)(struct t_xs_status *, gchar *); - void (*plrDeleteSID)(struct t_xs_status *); - t_xs_tuneinfo* (*plrGetSIDInfo)(const gchar *); - gboolean (*plrUpdateSIDInfo)(struct t_xs_status *); - void (*plrFlush)(struct t_xs_status *); -} t_xs_player; + gboolean (*plrProbe)(xs_file_t *); + gboolean (*plrInit)(struct xs_status_t *); + void (*plrClose)(struct xs_status_t *); + gboolean (*plrInitSong)(struct xs_status_t *); + guint (*plrFillBuffer)(struct xs_status_t *, gchar *, guint); + gboolean (*plrLoadSID)(struct xs_status_t *, gchar *); + void (*plrDeleteSID)(struct xs_status_t *); + xs_tuneinfo_t* (*plrGetSIDInfo)(const gchar *); + gboolean (*plrUpdateSIDInfo)(struct xs_status_t *); + void (*plrFlush)(struct xs_status_t *); +} xs_player_t; -typedef struct t_xs_status { +typedef struct xs_status_t { gint audioFrequency, /* Audio settings */ audioChannels, audioBitsPerSample, @@ -36,20 +36,20 @@ emulation backend supports oversampling. */ void *sidEngine; /* SID-emulation internal engine data */ - t_xs_player *sidPlayer; /* Selected player engine */ + xs_player_t *sidPlayer; /* Selected player engine */ gboolean isError, isPlaying, isInitialized; gint currSong, /* Current sub-tune */ lastTime; - t_xs_tuneinfo *tuneInfo; -} t_xs_status; + xs_tuneinfo_t *tuneInfo; +} xs_status_t; /* Global variables */ extern InputPlugin xs_plugin_ip; -extern t_xs_status xs_status; +extern xs_status_t xs_status; XS_MUTEX_H(xs_status);
--- a/src/sid/xs_sidplay.h Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_sidplay.h Wed Apr 02 19:53:39 2008 +0300 @@ -26,9 +26,9 @@ * (those variables that are only set by libSIDPlay when tune is initialized). * Rest of the information is acquired in TFUNCTION2() */ -t_xs_tuneinfo *TFUNCTION(const gchar *sidFilename) +xs_tuneinfo_t *TFUNCTION(const gchar *sidFilename) { - t_xs_tuneinfo *pResult; + xs_tuneinfo_t *pResult; TTUNEINFO myInfo; TTUNE *myTune; guint8 *buf = NULL; @@ -82,12 +82,12 @@ /* Updates the information of currently playing tune */ -gboolean TFUNCTION2(t_xs_status *myStatus) +gboolean TFUNCTION2(xs_status_t *myStatus) { TTUNEINFO myInfo; TTUNE *myTune; TENGINE *myEngine; - t_xs_tuneinfo *i; + xs_tuneinfo_t *i; /* Check if we have required structures initialized */ if (!myStatus || !myStatus->tuneInfo || !myStatus->sidEngine)
--- a/src/sid/xs_sidplay1.cc Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_sidplay1.cc Wed Apr 02 19:53:39 2008 +0300 @@ -43,7 +43,7 @@ sidTune *currTune; guint8 *buf; size_t bufSize; -} t_xs_sidplay1; +} xs_sidplay1_t; /* We need to 'export' all this pseudo-C++ crap */ @@ -56,13 +56,13 @@ #define TFUNCTION2 xs_sidplay1_updateinfo #define TTUNEINFO sidTuneInfo #define TTUNE sidTune -#define TENGINE t_xs_sidplay1 +#define TENGINE xs_sidplay1_t #include "xs_sidplay.h" /* Check if we can play the given file */ -gboolean xs_sidplay1_probe(t_xs_file *f) +gboolean xs_sidplay1_probe(xs_file_t *f) { gchar tmpBuf[4]; @@ -80,14 +80,14 @@ /* Initialize SIDPlay1 */ -gboolean xs_sidplay1_init(t_xs_status * myStatus) +gboolean xs_sidplay1_init(xs_status_t * myStatus) { gint tmpFreq; - t_xs_sidplay1 *myEngine; + xs_sidplay1_t *myEngine; assert(myStatus); /* Allocate internal structures */ - myEngine = (t_xs_sidplay1 *) g_malloc0(sizeof(t_xs_sidplay1)); + myEngine = (xs_sidplay1_t *) g_malloc0(sizeof(xs_sidplay1_t)); if (!myEngine) return FALSE; /* Initialize engine */ @@ -252,12 +252,12 @@ /* Close SIDPlay1 engine */ -void xs_sidplay1_close(t_xs_status * myStatus) +void xs_sidplay1_close(xs_status_t * myStatus) { - t_xs_sidplay1 *myEngine; + xs_sidplay1_t *myEngine; assert(myStatus); - myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; + myEngine = (xs_sidplay1_t *) myStatus->sidEngine; /* Free internals */ if (myEngine->currEng) { @@ -279,12 +279,12 @@ /* Initialize current song and sub-tune */ -gboolean xs_sidplay1_initsong(t_xs_status * myStatus) +gboolean xs_sidplay1_initsong(xs_status_t * myStatus) { - t_xs_sidplay1 *myEngine; + xs_sidplay1_t *myEngine; assert(myStatus); - myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; + myEngine = (xs_sidplay1_t *) myStatus->sidEngine; if (!myEngine) return FALSE; if (!myEngine->currTune) { @@ -305,12 +305,12 @@ /* Emulate and render audio data to given buffer */ -guint xs_sidplay1_fillbuffer(t_xs_status * myStatus, gchar * audioBuffer, guint audioBufSize) +guint xs_sidplay1_fillbuffer(xs_status_t * myStatus, gchar * audioBuffer, guint audioBufSize) { - t_xs_sidplay1 *myEngine; + xs_sidplay1_t *myEngine; assert(myStatus); - myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; + myEngine = (xs_sidplay1_t *) myStatus->sidEngine; if (!myEngine) return 0; sidEmuFillBuffer(*myEngine->currEng, *myEngine->currTune, audioBuffer, audioBufSize); @@ -321,19 +321,19 @@ /* Load a given SID-tune file */ -gboolean xs_sidplay1_load(t_xs_status * myStatus, gchar * pcFilename) +gboolean xs_sidplay1_load(xs_status_t * myStatus, gchar * filename) { - t_xs_sidplay1 *myEngine; + xs_sidplay1_t *myEngine; assert(myStatus); myStatus->isInitialized = FALSE; - myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; + myEngine = (xs_sidplay1_t *) myStatus->sidEngine; if (!myEngine) return FALSE; /* Try to get the tune */ - if (!pcFilename) return FALSE; + if (!filename) return FALSE; - if (xs_fload_buffer(pcFilename, &(myEngine->buf), &(myEngine->bufSize)) != 0) + if (xs_fload_buffer(filename, &(myEngine->buf), &(myEngine->bufSize)) != 0) return FALSE; if (!myEngine->currTune->load(myEngine->buf, myEngine->bufSize)) @@ -345,12 +345,12 @@ /* Delete INTERNAL information */ -void xs_sidplay1_delete(t_xs_status * myStatus) +void xs_sidplay1_delete(xs_status_t * myStatus) { - t_xs_sidplay1 *myEngine; + xs_sidplay1_t *myEngine; assert(myStatus); - myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; + myEngine = (xs_sidplay1_t *) myStatus->sidEngine; if (!myEngine) return; g_free(myEngine->buf);
--- a/src/sid/xs_sidplay1.h Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_sidplay1.h Wed Apr 02 19:53:39 2008 +0300 @@ -9,15 +9,15 @@ extern "C" { #endif -gboolean xs_sidplay1_probe(t_xs_file *); -void xs_sidplay1_close(t_xs_status *); -gboolean xs_sidplay1_init(t_xs_status *); -gboolean xs_sidplay1_initsong(t_xs_status *); -guint xs_sidplay1_fillbuffer(t_xs_status *, gchar *, guint); -gboolean xs_sidplay1_load(t_xs_status *, gchar *); -void xs_sidplay1_delete(t_xs_status *); -t_xs_tuneinfo* xs_sidplay1_getinfo(const gchar *); -gboolean xs_sidplay1_updateinfo(t_xs_status *); +gboolean xs_sidplay1_probe(xs_file_t *); +void xs_sidplay1_close(xs_status_t *); +gboolean xs_sidplay1_init(xs_status_t *); +gboolean xs_sidplay1_initsong(xs_status_t *); +guint xs_sidplay1_fillbuffer(xs_status_t *, gchar *, guint); +gboolean xs_sidplay1_load(xs_status_t *, gchar *); +void xs_sidplay1_delete(xs_status_t *); +xs_tuneinfo_t* xs_sidplay1_getinfo(const gchar *); +gboolean xs_sidplay1_updateinfo(xs_status_t *); #ifdef __cplusplus }
--- a/src/sid/xs_sidplay2.cc Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_sidplay2.cc Wed Apr 02 19:53:39 2008 +0300 @@ -45,7 +45,7 @@ SidTune *currTune; guint8 *buf; size_t bufSize; -} t_xs_sidplay2; +} xs_sidplay2_t; /* We need to 'export' all this pseudo-C++ crap */ @@ -58,13 +58,13 @@ #define TFUNCTION2 xs_sidplay2_updateinfo #define TTUNEINFO SidTuneInfo #define TTUNE SidTune -#define TENGINE t_xs_sidplay2 +#define TENGINE xs_sidplay2_t #include "xs_sidplay.h" /* Check if we can play the given file */ -gboolean xs_sidplay2_probe(t_xs_file *f) +gboolean xs_sidplay2_probe(xs_file_t *f) { gchar tmpBuf[4]; @@ -82,16 +82,16 @@ /* Initialize SIDPlay2 */ -gboolean xs_sidplay2_init(t_xs_status * myStatus) +gboolean xs_sidplay2_init(xs_status_t * myStatus) { gint tmpFreq, i; - t_xs_sidplay2 *myEngine; + xs_sidplay2_t *myEngine; sid_filter_t tmpFilter; t_xs_sid2_filter *f; assert(myStatus); /* Allocate internal structures */ - myEngine = (t_xs_sidplay2 *) g_malloc0(sizeof(t_xs_sidplay2)); + myEngine = (xs_sidplay2_t *) g_malloc0(sizeof(xs_sidplay2_t)); myStatus->sidEngine = myEngine; if (!myEngine) return FALSE; @@ -365,12 +365,12 @@ /* Close SIDPlay2 engine */ -void xs_sidplay2_close(t_xs_status * myStatus) +void xs_sidplay2_close(xs_status_t * myStatus) { - t_xs_sidplay2 *myEngine; + xs_sidplay2_t *myEngine; assert(myStatus); - myEngine = (t_xs_sidplay2 *) myStatus->sidEngine; + myEngine = (xs_sidplay2_t *) myStatus->sidEngine; /* Free internals */ if (myEngine->currBuilder) { @@ -397,12 +397,12 @@ /* Initialize current song and sub-tune */ -gboolean xs_sidplay2_initsong(t_xs_status * myStatus) +gboolean xs_sidplay2_initsong(xs_status_t * myStatus) { - t_xs_sidplay2 *myEngine; + xs_sidplay2_t *myEngine; assert(myStatus); - myEngine = (t_xs_sidplay2 *) myStatus->sidEngine; + myEngine = (xs_sidplay2_t *) myStatus->sidEngine; if (!myEngine) return FALSE; if (!myEngine->currTune->selectSong(myStatus->currSong)) { @@ -423,12 +423,12 @@ /* Emulate and render audio data to given buffer */ -guint xs_sidplay2_fillbuffer(t_xs_status * myStatus, gchar * audioBuffer, guint audioBufSize) +guint xs_sidplay2_fillbuffer(xs_status_t * myStatus, gchar * audioBuffer, guint audioBufSize) { - t_xs_sidplay2 *myEngine; + xs_sidplay2_t *myEngine; assert(myStatus); - myEngine = (t_xs_sidplay2 *) myStatus->sidEngine; + myEngine = (xs_sidplay2_t *) myStatus->sidEngine; if (!myEngine) return 0; return myEngine->currEng->play(audioBuffer, audioBufSize); @@ -437,13 +437,13 @@ /* Load a given SID-tune file */ -gboolean xs_sidplay2_load(t_xs_status * myStatus, gchar * pcFilename) +gboolean xs_sidplay2_load(xs_status_t * myStatus, gchar * pcFilename) { - t_xs_sidplay2 *myEngine; + xs_sidplay2_t *myEngine; assert(myStatus); myStatus->isInitialized = FALSE; - myEngine = (t_xs_sidplay2 *) myStatus->sidEngine; + myEngine = (xs_sidplay2_t *) myStatus->sidEngine; if (!myEngine) return FALSE; /* Try to get the tune */ @@ -461,12 +461,12 @@ /* Delete INTERNAL information */ -void xs_sidplay2_delete(t_xs_status * myStatus) +void xs_sidplay2_delete(xs_status_t * myStatus) { - t_xs_sidplay2 *myEngine; + xs_sidplay2_t *myEngine; assert(myStatus); - myEngine = (t_xs_sidplay2 *) myStatus->sidEngine; + myEngine = (xs_sidplay2_t *) myStatus->sidEngine; if (!myEngine) return; g_free(myEngine->buf); @@ -477,7 +477,7 @@ /* Hardware backend flushing */ -void xs_sidplay2_flush(t_xs_status * myStatus) +void xs_sidplay2_flush(xs_status_t * myStatus) { assert(myStatus);
--- a/src/sid/xs_sidplay2.h Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_sidplay2.h Wed Apr 02 19:53:39 2008 +0300 @@ -9,16 +9,16 @@ extern "C" { #endif -gboolean xs_sidplay2_probe(t_xs_file *); -void xs_sidplay2_close(t_xs_status *); -gboolean xs_sidplay2_init(t_xs_status *); -gboolean xs_sidplay2_initsong(t_xs_status *); -guint xs_sidplay2_fillbuffer(t_xs_status *, gchar *, guint); -gboolean xs_sidplay2_load(t_xs_status *, gchar *); -void xs_sidplay2_delete(t_xs_status *); -t_xs_tuneinfo* xs_sidplay2_getinfo(const gchar *); -gboolean xs_sidplay2_updateinfo(t_xs_status *); -void xs_sidplay2_flush(t_xs_status *); +gboolean xs_sidplay2_probe(xs_file_t *); +void xs_sidplay2_close(xs_status_t *); +gboolean xs_sidplay2_init(xs_status_t *); +gboolean xs_sidplay2_initsong(xs_status_t *); +guint xs_sidplay2_fillbuffer(xs_status_t *, gchar *, guint); +gboolean xs_sidplay2_load(xs_status_t *, gchar *); +void xs_sidplay2_delete(xs_status_t *); +xs_tuneinfo_t* xs_sidplay2_getinfo(const gchar *); +gboolean xs_sidplay2_updateinfo(xs_status_t *); +void xs_sidplay2_flush(xs_status_t *); #ifdef __cplusplus }
--- a/src/sid/xs_slsup.c Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_slsup.c Wed Apr 02 19:53:39 2008 +0300 @@ -24,10 +24,10 @@ #include "xs_config.h" -static t_xs_sldb *xs_sldb_db = NULL; +static xs_sldb_t *xs_sldb_db = NULL; XS_MUTEX(xs_sldb_db); -static t_xs_stildb *xs_stildb_db = NULL; +static xs_stildb_t *xs_stildb_db = NULL; XS_MUTEX(xs_stildb_db); @@ -49,7 +49,7 @@ xs_stildb_free(xs_stildb_db); /* Allocate database */ - xs_stildb_db = (t_xs_stildb *) g_malloc0(sizeof(t_xs_stildb)); + xs_stildb_db = (xs_stildb_t *) g_malloc0(sizeof(xs_stildb_t)); if (!xs_stildb_db) { XS_MUTEX_UNLOCK(xs_cfg); XS_MUTEX_UNLOCK(xs_stildb_db); @@ -89,9 +89,9 @@ } -t_xs_stil_node *xs_stil_get(gchar *pcFilename) +stil_node_t *xs_stil_get(gchar *filename) { - t_xs_stil_node *pResult; + stil_node_t *result; gchar *tmpFilename; XS_MUTEX_LOCK(xs_stildb_db); @@ -105,22 +105,22 @@ tmpFilename[0] = 0; /* Remove HVSC location-prefix from filename */ - tmpFilename = strstr(pcFilename, xs_cfg.hvscPath); + tmpFilename = strstr(filename, xs_cfg.hvscPath); if (tmpFilename) tmpFilename += strlen(xs_cfg.hvscPath); else - tmpFilename = pcFilename; + tmpFilename = filename; } else - tmpFilename = pcFilename; + tmpFilename = filename; - pResult = xs_stildb_get_node(xs_stildb_db, tmpFilename); + result = xs_stildb_get_node(xs_stildb_db, tmpFilename); } else - pResult = NULL; + result = NULL; XS_MUTEX_UNLOCK(xs_stildb_db); XS_MUTEX_UNLOCK(xs_cfg); - return pResult; + return result; } @@ -142,7 +142,7 @@ xs_sldb_free(xs_sldb_db); /* Allocate database */ - xs_sldb_db = (t_xs_sldb *) g_malloc0(sizeof(t_xs_sldb)); + xs_sldb_db = (xs_sldb_t *) g_malloc0(sizeof(xs_sldb_t)); if (!xs_sldb_db) { XS_MUTEX_UNLOCK(xs_cfg); XS_MUTEX_UNLOCK(xs_sldb_db); @@ -182,106 +182,106 @@ } -t_xs_sldb_node *xs_songlen_get(const gchar * pcFilename) +sldb_node_t *xs_songlen_get(const gchar * filename) { - t_xs_sldb_node *pResult; + sldb_node_t *result; XS_MUTEX_LOCK(xs_sldb_db); if (xs_cfg.songlenDBEnable && xs_sldb_db) - pResult = xs_sldb_get(xs_sldb_db, pcFilename); + result = xs_sldb_get(xs_sldb_db, filename); else - pResult = NULL; + result = NULL; XS_MUTEX_UNLOCK(xs_sldb_db); - return pResult; + return result; } /* Allocate a new tune information structure */ -t_xs_tuneinfo *xs_tuneinfo_new(const gchar * pcFilename, +xs_tuneinfo_t *xs_tuneinfo_new(const gchar * filename, gint nsubTunes, gint startTune, const gchar * sidName, const gchar * sidComposer, const gchar * sidCopyright, gint loadAddr, gint initAddr, gint playAddr, gint dataFileLen, const gchar *sidFormat, gint sidModel) { - t_xs_tuneinfo *pResult; - t_xs_sldb_node *tmpLength; + xs_tuneinfo_t *result; + sldb_node_t *tmpLength; gint i; /* Allocate structure */ - pResult = (t_xs_tuneinfo *) g_malloc0(sizeof(t_xs_tuneinfo)); - if (!pResult) { - xs_error("Could not allocate memory for t_xs_tuneinfo ('%s')\n", - pcFilename); + result = (xs_tuneinfo_t *) g_malloc0(sizeof(xs_tuneinfo_t)); + if (!result) { + xs_error("Could not allocate memory for tuneinfo ('%s')\n", + filename); return NULL; } - pResult->sidFilename = XS_CS_FILENAME(pcFilename); - if (!pResult->sidFilename) { + result->sidFilename = XS_CS_FILENAME(filename); + if (!result->sidFilename) { xs_error("Could not allocate sidFilename ('%s')\n", - pcFilename); - g_free(pResult); + filename); + g_free(result); return NULL; } /* Allocate space for subtune information */ - pResult->subTunes = g_malloc0(sizeof(t_xs_subtuneinfo) * (nsubTunes + 1)); - if (!pResult->subTunes) { - xs_error("Could not allocate memory for t_xs_subtuneinfo ('%s', %i)\n", - pcFilename, nsubTunes); + result->subTunes = g_malloc0(sizeof(xs_subtuneinfo_t) * (nsubTunes + 1)); + if (!result->subTunes) { + xs_error("Could not allocate memory for subtuneinfo ('%s', %i)\n", + filename, nsubTunes); - g_free(pResult->sidFilename); - g_free(pResult); + g_free(result->sidFilename); + g_free(result); return NULL; } /* The following allocations don't matter if they fail */ - pResult->sidName = XS_CS_SID(sidName); - pResult->sidComposer = XS_CS_SID(sidComposer); - pResult->sidCopyright = XS_CS_SID(sidCopyright); + result->sidName = XS_CS_SID(sidName); + result->sidComposer = XS_CS_SID(sidComposer); + result->sidCopyright = XS_CS_SID(sidCopyright); - pResult->nsubTunes = nsubTunes; - pResult->startTune = startTune; + result->nsubTunes = nsubTunes; + result->startTune = startTune; - pResult->loadAddr = loadAddr; - pResult->initAddr = initAddr; - pResult->playAddr = playAddr; - pResult->dataFileLen = dataFileLen; - pResult->sidFormat = XS_CS_SID(sidFormat); + result->loadAddr = loadAddr; + result->initAddr = initAddr; + result->playAddr = playAddr; + result->dataFileLen = dataFileLen; + result->sidFormat = XS_CS_SID(sidFormat); - pResult->sidModel = sidModel; + result->sidModel = sidModel; /* Get length information (NOTE: Do not free this!) */ - tmpLength = xs_songlen_get(pcFilename); + tmpLength = xs_songlen_get(filename); /* Fill in sub-tune information */ - for (i = 0; i < pResult->nsubTunes; i++) { - if (tmpLength && (i < tmpLength->nLengths)) - pResult->subTunes[i].tuneLength = tmpLength->sLengths[i]; + for (i = 0; i < result->nsubTunes; i++) { + if (tmpLength && (i < tmpLength->nlengths)) + result->subTunes[i].tuneLength = tmpLength->lengths[i]; else - pResult->subTunes[i].tuneLength = -1; + result->subTunes[i].tuneLength = -1; - pResult->subTunes[i].tuneSpeed = -1; + result->subTunes[i].tuneSpeed = -1; } - return pResult; + return result; } /* Free given tune information structure */ -void xs_tuneinfo_free(t_xs_tuneinfo * pTune) +void xs_tuneinfo_free(xs_tuneinfo_t * tune) { - if (!pTune) return; + if (!tune) return; - g_free(pTune->subTunes); - g_free(pTune->sidFilename); - g_free(pTune->sidName); - g_free(pTune->sidComposer); - g_free(pTune->sidCopyright); - g_free(pTune->sidFormat); - g_free(pTune); + g_free(tune->subTunes); + g_free(tune->sidFilename); + g_free(tune->sidName); + g_free(tune->sidComposer); + g_free(tune->sidCopyright); + g_free(tune->sidFormat); + g_free(tune); }
--- a/src/sid/xs_slsup.h Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_slsup.h Wed Apr 02 19:53:39 2008 +0300 @@ -11,18 +11,18 @@ gint xs_stil_init(void); void xs_stil_close(void); -t_xs_stil_node *xs_stil_get(gchar *pcFilename); +stil_node_t *xs_stil_get(gchar *filename); gint xs_songlen_init(void); void xs_songlen_close(void); -t_xs_sldb_node *xs_songlen_get(const gchar *); +sldb_node_t *xs_songlen_get(const gchar *); -t_xs_tuneinfo *xs_tuneinfo_new(const gchar * pcFilename, +xs_tuneinfo_t *xs_tuneinfo_new(const gchar * pcFilename, gint nsubTunes, gint startTune, const gchar * sidName, const gchar * sidComposer, const gchar * sidCopyright, gint loadAddr, gint initAddr, gint playAddr, gint dataFileLen, const gchar *sidFormat, gint sidModel); -void xs_tuneinfo_free(t_xs_tuneinfo *); +void xs_tuneinfo_free(xs_tuneinfo_t *); #ifdef __cplusplus
--- a/src/sid/xs_stil.c Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_stil.c Wed Apr 02 19:53:39 2008 +0300 @@ -30,42 +30,42 @@ /* Database handling functions */ -static gboolean xs_stildb_node_realloc(t_xs_stil_node *pNode, gint nsubTunes) +static gboolean xs_stildb_node_realloc(stil_node_t *node, gint nsubTunes) { - if (!pNode) return FALSE; + if (!node) return FALSE; /* Re-allocate subTune structure if needed */ - if (nsubTunes > pNode->nsubTunes) { + if (nsubTunes > node->nsubTunes) { gint clearIndex, clearLength; - pNode->subTunes = - (t_xs_stil_subnode **) g_realloc(pNode->subTunes, - (nsubTunes + 1) * sizeof(t_xs_stil_subnode **)); + node->subTunes = + (stil_subnode_t **) g_realloc(node->subTunes, + (nsubTunes + 1) * sizeof(stil_subnode_t **)); - if (!pNode->subTunes) { + if (!node->subTunes) { xs_error("SubTune pointer structure realloc failed.\n"); return FALSE; } /* Clear the newly allocated memory */ - if (pNode->nsubTunes == 0) { + if (node->nsubTunes == 0) { clearIndex = 0; clearLength = nsubTunes + 1; } else { - clearIndex = pNode->nsubTunes + 1; + clearIndex = node->nsubTunes + 1; clearLength = (nsubTunes - clearIndex + 1); } - memset(&(pNode->subTunes[clearIndex]), 0, clearLength * sizeof(t_xs_stil_subnode **)); + memset(&(node->subTunes[clearIndex]), 0, clearLength * sizeof(stil_subnode_t **)); - pNode->nsubTunes = nsubTunes; + node->nsubTunes = nsubTunes; } /* Allocate memory for subTune */ - if (!pNode->subTunes[nsubTunes]) { - pNode->subTunes[nsubTunes] = (t_xs_stil_subnode *) - g_malloc0(sizeof(t_xs_stil_subnode)); + if (!node->subTunes[nsubTunes]) { + node->subTunes[nsubTunes] = (stil_subnode_t *) + g_malloc0(sizeof(stil_subnode_t)); - if (!pNode->subTunes[nsubTunes]) { + if (!node->subTunes[nsubTunes]) { xs_error("SubTune structure malloc failed!\n"); return FALSE; } @@ -75,67 +75,65 @@ } -static void xs_stildb_node_free(t_xs_stil_node *pNode) +static void xs_stildb_node_free(stil_node_t *node) { gint i; - t_xs_stil_subnode *pSub; + stil_subnode_t *subnode; + + if (!node) return; - if (pNode) { - /* Free subtune information */ - for (i = 0; i <= pNode->nsubTunes; i++) { - pSub = pNode->subTunes[i]; - if (pSub) { - g_free(pSub->pName); - g_free(pSub->pAuthor); - g_free(pSub->pInfo); - g_free(pSub->pTitle); - - g_free(pSub); - } + /* Free subtune information */ + for (i = 0; i <= node->nsubTunes; i++) { + subnode = node->subTunes[i]; + if (subnode) { + g_free(subnode->name); + g_free(subnode->author); + g_free(subnode->info); + g_free(subnode->title); + g_free(subnode); } - - g_free(pNode->subTunes); - g_free(pNode->pcFilename); - g_free(pNode); } + g_free(node->subTunes); + g_free(node->filename); + g_free(node); } -static t_xs_stil_node *xs_stildb_node_new(gchar *pcFilename) +static stil_node_t *xs_stildb_node_new(gchar *filename) { - t_xs_stil_node *pResult; + stil_node_t *result; /* Allocate memory for new node */ - pResult = (t_xs_stil_node *) g_malloc0(sizeof(t_xs_stil_node)); - if (!pResult) + result = (stil_node_t *) g_malloc0(sizeof(stil_node_t)); + if (!result) return NULL; /* Allocate filename and initial space for one subtune */ - pResult->pcFilename = g_strdup(pcFilename); - if (!pResult->pcFilename || !xs_stildb_node_realloc(pResult, 1)) { - xs_stildb_node_free(pResult); + result->filename = g_strdup(filename); + if (!result->filename || !xs_stildb_node_realloc(result, 1)) { + xs_stildb_node_free(result); return NULL; } - return pResult; + return result; } /* Insert given node to db linked list */ -static void xs_stildb_node_insert(t_xs_stildb *db, t_xs_stil_node *pNode) +static void xs_stildb_node_insert(xs_stildb_t *db, stil_node_t *node) { - assert(db); + assert(db != NULL); - if (db->pNodes) { + if (db->nodes) { /* The first node's pPrev points to last node */ - LPREV = db->pNodes->pPrev; /* New node's prev = Previous last node */ - db->pNodes->pPrev->pNext = pNode; /* Previous last node's next = New node */ - db->pNodes->pPrev = pNode; /* New last node = New node */ + LPREV = db->nodes->prev; /* New node's prev = Previous last node */ + db->nodes->prev->next = node; /* Previous last node's next = New node */ + db->nodes->prev = node; /* New last node = New node */ LNEXT = NULL; /* But next is NULL! */ } else { - db->pNodes = pNode; /* First node ... */ - LPREV = pNode; /* ... it's also last */ + db->nodes = node; /* First node ... */ + LPREV = node; /* ... it's also last */ LNEXT = NULL; /* But next is NULL! */ } } @@ -146,7 +144,7 @@ #define XS_STILDB_MULTI \ if (isMulti) { \ isMulti = FALSE; \ - xs_pstrcat(&(tmpNode->subTunes[subEntry]->pInfo), "\n");\ + xs_pstrcat(&(tmnode->subTunes[subEntry]->info), "\n");\ } static void XS_STILDB_ERR(gint lineNum, gchar *inLine, const char *fmt, ...) @@ -160,16 +158,16 @@ fprintf(stderr, "#%d: '%s'\n", lineNum, inLine); } -gint xs_stildb_read(t_xs_stildb *db, gchar *dbFilename) +gint xs_stildb_read(xs_stildb_t *db, gchar *dbFilename) { FILE *inFile; gchar inLine[XS_BUF_SIZE + 16]; /* Since we add some chars here and there */ size_t lineNum; - t_xs_stil_node *tmpNode; + stil_node_t *tmnode; gboolean isError, isMulti; gint subEntry; gchar *tmpLine = inLine; - assert(db); + assert(db != NULL); /* Try to open the file */ if ((inFile = fopen(dbFilename, "ra")) == NULL) { @@ -181,7 +179,7 @@ lineNum = 0; isError = FALSE; isMulti = FALSE; - tmpNode = NULL; + tmnode = NULL; subEntry = 0; while (!isError && fgets(inLine, XS_BUF_SIZE, inFile) != NULL) { @@ -196,17 +194,17 @@ case '/': /* Check if we are already parsing entry */ isMulti = FALSE; - if (tmpNode) { + if (tmnode) { XS_STILDB_ERR(lineNum, tmpLine, "New entry found before end of current ('%s')!\n", - tmpNode->pcFilename); - xs_stildb_node_free(tmpNode); + tmnode->filename); + xs_stildb_node_free(tmnode); } /* A new node */ subEntry = 0; - tmpNode = xs_stildb_node_new(tmpLine); - if (!tmpNode) { + tmnode = xs_stildb_node_new(tmpLine); + if (!tmnode) { /* Allocation failed */ XS_STILDB_ERR(lineNum, tmpLine, "Could not allocate new STILdb-node!\n"); @@ -230,7 +228,7 @@ if (subEntry < 1) { XS_STILDB_ERR(lineNum, tmpLine, "Number of subEntry (%i) for '%s' is invalid\n", - subEntry, tmpNode->pcFilename); + subEntry, tmnode->filename); subEntry = 0; } } else { @@ -252,10 +250,10 @@ case '\r': /* End of entry/field */ isMulti = FALSE; - if (tmpNode) { + if (tmnode) { /* Insert to database */ - xs_stildb_node_insert(db, tmpNode); - tmpNode = NULL; + xs_stildb_node_insert(db, tmnode); + tmnode = NULL; } break; @@ -263,13 +261,13 @@ /* Check if we are parsing an entry */ xs_findnext(tmpLine, &linePos); - if (!tmpNode) { + if (!tmnode) { XS_STILDB_ERR(lineNum, tmpLine, "Entry data encountered outside of entry or syntax error!\n"); break; } - if (!xs_stildb_node_realloc(tmpNode, subEntry)) { + if (!xs_stildb_node_realloc(tmnode, subEntry)) { XS_STILDB_ERR(lineNum, tmpLine, "Could not (re)allocate memory for subEntries!\n"); isError = TRUE; @@ -279,30 +277,30 @@ /* Some other type */ if (strncmp(tmpLine, " NAME:", 8) == 0) { XS_STILDB_MULTI; - g_free(tmpNode->subTunes[subEntry]->pName); - tmpNode->subTunes[subEntry]->pName = g_strdup(&tmpLine[9]); + g_free(tmnode->subTunes[subEntry]->name); + tmnode->subTunes[subEntry]->name = g_strdup(&tmpLine[9]); } else if (strncmp(tmpLine, " TITLE:", 8) == 0) { XS_STILDB_MULTI; isMulti = TRUE; - if (!tmpNode->subTunes[subEntry]->pTitle) - tmpNode->subTunes[subEntry]->pTitle = g_strdup(&tmpLine[9]); - xs_pstrcat(&(tmpNode->subTunes[subEntry]->pInfo), &tmpLine[2]); + if (!tmnode->subTunes[subEntry]->title) + tmnode->subTunes[subEntry]->title = g_strdup(&tmpLine[9]); + xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[2]); } else if (strncmp(tmpLine, " AUTHOR:", 8) == 0) { XS_STILDB_MULTI; - g_free(tmpNode->subTunes[subEntry]->pAuthor); - tmpNode->subTunes[subEntry]->pAuthor = g_strdup(&tmpLine[9]); + g_free(tmnode->subTunes[subEntry]->author); + tmnode->subTunes[subEntry]->author = g_strdup(&tmpLine[9]); } else if (strncmp(tmpLine, " ARTIST:", 8) == 0) { XS_STILDB_MULTI; isMulti = TRUE; - xs_pstrcat(&(tmpNode->subTunes[subEntry]->pInfo), &tmpLine[1]); + xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[1]); } else if (strncmp(tmpLine, "COMMENT:", 8) == 0) { XS_STILDB_MULTI; isMulti = TRUE; - xs_pstrcat(&(tmpNode->subTunes[subEntry]->pInfo), tmpLine); + xs_pstrcat(&(tmnode->subTunes[subEntry]->info), tmpLine); } else { if (isMulti) { - xs_pstrcat(&(tmpNode->subTunes[subEntry]->pInfo), " "); - xs_pstrcat(&(tmpNode->subTunes[subEntry]->pInfo), &tmpLine[linePos]); + xs_pstrcat(&(tmnode->subTunes[subEntry]->info), " "); + xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[linePos]); } else { XS_STILDB_ERR(lineNum, tmpLine, "Entry continuation found when isMulti == FALSE.\n"); @@ -316,8 +314,8 @@ } /* while */ /* Check if there is one remaining node */ - if (tmpNode) - xs_stildb_node_insert(db, tmpNode); + if (tmnode) + xs_stildb_node_insert(db, tmnode); /* Close the file */ fclose(inFile); @@ -328,53 +326,53 @@ /* Compare two nodes */ -static gint xs_stildb_cmp(const void *pNode1, const void *pNode2) +static gint xs_stildb_cmp(const void *node1, const void *node2) { /* We assume here that we never ever get NULL-pointers or similar */ return strcmp( - (*(t_xs_stil_node **) pNode1)->pcFilename, - (*(t_xs_stil_node **) pNode2)->pcFilename); + (*(stil_node_t **) node1)->filename, + (*(stil_node_t **) node2)->filename); } /* (Re)create index */ -gint xs_stildb_index(t_xs_stildb *db) +gint xs_stildb_index(xs_stildb_t *db) { - t_xs_stil_node *pCurr; + stil_node_t *curr; size_t i; /* Free old index */ - if (db->ppIndex) { - g_free(db->ppIndex); - db->ppIndex = NULL; + if (db->pindex) { + g_free(db->pindex); + db->pindex = NULL; } /* Get size of db */ - pCurr = db->pNodes; + curr = db->nodes; db->n = 0; - while (pCurr) { + while (curr) { db->n++; - pCurr = pCurr->pNext; + curr = curr->next; } /* Check number of nodes */ if (db->n > 0) { /* Allocate memory for index-table */ - db->ppIndex = (t_xs_stil_node **) g_malloc(sizeof(t_xs_stil_node *) * db->n); - if (!db->ppIndex) + db->pindex = (stil_node_t **) g_malloc(sizeof(stil_node_t *) * db->n); + if (!db->pindex) return -1; /* Get node-pointers to table */ i = 0; - pCurr = db->pNodes; - while (pCurr && (i < db->n)) { - db->ppIndex[i++] = pCurr; - pCurr = pCurr->pNext; + curr = db->nodes; + while (curr && (i < db->n)) { + db->pindex[i++] = curr; + curr = curr->next; } /* Sort the indexes */ - qsort(db->ppIndex, db->n, sizeof(t_xs_stil_node *), xs_stildb_cmp); + qsort(db->pindex, db->n, sizeof(stil_node_t *), xs_stildb_cmp); } return 0; @@ -383,27 +381,27 @@ /* Free a given STIL database */ -void xs_stildb_free(t_xs_stildb *db) +void xs_stildb_free(xs_stildb_t *db) { - t_xs_stil_node *pCurr, *pNext; + stil_node_t *curr, *next; if (!db) return; /* Free the memory allocated for nodes */ - pCurr = db->pNodes; - while (pCurr) { - pNext = pCurr->pNext; - xs_stildb_node_free(pCurr); - pCurr = pNext; + curr = db->nodes; + while (curr) { + next = curr->next; + xs_stildb_node_free(curr); + curr = next; } - db->pNodes = NULL; + db->nodes = NULL; /* Free memory allocated for index */ - if (db->ppIndex) { - g_free(db->ppIndex); - db->ppIndex = NULL; + if (db->pindex) { + g_free(db->pindex); + db->pindex = NULL; } /* Free structure */ @@ -414,18 +412,18 @@ /* Get STIL information node from database */ -t_xs_stil_node *xs_stildb_get_node(t_xs_stildb *db, gchar *pcFilename) +stil_node_t *xs_stildb_get_node(xs_stildb_t *db, gchar *filename) { - t_xs_stil_node keyItem, *key, **item; + stil_node_t keyItem, *key, **item; /* Check the database pointers */ - if (!db || !db->pNodes || !db->ppIndex) + if (!db || !db->nodes || !db->pindex) return NULL; /* Look-up index using binary search */ - keyItem.pcFilename = pcFilename; + keyItem.filename = filename; key = &keyItem; - item = bsearch(&key, db->ppIndex, db->n, sizeof(t_xs_stil_node *), xs_stildb_cmp); + item = bsearch(&key, db->pindex, db->n, sizeof(stil_node_t *), xs_stildb_cmp); if (item) return *item; else
--- a/src/sid/xs_stil.h Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_stil.h Wed Apr 02 19:53:39 2008 +0300 @@ -10,35 +10,34 @@ /* Types */ typedef struct { - gchar *pName, - *pAuthor, - *pTitle, - *pInfo; -} t_xs_stil_subnode; + gchar *name, + *author, + *title, + *info; +} stil_subnode_t; -typedef struct _t_xs_stil_node { - gchar *pcFilename; +typedef struct _stil_node_t { + gchar *filename; gint nsubTunes; - t_xs_stil_subnode **subTunes; - - struct _t_xs_stil_node *pPrev, *pNext; -} t_xs_stil_node; + stil_subnode_t **subTunes; + struct _stil_node_t *prev, *next; +} stil_node_t; typedef struct { - t_xs_stil_node *pNodes, - **ppIndex; + stil_node_t *nodes, + **pindex; size_t n; -} t_xs_stildb; +} xs_stildb_t; /* Functions */ -gint xs_stildb_read(t_xs_stildb *, gchar *); -gint xs_stildb_index(t_xs_stildb *); -void xs_stildb_free(t_xs_stildb *); -t_xs_stil_node * xs_stildb_get_node(t_xs_stildb *, gchar *); +gint xs_stildb_read(xs_stildb_t *, gchar *); +gint xs_stildb_index(xs_stildb_t *); +void xs_stildb_free(xs_stildb_t *); +stil_node_t * xs_stildb_get_node(xs_stildb_t *, gchar *); #ifdef __cplusplus }
--- a/src/sid/xs_support.c Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_support.c Wed Apr 02 19:53:39 2008 +0300 @@ -24,13 +24,13 @@ #include <ctype.h> -guint16 xs_fread_be16(t_xs_file *f) +guint16 xs_fread_be16(xs_file_t *f) { return (((guint16) xs_fgetc(f)) << 8) | ((guint16) xs_fgetc(f)); } -guint32 xs_fread_be32(t_xs_file *f) +guint32 xs_fread_be32(xs_file_t *f) { return (((guint32) xs_fgetc(f)) << 24) | (((guint32) xs_fgetc(f)) << 16) | @@ -41,13 +41,13 @@ /* Load a file to a buffer, return 0 on success, negative value on error */ -gint xs_fload_buffer(const gchar *pcFilename, guint8 **buf, size_t *bufSize) +gint xs_fload_buffer(const gchar *filename, guint8 **buf, size_t *bufSize) { - t_xs_file *f; + xs_file_t *f; glong seekPos; /* Open file, get file size */ - if ((f = xs_fopen(pcFilename, "rb")) == NULL) + if ((f = xs_fopen(filename, "rb")) == NULL) return -1; xs_fseek(f, 0, SEEK_END);
--- a/src/sid/xs_support.h Wed Apr 02 18:06:07 2008 +0300 +++ b/src/sid/xs_support.h Wed Apr 02 19:53:39 2008 +0300 @@ -67,7 +67,7 @@ /* VFS replacement functions */ #ifdef __AUDACIOUS_NEWVFS__ -#define t_xs_file VFSFile +#define xs_file_t VFSFile #define xs_fopen(a,b) aud_vfs_fopen(a,b) #define xs_fclose(a) aud_vfs_fclose(a) #define xs_fgetc(a) aud_vfs_getc(a) @@ -77,7 +77,7 @@ #define xs_ftell(a) aud_vfs_ftell(a) #define xs_fseek(a,b,c) aud_vfs_fseek(a,b,c) #else -#define t_xs_file FILE +#define xs_file_t FILE #define xs_fopen(a,b) fopen(a,b) #define xs_fclose(a) fclose(a) #define xs_fgetc(a) fgetc(a) @@ -87,8 +87,8 @@ #define xs_ftell(a) ftell(a) #define xs_fseek(a,b,c) fseek(a,b,c) #endif -guint16 xs_fread_be16(t_xs_file *); -guint32 xs_fread_be32(t_xs_file *); +guint16 xs_fread_be16(xs_file_t *); +guint32 xs_fread_be32(xs_file_t *); gint xs_fload_buffer(const gchar *, guint8 **, size_t *);