void *heapAlloc (heap_t *h, size_t size) { sector_t *s,*item,*so; item=(sector_t*)malloc(sizeof(sector_t)); item->dimen=size; char*tmp; if(h->dim<size) { printf("the sector is too big\n"); return NULL; } if(h->policy==first_fit)s=(sector_t*)ExtractElement(h->empty,compare_by_size,(void*)item); if(h->policy==best_fit) s=(sector_t*)ExtractMINElement(h->empty,compare_by_size,(void*)item); if(h->policy==wors_fit)s=(sector_t*)ExtractMAXElement(h->empty,compare_by_size,(void*)item); so=s; s->dimen-=size; if(s->dimen!=0) h->empty=OrderInsert(h->empty,(void*)s,compare_by_offset);//reinserisco avanzo so->offset=(int)h->base; so->offset=size; h->full=OrderInsert(h->full,(void*)so,compare_by_offset); tmp=(char*)h->base; tmp+=size; h->base=(void*)tmp; return(void*)(so->offset); return h->base; }
static void ProcessSingleNewsItem(streamtokenizer *st, hashset *stopWords, hashset *prevSeenArticles, hashset *wordCounts) { char htmlTag[1024]; char articleTitle[1024]; char articleDescription[1024]; char articleURL[1024]; articleTitle[0] = articleDescription[0] = articleURL[0] = '\0'; while (GetNextTag(st, htmlTag, sizeof(htmlTag)) && (strcasecmp(htmlTag, kItemEndTag) != 0)) { if (strncasecmp(htmlTag, kTitleTagPrefix, strlen(kTitleTagPrefix)) == 0) ExtractElement(st, htmlTag, articleTitle, sizeof(articleTitle)); if (strncasecmp(htmlTag, kDescriptionTagPrefix, strlen(kDescriptionTagPrefix)) == 0) ExtractElement(st, htmlTag, articleDescription, sizeof(articleDescription)); if (strncasecmp(htmlTag, kLinkTagPrefix, strlen(kLinkTagPrefix)) == 0) ExtractElement(st, htmlTag, articleURL, sizeof(articleURL)); } if (strncmp(articleURL, "", sizeof(articleURL)) == 0) return; // punt, since it's not going to take us anywhere if (isNewArticle(prevSeenArticles, articleTitle, articleURL)) { ParseArticle(articleTitle, articleDescription, articleURL, stopWords, wordCounts); } else { printf("Skipping previously seen article: \"%s\"\n\tfrom \"%s\"\n", articleTitle, articleURL); } }
static void ProcessSingleNewsItem(streamtokenizer *st, hashset *stopWords, hashset * wordHash, hashset *articlesSeen) { char htmlTag[1024]; char articleTitle[1024]; char articleDescription[1024]; char articleURL[1024]; articleTitle[0] = articleDescription[0] = articleURL[0] = '\0'; while (GetNextTag(st, htmlTag, sizeof(htmlTag)) && (strcasecmp(htmlTag, kItemEndTag) != 0)) { if (strncasecmp(htmlTag, kTitleTagPrefix, strlen(kTitleTagPrefix)) == 0) ExtractElement(st, htmlTag, articleTitle, sizeof(articleTitle)); if (strncasecmp(htmlTag, kDescriptionTagPrefix,strlen(kDescriptionTagPrefix)) == 0) ExtractElement(st, htmlTag, articleDescription, sizeof(articleDescription)); if (strncasecmp(htmlTag, kLinkTagPrefix, strlen(kLinkTagPrefix)) == 0) ExtractElement(st, htmlTag, articleURL, sizeof(articleURL)); } if (strncmp(articleURL, "", sizeof(articleURL)) == 0) return; // punt, since it's not going to take us anywhere ParseArticle(articleTitle,articleDescription,articleURL,stopWords,wordHash,articlesSeen); }
static void ProcessSingleNewsItem(streamtokenizer *st, rssData *allData) { char htmlTag[1024]; char articleTitle[1024]; char articleDescription[1024]; char articleURL[1024]; articleTitle[0] = articleDescription[0] = articleURL[0] = '\0'; int count = 0; while (GetNextTag(st, htmlTag, sizeof(htmlTag)) && (strcasecmp(htmlTag, kItemEndTag) != 0)) { if (strncasecmp(htmlTag, kTitleTagPrefix, strlen(kTitleTagPrefix)) == 0) ExtractElement(st, htmlTag, articleTitle, sizeof(articleTitle)); if (strncasecmp(htmlTag, kDescriptionTagPrefix, strlen(kDescriptionTagPrefix)) == 0) ExtractElement(st, htmlTag, articleDescription, sizeof(articleDescription)); if (strncasecmp(htmlTag, kLinkTagPrefix, strlen(kLinkTagPrefix)) == 0) ExtractElement(st, htmlTag, articleURL, sizeof(articleURL)); count++; if (count == 5 ) break; } if (strncmp(articleURL, "", sizeof(articleURL)) == 0) return; // punt, since it's not going to take us anywhere ParseArticle(articleURL, articleTitle, allData); }