utils.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __BG_UTILS_H_
00023 #define __BG_UTILS_H_
00024
00025 #include <gavl/gavl.h>
00026
00048
00049
00050 char * bg_fix_path(char * path);
00051
00059 int bg_ensure_directory(const char * dir);
00060
00061
00073 char * bg_search_file_read(const char * directory, const char * file);
00074
00087 char * bg_search_file_write(const char * directory, const char * file);
00088
00098 int bg_search_file_exec(const char * file, char ** path);
00099
00108 char * bg_find_url_launcher();
00109
00117 void bg_display_html_help(const char * path);
00118
00126 char * bg_create_unique_filename(char * format);
00127
00135 char * bg_canonical_filename(const char * name);
00136
00148 char * bg_filename_ensure_extension(const char * filename,
00149 const char * ext);
00150
00151
00152
00171 char * bg_strdup(char * old_string, const char * new_string);
00172
00183 char * bg_strndup(char * old_string,
00184 const char * new_start,
00185 const char * new_end);
00186
00193 char * bg_strcat(char * old_string, const char * tail);
00194
00202 char * bg_strncat(char * old_string, const char * start, const char * end);
00203
00209 char * bg_toupper(const char * str);
00210
00211
00220 int bg_string_is_url(const char * str);
00221
00237 int bg_url_split(const char * url,
00238 char ** protocol,
00239 char ** user,
00240 char ** password,
00241 char ** hostname,
00242 int * port,
00243 char ** path);
00244
00254 void bg_get_filename_hash(const char * gml, char ret[33]);
00255
00264 char * bg_sprintf(const char * format,...) __attribute__ ((format (printf, 1, 2)));
00265
00274 char ** bg_strbreak(const char * str, char delim);
00275
00282 void bg_strbreak_free(char ** retval);
00283
00294 char * bg_scramble_string(const char * str);
00295
00306 char * bg_descramble_string(const char * str);
00307
00315 char * bg_string_to_uri(const char * pos1, int len);
00316
00324 char * bg_uri_to_string(const char * pos1, int len);
00325
00336 char ** bg_urilist_decode(const char * str, int len);
00337
00342 void bg_urilist_free(char ** uri_list);
00343
00352 char * bg_system_to_utf8(const char * str, int len);
00353
00362 char * bg_utf8_to_system(const char * str, int len);
00363
00369 const char * bg_get_language_name(const char * iso);
00370
00377 int bg_string_match(const char * str, const char * key_list);
00378
00379
00380
00396 void bg_hexdump(uint8_t * data, int len, int linebreak);
00397
00404 char * bg_audio_format_to_string(gavl_audio_format_t * format, int use_tabs);
00405
00406
00413 char * bg_video_format_to_string(gavl_video_format_t * format, int use_tabs);
00414
00422 char * bg_get_stream_label(int index, const char * info, const char * language);
00423
00428 void bg_dprintf(const char * format, ...) __attribute__ ((format (printf, 1, 2)));
00429
00435 void bg_diprintf(int indent, const char * format, ...) __attribute__ ((format (printf, 2, 3)));
00436
00437
00438
00439 extern char const * const bg_language_codes[];
00440 extern char const * const bg_language_labels[];
00441
00442 #ifdef DEBUG
00443 #define bg_debug(f,...) fprintf(stderr, f, __VA_ARGS__)
00444 #else
00445 #define bg_debug(f,...)
00446 #endif
00447
00448
00449
00450 #endif // __BG_UTILS_H_