コード例 #1
0
ファイル: mapoutput.c プロジェクト: bschantz/mapserver
int msRemoveOutputFormat(mapObj *map, const char *name)
{
  int i, j;
  /* -------------------------------------------------------------------- */
  /*      Detach from map.                                                */
  /* -------------------------------------------------------------------- */
  if (map != NULL) {
    if (map->outputformatlist == NULL) {
      msSetError(MS_CHILDERR, "Can't remove format from empty outputformatlist", "msRemoveOutputFormat()");
      return MS_FAILURE;
    } else {
      i = msGetOutputFormatIndex(map, name);
      if (i >= 0) {
        map->numoutputformats--;
	if(MS_REFCNT_DECR_IS_ZERO(map->outputformatlist[i]))
           msFreeOutputFormat( map->outputformatlist[i] );

        for (j=i; j<map->numoutputformats-1; j++) {
          map->outputformatlist[j] = map->outputformatlist[j+1];
        }
      }
      map->outputformatlist = (outputFormatObj **)
                              realloc(map->outputformatlist,
                                      sizeof(void*) * (map->numoutputformats) );
      return MS_SUCCESS;
    }
  }
  return MS_FAILURE;
}
コード例 #2
0
ファイル: mapoutput.c プロジェクト: bb1ackwe11/mapserver
outputFormatObj *msSelectOutputFormat( mapObj *map, 
                                       const char *imagetype )

{
    int index;
    outputFormatObj *format = NULL;

    if( map == NULL || imagetype == NULL || strlen(imagetype) == 0 )
        return NULL;
    
/* -------------------------------------------------------------------- */
/*      Try to find the format in the maps list of formats, first by    */
/*      mime type, and then by output format name.                      */
/* -------------------------------------------------------------------- */
    index = msGetOutputFormatIndex(map, imagetype);
    if (index >= 0) {
        format = map->outputformatlist[index];
    } else {
       struct defaultOutputFormatEntry *formatEntry = defaultoutputformats;
       while(formatEntry->name) {
          if(!strcasecmp(imagetype,formatEntry->name) || !strcasecmp(imagetype,formatEntry->mimetype)) {
             format = msCreateDefaultOutputFormat( map, formatEntry->driver, formatEntry->name );
             break;
          }
          formatEntry++;
       }

    }

    if (format)
    {
        if (map->imagetype)
            free(map->imagetype);
        map->imagetype = msStrdup(format->name);
    }

    if( format != NULL )
        msOutputFormatValidate( format, MS_FALSE );

    return format;
}