diff options
| author | Frank Warmerdam <warmerdam@pobox.com> | 2009-03-09 13:32:02 +0000 |
|---|---|---|
| committer | Frank Warmerdam <warmerdam@pobox.com> | 2009-03-09 13:32:02 +0000 |
| commit | d3c86d308fbf9100462618619f623d01bb450bbd (patch) | |
| tree | 559e8dfe7c0b10579f912d4e2d37a0fc0bd5cc17 /src/pj_init.c | |
| parent | 79ab268f30b5705810b06c9997f20528160e48d3 (diff) | |
| download | PROJ-d3c86d308fbf9100462618619f623d01bb450bbd.tar.gz PROJ-d3c86d308fbf9100462618619f623d01bb450bbd.zip | |
added initial init file caching
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@1542 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src/pj_init.c')
| -rw-r--r-- | src/pj_init.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/pj_init.c b/src/pj_init.c index 5f09c569..6b70d62b 100644 --- a/src/pj_init.c +++ b/src/pj_init.c @@ -106,8 +106,27 @@ static paralist * get_init(paralist **start, paralist *next, char *name) { char fname[MAX_PATH_FILENAME+ID_TAG_MAX+3], *opt; FILE *fid; + paralist *init_items = NULL; + const paralist *orig_next = next; (void)strncpy(fname, name, MAX_PATH_FILENAME + ID_TAG_MAX + 1); + + /* + ** Search for file/key pair in cache + */ + + init_items = pj_search_initcache( name ); + if( init_items != NULL ) + { + next->next = init_items; + while( next->next != NULL ) + next = next->next; + return next; + } + + /* + ** Otherwise we try to open the file and search for it. + */ if (opt = strrchr(fname, ':')) *opt++ = '\0'; else { pj_errno = -3; return(0); } @@ -118,6 +137,14 @@ get_init(paralist **start, paralist *next, char *name) { (void)fclose(fid); if (errno == 25) errno = 0; /* unknown problem with some sys errno<-25 */ + + /* + ** If we seem to have gotten a result, insert it into the + ** init file cache. + */ + if( next != NULL && next != orig_next ) + pj_insert_initcache( name, orig_next->next ); + return next; } |
