~ubuntu-branches/ubuntu/saucy/mapserver/saucy-security

« back to all changes in this revision

Viewing changes to mapimagemap.c

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-12-23 14:02:06 UTC
  • mfrom: (26.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20111223140206-n3h9t2hsa8hyslmu
Tags: 6.0.1-2
Added missed stuff for libmapscript-perl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: mapimagemap.c 9472 2009-10-16 18:17:05Z aboudreault $
 
2
 * $Id: mapimagemap.c 11473 2011-04-06 03:05:02Z dmorissette $
3
3
 *
4
4
 * Project:  MapServer
5
5
 * Purpose:  Implements imagemap outputformat support.
38
38
#include <io.h>
39
39
#endif
40
40
 
41
 
MS_CVSID("$Id: mapimagemap.c 9472 2009-10-16 18:17:05Z aboudreault $")
 
41
MS_CVSID("$Id: mapimagemap.c 11473 2011-04-06 03:05:02Z dmorissette $")
42
42
 
43
43
#define MYDEBUG 0
44
44
#define DEBUG_IF if (MYDEBUG > 2) 
124
124
static const char *makeFmtSafe(const char *fmt, int MAX) {
125
125
  /* format string should have exactly 'MAX' %s */
126
126
 
127
 
  char *result = malloc(strlen(fmt)+1+3*MAX), *cp;
 
127
  char *result = msSmallMalloc(strlen(fmt)+1+3*MAX), *cp;
128
128
  int numstr=0, saw_percent=0;
129
129
 
130
130
  strcpy(result, fmt);
186
186
                        if (n>-1 && *(ps->alloc_size) <= (n + ps->string_len))
187
187
                                /* ensure at least as much as what is needed */
188
188
                                *(ps->alloc_size) = n+ps->string_len+1;
189
 
                        *(ps->string) = (char *) realloc
 
189
                        *(ps->string) = (char *) msSmallRealloc
190
190
                                (*(ps->string), *(ps->alloc_size));
191
191
                        /* if realloc doesn't work, we're screwed! */
192
192
                }
246
246
DEBUG_IF printf("ImageStartLayerIM\n<BR>");
247
247
        free(lname);
248
248
        if (layer->name)
249
 
                lname = strdup(layer->name);
 
249
                lname = msStrdup(layer->name);
250
250
        else
251
 
                lname = strdup("NONE");
 
251
                lname = msStrdup("NONE");
252
252
        if (dxf == 2){
253
253
                im_iprintf(&layerStr, "LAYER\n%s\n", lname);
254
254
        } else if (dxf) {
272
272
  } else 
273
273
    *icsize += 1;
274
274
 
275
 
  if((icp = (struct imageCacheObj *)malloc(sizeof(struct imageCacheObj))) == NULL) {
276
 
    msSetError(MS_MEMERR, NULL, "initImageCache()");
277
 
    return(NULL);
278
 
  }
 
275
  icp = (struct imageCacheObj *)malloc(sizeof(struct imageCacheObj));
 
276
  MS_CHECK_ALLOC(icp, sizeof(struct imageCacheObj), NULL);
279
277
  
280
278
  icp->img = img;
281
279
  icp->color = style->color;
303
301
    if (width > 0 && height > 0)
304
302
    {
305
303
        image = (imageObj *)calloc(1,sizeof(imageObj));
 
304
        MS_CHECK_ALLOC(image, sizeof(imageObj), NULL);
306
305
/*
307
306
 
308
307
        if( format->imagemode == MS_IMAGEMODE_RGB 
365
364
              suppressEmpty=1;
366
365
            }
367
366
 
368
 
            lname = strdup("NONE");
369
 
            *(imgStr.string) = strdup("");
 
367
            lname = msStrdup("NONE");
 
368
            *(imgStr.string) = msStrdup("");
370
369
            if (*(imgStr.string)){
371
370
                    *(imgStr.alloc_size) =
372
371
                            imgStr.string_len = strlen(*(imgStr.string));
376
375
            }
377
376
            if (imagepath)
378
377
            {
379
 
                image->imagepath = strdup(imagepath);
 
378
                image->imagepath = msStrdup(imagepath);
380
379
            }
381
380
            if (imageurl)
382
381
            {
383
 
                image->imageurl = strdup(imageurl);
 
382
                image->imageurl = msStrdup(imageurl);
384
383
            }
385
384
            
386
385
            return image;
629
628
    // msImageTruetypePolyline(img, p, symbol, fc, size, symbolset->fontset);
630
629
    return;
631
630
    break;
632
 
  case(MS_SYMBOL_CARTOLINE):
633
 
    return;
634
 
    break;
635
631
  case(MS_SYMBOL_ELLIPSE):   
636
632
    bc = imTransparent;
637
633
 
1266
1262
    msImageTruetypePolyline(symbolset, img, p, style, scalefactor);
1267
1263
    return;
1268
1264
    break;
1269
 
  case(MS_SYMBOL_CARTOLINE):
1270
 
    // Single line //
1271
 
    if (size == 1) {
1272
 
      bc = imTransparent;
1273
 
      break;
1274
 
    } else {
1275
 
      msImageCartographicPolyline(img, p, fc, size, symbol->linecap, symbol->linejoin, symbol->linejoinmaxsize);
1276
 
    }
1277
 
    return;
1278
 
    break;
1279
1265
  case(MS_SYMBOL_ELLIPSE):
1280
1266
    bc = imTransparent;
1281
1267
 
1845
1831
   cacheslot = &(map->labelcache.slots[priority]);
1846
1832
 
1847
1833
   for(l=cacheslot->numlabels-1; l>=0; l--) {
1848
 
 
 
1834
        double size = cachePtr->label.size*layerPtr->scalefactor;
1849
1835
    cachePtr = &(cacheslot->labels[l]); /* point to right spot in the label cache */
1850
1836
 
1851
1837
    layerPtr = (GET_LAYER(map, cachePtr->layerindex)); /* set a couple of other pointers, avoids nasty references */
1854
1840
    if(!cachePtr->text || strlen(cachePtr->text) == 0)
1855
1841
      continue; /* not an error, just don't want to do anything */
1856
1842
 
1857
 
    if(cachePtr->label.type == MS_TRUETYPE)
1858
 
      cachePtr->label.size = (cachePtr->label.size*layerPtr->scalefactor);
 
1843
    if(labelPtr->type == MS_TRUETYPE) {
 
1844
        size = MS_MAX(size, labelPtr->minsize*img->resolutionfactor);
 
1845
        size = MS_MIN(size, labelPtr->maxsize*img->resolutionfactor);  
 
1846
    }
1859
1847
 
1860
 
    if(msGetLabelSize(img,cachePtr->text, labelPtr, &r, &(map->fontset), layerPtr->scalefactor, MS_TRUE,NULL) == -1)
1861
 
      return(-1);
 
1848
    if(msGetLabelSize(map,labelPtr,cachePtr->text, size,&r, NULL) != MS_SUCCESS) {
 
1849
      return MS_FAILURE;
 
1850
    }
1862
1851
 
1863
1852
    label_offset_x = labelPtr->offsetx*layerPtr->scalefactor;
1864
1853
    label_offset_y = labelPtr->offsety*layerPtr->scalefactor;
1873
1862
 
1874
1863
      /* TO DO: at the moment only checks the bottom style, perhaps should check all of them */
1875
1864
      if (msGetMarkerSize(&map->symbolset, &(cachePtr->styles[0]), &marker_width, &marker_height, layerPtr->scalefactor) != MS_SUCCESS)
1876
 
        return(-1);
 
1865
        return(MS_FAILURE);
1877
1866
 
1878
1867
      marker_width = (int) (marker_width * layerPtr->scalefactor);
1879
1868
      marker_height = (int) (marker_height * layerPtr->scalefactor);
1977
1966
   } /* next label in cache */
1978
1967
  } /* next priority */
1979
1968
 
1980
 
  return(0);
 
1969
  return(MS_SUCCESS);
1981
1970
}
1982
1971
 
1983
1972
/*