1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@videolan.org>
8 * code from projectM http://xmms-projectm.sourceforge.net
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
29 /* Compares integer value numbers in 32 bit range */
30 int compare_int(int * num1, int * num2) {
32 if ((*num1) < (*num2))
34 if ((*num1) > (*num2))
40 /* Compares strings in lexographical order */
41 int compare_string(char * str1, char * str2) {
43 // printf("comparing \"%s\" to \"%s\"\n", str1, str2);
44 //return strcmp(str1, str2);
45 return strncmp(str1, str2, MAX_TOKEN_SIZE-1);
49 /* Compares a string in version order. That is, file1 < file2 < file10 */
50 int compare_string_version(char * str1, char * str2) {
52 return strverscmp(str1, str2);
57 void free_int(void * num) {
62 void free_string(char * string) {
67 void * copy_int(int * num) {
71 if ((new_num = (int*)malloc(sizeof(int))) == NULL)
76 return (void*)new_num;
80 void * copy_string(char * string) {
84 if ((new_string = (char*)malloc(MAX_TOKEN_SIZE)) == NULL)
87 strncpy(new_string, string, MAX_TOKEN_SIZE-1);
89 return (void*)new_string;