Пример #1
0
void
DoArticle(History *h, const char *id, char *nglist, char *dist,
		char *npath, int headOnly, char *artType, char *cSize)
{
    int r = 0;
    if (RequeueOpt) {
	char path[PATH_MAX];
	ArticleFileName(path, (int)sizeof(path), h, ARTFILE_FILE_REL);
	printf("SOUT\t%s\t%lld,%ld\t%s\t%s\t%s\t%s\t%d\t%s\t%s\n",
	    path, (long long)h->boffset, (long)h->bsize, id, nglist, dist,
	    npath, headOnly, artType, cSize
	);
	++LoadCount;
    } else {
	History htmp;

	if ((r = HistoryLookupByHash(h->hv, &htmp)) == 0) {
	    if (UnExpireOpt) {
		uint32 pos = HistoryPosLookupByHash(h->hv, &htmp);
		htmp.exp &= ~EXPF_EXPIRED;
		if (pos != -1 && ForReal && htmp.iter == h->iter &&
						htmp.boffset == h->boffset)
		    HistoryStoreExp(&htmp, (HistIndex)pos);
	    }
	    ++LoadDupCount;
	} else {
	    if (ForReal && !UnExpireOpt)
		HistoryAdd(id, h);
	    ++LoadCount;
	}
    }
    if (VerboseOpt > 1 || (VerboseOpt && r != 0))
	printf("\tMessage %d,%d %s %s\n", h->boffset, h->bsize,
				((r == 0) ? "dup" : "add"), id);
}
Пример #2
0
struct History *HistoryAdd(struct History **hist, char *pszValue, int *count)
{
  struct History *temp = NULL;

  if(pszValue)
  {
    char* szData = (char *)malloc(strlen(pszValue) + 1);
    
    strcpy(szData, pszValue);
    if(*hist) {
      HistoryMoveToTail(hist);
      if(!(*((*hist)->path))) {
        temp = *hist;
        HistoryMovePrev(hist, 1);
      } else temp = NULL;
      if(*hist == temp) {
        (*hist)->path = szData;
        HistoryAdd(hist, "", NULL);
      } else {
        (*hist)->next = (struct History *)malloc(sizeof(struct History));
        if(temp)
          temp->prev = (*hist)->next;
        (*hist)->next->next = temp;
        (*hist)->next->prev = (struct History *)*hist;
        (*hist)->next->path = szData;
      }
    } else {
      *hist = (struct History *)malloc(sizeof(struct History));
      (*hist)->next = NULL;
      (*hist)->prev = NULL;
      (*hist)->path = szData;
    }

    *hist = ((*hist)->next) ? (struct History *)(*hist)->next : (struct History *)(*hist);
    if(count)
      ++(*count);
  }

	return *hist;
}