/* process a url specified in a META refresh tag */ static CRAWL_TagError crawl_addPageMetaRefresh(CRAWL_PageInfo page, char *content) { /* look for the url= */ char *url = XP_STRCASESTR(content, "url="); if (url != NULL) { url += 4; /* go past the url= */ url = XP_STRTOK(url, " '\""); return(crawl_addPageLink(page, url, LINK_CONTEXT_HREF)); } else return CRAWL_TAG_SYNTAX_ERR; }
/* parse lines in an HTML help mapping file. * get window_size and name, etc... * * when the id is found function returns HTML_HELP_ID_FOUND * on error function returns negative error code. */ PRIVATE int net_ParseHTMLHelpLine(HTMLHelpParseObj *obj, char *line_data) { char *line = XP_StripLine(line_data); char *token; char *next_word; if(*line == '<') { /* find and terminate the end '>' */ XP_STRTOK(line, ">"); token = XP_StripLine(line+1); if(!strncasecomp(token, ID_MAP_TOKEN, sizeof(ID_MAP_TOKEN)-1)) { obj->in_id_mapping = TRUE; } else if(!strncasecomp(token, END_ID_MAP_TOKEN, sizeof(END_ID_MAP_TOKEN)-1)) { obj->in_id_mapping = FALSE; } else if(!strncasecomp(token, FRAME_GROUP_TOKEN, sizeof(FRAME_GROUP_TOKEN)-1)) { char *cp = token + sizeof(FRAME_GROUP_TOKEN)-1; frame_set_struct * fgs = XP_NEW(frame_set_struct); while(isspace(*cp)) cp++; if(fgs) { XP_MEMSET(fgs, 0, sizeof(frame_set_struct)); next_word=NULL; /* init */ do { if(!strncasecomp(cp, SRC_TOKEN, sizeof(SRC_TOKEN)-1)) { char *address = net_get_html_help_token( cp+sizeof(SRC_TOKEN)-1, &next_word); cp = next_word; fgs->address = XP_STRDUP(address); } else if(!strncasecomp(cp, WINDOW_TOKEN, sizeof(WINDOW_TOKEN)-1)) { char *window = net_get_html_help_token( cp+sizeof(WINDOW_TOKEN)-1, &next_word); cp = next_word; fgs->target = XP_STRDUP(window); } else { /* unknown attribute. Skip to next whitespace */ while(*cp && !isspace(*cp)) cp++; if(*cp) { while(isspace(*cp)) cp++; next_word = cp; } else { next_word = NULL; } } } while(next_word); XP_ListAddObject(obj->frame_group_stack, fgs); } } else if(!strncasecomp(token, END_FRAME_GROUP_TOKEN, sizeof(END_FRAME_GROUP_TOKEN)-1)) { frame_set_struct *fgs; fgs = XP_ListRemoveTopObject(obj->frame_group_stack); if(fgs) net_help_free_frame_group_struct(fgs); } } else if(!obj->in_id_mapping) { if(!strncasecomp(line, WINDOW_SIZE_TOKEN, sizeof(WINDOW_SIZE_TOKEN)-1)) { /* get window size */ char *comma=0; char *window_size = net_get_html_help_token(line+ sizeof(WINDOW_SIZE_TOKEN)-1, NULL); if(window_size) comma = XP_STRCHR(window_size, ','); if(comma) { *comma = '\0'; obj->window_width = XP_ATOI(window_size); obj->window_height = XP_ATOI(comma+1); } } else if(!strncasecomp(line, WINDOW_NAME_TOKEN, sizeof(WINDOW_NAME_TOKEN)-1)) { char *window_name = net_get_html_help_token(line+ sizeof(WINDOW_NAME_TOKEN)-1, NULL); if(window_name) { FREEIF(obj->window_name); obj->window_name = XP_STRDUP(window_name); } } else if(!strncasecomp(line, HELP_VERSION_TOKEN, sizeof(HELP_VERSION_TOKEN)-1)) { /* get window size */ char *help_version = net_get_html_help_token(line+ sizeof(HELP_VERSION_TOKEN)-1, NULL); if(help_version) { obj->helpVersion = XP_ATOI(help_version); } } } else { /* id mapping pair */ if(!strncasecomp(line, obj->id, XP_STRLEN(obj->id))) { char *id_value = net_get_html_help_token(line+XP_STRLEN(obj->id), &next_word); if(id_value) { obj->id_value = XP_STRDUP(id_value); while(next_word) { char *cp = next_word; if(!strncasecomp(cp, TARGET_TOKEN, sizeof(TARGET_TOKEN)-1)) { char *target = net_get_html_help_token( cp+sizeof(TARGET_TOKEN)-1, &next_word); cp = next_word; obj->content_target = XP_STRDUP(target); } else { /* unknown attribute. Skip to next whitespace */ while(*cp && !isspace(*cp)) cp++; if(*cp) { while(isspace(*cp)) cp++; next_word = cp; } else { next_word = NULL; } } } } return(HTML_HELP_ID_FOUND); } if(!strncasecomp(line, DEFAULT_HELP_ID, sizeof(DEFAULT_HELP_ID)-1)) { char *default_id_value = net_get_html_help_token( line+sizeof(DEFAULT_HELP_ID)-1, NULL); if(default_id_value) obj->default_id_value = XP_STRDUP(default_id_value); } } return(0); }