aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am1
-rw-r--r--src/ctx.cpp2
-rw-r--r--src/fileapi.cpp240
-rw-r--r--src/filemanager.cpp95
-rw-r--r--src/lib_proj.cmake1
-rw-r--r--src/proj_internal.h27
6 files changed, 0 insertions, 366 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index edfd05ef..2c175e42 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -216,7 +216,6 @@ libproj_la_SOURCES = \
qsfn.cpp strerrno.cpp \
tsfn.cpp units.cpp ctx.cpp log.cpp zpoly1.cpp rtodms.cpp \
release.cpp gauss.cpp \
- fileapi.cpp \
generic_inverse.cpp \
quadtree.hpp \
\
diff --git a/src/ctx.cpp b/src/ctx.cpp
index 24d3773b..d3eee39f 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -100,7 +100,6 @@ pj_ctx pj_ctx::createDefault()
pj_ctx ctx;
ctx.debug_level = PJ_LOG_NONE;
ctx.logger = pj_stderr_logger;
- ctx.fileapi_legacy = pj_get_default_fileapi();
NS_PROJ::FileManager::fillDefaultNetworkInterface(&ctx);
if( getenv("PROJ_DEBUG") != nullptr )
@@ -170,7 +169,6 @@ pj_ctx::pj_ctx(const pj_ctx& other) :
debug_level(other.debug_level),
logger(other.logger),
logger_app_data(other.logger_app_data),
- fileapi_legacy(other.fileapi_legacy),
cpp_context(other.cpp_context ? other.cpp_context->clone(this) : nullptr),
use_proj4_init_rules(other.use_proj4_init_rules),
epsg_file_exists(other.epsg_file_exists),
diff --git a/src/fileapi.cpp b/src/fileapi.cpp
deleted file mode 100644
index 0af83926..00000000
--- a/src/fileapi.cpp
+++ /dev/null
@@ -1,240 +0,0 @@
-/******************************************************************************
- * Project: PROJ.4
- * Purpose: Implementation of the pj_ctx_* file api, and the default stdio
- * based implementation.
- * Author: Frank Warmerdam, warmerdam@pobox.com
- *
- ******************************************************************************
- * Copyright (c) 2013, Frank Warmerdam
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *****************************************************************************/
-
-#include <errno.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "proj.h"
-#include "proj_internal.h"
-#include "filemanager.hpp"
-
-static PAFile stdio_fopen(PJ_CONTEXT *ctx, const char *filename,
- const char *access);
-static size_t stdio_fread(void *buffer, size_t size, size_t nmemb,
- PAFile file);
-static int stdio_fseek(PAFile file, long offset, int whence);
-static long stdio_ftell(PAFile file);
-static void stdio_fclose(PAFile file);
-
-static projFileAPI default_fileapi = {
- stdio_fopen,
- stdio_fread,
- stdio_fseek,
- stdio_ftell,
- stdio_fclose
-};
-
-typedef struct {
- PJ_CONTEXT *ctx;
- FILE *fp;
-} stdio_pafile;
-
-/************************************************************************/
-/* pj_get_default_fileapi() */
-/************************************************************************/
-
-projFileAPI *pj_get_default_fileapi(void)
-{
- return &default_fileapi;
-}
-
-/************************************************************************/
-/* stdio_fopen() */
-/************************************************************************/
-
-static PAFile stdio_fopen(PJ_CONTEXT *ctx, const char *filename,
- const char *access)
-{
- stdio_pafile *pafile;
- FILE *fp;
-
- fp = fopen(filename, access);
- if (fp == nullptr)
- {
- return nullptr;
- }
-
- pafile = (stdio_pafile *) malloc(sizeof(stdio_pafile));
- if (!pafile)
- {
- pj_ctx_set_errno(ctx, ENOMEM);
- fclose(fp);
- return nullptr;
- }
-
- pafile->fp = fp;
- pafile->ctx = ctx;
- return (PAFile) pafile;
-}
-
-/************************************************************************/
-/* stdio_fread() */
-/************************************************************************/
-
-static size_t stdio_fread(void *buffer, size_t size, size_t nmemb,
- PAFile file)
-{
- stdio_pafile *pafile = (stdio_pafile *) file;
- return fread(buffer, size, nmemb, pafile->fp);
-}
-
-/************************************************************************/
-/* stdio_fseek() */
-/************************************************************************/
-static int stdio_fseek(PAFile file, long offset, int whence)
-{
- stdio_pafile *pafile = (stdio_pafile *) file;
- return fseek(pafile->fp, offset, whence);
-}
-
-/************************************************************************/
-/* stdio_ftell() */
-/************************************************************************/
-static long stdio_ftell(PAFile file)
-{
- stdio_pafile *pafile = (stdio_pafile *) file;
- return ftell(pafile->fp);
-}
-
-/************************************************************************/
-/* stdio_fclose() */
-/************************************************************************/
-static void stdio_fclose(PAFile file)
-{
- stdio_pafile *pafile = (stdio_pafile *) file;
- fclose(pafile->fp);
- free(pafile);
-}
-
-/************************************************************************/
-/* pj_ctx_fopen() */
-/* */
-/* Open a file using the provided file io hooks. */
-/************************************************************************/
-
-PAFile pj_ctx_fopen(PJ_CONTEXT *ctx, const char *filename, const char *access)
-{
- return ctx->fileapi_legacy->FOpen(ctx, filename, access);
-}
-
-/************************************************************************/
-/* pj_ctx_fread() */
-/************************************************************************/
-size_t pj_ctx_fread(PJ_CONTEXT *ctx, void *buffer, size_t size, size_t nmemb, PAFile file)
-{
- return ctx->fileapi_legacy->FRead(buffer, size, nmemb, file);
-}
-
-/************************************************************************/
-/* pj_ctx_fseek() */
-/************************************************************************/
-int pj_ctx_fseek(PJ_CONTEXT *ctx, PAFile file, long offset, int whence)
-{
- return ctx->fileapi_legacy->FSeek(file, offset, whence);
-}
-
-/************************************************************************/
-/* pj_ctx_ftell() */
-/************************************************************************/
-long pj_ctx_ftell(PJ_CONTEXT *ctx, PAFile file)
-{
- return ctx->fileapi_legacy->FTell(file);
-}
-
-/************************************************************************/
-/* pj_ctx_fclose() */
-/************************************************************************/
-void pj_ctx_fclose(PJ_CONTEXT *ctx, PAFile file)
-{
- ctx->fileapi_legacy->FClose(file);
-}
-
-/************************************************************************/
-/* pj_ctx_fgets() */
-/* */
-/* A not very optimal implementation of fgets on top of */
-/* fread(). If we end up using this a lot more care should be */
-/* taken. */
-/************************************************************************/
-
-char *pj_ctx_fgets(PJ_CONTEXT *ctx, char *line, int size, PAFile file)
-{
- long start = pj_ctx_ftell(ctx, file);
- size_t bytes_read;
- int i;
- int max_size;
-
- line[size-1] = '\0';
- bytes_read = pj_ctx_fread(ctx, line, 1, size-1, file);
- if(bytes_read == 0)
- return nullptr;
- if(bytes_read < (size_t)size)
- {
- line[bytes_read] = '\0';
- }
-
- max_size = (int)MIN(bytes_read, (size_t)(size > 2 ? size - 2 : 0));
- for( i = 0; i < max_size; i++)
- {
- if (line[i] == '\n')
- {
- line[i+1] = '\0';
- pj_ctx_fseek(ctx, file, start + i + 1, SEEK_SET);
- break;
- }
- }
- return line;
-}
-
-/************************************************************************/
-/* pj_ctx_set_fileapi() */
-/************************************************************************/
-
-void pj_ctx_set_fileapi( PJ_CONTEXT *ctx, projFileAPI *fileapi )
-
-{
- if (nullptr==ctx)
- return;
- ctx->fileapi_legacy = fileapi;
-}
-
-/************************************************************************/
-/* pj_ctx_get_fileapi() */
-/************************************************************************/
-
-projFileAPI *pj_ctx_get_fileapi( PJ_CONTEXT *ctx )
-
-{
- if (nullptr==ctx)
- return nullptr;
- return ctx->fileapi_legacy;
-}
-
diff --git a/src/filemanager.cpp b/src/filemanager.cpp
index 37dc920e..66a8faf8 100644
--- a/src/filemanager.cpp
+++ b/src/filemanager.cpp
@@ -786,75 +786,6 @@ std::unique_ptr<File> FileStdio::open(PJ_CONTEXT *ctx, const char *filename,
// ---------------------------------------------------------------------------
-#ifndef REMOVE_LEGACY_SUPPORT
-
-class FileLegacyAdapter : public File {
- PJ_CONTEXT *m_ctx;
- PAFile m_fp;
-
- FileLegacyAdapter(const FileLegacyAdapter &) = delete;
- FileLegacyAdapter &operator=(const FileLegacyAdapter &) = delete;
-
- protected:
- FileLegacyAdapter(const std::string &filename, PJ_CONTEXT *ctx, PAFile fp)
- : File(filename), m_ctx(ctx), m_fp(fp) {}
-
- public:
- ~FileLegacyAdapter() override;
-
- size_t read(void *buffer, size_t sizeBytes) override;
- size_t write(const void *, size_t) override { return 0; }
- bool seek(unsigned long long offset, int whence = SEEK_SET) override;
- unsigned long long tell() override;
- void reassign_context(PJ_CONTEXT *ctx) override { m_ctx = ctx; }
-
- // We may lie, but the real use case is only for network files
- bool hasChanged() const override { return false; }
-
- static std::unique_ptr<File> open(PJ_CONTEXT *ctx, const char *filename,
- FileAccess access);
-};
-
-// ---------------------------------------------------------------------------
-
-FileLegacyAdapter::~FileLegacyAdapter() { pj_ctx_fclose(m_ctx, m_fp); }
-
-// ---------------------------------------------------------------------------
-
-size_t FileLegacyAdapter::read(void *buffer, size_t sizeBytes) {
- return pj_ctx_fread(m_ctx, buffer, 1, sizeBytes, m_fp);
-}
-
-// ---------------------------------------------------------------------------
-
-bool FileLegacyAdapter::seek(unsigned long long offset, int whence) {
- if (offset != static_cast<unsigned long long>(static_cast<long>(offset))) {
- pj_log(m_ctx, PJ_LOG_ERROR,
- "Attempt at seeking to a 64 bit offset. Not supported yet");
- return false;
- }
- return pj_ctx_fseek(m_ctx, m_fp, static_cast<long>(offset), whence) == 0;
-}
-
-// ---------------------------------------------------------------------------
-
-unsigned long long FileLegacyAdapter::tell() {
- return pj_ctx_ftell(m_ctx, m_fp);
-}
-
-// ---------------------------------------------------------------------------
-
-std::unique_ptr<File>
-FileLegacyAdapter::open(PJ_CONTEXT *ctx, const char *filename, FileAccess) {
- auto fid = pj_ctx_fopen(ctx, filename, "rb");
- return std::unique_ptr<File>(fid ? new FileLegacyAdapter(filename, ctx, fid)
- : nullptr);
-}
-
-#endif // REMOVE_LEGACY_SUPPORT
-
-// ---------------------------------------------------------------------------
-
class FileApiAdapter : public File {
PJ_CONTEXT *m_ctx;
PROJ_FILE_HANDLE *m_fp;
@@ -954,12 +885,6 @@ std::unique_ptr<File> FileManager::open(PJ_CONTEXT *ctx, const char *filename,
}
return pj_network_file_open(ctx, filename);
}
-#ifndef REMOVE_LEGACY_SUPPORT
- // If the user has specified a legacy fileapi, use it
- if (ctx->fileapi_legacy != pj_get_default_fileapi()) {
- return FileLegacyAdapter::open(ctx, filename, access);
- }
-#endif
if (ctx->fileApi.open_cbk != nullptr) {
return FileApiAdapter::open(ctx, filename, access);
}
@@ -1729,26 +1654,6 @@ NS_PROJ::FileManager::open_resource_file(PJ_CONTEXT *ctx, const char *name) {
}
/************************************************************************/
-/* pj_open_lib() */
-/************************************************************************/
-
-#ifndef REMOVE_LEGACY_SUPPORT
-
-// Used by following legacy function
-static void *pj_ctx_fopen_adapter(PJ_CONTEXT *ctx, const char *name,
- const char *mode) {
- return pj_ctx_fopen(ctx, name, mode);
-}
-
-// Legacy function
-PAFile pj_open_lib(PJ_CONTEXT *ctx, const char *name, const char *mode) {
- return (PAFile)pj_open_lib_internal(ctx, name, mode, pj_ctx_fopen_adapter,
- nullptr, 0);
-}
-
-#endif // REMOVE_LEGACY_SUPPORT
-
-/************************************************************************/
/* pj_find_file() */
/************************************************************************/
diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake
index b0f9a6ba..997eb22d 100644
--- a/src/lib_proj.cmake
+++ b/src/lib_proj.cmake
@@ -219,7 +219,6 @@ set(SRC_LIBPROJ_CORE
ellps.cpp
errno.cpp
factors.cpp
- fileapi.cpp
fwd.cpp
gauss.cpp
generic_inverse.cpp
diff --git a/src/proj_internal.h b/src/proj_internal.h
index 273c1efd..3c1571eb 100644
--- a/src/proj_internal.h
+++ b/src/proj_internal.h
@@ -711,7 +711,6 @@ struct pj_ctx{
int debug_level = 0;
void (*logger)(void *, int, const char *) = nullptr;
void *logger_app_data = nullptr;
- struct projFileAPI_t *fileapi_legacy = nullptr; // for proj_api.h legacy API
struct projCppContext* cpp_context = nullptr; /* internal context for C++ code */
int use_proj4_init_rules = -1; /* -1 = unknown, 0 = no, 1 = yes */
int epsg_file_exists = -1; /* -1 = unknown, 0 = no, 1 = yes */
@@ -933,19 +932,6 @@ PROJ_DLL extern int pj_errno; /* global error return code */
#endif
-/* If included *after* proj.h finishes, we have alternative names */
-/* file reading api, like stdio */
-typedef int *PAFile;
-typedef struct projFileAPI_t {
- PAFile (*FOpen)(PJ_CONTEXT * ctx, const char *filename, const char *access);
- size_t (*FRead)(void *buffer, size_t size, size_t nmemb, PAFile file);
- int (*FSeek)(PAFile file, long offset, int whence);
- long (*FTell)(PAFile file);
- void (*FClose)(PAFile);
-} projFileAPI;
-
-
-
/* procedure prototypes */
PJ_CONTEXT PROJ_DLL *pj_get_default_ctx(void);
@@ -999,23 +985,10 @@ void PROJ_DLL pj_ctx_set_debug( PJ_CONTEXT *, int );
void PROJ_DLL pj_ctx_set_logger( PJ_CONTEXT *, void (*)(void *, int, const char *) );
void PROJ_DLL pj_ctx_set_app_data( PJ_CONTEXT *, void * );
void PROJ_DLL *pj_ctx_get_app_data( PJ_CONTEXT * );
-void PROJ_DLL pj_ctx_set_fileapi( PJ_CONTEXT *, projFileAPI *);
-projFileAPI PROJ_DLL *pj_ctx_get_fileapi( PJ_CONTEXT * );
void PROJ_DLL pj_log( PJ_CONTEXT * ctx, int level, const char *fmt, ... );
void PROJ_DLL pj_stderr_logger( void *, int, const char * );
-/* file api */
-projFileAPI PROJ_DLL *pj_get_default_fileapi(void);
-
-PAFile PROJ_DLL pj_ctx_fopen(PJ_CONTEXT * ctx, const char *filename, const char *access);
-size_t PROJ_DLL pj_ctx_fread(PJ_CONTEXT * ctx, void *buffer, size_t size, size_t nmemb, PAFile file);
-int PROJ_DLL pj_ctx_fseek(PJ_CONTEXT * ctx, PAFile file, long offset, int whence);
-long PROJ_DLL pj_ctx_ftell(PJ_CONTEXT * ctx, PAFile file);
-void PROJ_DLL pj_ctx_fclose(PJ_CONTEXT * ctx, PAFile file);
-char PROJ_DLL *pj_ctx_fgets(PJ_CONTEXT * ctx, char *line, int size, PAFile file);
-
-PAFile PROJ_DLL pj_open_lib(PJ_CONTEXT *, const char *, const char *);
int PROJ_DLL pj_find_file(PJ_CONTEXT * ctx, const char *short_filename,
char* out_full_filename, size_t out_full_filename_size);