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

« back to all changes in this revision

Viewing changes to .pc/gdalpaths/ogr/ogrsf_frmts/generic/ogrsfdriverregistrar.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: ogrsfdriverregistrar.cpp 18771 2010-02-09 01:30:33Z hobu $
 
2
 * $Id: ogrsfdriverregistrar.cpp 22812 2011-07-25 04:50:23Z warmerdam $
3
3
 *
4
4
 * Project:  OpenGIS Simple Features Reference Implementation
5
5
 * Purpose:  The OGRSFDriverRegistrar class implementation.
31
31
#include "ogr_api.h"
32
32
#include "ogr_p.h"
33
33
#include "cpl_multiproc.h"
34
 
 
35
 
CPL_CVSID("$Id: ogrsfdriverregistrar.cpp 18771 2010-02-09 01:30:33Z hobu $");
 
34
#include "swq.h"
 
35
 
 
36
#ifdef HAVE_UNISTD_H
 
37
#include <unistd.h>
 
38
#endif
 
39
 
 
40
CPL_CVSID("$Id: ogrsfdriverregistrar.cpp 22812 2011-07-25 04:50:23Z warmerdam $");
36
41
 
37
42
static void *hDRMutex = NULL;
38
43
static OGRSFDriverRegistrar * volatile poRegistrar = NULL;
142
147
        if( poRegistrar != NULL )
143
148
            delete poRegistrar;
144
149
        OSRCleanup();
 
150
        swq_op_registrar::DeInitialize();
145
151
    }
146
152
 
 
153
    CPLDestroyMutex( hDRMutex );
 
154
    hDRMutex = NULL;
 
155
 
147
156
    CPLFinderClean();
148
157
    VSICleanupFileManager();
149
158
    CPLFreeConfig();
191
200
{
192
201
    OGRDataSource       *poDS;
193
202
 
 
203
#ifdef HAVE_READLINK
 
204
    char szPointerFilename[2048];
 
205
    int  bHasRetried = FALSE;
 
206
#endif
 
207
 
194
208
    if( ppoDriver != NULL )
195
209
        *ppoDriver = NULL;
196
210
 
200
214
 
201
215
    CPLAcquireMutex( hDRMutex, 0.1 );
202
216
 
 
217
#ifdef HAVE_READLINK
 
218
retry:
 
219
#endif
203
220
    for( int iDriver = 0; iDriver < poRegistrar->nDrivers; iDriver++ )
204
221
    {
205
222
        OGRSFDriver *poDriver = poRegistrar->papoDrivers[iDriver];
228
245
        CPLAcquireMutex( hDRMutex, 0.1 );
229
246
    }
230
247
 
 
248
#ifdef HAVE_READLINK
 
249
    if (!bHasRetried)
 
250
    {
 
251
        /* If someone creates a file with "ln -sf /vsicurl/http://svn.osgeo.org/gdal/trunk/autotest/ogr/data/poly.shp my_remote_poly.shp" */
 
252
        /* we will be able to open it by passing my_remote_poly.shp */
 
253
        /* This helps a lot for OGR based readers that only provide file explorers to open datasources */
 
254
        int nBytes = readlink(pszName, szPointerFilename, sizeof(szPointerFilename));
 
255
        if (nBytes != -1)
 
256
        {
 
257
            szPointerFilename[MIN(nBytes, (int)sizeof(szPointerFilename)-1)] = 0;
 
258
            pszName = szPointerFilename;
 
259
            bHasRetried = TRUE;
 
260
            goto retry;
 
261
        }
 
262
    }
 
263
#endif
 
264
 
231
265
    CPLReleaseMutex( hDRMutex );
232
266
 
233
267
    CPLDebug( "OGR", "OGROpen(%s) failed.", pszName );
589
623
}
590
624
 
591
625
/************************************************************************/
 
626
/*                          DeregisterDriver()                          */
 
627
/************************************************************************/
 
628
 
 
629
void OGRSFDriverRegistrar::DeregisterDriver( OGRSFDriver * poDriver )
 
630
 
 
631
{
 
632
    CPLMutexHolderD( &hDRMutex );
 
633
    int         i;
 
634
 
 
635
    for( i = 0; i < nDrivers; i++ )
 
636
    {
 
637
        if( poDriver == papoDrivers[i] )
 
638
            break;
 
639
    }
 
640
 
 
641
    if (i == nDrivers)
 
642
        return;
 
643
 
 
644
    while( i < nDrivers-1 )
 
645
    {
 
646
        papoDrivers[i] = papoDrivers[i+1];
 
647
        i++;
 
648
    }
 
649
    nDrivers--;
 
650
}
 
651
 
 
652
/************************************************************************/
 
653
/*                        OGRDeregisterDriver()                         */
 
654
/************************************************************************/
 
655
 
 
656
void OGRDeregisterDriver( OGRSFDriverH hDriver )
 
657
 
 
658
{
 
659
    VALIDATE_POINTER0( hDriver, "OGRDeregisterDriver" );
 
660
 
 
661
    OGRSFDriverRegistrar::GetRegistrar()->DeregisterDriver( 
 
662
        (OGRSFDriver *) hDriver );
 
663
}
 
664
 
 
665
/************************************************************************/
592
666
/*                           GetDriverCount()                           */
593
667
/************************************************************************/
594
668
 
691
765
 * If that is not set the following defaults are used:
692
766
 *
693
767
 * <ul>
694
 
 * <li> Linux/Unix: <prefix>/lib/gdalplugins is searched or 
 
768
 * <li> Linux/Unix: &lt;prefix&gt;/lib/gdalplugins is searched or
695
769
 * /usr/local/lib/gdalplugins if the install prefix is not known.
696
 
 * <li> MacOSX: <prefix>/PlugIns is searched, or /usr/local/lib/gdalplugins if
 
770
 * <li> MacOSX: &lt;prefix&gt;/PlugIns is searched, or /usr/local/lib/gdalplugins if
697
771
 * the install prefix is not known.  Also, the framework directory
698
772
 * /Library/Application Support/GDAL/PlugIns is searched.
699
 
 * <li> Win32: <prefix>/lib/gdalplugins if the prefix is known (normally it 
 
773
 * <li> Win32: &lt;prefix&gt;/lib/gdalplugins if the prefix is known (normally it
700
774
 * is not), otherwise the gdalplugins subdirectory of the directory containing
701
775
 * the currently running executable is used. 
702
776
 * </ul>
764
838
    }
765
839
 
766
840
/* -------------------------------------------------------------------- */
767
 
/*      Scan each directory looking for files starting with gdal_       */
 
841
/*      Format the ABI version specific subdirectory to look in.        */
 
842
/* -------------------------------------------------------------------- */
 
843
    CPLString osABIVersion;
 
844
 
 
845
    osABIVersion.Printf( "%d.%d", GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR );
 
846
 
 
847
/* -------------------------------------------------------------------- */
 
848
/*      Scan each directory looking for files starting with ogr_        */
768
849
/* -------------------------------------------------------------------- */
769
850
    for( int iDir = 0; iDir < CSLCount(papszSearchPath); iDir++ )
770
851
    {
771
 
        char  **papszFiles = CPLReadDir( papszSearchPath[iDir] );
 
852
        char **papszFiles = NULL;
 
853
        VSIStatBufL sStatBuf;
 
854
        CPLString osABISpecificDir =
 
855
            CPLFormFilename( papszSearchPath[iDir], osABIVersion, NULL );
 
856
        
 
857
        if( VSIStatL( osABISpecificDir, &sStatBuf ) != 0 )
 
858
            osABISpecificDir = papszSearchPath[iDir];
 
859
 
 
860
        papszFiles = CPLReadDir( osABISpecificDir );
772
861
 
773
862
        for( int iFile = 0; iFile < CSLCount(papszFiles); iFile++ )
774
863
        {
790
879
                     CPLGetBasename(papszFiles[iFile]) + 4 );
791
880
            
792
881
            pszFilename = 
793
 
                CPLFormFilename( papszSearchPath[iDir], 
 
882
                CPLFormFilename( osABISpecificDir,
794
883
                                 papszFiles[iFile], NULL );
795
884
 
796
885
            pRegister = CPLGetSymbol( pszFilename, pszFuncName );