1 /* -*- linux-c -*- 2 Copyright (C) 2007 Tom Szilagyi 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 18 $Id: utils.h 1253 2012-10-23 21:50:31Z assworth $ 19 */ 20 21 #ifndef AQUALUNG_UTILS_H 22 #define AQUALUNG_UTILS_H 23 24 #include <config.h> 25 26 #include "common.h" 27 28 29 /* Please update when we reach the 22nd century. */ 30 #define YEAR_MIN 1900 31 #define YEAR_MAX 2100 32 33 34 float convf(char * s); 35 int cut_trailing_whitespace(char * str); 36 void escape_percents(char * in, char * out); 37 38 int make_string_va(char * buf, char * format, ...); 39 void make_title_string(char * dest, char * templ, 40 char * artist, char * record, char * track); 41 void make_string_strerror(int ret, char * buf); 42 43 void sample2time(unsigned long SR, unsigned long long sample, char * str, int sign); 44 void time2time(float samples, char * str); 45 void time2time_na(float seconds, char * str); 46 47 void normalize_filename(const char * in, char * out); 48 49 void free_strdup(char ** s, const char * str); 50 int is_valid_year(int y); 51 int is_all_wspace(char * str); 52 53 int is_dir(char * path); 54 55 #ifndef HAVE_STRNDUP 56 char * strndup(char * str, size_t len); 57 #endif /* HAVE_STRNDUP */ 58 59 #ifndef HAVE_STRCASESTR 60 char * strcasestr(char * haystack, char * needle); 61 #endif /* HAVE_STRCASESTR */ 62 63 64 typedef struct _map_t { 65 66 char str[MAXLEN]; 67 int count; 68 struct _map_t * next; 69 70 } map_t; 71 72 void map_put(map_t ** map, char * str); 73 char * map_get_max(map_t * map); 74 void map_free(map_t * map); 75 76 77 #endif /* AQUALUNG_UTILS_H */ 78 79 // vim: shiftwidth=8:tabstop=8:softtabstop=8: 80 81