source: trunk/zoo-kernel/service_internal_perl.c @ 17

Last change on this file since 17 was 17, checked in by david, 11 years ago

-ajout support perl

File size: 3.1 KB
Line 
1/**
2 * Author : David SAGGIORATO
3 *
4 * Copyright (c) 2009-2010 GeoLabs SARL
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25#include "service_internal_perl.h"
26
27
28static PerlInterpreter *my_perl;
29
30EXTERN_C
31
32void xs_init(pTHX)
33{
34        char *file = __FILE__;
35        dXSUB_SYS;
36       
37        /* DynaLoader is a special case */
38        newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
39}
40
41
42
43int map_to_hash(map * m, HV ** hash_map) {
44        HV * tmp = *hash_map;
45        map * tmp_m = m;
46        do {
47                printf("map name %s  value %s \n",m->name,m->value);
48
49                if ( NULL == hv_store( tmp, tmp_m->name, strlen(tmp_m->name), sv_2mortal(newSVpv(tmp_m->value, strlen(tmp_m->value))), 0) ) {
50                        return 1;
51                        }
52                tmp_m = tmp_m->next;
53                }
54        while (tmp_m != NULL);
55        return 0;
56}
57
58int maps_to_hash( maps* m, HV ** hash_maps){
59        HV * tmp = *hash_maps;
60        if (m != NULL) {
61                printf("maps name %s \n",m->name);
62                HV* hash_m = (HV *)sv_2mortal((SV *)newHV());
63                if (map_to_hash(m->content,&hash_m) != 0){
64                        return 1;
65                }
66               
67                if ( NULL == hv_store( tmp, m->name, strlen(m->name),sv_2mortal(newRV_inc((SV *)hash_m)), 0) ) {
68                        return 1;
69                }       
70                return maps_to_hash(m->next,hash_maps);
71        }
72        return 0;
73}
74
75int hash_to_map(HV * hh,map ** m){
76        hv_iterinit(hh);
77        *m = (map *)malloc(MAP_SIZE);
78        if (*m == NULL){
79                // erreur d'allocation memoire
80                return 1;
81        }
82        map * tmp = *m;
83        HE * he = hv_iternext(hh);
84        while (he != NULL){
85                printf("key : %s  value : %s \n",HeKEY(he),(char *)SvRV(HeVAL(he)));
86                tmp->name = HeKEY(he);
87                tmp->value = (char *)SvRV(HeVAL(he));
88                he = hv_iternext(hh);
89                if(he != NULL){
90                        tmp->next = (map *)malloc(MAP_SIZE);
91                        if (tmp->next == NULL){
92                                //erreur allocation memoire
93                                return 1;
94                        }
95                        tmp=tmp->next;
96                }
97                else {
98                        tmp->next = NULL;
99                }
100
101        }
102
103        return 1;
104}
105       
106int hash_to_maps(HV * hh,maps** m){
107        hv_iterinit(hh);
108        *m = (maps *)malloc(MAPS_SIZE);
109        maps * tmp = *m;
110        HE * he = hv_iternext(hh);
111        map *mm;
112        while (he != NULL) {
113                printf("key ===> %s \n",HeKEY(he));
114                tmp->name = HeKEY(he);
115                hash_to_map((HV *) SvRV(HeVAL(he)),&mm);
116                tmp->content = mm;
117                he = hv_iternext(hh);
118                if (he != NULL){
119                        tmp->next = (maps *)malloc(MAPS_SIZE);
120                        tmp= tmp->next;
121                }
122                else {
123                        tmp->next = NULL;
124                }               
125        }
126        return 1;
127}
128       
129
Note: See TracBrowser for help on using the repository browser.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png