# HG changeset patch # User Matti Hamalainen # Date 1207154819 -10800 # Node ID acaba070cf492df79fa7fbff94596d324ae3ea5c # Parent e9257f006f416418447e551e3e8c71c0ca833cca Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ... diff -r e9257f006f41 -r acaba070cf49 src/xmms-sid.c --- a/src/xmms-sid.c Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xmms-sid.c Wed Apr 02 19:46:59 2008 +0300 @@ -56,7 +56,7 @@ /* * List of players and links to their functions */ -t_xs_player xs_playerlist[] = { +xs_player_t xs_playerlist[] = { #ifdef HAVE_SIDPLAY1 {XS_ENG_SIDPLAY1, xs_sidplay1_probe, @@ -79,13 +79,13 @@ #endif }; -const gint xs_nplayerlist = (sizeof(xs_playerlist) / sizeof(t_xs_player)); +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; @@ -144,7 +144,7 @@ XS_MUTEX_LOCK(xs_cfg); /* Initialize status and sanitize configuration */ - xs_memset(&xs_status, 0, sizeof(xs_status)); + memset(&xs_status, 0, sizeof(xs_status)); if (xs_cfg.audioFrequency < 8000) xs_cfg.audioFrequency = 8000; @@ -173,7 +173,7 @@ if (xs_playerlist[iPlayer].plrIdent == xs_cfg.playerEngine) { if (xs_playerlist[iPlayer].plrInit(&xs_status)) { isInitialized = TRUE; - xs_status.sidPlayer = (t_xs_player *) & xs_playerlist[iPlayer]; + xs_status.sidPlayer = (xs_player_t *) & xs_playerlist[iPlayer]; } } iPlayer++; @@ -185,7 +185,7 @@ while ((iPlayer < xs_nplayerlist) && !isInitialized) { if (xs_playerlist[iPlayer].plrInit(&xs_status)) { isInitialized = TRUE; - xs_status.sidPlayer = (t_xs_player *) & xs_playerlist[iPlayer]; + xs_status.sidPlayer = (xs_player_t *) & xs_playerlist[iPlayer]; xs_cfg.playerEngine = xs_playerlist[iPlayer].plrIdent; } else iPlayer++; @@ -206,13 +206,13 @@ /* Initialize song-length database */ xs_songlen_close(); if (xs_cfg.songlenDBEnable && (xs_songlen_init() != 0)) { - xs_error(_("Error initializing song-length database!\n")); + xs_error("Error initializing song-length database!\n"); } /* Initialize STIL database */ xs_stil_close(); if (xs_cfg.stilDBEnable && (xs_stil_init() != 0)) { - xs_error(_("Error initializing STIL database!\n")); + xs_error("Error initializing STIL database!\n"); } } @@ -272,7 +272,7 @@ /* Try to detect via detection routine, if required */ if (xs_cfg.detectMagic) { - t_xs_file *f; + xs_file_t *f; if ((f = xs_fopen(pcFilename, "rb")) != NULL) { if (xs_status.sidPlayer->plrProbe(f)) return TRUE; @@ -310,8 +310,8 @@ */ void *xs_playthread(void *argPointer) { - t_xs_status myStatus; - t_xs_tuneinfo *myTune; + xs_status_t myStatus; + xs_tuneinfo_t *myTune; gboolean audioOpen = FALSE, doPlay = FALSE, isFound = FALSE; gint audioGot, songLength, i; gchar *audioBuffer = NULL, *oversampleBuffer = NULL, *tmpTitle; @@ -321,7 +321,7 @@ /* Initialize */ XSDEBUG("entering player thread\n"); XS_MUTEX_LOCK(xs_status); - memcpy(&myStatus, &xs_status, sizeof(t_xs_status)); + memcpy(&myStatus, &xs_status, sizeof(xs_status_t)); myTune = xs_status.tuneInfo; for (i = 0; i <= myTune->nsubTunes; i++) myTune->subTunes[i].tunePlayed = FALSE; @@ -330,14 +330,14 @@ /* Allocate audio buffer */ audioBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE); if (audioBuffer == NULL) { - xs_error(_("Couldn't allocate memory for audio data buffer!\n")); + xs_error("Couldn't allocate memory for audio data buffer!\n"); goto xs_err_exit; } if (myStatus.oversampleEnable) { oversampleBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE * myStatus.oversampleFactor); if (oversampleBuffer == NULL) { - xs_error(_("Couldn't allocate memory for audio oversampling buffer!\n")); + xs_error("Couldn't allocate memory for audio oversampling buffer!\n"); goto xs_err_exit; } } @@ -414,7 +414,7 @@ /* Initialize song */ if (!myStatus.sidPlayer->plrInitSong(&myStatus)) { - xs_error(_("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n"), + xs_error("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n", myTune->sidFilename, myStatus.currSong); goto xs_err_exit; } @@ -425,7 +425,7 @@ if (!xs_plugin_ip.output-> open_audio(myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels)) { - xs_error(_("Couldn't open XMMS audio output (fmt=%x, freq=%i, nchan=%i)!\n"), + xs_error("Couldn't open XMMS audio output (fmt=%x, freq=%i, nchan=%i)!\n", myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels); @@ -471,7 +471,7 @@ /* Execute rate-conversion with filtering */ if (xs_filter_rateconv(audioBuffer, oversampleBuffer, myStatus.audioFormat, myStatus.oversampleFactor, audioGot) < 0) { - xs_error(_("Oversampling rate-conversion pass failed.\n")); + xs_error("Oversampling rate-conversion pass failed.\n"); XS_MUTEX_LOCK(xs_status); xs_status.isError = TRUE; XS_MUTEX_UNLOCK(xs_status); @@ -591,7 +591,7 @@ /* Start the playing thread! */ if (pthread_create(&xs_decode_thread, NULL, xs_playthread, NULL) < 0) { - xs_error(_("Couldn't create playing thread!\n")); + xs_error("Couldn't create playing thread!\n"); xs_tuneinfo_free(xs_status.tuneInfo); xs_status.tuneInfo = NULL; xs_status.sidPlayer->plrDeleteSID(&xs_status); @@ -938,7 +938,7 @@ */ void xs_get_song_info(gchar * songFilename, gchar ** songTitle, gint * songLength) { - t_xs_tuneinfo *pInfo; + xs_tuneinfo_t *pInfo; XS_MUTEX_LOCK(xs_status); diff -r e9257f006f41 -r acaba070cf49 src/xmms-sid.h --- a/src/xmms-sid.h Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xmms-sid.h Wed Apr 02 19:46:59 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 diff -r e9257f006f41 -r acaba070cf49 src/xs_config.c --- a/src/xs_config.c Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_config.c Wed Apr 02 19:46:59 2008 +0300 @@ -210,7 +210,7 @@ XSDEBUG("initializing configuration ...\n"); XS_MUTEX_LOCK(xs_cfg); - xs_memset(&xs_cfg, 0, sizeof(xs_cfg)); + memset(&xs_cfg, 0, sizeof(xs_cfg)); /* Initialize values with sensible defaults */ xs_cfg.audioBitsPerSample = XS_RES_16BIT; diff -r e9257f006f41 -r acaba070cf49 src/xs_fileinfo.c --- a/src/xs_fileinfo.c Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_fileinfo.c Wed Apr 02 19:46:59 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; @@ -170,8 +170,8 @@ void xs_fileinfo(gchar * pcFilename) { 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; @@ -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; } diff -r e9257f006f41 -r acaba070cf49 src/xs_length.c --- a/src/xs_length.c Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_length.c Wed Apr 02 19:46:59 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,55 +62,55 @@ /* 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) { - xs_error(_("Error allocating new node. Fatal error.\n")); + 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_error("'=' expected on column #%d.\n", linePos); + 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) { - xs_error(_("Could not allocate memory for node.\n")); - xs_sldb_node_free(tmpNode); + 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(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,17 +191,17 @@ /* 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 */ if ((inFile = fopen(dbFilename, "ra")) == NULL) { - xs_error(_("Could not open SongLengthDB '%s'\n"), dbFilename); + xs_error("Could not open SongLengthDB '%s'\n", dbFilename); return -1; } @@ -221,19 +221,19 @@ for (hashLen = 0; inLine[linePos] && isxdigit(inLine[linePos]); hashLen++, linePos++); if (hashLen != XS_MD5HASH_LENGTH_CH) { - xs_error(_("Invalid MD5-hash in SongLengthDB file '%s' line #%d!\n"), + xs_error("Invalid MD5-hash in SongLengthDB file '%s' line #%d!\n", 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"), + xs_error("Invalid entry in SongLengthDB file '%s' line #%d!\n", dbFilename, lineNum); } } } else if ((inLine[linePos] != ';') && (inLine[linePos] != '[') && (inLine[linePos] != 0)) { - xs_error(_("Invalid line in SongLengthDB file '%s' line #%d\n"), + xs_error("Invalid line 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; diff -r e9257f006f41 -r acaba070cf49 src/xs_length.h --- a/src/xs_length.h Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_length.h Wed Apr 02 19:46:59 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 } diff -r e9257f006f41 -r acaba070cf49 src/xs_md5.c --- a/src/xs_md5.c Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_md5.c Wed Apr 02 19:46:59 2008 +0300 @@ -12,10 +12,11 @@ #include -#ifndef WORDS_BIGENDIAN +#if G_BYTE_ORDER == G_LITTLE_ENDIAN #define xs_md5_bytereverse(buf, len) /* Nothing */ #else -void xs_md5_bytereverse(guint8 *buf, guint l) +#if G_BYTE_ORDER == G_BIG_ENDIAN +static void xs_md5_bytereverse(guint8 *buf, guint l) { guint32 t; do { @@ -24,13 +25,16 @@ buf += sizeof(guint32); } while (--l); } +#else +#error Unsupported endianess! +#endif #endif /* 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; @@ -53,7 +57,7 @@ #define MD5STEP(f, w, x, y, z, data, s) \ ( w += f(x, y, z) + data, w = 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; @@ -140,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; @@ -153,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; @@ -168,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); @@ -179,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; @@ -205,15 +207,15 @@ /* Pad out to 56 mod 64 */ if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ - xs_memset(p, 0, count); + memset(p, 0, count); xs_md5_bytereverse(ctx->in, 16); xs_md5_transform(ctx->buf, (guint32 *) ctx->in); /* Now fill the next block with 56 bytes */ - xs_memset(ctx->in, 0, 56); + memset(ctx->in, 0, 56); } else { /* Pad block to 56 bytes */ - xs_memset(p, 0, count - 8); + memset(p, 0, count - 8); } xs_md5_bytereverse(ctx->in, 14); @@ -224,5 +226,5 @@ xs_md5_transform(ctx->buf, (guint32 *) ctx->in); xs_md5_bytereverse((guint8 *) ctx->buf, 4); memcpy(digest, ctx->buf, 16); - xs_memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ } diff -r e9257f006f41 -r acaba070cf49 src/xs_md5.h --- a/src/xs_md5.h Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_md5.h Wed Apr 02 19:46:59 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 diff -r e9257f006f41 -r acaba070cf49 src/xs_player.h --- a/src/xs_player.h Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_player.h Wed Apr 02 19:46:59 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); diff -r e9257f006f41 -r acaba070cf49 src/xs_sidplay.h --- a/src/xs_sidplay.h Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_sidplay.h Wed Apr 02 19:46:59 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) diff -r e9257f006f41 -r acaba070cf49 src/xs_sidplay1.cc --- a/src/xs_sidplay1.cc Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_sidplay1.cc Wed Apr 02 19:46:59 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,27 +80,27 @@ /* 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 */ myEngine->currEng = new emuEngine(); if (!myEngine->currEng) { - xs_error(_("[SIDPlay1] Could not initialize emulation engine.\n")); + xs_error("[SIDPlay1] Could not initialize emulation engine.\n"); g_free(myEngine); return FALSE; } /* Verify endianess */ if (!myEngine->currEng->verifyEndianess()) { - xs_error(_("[SIDPlay1] Endianess verification failed.\n")); + xs_error("[SIDPlay1] Endianess verification failed.\n"); delete myEngine->currEng; g_free(myEngine); return FALSE; @@ -235,14 +235,14 @@ /* Now set the emulator configuration */ if (!myEngine->currEng->setConfig(myEngine->currConfig)) { - xs_error(_("[SIDPlay1] Emulator engine configuration failed!\n")); + xs_error("[SIDPlay1] Emulator engine configuration failed!\n"); return FALSE; } /* Create sidtune object */ myEngine->currTune = new sidTune(0); if (!myEngine->currTune) { - xs_error(_("[SIDPlay1] Could not initialize SIDTune object.\n")); + xs_error("[SIDPlay1] Could not initialize SIDTune object.\n"); return FALSE; } @@ -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,21 +279,21 @@ /* 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) { - xs_error(_("[SIDPlay1] SID-tune struct pointer was NULL. This should not happen, report to XMMS-SID author.\n")); + xs_error("[SIDPlay1] SID-tune struct pointer was NULL. This should not happen, report to XMMS-SID author.\n"); return FALSE; } if (!myEngine->currTune->getStatus()) { - xs_error(_("[SIDPlay1] SID-tune status check failed. This should not happen, report to XMMS-SID author.\n")); + xs_error("[SIDPlay1] SID-tune status check failed. This should not happen, report to XMMS-SID author.\n"); return FALSE; } @@ -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); diff -r e9257f006f41 -r acaba070cf49 src/xs_sidplay1.h --- a/src/xs_sidplay1.h Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_sidplay1.h Wed Apr 02 19:46:59 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 } diff -r e9257f006f41 -r acaba070cf49 src/xs_sidplay2.cc --- a/src/xs_sidplay2.cc Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_sidplay2.cc Wed Apr 02 19:46:59 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,23 +82,23 @@ /* 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; /* Initialize the engine */ myEngine->currEng = new sidplay2; if (!myEngine->currEng) { - xs_error(_("[SIDPlay2] Could not initialize emulation engine.\n")); + xs_error("[SIDPlay2] Could not initialize emulation engine.\n"); return FALSE; } @@ -173,10 +173,14 @@ break; case FMT_U16_NE: -#ifdef WORDS_BIGENDIAN +#if G_BYTE_ORDER == G_BIG_ENDIAN myEngine->currConfig.sampleFormat = SID2_BIG_UNSIGNED; #else +#if G_BYTE_ORDER == G_LITTLE_ENDIAN myEngine->currConfig.sampleFormat = SID2_LITTLE_UNSIGNED; +#else +#error Unsupported endianess! +#endif #endif break; @@ -190,10 +194,14 @@ default: myStatus->audioFormat = FMT_S16_NE; -#ifdef WORDS_BIGENDIAN +#if G_BYTE_ORDER == G_BIG_ENDIAN myEngine->currConfig.sampleFormat = SID2_BIG_SIGNED; #else +#if G_BYTE_ORDER == G_LITTLE_ENDIAN myEngine->currConfig.sampleFormat = SID2_LITTLE_SIGNED; +#else +#error Unsupported endianess! +#endif #endif break; @@ -205,7 +213,7 @@ f = &(xs_cfg.sid2Filter); XSDEBUG("using filter '%s', %d points\n", f->name, f->npoints); if (f->npoints > XS_SIDPLAY2_NFPOINTS) { - xs_error(_("[SIDPlay2] Invalid number of filter curve points (%d > %d)\n"), + xs_error("[SIDPlay2] Invalid number of filter curve points (%d > %d)\n", f->npoints, XS_SIDPLAY2_NFPOINTS); f->npoints = XS_SIDPLAY2_NFPOINTS; } @@ -226,13 +234,13 @@ /* Builder object created, initialize it */ rs->create((myEngine->currEng->info()).maxsids); if (!*rs) { - xs_error(_("reSID->create() failed.\n")); + xs_error("reSID->create() failed.\n"); return FALSE; } rs->filter(xs_cfg.emulateFilters); if (!*rs) { - xs_error(_("reSID->filter(%d) failed.\n"), xs_cfg.emulateFilters); + xs_error("reSID->filter(%d) failed.\n", xs_cfg.emulateFilters); return FALSE; } @@ -240,7 +248,7 @@ // ... WHEN/IF resid-builder+libsidplay2 gets fixed rs->sampling(tmpFreq); if (!*rs) { - xs_error(_("reSID->sampling(%d) failed.\n"), tmpFreq); + xs_error("reSID->sampling(%d) failed.\n", tmpFreq); return FALSE; } @@ -250,7 +258,7 @@ rs->filter((sid_filter_t *) NULL); if (!*rs) { - xs_error(_("reSID->filter(NULL) failed.\n")); + xs_error("reSID->filter(NULL) failed.\n"); return FALSE; } } @@ -264,13 +272,13 @@ /* Builder object created, initialize it */ hs->create((myEngine->currEng->info()).maxsids); if (!*hs) { - xs_error(_("hardSID->create() failed.\n")); + xs_error("hardSID->create() failed.\n"); return FALSE; } hs->filter(xs_cfg.emulateFilters); if (!*hs) { - xs_error(_("hardSID->filter(%d) failed.\n"), xs_cfg.emulateFilters); + xs_error("hardSID->filter(%d) failed.\n", xs_cfg.emulateFilters); return FALSE; } } @@ -278,7 +286,7 @@ #endif if (!myEngine->currBuilder) { - xs_error(_("[SIDPlay2] Could not initialize SIDBuilder object.\n")); + xs_error("[SIDPlay2] Could not initialize SIDBuilder object.\n"); return FALSE; } @@ -292,7 +300,7 @@ break; default: - xs_error(_("[SIDPlay2] Invalid clockSpeed=%d, falling back to PAL.\n"), + xs_error("[SIDPlay2] Invalid clockSpeed=%d, falling back to PAL.\n", xs_cfg.clockSpeed); case XS_CLOCK_PAL: @@ -316,7 +324,7 @@ if ((xs_cfg.sid2OptLevel >= 0) && (xs_cfg.sid2OptLevel <= SID2_MAX_OPTIMISATION)) myEngine->currConfig.optimisation = xs_cfg.sid2OptLevel; else { - xs_error(_("Invalid sid2OptLevel=%d, falling back to %d.\n"), + xs_error("Invalid sid2OptLevel=%d, falling back to %d.\n", xs_cfg.sid2OptLevel, SID2_DEFAULT_OPTIMISATION); xs_cfg.sid2OptLevel = @@ -340,14 +348,14 @@ /* Now set the emulator configuration */ if (myEngine->currEng->config(myEngine->currConfig) < 0) { - xs_error(_("[SIDPlay2] Emulator engine configuration failed!\n")); + xs_error("[SIDPlay2] Emulator engine configuration failed!\n"); return FALSE; } /* Create the sidtune */ myEngine->currTune = new SidTune(0); if (!myEngine->currTune) { - xs_error(_("[SIDPlay2] Could not initialize SIDTune object.\n")); + xs_error("[SIDPlay2] Could not initialize SIDTune object.\n"); return FALSE; } @@ -357,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) { @@ -389,21 +397,21 @@ /* 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)) { - xs_error(_("[SIDPlay2] currTune->selectSong() failed\n")); + xs_error("[SIDPlay2] currTune->selectSong() failed\n"); return FALSE; } if (myEngine->currEng->load(myEngine->currTune) < 0) { - xs_error(_("[SIDPlay2] currEng->load() failed\n")); + xs_error("[SIDPlay2] currEng->load() failed\n"); return FALSE; } @@ -415,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); @@ -429,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 */ @@ -453,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); @@ -469,7 +477,7 @@ /* Hardware backend flushing */ -void xs_sidplay2_flush(t_xs_status * myStatus) +void xs_sidplay2_flush(xs_status_t * myStatus) { assert(myStatus); diff -r e9257f006f41 -r acaba070cf49 src/xs_sidplay2.h --- a/src/xs_sidplay2.h Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_sidplay2.h Wed Apr 02 19:46:59 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 } diff -r e9257f006f41 -r acaba070cf49 src/xs_slsup.c --- a/src/xs_slsup.c Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_slsup.c Wed Apr 02 19:46:59 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) { - xs_error(_("Could not allocate sidFilename ('%s')\n"), - pcFilename); - g_free(pResult); + result->sidFilename = XS_CS_FILENAME(filename); + if (!result->sidFilename) { + xs_error("Could not allocate sidFilename ('%s')\n", + 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); } diff -r e9257f006f41 -r acaba070cf49 src/xs_slsup.h --- a/src/xs_slsup.h Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_slsup.h Wed Apr 02 19:46:59 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 diff -r e9257f006f41 -r acaba070cf49 src/xs_stil.c --- a/src/xs_stil.c Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_stil.c Wed Apr 02 19:46:59 2008 +0300 @@ -30,43 +30,43 @@ /* 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) { - xs_error(_("SubTune pointer structure realloc failed.\n")); + 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); } - xs_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]) { - xs_error(_("SubTune structure malloc failed!\n")); + 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,21 +158,20 @@ 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) { - xs_error(_("Could not open STILDB '%s'\n"), - dbFilename); + xs_error("Could not open STILDB '%s'\n", dbFilename); return -1; } @@ -182,7 +179,7 @@ lineNum = 0; isError = FALSE; isMulti = FALSE; - tmpNode = NULL; + tmnode = NULL; subEntry = 0; while (!isError && fgets(inLine, XS_BUF_SIZE, inFile) != NULL) { @@ -197,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"); @@ -231,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 { @@ -253,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; @@ -264,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; @@ -280,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"); @@ -317,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); @@ -329,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; @@ -384,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 */ @@ -415,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 diff -r e9257f006f41 -r acaba070cf49 src/xs_stil.h --- a/src/xs_stil.h Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_stil.h Wed Apr 02 19:46:59 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 } diff -r e9257f006f41 -r acaba070cf49 src/xs_support.c --- a/src/xs_support.c Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_support.c Wed Apr 02 19:46:59 2008 +0300 @@ -24,65 +24,13 @@ #include -#ifndef __AUDACIOUS_NEWVFS__ -/* File handling - */ -t_xs_file *xs_fopen(const gchar *path, const gchar *mode) -{ - return fopen(path, mode); -} - - -gint xs_fclose(t_xs_file *f) -{ - return fclose(f); -} - - -gint xs_fgetc(t_xs_file *f) -{ - return fgetc(f); -} - - -size_t xs_fread(void *p, size_t s, size_t n, t_xs_file *f) -{ - return fread(p, s, n, f); -} - - -gint xs_feof(t_xs_file *f) -{ - return feof(f); -} - - -gint xs_ferror(t_xs_file *f) -{ - return ferror(f); -} - - -glong xs_ftell(t_xs_file *f) -{ - return ftell(f); -} - - -gint xs_fseek(t_xs_file *f, glong o, gint w) -{ - return fseek(f, o, w); -} -#endif - - -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) | @@ -93,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); @@ -139,9 +87,6 @@ } - - - /* Copy a string */ gchar *xs_strncpy(gchar *pDest, const gchar *pSource, size_t n) @@ -298,16 +243,3 @@ (*piPos)++; } - -#ifndef HAVE_MEMSET -void *xs_memset(void *p, int c, size_t n) -{ - guint8 *dp; - - dp = (guint8 *) p; - while (n--) - *(dp++) = c; - - return p; -} -#endif diff -r e9257f006f41 -r acaba070cf49 src/xs_support.h --- a/src/xs_support.h Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_support.h Wed Apr 02 19:46:59 2008 +0300 @@ -16,7 +16,6 @@ #include #include #include -#define HAVE_MEMSET #else #include #include @@ -68,8 +67,7 @@ /* VFS replacement functions */ #ifdef __AUDACIOUS_NEWVFS__ -#include -#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) @@ -79,18 +77,18 @@ #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 -t_xs_file *xs_fopen(const gchar *, const gchar *); -gint xs_fclose(t_xs_file *); -gint xs_fgetc(t_xs_file *); -size_t xs_fread(void *, size_t, size_t, t_xs_file *); -gint xs_feof(t_xs_file *); -gint xs_ferror(t_xs_file *); -glong xs_ftell(t_xs_file *); -gint xs_fseek(t_xs_file *, glong, gint); +#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) +#define xs_fread(a,b,c,d) fread(a,b,c,d) +#define xs_feof(a) feof(a) +#define xs_ferror(a) ferror(a) +#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 *); @@ -105,12 +103,6 @@ void xs_findeol(const gchar *, size_t *); void xs_findnum(const gchar *, size_t *); -#ifdef HAVE_MEMSET -#define xs_memset memset -#else -void *xs_memset(void *, int, size_t); -#endif - #ifdef __cplusplus } #endif diff -r e9257f006f41 -r acaba070cf49 src/xs_title.c --- a/src/xs_title.c Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_title.c Wed Apr 02 19:46:59 2008 +0300 @@ -52,25 +52,25 @@ /* Create a title string based on given information and settings. */ #define VPUTCH(MCH) \ - if (iIndex < XS_BUF_SIZE) tmpBuf[iIndex++] = MCH; + if (index < XS_BUF_SIZE) tmpBuf[index++] = MCH; #define VPUTSTR(MSTR) { \ if (MSTR) { \ - if ((iIndex + strlen(MSTR) + 1) < XS_BUF_SIZE) {\ - strcpy(&tmpBuf[iIndex], MSTR); \ - iIndex += strlen(MSTR); \ + if ((index + strlen(MSTR) + 1) < XS_BUF_SIZE) {\ + strcpy(&tmpBuf[index], MSTR); \ + index += strlen(MSTR); \ } else \ - iIndex = XS_BUF_SIZE; \ + index = XS_BUF_SIZE; \ } \ } -gchar *xs_make_titlestring(t_xs_tuneinfo *p, gint subTune) +gchar *xs_make_titlestring(xs_tuneinfo_t *p, gint subTune) { gchar *tmpFilename, *tmpFilePath, *tmpFileExt, - *pcStr, *pcResult, tmpStr[XS_BUF_SIZE], tmpBuf[XS_BUF_SIZE]; - t_xs_subtuneinfo *subInfo; - gint iIndex; + *str, *result, tmpStr[XS_BUF_SIZE], tmpBuf[XS_BUF_SIZE]; + xs_subtuneinfo_t *subInfo; + gint index; /* Get filename parts */ xs_path_split(p->sidFilename, &tmpFilename, @@ -107,7 +107,7 @@ pTuple->genre = g_strdup("SID-tune"); pTuple->comment = g_strdup(p->sidCopyright); - pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), pTuple); + result = xmms_get_titlestring(xmms_get_gentitle_format(), pTuple); g_free(pTuple->track_name); g_free(pTuple->album_name); @@ -120,12 +120,12 @@ #endif { /* Create the string */ - pcStr = xs_cfg.titleFormat; - iIndex = 0; - while (*pcStr && (iIndex < XS_BUF_SIZE)) { - if (*pcStr == '%') { - pcStr++; - switch (*pcStr) { + str = xs_cfg.titleFormat; + index = 0; + while (*str && (index < XS_BUF_SIZE)) { + if (*str == '%') { + str++; + switch (*str) { case '%': VPUTCH('%'); break; @@ -202,20 +202,20 @@ break; } } else - VPUTCH(*pcStr); + VPUTCH(*str); - pcStr++; + str++; } - tmpBuf[iIndex] = 0; + tmpBuf[index] = 0; /* Make resulting string */ - pcResult = g_strdup(tmpBuf); + result = g_strdup(tmpBuf); } /* Free temporary strings */ g_free(tmpFilename); g_free(tmpFilePath); - return pcResult; + return result; } diff -r e9257f006f41 -r acaba070cf49 src/xs_title.h --- a/src/xs_title.h Wed Mar 26 08:55:29 2008 +0200 +++ b/src/xs_title.h Wed Apr 02 19:46:59 2008 +0300 @@ -7,7 +7,7 @@ extern "C" { #endif -gchar *xs_make_titlestring(t_xs_tuneinfo *, gint); +gchar *xs_make_titlestring(xs_tuneinfo_t *, gint); #ifdef __cplusplus }