149
char *gstrchr(const char *str, int c)
154
return strchr(str, c);
157
int gstrcmp(const char *a, const char *b)
167
int gstrcasecmp(const char *a, const char *b)
174
return strcasecmp(a, b);
177
int gstrncmp(const char *a, const char *b, int n)
184
return strncmp(a, b, n);
188
* @brief Duplicate a string.
190
* If @a str is NULL, it returns NULL.
191
* The string is duplicated by calling strdup().
193
* @param str string to be duplicated
195
* @return duplicated string (newly allocated)
197
char *gstrdup(const char *str)
206
* @brief Assign a duplicated string.
208
* The string is duplicated by calling #gstrdup().
210
* @note @a *old is freed prior to the assignment.
212
* @param old pointer to a variable suitable to store the new pointer
213
* @param str string to be duplicated
215
void setdup(char **old, const char *str)
222
* @brief Assign a newly allocated string
223
* containing the path created from a directory and a filename.
225
* @note @a *old is freed prior to the assignment.
227
* @param old pointer to a variable suitable to store the new pointer
228
* @param dir directory
229
* @param name filename
231
void setddup(char **old, const char *dir, const char *name)
234
*old = malloc(strlen(dir) + strlen(name) + 2);
236
sprintf(*old, "%s/%s", dir, name);
240
* @brief Convert #guiInfo member Filename.
242
* @param how 0 (cut file path and extension),
243
* 1 (additionally, convert lower case) or
244
* 2 (additionally, convert upper case)
245
* @param fname pointer to a buffer to receive the converted Filename
246
* @param maxlen size of @a fname buffer
248
* @return pointer to @a fname buffer
250
char *TranslateFilename(int how, char *fname, size_t maxlen)
255
switch (guiInfo.StreamType) {
256
case STREAMTYPE_FILE:
257
if (guiInfo.Filename && *guiInfo.Filename) {
258
p = strrchr(guiInfo.Filename,
266
av_strlcpy(fname, p + 1, maxlen);
268
av_strlcpy(fname, guiInfo.Filename, maxlen);
272
if (len > 3 && fname[len - 3] == '.')
274
else if (len > 4 && fname[len - 4] == '.')
276
else if (len > 5 && fname[len - 5] == '.')
279
av_strlcpy(fname, MSGTR_NoFileLoaded, maxlen);
282
case STREAMTYPE_STREAM:
283
av_strlcpy(fname, guiInfo.Filename, maxlen);
287
case STREAMTYPE_CDDA:
288
snprintf(fname, maxlen, MSGTR_Title, guiInfo.Track);
294
snprintf(fname, maxlen, MSGTR_Title, guiInfo.Track - 1);
298
#ifdef CONFIG_DVDREAD
301
snprintf(fname, maxlen, MSGTR_Chapter, guiInfo.Chapter);
303
av_strlcat(fname, MSGTR_NoChapter, maxlen);
308
av_strlcpy(fname, MSGTR_NoMediaOpened, maxlen);
318
if (how == 1 && *p >= 'A' && *p <= 'Z')
320
if (how == 2 && *p >= 'a' && *p <= 'z')