pelib
2.0.0
|
00001 /* 00002 * integer.c 00003 * 00004 * Created on: 20 Feb 2012 00005 * Copyright 2012 Nicolas Melot 00006 * 00007 * This file is part of pelib. 00008 * 00009 * pelib is free software: you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation, either version 3 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * pelib is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with pelib. If not, see <http://www.gnu.org/licenses/>. 00021 * 00022 */ 00023 00024 #include <stdlib.h> 00025 #include <string.h> 00026 00027 #include <pelib/pelib_string.h> 00028 00029 int 00030 pelib_copy(pelib_string)(pelib_string s1, pelib_string *s2) 00031 { 00032 strcpy((char*)*s2, (char*)s1); 00033 00034 return 1; 00035 } 00036 00037 int 00038 pelib_init(pelib_string)(pelib_string *val) 00039 { 00040 **val = '\0'; 00041 00042 return 1; 00043 } 00044 00045 int 00046 pelib_compare(pelib_string)(pelib_string a, pelib_string b) 00047 { 00048 return strcmp((char*)a, (char*)b); 00049 } 00050 00051 char* 00052 pelib_string(pelib_string)(pelib_string a) 00053 { 00054 size_t size; 00055 char* str; 00056 00057 str = malloc(sizeof(char) * pelib_string_length(a)); 00058 sprintf(str, "%s", a); 00059 00060 return str; 00061 } 00062 00063 size_t 00064 pelib_string_length(pelib_string str) 00065 { 00066 return strlen(str); 00067 } 00068 00069 char* 00070 pelib_string_detail(pelib_string)(pelib_string a, int level) 00071 { 00072 return pelib_string(pelib_string)(a); 00073 } 00074 00075 FILE* 00076 pelib_printf(pelib_string)(FILE* stream, pelib_string a) 00077 { 00078 char* str = pelib_string(pelib_string)(a); 00079 fprintf(stream, "%s", str); 00080 free(str); 00081 00082 return stream; 00083 }