gmerlin
|
00001 /***************************************************************** 00002 * gmerlin - a general purpose multimedia framework and applications 00003 * 00004 * Copyright (c) 2001 - 2011 Members of the Gmerlin project 00005 * gmerlin-general@lists.sourceforge.net 00006 * http://gmerlin.sourceforge.net 00007 * 00008 * This program is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 * *****************************************************************/ 00021 00022 #ifndef __BG_UTILS_H_ 00023 #define __BG_UTILS_H_ 00024 00025 #include <gavl/gavl.h> 00026 #include <gavl/metadata.h> 00027 00049 /* Append a trailing '/' if it's missing. Argument must be free()able */ 00050 00051 char * bg_fix_path(char * path); 00052 00060 int bg_ensure_directory(const char * dir); 00061 00062 00074 char * bg_search_file_read(const char * directory, const char * file); 00075 00088 char * bg_search_file_write(const char * directory, const char * file); 00089 00099 int bg_search_file_exec(const char * file, char ** path); 00100 00109 char * bg_find_url_launcher(); 00110 00118 void bg_display_html_help(const char * path); 00119 00127 char * bg_create_unique_filename(char * format); 00128 00136 char * bg_canonical_filename(const char * name); 00137 00149 char * bg_filename_ensure_extension(const char * filename, 00150 const char * ext); 00151 00152 00153 00172 char * bg_strdup(char * old_string, const char * new_string); 00173 00184 char * bg_strndup(char * old_string, 00185 const char * new_start, 00186 const char * new_end); 00187 00194 char * bg_strcat(char * old_string, const char * tail); 00195 00203 char * bg_strncat(char * old_string, const char * start, const char * end); 00204 00210 char * bg_toupper(const char * str); 00211 00212 00221 int bg_string_is_url(const char * str); 00222 00238 int bg_url_split(const char * url, 00239 char ** protocol, 00240 char ** user, 00241 char ** password, 00242 char ** hostname, 00243 int * port, 00244 char ** path); 00245 00255 void bg_get_filename_hash(const char * gml, char ret[33]); 00256 00265 char * bg_sprintf(const char * format,...) __attribute__ ((format (printf, 1, 2))); 00266 00275 char ** bg_strbreak(const char * str, char delim); 00276 00283 void bg_strbreak_free(char ** retval); 00284 00295 char * bg_scramble_string(const char * str); 00296 00307 char * bg_descramble_string(const char * str); 00308 00316 char * bg_string_to_uri(const char * pos1, int len); 00317 00325 char * bg_uri_to_string(const char * pos1, int len); 00326 00337 char ** bg_urilist_decode(const char * str, int len); 00338 00343 void bg_urilist_free(char ** uri_list); 00344 00353 char * bg_system_to_utf8(const char * str, int len); 00354 00363 char * bg_utf8_to_system(const char * str, int len); 00364 00370 const char * bg_get_language_name(const char * iso); 00371 00378 int bg_string_match(const char * str, const char * key_list); 00379 00380 /* @} */ 00381 00397 void bg_hexdump(uint8_t * data, int len, int linebreak); 00398 00405 char * bg_audio_format_to_string(gavl_audio_format_t * format, int use_tabs); 00406 00407 00414 char * bg_video_format_to_string(gavl_video_format_t * format, int use_tabs); 00415 00422 char * bg_get_stream_label(int index, const gavl_metadata_t * m); 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 00443 void * bg_read_file(const char * filename, int * len); 00444 00452 int bg_write_file(const char * filename, void * data, int len); 00453 00454 00460 const char * bg_iso639_b_to_t(const char * code); 00461 00462 00463 /* @} */ 00464 00465 extern char const * const bg_language_codes[]; 00466 extern char const * const bg_language_labels[]; 00467 00468 #ifdef DEBUG 00469 #define bg_debug(f,...) fprintf(stderr, f, __VA_ARGS__) 00470 #else 00471 #define bg_debug(f,...) 00472 #endif 00473 00474 00475 00476 #endif // __BG_UTILS_H_