Changeset 14468
- Timestamp:
- 05/14/08 23:44:49 (2 months ago)
- Files:
-
- trunk/gdal/ogr/ogrsf_frmts/ingres/drv_ingres.html (added)
- trunk/gdal/ogr/ogrsf_frmts/ingres/ogr_ingres.h (modified) (2 diffs)
- trunk/gdal/ogr/ogrsf_frmts/ingres/ogringresdatasource.cpp (modified) (4 diffs)
- trunk/gdal/ogr/ogrsf_frmts/ingres/ogringresdriver.cpp (modified) (3 diffs)
- trunk/gdal/ogr/ogrsf_frmts/ogr_formats.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gdal/ogr/ogrsf_frmts/ingres/ogr_ingres.h
r14313 r14468 253 253 OGRErr InitializeMetadataTables(); 254 254 255 int Open( const char *, int bUpdate ); 255 int Open( const char *pszFullName, 256 char **papszOptions, int bUpdate ); 256 257 int OpenTable( const char *, int bUpdate ); 257 258 … … 286 287 class OGRIngresDriver : public OGRSFDriver 287 288 { 289 char **ParseWrappedName( const char * ); 290 288 291 public: 289 292 ~OGRIngresDriver(); trunk/gdal/ogr/ogrsf_frmts/ingres/ogringresdatasource.cpp
r14313 r14468 87 87 /************************************************************************/ 88 88 89 int OGRIngresDataSource::Open( const char * pszNewName, int bUpdate ) 89 int OGRIngresDataSource::Open( const char *pszFullName, 90 char **papszOptions, int bUpdate ) 90 91 91 92 … … 94 95 95 96 /* -------------------------------------------------------------------- */ 96 /* Verify Ingres prefix. */ 97 /* -------------------------------------------------------------------- */ 98 if( !EQUALN(pszNewName,"INGRES:",7) ) 99 { 97 /* Verify we have a dbname, this parameter is required. */ 98 /* -------------------------------------------------------------------- */ 99 const char *pszDBName = CSLFetchNameValue(papszOptions,"dbname"); 100 101 if( pszDBName == NULL ) 102 { 103 CPLError( CE_Failure, CPLE_OpenFailed, 104 "No DBNAME item provided in INGRES datasource name." ); 100 105 return FALSE; 101 106 } 102 107 103 108 /* -------------------------------------------------------------------- */ 104 /* For now we assume the whole argument is the "dbname". */ 105 /* -------------------------------------------------------------------- */ 106 const char *pszDBName = pszNewName + 7; 109 /* Do we have a table list? */ 110 /* -------------------------------------------------------------------- */ 107 111 char **papszTableNames = NULL; 108 112 const char *pszTables = CSLFetchNameValue(papszOptions,"tables"); 113 114 if( pszTables != NULL ) 115 papszTableNames = CSLTokenizeStringComplex(pszTables,"/",TRUE,FALSE); 116 109 117 /* -------------------------------------------------------------------- */ 110 118 /* Initialize the Ingres API. Should we only do this once per */ … … 129 137 connParm.co_connHandle = NULL; 130 138 connParm.co_tranHandle = NULL; 131 connParm.co_username = NULL; 132 connParm.co_password = NULL; 139 connParm.co_username = 140 (II_CHAR*) CSLFetchNameValue(papszOptions,"username"); 141 connParm.co_password = 142 (II_CHAR*)CSLFetchNameValue(papszOptions,"password"); 133 143 connParm.co_timeout = -1; 144 145 if( CSLFetchNameValue(papszOptions,"timeout") != NULL ) 146 connParm.co_timeout = atoi(CSLFetchNameValue(papszOptions,"timeout")); 134 147 135 148 IIapi_connect( &connParm ); … … 148 161 } 149 162 150 pszName = CPLStrdup( psz NewName );163 pszName = CPLStrdup( pszFullName ); 151 164 152 165 bDSUpdate = bUpdate; trunk/gdal/ogr/ogrsf_frmts/ingres/ogringresdriver.cpp
r13622 r14468 53 53 54 54 /************************************************************************/ 55 /* ParseWrappedName() */ 56 /************************************************************************/ 57 58 char **OGRIngresDriver::ParseWrappedName( const char *pszEncodedName ) 59 60 { 61 if( pszEncodedName[0] != '@' ) 62 return NULL; 63 64 return CSLTokenizeStringComplex( pszEncodedName+1, ",", TRUE, FALSE ); 65 } 66 67 /************************************************************************/ 55 68 /* Open() */ 56 69 /************************************************************************/ … … 60 73 61 74 { 62 OGRIngresDataSource *poDS; 75 OGRIngresDataSource *poDS = NULL; 76 char **papszOptions = ParseWrappedName( pszFilename ); 77 const char *pszDriver; 63 78 64 if( !EQUALN(pszFilename,"INGRES:",7) ) 65 return NULL; 79 pszDriver = CSLFetchNameValue( papszOptions, "driver" ); 80 if( pszDriver != NULL && EQUAL(pszDriver,"ingres") ) 81 { 82 poDS = new OGRIngresDataSource(); 66 83 67 poDS = new OGRIngresDataSource(); 84 if( !poDS->Open( pszFilename, papszOptions, TRUE ) ) 85 { 86 delete poDS; 87 poDS = NULL; 88 } 89 } 68 90 69 if( !poDS->Open( pszFilename, bUpdate ) ) 70 { 71 delete poDS; 72 return NULL; 73 } 74 else 75 return poDS; 91 CSLDestroy( papszOptions ); 92 93 return poDS; 76 94 } 77 95 … … 86 104 { 87 105 OGRIngresDataSource *poDS; 106 char **papszOpenOptions; 107 const char *pszDriver; 88 108 89 p oDS = new OGRIngresDataSource();109 papszOpenOptions = ParseWrappedName( pszName ); 90 110 111 pszDriver = CSLFetchNameValue( papszOpenOptions, "driver" ); 91 112 92 if( !poDS->Open( pszName, TRUE) )113 if( pszDriver != NULL && EQUAL(pszDriver,"ingres") ) 93 114 { 94 delete poDS; 95 CPLError( CE_Failure, CPLE_AppDefined, 96 "Ingres driver doesn't currently support database creation.\n" 97 "Please create database before using." ); 98 return NULL; 115 poDS = new OGRIngresDataSource(); 116 if( !poDS->Open( pszName, papszOpenOptions, TRUE ) ) 117 { 118 delete poDS; 119 poDS = NULL; 120 CPLError( CE_Failure, CPLE_AppDefined, 121 "Ingres driver doesn't currently support database creation.\n" 122 "Please create database before using." ); 123 } 99 124 } 125 126 CSLDestroy( papszOpenOptions ); 100 127 101 128 return poDS; trunk/gdal/ogr/ogrsf_frmts/ogr_formats.html
r13960 r14468 107 107 </td></tr> 108 108 109 <tr><td> <a href="drv_ingres.html">INGRES</a> 110 </td><td> INGRES 111 </td><td> Yes 112 </td><td> No 113 </td></tr> 114 109 115 <tr><td> <a href="drv_kml.html">KML</a> 110 116 </td><td> KML
