/* search list of servers and return first that succeeds when concatenated with the specified path part. Search list can be prefixed by the second argument. */ char* NC_findtestserver(const char* path, const char** servers) { #ifdef USE_DAP #ifdef ENABLE_DAP_REMOTE_TESTS /* NCDAP_ping is defined in libdap2/ncdap.c */ const char** svc; int stat; char* url = (char*)malloc(MAXSERVERURL); if(path == NULL) path = ""; if(strlen(path) > 0 && path[0] == '/') path++; if(servers != NULL) { for(svc=servers;*svc != NULL;svc++) { snprintf(url,MAXSERVERURL,"%s/%s",*svc,path); stat = NCDAP_ping(url); if(stat == NC_NOERR) return url; } } /* not found in user supplied list; try defaults */ for(svc=default_servers;*svc != NULL;svc++) { snprintf(url,MAXSERVERURL,"%s/%s",*svc,path); stat = NCDAP_ping(url); if(stat == NC_NOERR) return url; } if(url) free(url); #endif #endif return NULL; }
/* search list of servers and return first that succeeds when concatenated with the specified path part */ const char* NC_findtestserver(const char* path) { #ifdef USE_DAP /* NCDAP_ping is defined in libdap2/ncdap3.c */ const char** svc; if(path == NULL) path = ""; for(svc=servers;*svc != NULL;svc++) { int stat; char url[4096]; snprintf(url,sizeof(url),"%s%s%s", *svc, (path[0] == '/' ? "" : "/"), path); stat = NCDAP_ping(url); if(stat == NC_NOERR) return *svc; } #endif return NULL; }