~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to ogr/ogrsf_frmts/pgeo/ogrpgeodatasource.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: ogrpgeodatasource.cpp 10645 2007-01-18 02:22:39Z warmerdam $
 
2
 * $Id: ogrpgeodatasource.cpp 20440 2010-08-25 17:35:49Z rouault $
3
3
 *
4
4
 * Project:  OpenGIS Simple Features Reference Implementation
5
5
 * Purpose:  Implements OGRPGeoDataSource class.
32
32
#include "cpl_string.h"
33
33
#include <vector>
34
34
 
35
 
CPL_CVSID("$Id: ogrpgeodatasource.cpp 10645 2007-01-18 02:22:39Z warmerdam $");
 
35
CPL_CVSID("$Id: ogrpgeodatasource.cpp 20440 2010-08-25 17:35:49Z rouault $");
36
36
 
37
37
/************************************************************************/
38
38
/*                         OGRPGeoDataSource()                          */
64
64
}
65
65
 
66
66
/************************************************************************/
 
67
/*                  CheckDSNStringTemplate()                            */
 
68
/* The string will be used as the formatting argument of sprintf with   */
 
69
/* a string in vararg. So let's check there's only one '%s', and nothing*/
 
70
/* else                                                                 */
 
71
/************************************************************************/
 
72
 
 
73
static int CheckDSNStringTemplate(const char* pszStr)
 
74
{
 
75
    int nPercentSFound = FALSE;
 
76
    while(*pszStr)
 
77
    {
 
78
        if (*pszStr == '%')
 
79
        {
 
80
            if (pszStr[1] != 's')
 
81
            {
 
82
                return FALSE;
 
83
            }
 
84
            else
 
85
            {
 
86
                if (nPercentSFound)
 
87
                    return FALSE;
 
88
                nPercentSFound = TRUE;
 
89
            }
 
90
        }
 
91
        pszStr ++;
 
92
    }
 
93
    return TRUE;
 
94
}
 
95
 
 
96
/************************************************************************/
67
97
/*                                Open()                                */
68
98
/************************************************************************/
69
99
 
84
114
        pszDSN = CPLStrdup( pszNewName + 5 );
85
115
    else
86
116
    {
87
 
        pszDSN = (char *) CPLMalloc(strlen(pszNewName)+50);
88
 
        sprintf( pszDSN, "DRIVER=Microsoft Access Driver (*.mdb);DBQ=%s", 
89
 
                 pszNewName );
 
117
        const char *pszDSNStringTemplate = NULL;
 
118
        pszDSNStringTemplate = CPLGetConfigOption( "PGEO_DRIVER_TEMPLATE", "DRIVER=Microsoft Access Driver (*.mdb);DBQ=%s");
 
119
        if (!CheckDSNStringTemplate(pszDSNStringTemplate))
 
120
        {
 
121
            CPLError( CE_Failure, CPLE_AppDefined,
 
122
                      "Illegal value for PGEO_DRIVER_TEMPLATE option");
 
123
            return FALSE;
 
124
        }
 
125
        pszDSN = (char *) CPLMalloc(strlen(pszNewName)+strlen(pszDSNStringTemplate)+100);
 
126
        sprintf( pszDSN, pszDSNStringTemplate,  pszNewName );
90
127
    }
91
128
 
92
129
/* -------------------------------------------------------------------- */