diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-03-08 22:05:09 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-03-08 22:05:09 (GMT) |
commit | 29a22c425f492427f45b71de937f2d99587c8d34 (patch) | |
tree | 36e8bb3ef73bc91e812ed63205d10bfced578660 /src/common/extstr.c | |
parent | 674739bedc853681be5a2657a7a4f497d6e82c9b (diff) |
Added a partial support of the Itanium C++ ABI mangling.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@52 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/common/extstr.c')
-rw-r--r-- | src/common/extstr.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/common/extstr.c b/src/common/extstr.c new file mode 100644 index 0000000..aba9830 --- /dev/null +++ b/src/common/extstr.c @@ -0,0 +1,85 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * extstr.c - extension des fonctions relatives aux chaînes + * + * Copyright (C) 2008 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * OpenIDA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "extstr.h" + + +#include <malloc.h> +#include <string.h> + + + +/****************************************************************************** +* * +* Paramètres : str1 = chaîne de caractères à compléter. * +* str2 = chaîne de caractères à ajouter. * +* * +* Description : Complète une chaîne de caractères avec une autre. * +* * +* Retour : Chaîne de caractères complétée, à libérer de la mémoire. * +* * +* Remarques : - * +* * +******************************************************************************/ + +char *stradd(char *str1, const char *str2) +{ + char *result; /* Chaîne à renvoyer */ + + result = (char *)realloc(str1, (strlen(str1) + strlen(str2) + 1) * sizeof(char)); + + strcat(result, str2); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : str1 = chaîne de caractères à compléter. * +* str2 = chaîne de caractères à ajouter. * +* * +* Description : Fait précéder une chaîne de caractères par une autre. * +* * +* Retour : Chaîne de caractères complétée, à libérer de la mémoire. * +* * +* Remarques : - * +* * +******************************************************************************/ + +char *strprep(char *str1, const char *str2) +{ + char *result; /* Chaîne à renvoyer */ + size_t len2; /* Taille de la seconde chaîne */ + + result = (char *)realloc(str1, (strlen(str1) + strlen(str2) + 1) * sizeof(char)); + + len2 = strlen(str2); + + memmove(&result[len2], result, strlen(result) + 1); + memcpy(result, str2, len2); + + return result; + +} |