void ParseURL(char* url,char* protocol,int lprotocol, char* host,int lhost,char* request,int lrequest,int *port) { char *work,*ptr,*ptr2; *protocol = *host = *request = 0; *port=80; work = strdup(url); strupr2(work); ptr = strchr(work,':'); if(ptr!=NULL) { *(ptr++) = 0; strcpy(protocol,work); } else { strcpy(protocol,"HTTP"); ptr = work; } if( (*ptr=='/') && (*(ptr+1)=='/') ) ptr+=2; ptr2 = ptr; while( ValidHostChar(*ptr2) && *ptr2 ) ptr2++; *ptr2=0; strcpy(host,ptr); strcpy(request,url + (ptr2-work)); ptr = strchr(host,':'); if(ptr!=NULL) { *ptr=0; *port = atoi(ptr+1); } free(work); }
/************************************************************************* * *N vpf_display_record * *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * This function displays all of the fields of a particular VPF * record, including the descriptions of the fields and their * values. It accesses the online data dictionary metadata * contained in the specified Value Description Tables. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * row <input> == (row_type) vpf table row structure. * table <input> == (vpf_table_type) vpf table. * fp <input> == (FILE *) pointer to the output file. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels Sept 1991 DOS Turbo C *E *************************************************************************/ void vpf_display_record( row_type row, vpf_table_type table, FILE *fp ) { register int i,j; char *buf,*num, path[128], *tablename; char *attr,*val,*descr, vdtpath[128], fmtdate[40]; vpf_table_type vdt; row_type vdtrow; int found; ossim_int32 l, lval, count, *lptr; short int s,sval,*sptr; float f,*fptr; date_type date; int TABLE_ = 1, ATTR_ = 2, VAL_ = 3, DESCR_ = 4; num = (char *)vpfmalloc(20*sizeof(char)); strcpy( vdtpath, "" ); /* Display all secondary attributes */ for (i=0;i<table.nfields;i++) { switch (table.header[i].type) { case 'T': buf = (char *)get_table_element(i,row,table, NULL,&count); rightjust(buf); if (strcmp( buf, "" ) != 0) { fputs(table.header[i].name,fp); fputs(" - ",fp); fputs(table.header[i].description,fp); fputs(": ",fp); fputs(buf,fp); strcpy( path, table.path ); strcat( path, table.header[i].vdt ); if ( (access(path,4)==0) && (strcmp(table.header[i].vdt,"") != 0) ) { if (strcmp(vdtpath,path) != 0) { if (strcmp(vdtpath,"") != 0) { vpf_close_table(&vdt); } vdt = vpf_open_table( path, disk, "rb", NULL ); } strcpy( vdtpath, path ); for (j=1;j<=vdt.nrows;j++) { vdtrow = read_row( j, vdt ); tablename = (char *)get_table_element( TABLE_, vdtrow, vdt, NULL, &count ); rightjust(tablename); strupr2(tablename); attr = (char *)get_table_element( ATTR_, vdtrow, vdt, NULL, &count ); rightjust(attr); val = (char *)get_table_element( VAL_, vdtrow, vdt, NULL, &count ); rightjust(val); found = FALSE; if ( (strstr(table.name,tablename)) && (ossim_strcasecmp(attr,table.header[i].name)==0) && (ossim_strcasecmp(val,buf)==0) ) { descr = (char *)get_table_element(DESCR_,vdtrow,vdt, NULL, &count); rightjust(descr); fputs(" (",fp); fputs(descr,fp); fputs(")",fp); free(descr); found = TRUE; } free(tablename); free(attr); free(val); free_row( vdtrow, vdt ); if (found) break; } } fputc('\n',fp); } free(buf); break; case 'I': if (table.header[i].count==1) { get_table_element(i,row,table,&l,&count); if (l != NULLINT) { fputs(table.header[i].name,fp); fputs(" - ",fp); fputs(table.header[i].description,fp); fputs(": ",fp); ltoa((int)l,num,10); fputs(num,fp); strcpy( path, table.path ); strcat( path, table.header[i].vdt ); if ( (access(path,4)==0) && (strcmp(table.header[i].vdt,"") != 0) ) { if (strcmp(vdtpath,path) != 0) { if (strcmp(vdtpath,"") != 0) { vpf_close_table(&vdt); } vdt = vpf_open_table( path, disk, "rb", NULL ); } strcpy( vdtpath, path ); for (j=1;j<=vdt.nrows;j++) { vdtrow = read_row( j, vdt ); tablename = (char *)get_table_element( TABLE_, vdtrow, vdt, NULL, &count ); rightjust(tablename); strupr2(tablename); attr = (char *)get_table_element( ATTR_, vdtrow, vdt, NULL, &count ); rightjust(attr); get_table_element( VAL_, vdtrow, vdt, &lval, &count ); found = FALSE; if ( (strstr(table.name,tablename)) && (ossim_strcasecmp(attr,table.header[i].name)==0) && (lval==l) ) { descr = (char *)get_table_element(DESCR_,vdtrow, vdt, NULL, &count); rightjust(descr); fputs(" (",fp); fputs(descr,fp); fputs(")",fp); free(descr); found = TRUE; } free(tablename); free(attr); free_row( vdtrow, vdt ); if (found) break; } } fputc('\n',fp); } } else { get_table_element(i,row,table,&lptr,&count); fputs(table.header[i].name,fp); fputs(" - ",fp); fputs(table.header[i].description,fp); fputs(": (",fp); for (j=0;j<count;j++) { ltoa((int)lptr[j],num,10); fputs(num,fp); if (j<count-1) fputs(", ",fp); } fputs(")\n",fp); } break; case 'S': if (table.header[i].count==1) { get_table_element(i,row,table,&s,&count); if (s != NULLSHORT) { fputs(table.header[i].name,fp); fputs(" - ",fp); fputs(table.header[i].description,fp); fputs(": ",fp); itoa(s,num,10); fputs(num,fp); strcpy( path, table.path ); strcat( path, table.header[i].vdt ); if ( (access(path,4)==0) && (strcmp(table.header[i].vdt,"") != 0) ) { if (strcmp(vdtpath,path) != 0) { if (strcmp(vdtpath,"") != 0) { vpf_close_table(&vdt); } vdt = vpf_open_table( path, disk, "rb", NULL ); } strcpy( vdtpath, path ); for (j=1;j<=vdt.nrows;j++) { vdtrow = read_row( j, vdt ); tablename = (char *)get_table_element( TABLE_, vdtrow, vdt, NULL, &count ); rightjust(tablename); strupr2(tablename); attr = (char *)get_table_element( ATTR_, vdtrow, vdt, NULL, &count ); rightjust(attr); get_table_element( VAL_, vdtrow, vdt, &sval, &count ); found = FALSE; if ( (strstr(table.name,tablename)) && (ossim_strcasecmp(attr,table.header[i].name)==0) && (sval==s) ) { descr = (char *)get_table_element(DESCR_,vdtrow, vdt, NULL, &count); rightjust(descr); fputs(" (",fp); fputs(descr,fp); fputs(")",fp); free(descr); found = TRUE; } free(tablename); free(attr); free_row( vdtrow, vdt ); if (found) break; } } fputc('\n',fp); } } else { get_table_element(i,row,table,&sptr,&count); fputs(table.header[i].name,fp); fputs(" - ",fp); fputs(table.header[i].description,fp); fputs(": (",fp); for (j=0;j<count;j++) { itoa(sptr[j],num,10); fputs(num,fp); if (j<count-1) fputs(", ",fp); } fputs(")\n",fp); } break; case 'F': if (table.header[i].count==1) { get_table_element(i,row,table,&f,&count); if (!is_vpf_null_float(f)) { fputs(table.header[i].name,fp); fputs(" - ",fp); fputs(table.header[i].description,fp); fputs(": ",fp); #if !defined(__APPLE__) && !defined(__FreeBSD__) gcvt(f,6,num); #endif fputs(num,fp); fputc('\n',fp); } } else { get_table_element(i,row,table,&fptr,&count); fputs(table.header[i].name,fp); fputs(" - ",fp); fputs(table.header[i].description,fp); fputs(": (",fp); for (j=0;j<count;j++) { if (is_vpf_null_float(fptr[j])) { fputs("(null)",fp); } else { #if !defined(__APPLE__) && !defined(__FreeBSD__) gcvt(fptr[j],6,num); #endif fputs(num,fp); } if (j<count-1) fputs(", ",fp); } fputs(")\n",fp); } break; case 'D': if (table.header[i].count==1) { get_table_element(i,row,table,date,&count); fputs(table.header[i].name,fp); fputs(" - ",fp); fputs(table.header[i].description,fp); fputs(": ",fp); format_date(date,fmtdate); fputs(fmtdate,fp); fputc('\n',fp); } break; } } if (strcmp(vdtpath,"") != 0) vpf_close_table( &vdt ); free(num); }