Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

tree_types.c

00001 /*****************************************************************************
00002  * tree_types.c:
00003  *****************************************************************************
00004  * Copyright (C) 2004 the VideoLAN team
00005  * $Id: tree_types.c 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Cyril Deguet <[email protected]>
00008  *          code from projectM http://xmms-projectm.sourceforge.net
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 
00025 
00026 
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <string.h>
00030 #include "common.h"
00031 
00032 /* Compares integer value numbers in 32 bit range */
00033 int compare_int(int * num1, int * num2) {
00034 
00035         if ((*num1) < (*num2))
00036                 return -1;
00037         if ((*num1) > (*num2))
00038                 return 1;
00039         
00040         return 0;
00041 }
00042 
00043 /* Compares strings in lexographical order */
00044 int compare_string(char * str1, char * str2) {
00045 
00046   //  printf("comparing \"%s\" to \"%s\"\n", str1, str2);
00047   //return strcmp(str1, str2);
00048   return strncmp(str1, str2, MAX_TOKEN_SIZE-1);
00049         
00050 }       
00051 
00052 /* Compares a string in version order. That is, file1 < file2 < file10 */
00053 int compare_string_version(char * str1, char * str2) {
00054 
00055   return strverscmp(str1, str2);
00056 
00057 }
00058 
00059 
00060 void free_int(void * num) {
00061         free(num);
00062 }
00063 
00064 
00065 void free_string(char * string) {
00066         
00067         free(string);   
00068 }       
00069  
00070 void * copy_int(int * num) {
00071         
00072         int * new_num;
00073         
00074         if ((new_num = (int*)malloc(sizeof(int))) == NULL)
00075                 return NULL;
00076 
00077         *new_num = *num;
00078         
00079         return (void*)new_num;
00080 }       
00081 
00082 
00083 void * copy_string(char * string) {
00084         
00085         char * new_string;
00086         
00087         if ((new_string = (char*)malloc(MAX_TOKEN_SIZE)) == NULL)
00088                 return NULL;
00089         
00090         strncpy(new_string, string, MAX_TOKEN_SIZE-1);
00091         
00092         return (void*)new_string;
00093 }

Generated on Tue Dec 20 10:14:59 2005 for vlc-0.8.4a by  doxygen 1.4.2