MED fichier
MEDcstring.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2  *
3  * COPYRIGHT (C) 1999 - 2016 EDF R&D, CEA/DEN
4  * MED is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * MED 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 Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with MED. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 
19 #include <med.h>
20 #include "med_config.h"
21 #include "med_outils.h"
22 #include <stdlib.h>
23 #include <string.h>
24 
25 /*
26  * - Nom de la fonction _MEDcstring
27  * - Description : convertit une chaine de caracteres C en
28  * nouvelle chaine de caracteres sans blancs terminaux
29  * Cette opération est réalisée à partir du buffer source
30  * dans le buffer destination déjà alloué de taille supposée
31  * suffisante.
32  * - Parametres :
33  * - source (IN) : la chaine C
34  * - dest (OUT) : la chaine C
35  * - Resultat : la nouvelle chaine C en cas de succes, NULL sinon
36  */
37 med_err _MEDcstring(char *source, char *dest)
38 {
39  char *temoin;
40  int longueur_source,long_reelle;
41  int i;
42 
43  longueur_source = strlen(source);
44  long_reelle = longueur_source;
45 
46  if ( longueur_source <= 0 ) return -1;
47 
48  temoin = source+longueur_source-1;
49  while (*temoin == ' ' && (temoin > source) )
50  {
51  temoin --;
52  long_reelle--;
53  }
54  if ( *temoin == ' ') long_reelle = 0;
55 /* ISCRUTE_int(long_reelle); */
56 
57  for (i=0;i<long_reelle+1;i++)
58  *(dest+i) = *(source+i);
59  *(dest+long_reelle) = '\0';
60 
61  return 0;
62 }
herr_t med_err
Definition: med.h:310
med_err _MEDcstring(char *source, char *dest)
Definition: MEDcstring.c:37