Example #1
0
/*
 * This static method is used to load catalog config info and return the
 * error status (0 is OK, 1 for error).
 *
 * The argument should be a catalog entry of type "directory", where the
 * URL points to the catalog config file. There may be multiple such
 * entries in the form of a catalog server tree.
 */
int CatalogInfo::load(CatalogInfoEntry* e) {
    // loop through the url list until success
    HTTP http;
    int nlines = 0;
    char * s = http.get(e->url(), nlines);
    if (!s) 
	return 1; // http error

    char* ctype = (http.content_type() ? http.content_type() : (char*)"");
    if (strcmp(ctype, "text/html") == 0) {
	// most likely an error message
	return http.html_error(s);
    }

    istringstream is(s);
    e->link(load(is, e->url()));
    if (! e->link()) 
	return 1;		// input error

    // if it is a local config file, allow URL commands
    if (strncmp(e->url(), "file:", 5) == 0)
	HTTP::allowUrlExec(1);
	    
    return 0;	// normal return
}