static char * get_map_value ( char *map_file, /* Name of map file */ char *request_point /* Point coordinates */ ) { static char buffer [LINE_MAX], /* Buffer for map file line */ url [LINE_MAX], /* Buffer to store URL */ default_url [LINE_MAX]; /* Default URL value for the map */ char *full_uri; /* Full URI */ FILE *file; int point_x = 0, /* Used only for sscanf */ point_y = 0; ASSERT (map_file); strclr (url); strclr (default_url); file = file_open (map_file, 'r'); if (file) { /* Get the coodinates of point */ if (request_point) sscanf (request_point, "%d,%d", &point_x, &point_y); /* Note: The first line of map sets the value url_def */ while (file_readn (file, buffer, LINE_MAX)) { /* Ignore comments and blank lines */ if ((buffer [0] == '#') || strnull (buffer)) continue; point_in_map_element (buffer, url, point_x, point_y, default_url); if (strused (url)) break; } /* If not found a URL, set the return with the default value */ if (strnull (url)) strcpy (url, default_url); file_close (file); } /* Return final URL string, or NULL if we did not find anything */ if (strused (url)) { full_uri = build_full_url (url, map_file); strcpy (url, full_uri); mem_free (full_uri); return (url); } else return (NULL); }
static rc_t prepare_load( KDirectory * dir, const p_context ctx ) { rc_t rc = 0; if ( !ctx->input_is_file ) { /* if the input is not specified as a file, we check for url and correctness */ if ( !is_full_url( ctx->src ) ) { if ( !ctx->quiet ) KOutMsg( "src is not a full url, assuming it is a accession\n" ); rc = build_full_url( &ctx->src ); if ( rc != 0 ) { LOGERR( klogErr, rc, "prepare_load:build_full_url() failed" ); } } } /* and then we look if the given schema does exist */ if ( rc == 0 ) { if ( ctx->schema == NULL ) { ctx->schema = string_dup_measure ( DEFAULT_SCHEMA, NULL ); } if ( ctx->chunk_size == 0 ) { ctx->chunk_size = TableWriterRefSeq_MAX_SEQ_LEN; } rc = check_if_schema_exists( dir, ctx->schema ); if ( rc != 0 ) { LOGERR( klogErr, rc, "check_if_schema_exists() failed" ); } else if ( !ctx->quiet ) { KOutMsg( "src = '%s'\n", ctx->src ); KOutMsg( "dst = '%s'\n", ctx->dst_path ); KOutMsg( "schema = '%s'\n", ctx->schema ); KOutMsg( "chunk-size = %u\n", ctx->chunk_size ); KOutMsg( "srs is file= %s\n", ctx->input_is_file ? "yes" : "no" ); } } return rc; }