Ok, here is the actual code
DLL code
-----------------------------------------------------------------------------
mapObj *msNewMapObj()
{
mapObj *map;
/* create an empty map, no layers etc... */
map = (mapObj *)calloc(sizeof(mapObj),1);
if(!map)
{
msSetError(MS_MEMERR, NULL, "msCreateMap()");
return NULL;
}
if( initMap( map ) == -1 )
return NULL;
if( msPostMapParseOutputFormatSetup( map ) == MS_FAILURE )
return NULL;
return map;
}
************************ the initMap function set the map->shapepath to NULL
************************ msSaveMap test if map->shapepath!=NULL
int msSaveMap(mapObj *map, char *filename)
{
int i;
FILE *stream;
char szPath[MS_MAXPATHLEN];
const char *key;
if(!map) {
msSetError(MS_MISCERR, "Map is undefined.", "msSaveMap()");
return(-1);
}
if(!filename) {
msSetError(MS_MISCERR, "Filename is undefined.", "msSaveMap()");
return(-1);
}
stream = fopen(msBuildPath(szPath, map->mappath, filename), "w");
if(!stream) {
msSetError(MS_IOERR, "(%s)", "msSaveMap()", filename);
return(-1);
}
fprintf(stream, "MAP\n");
if(map->datapattern) fprintf(stream, " DATAPATTERN \"%s\"\n",
map->datapattern);
fprintf(stream, " EXTENT %.15g %.15g %.15g %.15g\n", map->extent.minx,
map->extent.miny, map->extent.maxx, map->extent.maxy);
if(map->fontset.filename) fprintf(stream, " FONTSET \"%s\"\n",
map->fontset.filename);
if(map->templatepattern) fprintf(stream, " TEMPLATEPATTERN \"%s\"\n",
map->templatepattern);
fprintf(stream, " IMAGECOLOR %d %d %d\n", map->imagecolor.red,
map->imagecolor.green, map->imagecolor.blue);
if( map->imagetype != NULL )
fprintf(stream, " IMAGETYPE %s\n", map->imagetype );
if(map->resolution != 72.0) fprintf(stream, " RESOLUTION %f\n",
map->resolution);
if(map->interlace != MS_NOOVERRIDE)
fprintf(stream, " INTERLACE %s\n", msTrueFalse[map->interlace]);
if(map->symbolset.filename) fprintf(stream, " SYMBOLSET \"%s\"\n",
map->symbolset.filename);
if(map->shapepath) fprintf(stream, " SHAPEPATH \"%s\"\n", map->shapepath);
fprintf(stream, " SIZE %d %d\n", map->width, map->height);
if(map->maxsize != MS_MAXIMAGESIZE_DEFAULT) fprintf(stream, " MAXSIZE
%d\n", map->maxsize);
fprintf(stream, " STATUS %s\n", msStatus[map->status]);
if( map->transparent != MS_NOOVERRIDE )
fprintf(stream, " TRANSPARENT %s\n", msTrueFalse[map->transparent]);
fprintf(stream, " UNITS %s\n", msUnits[map->units]);
for( key = msFirstKeyFromHashTable( &(map->configoptions) );
key != NULL;
key = msNextKeyFromHashTable( &(map->configoptions), key ) )
{
fprintf( stream, " CONFIG %s \"%s\"\n",
key, msLookupHashTable( &(map->configoptions), key ) );
}
fprintf(stream, " NAME \"%s\"\n\n", map->name);
if(map->debug) fprintf(stream, " DEBUG ON\n");
writeOutputformat(map, stream);
/* write symbol with INLINE tag in mapfile */
for(i=0; i<map->symbolset.numsymbols; i++)
{
writeSymbol(&(map->symbolset.symbol[i]), stream);
}
writeProjection(&(map->projection), stream, " ");
writeLegend(&(map->legend), stream);
writeQueryMap(&(map->querymap), stream);
writeReferenceMap(&(map->reference), stream);
writeScalebar(&(map->scalebar), stream);
writeWeb(&(map->web), stream);
for(i=0; i<map->numlayers; i++)
{
writeLayer(&(map->layers[map->layerorder[i]]), stream);
/* writeLayer(&(map->layers[i]), stream); */
}
fprintf(stream, "END\n");
fclose(stream);
return(0);
}
Client code
-----------------------------------------------------------------------------
int main(int argc, char* argv[])
{
mapObj* map = msNewMapObj( );
msMapSetExtent( map,0,1,10,20000 );
msMapSetSize( map,50,60 );
map->shapepath = strdup("xx");
map->status = MS_ON;
map->imagetype = "JPG";
msSaveMap( map,"c:/11/a.map");
msFreeMap( map );
printf("terminado...");
return 0;
}
after that code, there is a file called c:/11/a.map thet must contains the
text
...
SHAPEPATH xx
"Dennis Jones" <
XXXX@XXXXX.COM >escribi?en el mensaje
Quote
"jaimes" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>Now I have anothe problem, in the DLL I have one struct
>
>struct XX
>{
>char* text;
>}
>
>void someFunctionInit(XX* x)
>{
>x.text = NULL;
>}
>void someFunction(XX* x)
>{
>if( x.text )
>{
>printf("%s",x->text);
>}
>}
>
>
>in the client code I have:
>
>XX x = new XX();
>
>someFunctionInit( x);
>x->text = strdup( "something" );
>someFunction( x );
>
>but when the program is running x->text still have a NULL value inside
>someFunction, some idea??
None of the code you show here should even compile! Therefore, one can
only assume that it is not your actual code. Please show the *actual*
code.
- Dennis