int CScntv2Q (struct csGeodeticXfromParmsFile_* fileParms,Const char* dictDir,int err_list [],int list_sz) { extern char cs_DirsepC; int err_cnt; size_t rdCnt; char *cp; csFILE* strm; char chrBuffer [16]; char pathBuffer [MAXPATH]; cp = fileParms->fileName; if (*cp == '.' && *(cp + 1) == cs_DirsepC) { CS_stncp (pathBuffer,dictDir,sizeof (pathBuffer)); CS_stncat (pathBuffer,cp,MAXPATH); } else { CS_stncp (pathBuffer,cp,MAXPATH); } /* We will return (err_cnt + 1) below. */ err_cnt = -1; if (err_list == NULL) list_sz = 0; /* Verify that the file exists and that the format appears to be correct. */ strm = CS_fopen (pathBuffer,_STRM_BINRD); if (strm != NULL) { rdCnt = CS_fread (chrBuffer,1,sizeof (chrBuffer),strm); CS_fclose (strm); strm = NULL; if (rdCnt != sizeof (chrBuffer) || CS_strnicmp (chrBuffer,"NUM_OREC",8)) { if (++err_cnt < list_sz) err_list [err_cnt] = cs_DTQ_FORMAT; } } else { if (++err_cnt < list_sz) err_list [err_cnt] = cs_DTQ_FILE; } return (err_cnt + 1); }
Const char* EXP_LVL3 CS_stristr (Const char *str1,Const char *str2) { int status; int cmpCnt; size_t strLen; strLen = strlen (str2); if (strLen == 0) return NULL; status = -1; cmpCnt = (int)strlen (str1) - (int)strLen + 1; while (cmpCnt-- > 0) { if ((status = CS_strnicmp (str1,str2,strLen)) == 0) break; str1 += 1; } return status ? NULL : str1; }
Const void * EXP_LVL9 CS_tpars (char **pntr,Const void *table,int tab_size) { Const char *tab_ptr; tab_ptr = (Const char *)table; while (*tab_ptr != '\0') { if (!CS_strnicmp ((tab_ptr + 1),*pntr,(unsigned char)*tab_ptr)) { break; } tab_ptr += tab_size; } if (*tab_ptr) { *pntr += (unsigned char)*tab_ptr; } else { tab_ptr = NULL; } return (tab_ptr); }
/****************************************************************************** Constructor: This is a constructor for the "Entry" object. A linked list of these "Entry" objects is underlying structure of the main object. NOTE: the specific of handling different file types are handled here. */ struct csNad27ToCsrsEntry_* CSnewNad27ToCsrsEntry (struct csDatumCatalogEntry_* catPtr) { extern char cs_DirsepC; extern struct csNad27ToAts77_* csNad27ToAts77; extern struct csAts77ToCsrs_* csAts77ToCsrs; int st; char *cp; struct csNad27ToCsrsEntry_* __This; /* Prepare for an error. */ __This = NULL; /* Allocate some storage. */ __This = (struct csNad27ToCsrsEntry_*) CS_malc (sizeof (struct csNad27ToCsrsEntry_)); if (__This == NULL) { CS_erpt (cs_NO_MEM); goto error; } __This->next = NULL; __This->type = dtNad27ToCsrsNoneYet; __This->density = catPtr->density; __This->pointers.c2DatumPtr = NULL; /* See if this is the special case where conversion required is through the ATS77 facility. */ cp = strrchr (catPtr->pathName,cs_DirsepC); if (cp != NULL) cp += 1; else cp = catPtr->pathName; if (!CS_strnicmp (cp,"Ats77ToCsrs",11)) { /* Here if we have a Maritime Province reference. */ __This->pointers.nad27ToCsrsViaXfrm = (struct csNad27ToCsrsXfrm_ *)CS_malc (sizeof (struct csNad27ToCsrsXfrm_)); if (__This->pointers.nad27ToCsrsViaXfrm == NULL) { CS_erpt (cs_NO_MEM); goto error; } __This->pointers.nad27ToCsrsViaXfrm->nad27ToAts77 = NULL; __This->pointers.nad27ToCsrsViaXfrm->ats77ToCsrs = NULL; __This->type = dtNad27ToCsrsXfrm; st = CSn27a77Init (); if (st == 0) { __This->pointers.nad27ToCsrsViaXfrm->nad27ToAts77 = csNad27ToAts77; if (__This->density == 0.0) { __This->density = 0.100000; } } else { goto error; } st = CSats77Init (); if (st == 0) { __This->pointers.nad27ToCsrsViaXfrm->ats77ToCsrs = csAts77ToCsrs; if (__This->density < 0.00833333333) { __This->density = 0.098333333333; } } else { goto error; } } else { /* Set up the file; construct a Canadian National Transformation, Version 2 object. It's smart enough to deal with the differences between the Canadian format and the Australian variation. */ __This->pointers.c2DatumPtr = CSnewDatumShiftCa2 (dtcTypeAustralian,catPtr->pathName,catPtr->bufferSize,catPtr->flags,catPtr->density); if (__This->pointers.c2DatumPtr == NULL) { goto error; } __This->type = dtNad27ToCsrsC2; } return __This; error: CSdeleteNad27ToCsrsEntry (__This); return NULL; }