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
00139 char * bg_filename_ensure_extension(const char * filename,
00140 const char * ext);
00141
00142
00143
00162 char * bg_strdup(char * old_string, const char * new_string);
00163
00174 char * bg_strndup(char * old_string,
00175 const char * new_start,
00176 const char * new_end);
00177
00184 char * bg_strcat(char * old_string, const char * tail);
00185
00193 char * bg_strncat(char * old_string, const char * start, const char * end);
00194
00200 char * bg_toupper(const char * str);
00201
00202
00211 int bg_string_is_url(const char * str);
00212
00228 int bg_url_split(const char * url,
00229 char ** protocol,
00230 char ** user,
00231 char ** password,
00232 char ** hostname,
00233 int * port,
00234 char ** path);
00235
00245 void bg_get_filename_hash(const char * gml, char ret[33]);
00246
00255 char * bg_sprintf(const char * format,...) __attribute__ ((format (printf, 1, 2)));
00256
00265 char ** bg_strbreak(const char * str, char delim);
00266
00273 void bg_strbreak_free(char ** retval);
00274
00285 char * bg_scramble_string(const char * str);
00286
00297 char * bg_descramble_string(const char * str);
00298
00306 char * bg_string_to_uri(const char * pos1, int len);
00307
00315 char * bg_uri_to_string(const char * pos1, int len);
00316
00327 char ** bg_urilist_decode(const char * str, int len);
00328
00333 void bg_urilist_free(char ** uri_list);
00334
00343 char * bg_system_to_utf8(const char * str, int len);
00344
00353 char * bg_utf8_to_system(const char * str, int len);
00354
00360 const char * bg_get_language_name(const char * iso);
00361
00368 int bg_string_match(const char * str, const char * key_list);
00369
00370
00371
00387 void bg_hexdump(uint8_t * data, int len, int linebreak);
00388
00395 char * bg_audio_format_to_string(gavl_audio_format_t * format, int use_tabs);
00396
00397
00404 char * bg_video_format_to_string(gavl_video_format_t * format, int use_tabs);
00405
00413 char * bg_get_stream_label(int index, const char * info, const char * language);
00414
00419 void bg_dprintf(const char * format, ...) __attribute__ ((format (printf, 1, 2)));
00420
00426 void bg_diprintf(int indent, const char * format, ...) __attribute__ ((format (printf, 2, 3)));
00427
00428
00429
00430 extern char const * const bg_language_codes[];
00431 extern char const * const bg_language_labels[];
00432
00433 #ifdef DEBUG
00434 #define bg_debug(f,...) fprintf(stderr, f, __VA_ARGS__)
00435 #else
00436 #define bg_debug(f,...)
00437 #endif
00438
00439
00440
00441 #endif // __BG_UTILS_H_