Merge remote-tracking branch 'origin/master' into YaSp
[scilab.git] / scilab / modules / localization / src / c / getentrieshashtable.c
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2007 - INRIA - Allan CORNET
4  * 
5  * This file must be used under the terms of the CeCILL.
6  * This source file is licensed as described in the file COPYING, which
7  * you should have received as part of this distribution.  The terms
8  * are also available at    
9  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10  *
11  */
12
13 #include "getentrieshashtable.h"
14 #include "hashtable_private.h"
15 #include "MALLOC.h"
16 #include "hashtable_localization.h"
17 /*--------------------------------------------------------------------------*/
18 char **getTAGSinhashtable(struct hashtable *tableIN,int *numbersEntries)
19 {
20         char **return_entries=NULL;
21         unsigned int i=0;
22         unsigned int j=0;
23         struct entry *e=NULL;
24         struct entry **table = tableIN->table;
25
26         *numbersEntries=tableIN->entrycount;
27         if (*numbersEntries>0)
28         {
29                 return_entries=(char **)MALLOC(sizeof(char *)*tableIN->entrycount);
30                 if (return_entries)
31                 {
32                         j=0;
33                         for (i = 0; i < tableIN->tablelength; i++)
34                         {
35                                 e = table[i];
36                                 while (NULL != e)
37                                 { 
38                                         struct key_string *Key=NULL;
39                                         Key=e->k;
40                                         return_entries[j]=(char *)MALLOC(sizeof(char)*(strlen(Key->Key_String)+1));
41                                         if (return_entries[j]) strcpy(return_entries[j],Key->Key_String);
42                                         e = e->next;
43                                         j++;
44                                 }
45                         }
46                 }
47         }
48         return return_entries;
49 }
50 /*--------------------------------------------------------------------------*/
51 char **getSTRINGSinhashtable(struct hashtable *tableIN,int *numbersEntries)
52 {
53         char **return_entries=NULL;
54         unsigned int i=0;
55         unsigned int j=0;
56         struct entry *e=NULL;
57         struct entry **table = tableIN->table;
58
59         *numbersEntries=tableIN->entrycount;
60         if (*numbersEntries>0)
61         {
62                 return_entries=(char **)MALLOC(sizeof(char *)*tableIN->entrycount);
63                 if (return_entries)
64                 {
65                         j=0;
66                         for (i = 0; i < tableIN->tablelength; i++)
67                         {
68                                 e = table[i];
69                                 while (NULL != e)
70                                 { 
71                                         struct value_string *Key=NULL;
72                                         Key=e->v;
73                                         return_entries[j]=(char *)MALLOC(sizeof(char)*(strlen(Key->Value_String)+1));
74                                         if (return_entries[j]) strcpy(return_entries[j],Key->Value_String);
75                                         e = e->next;
76                                         j++;
77                                 }
78                         }
79                 }
80         }
81         return return_entries;
82 }
83 /*--------------------------------------------------------------------------*/
84 char **getPATHSinhashtable(struct hashtable *tableIN,int *numbersEntries)
85 {
86         char **return_entries=NULL;
87         unsigned int i=0;
88         unsigned int j=0;
89         struct entry *e=NULL;
90         struct entry **table = tableIN->table;
91
92         *numbersEntries=tableIN->entrycount;
93         if (*numbersEntries>0)
94         {
95                 return_entries=(char **)MALLOC(sizeof(char *)*tableIN->entrycount);
96                 if (return_entries)
97                 {
98                         j=0;
99                         for (i = 0; i < tableIN->tablelength; i++)
100                         {
101                                 e = table[i];
102                                 while (NULL != e)
103                                 { 
104                                         struct value_string *Key=NULL;
105                                         Key=e->v;
106                                         return_entries[j]=(char *)MALLOC(sizeof(char)*(strlen(Key->Path_String)+1));
107                                         if (return_entries[j]) strcpy(return_entries[j],Key->Path_String);
108                                         e = e->next;
109                                         j++;
110                                 }
111                         }
112                 }
113         }
114         return return_entries;
115 }
116 /*--------------------------------------------------------------------------*/