Пример #1
0
int modifyArticle(Product *article, Suplier *provider, int lenght)
{
    int modIndex;
    int flagModifyOk = 1;
    int i;
    int ret = -1;

    if (article!=NULL && lenght>0)
    {
        getUserInputInt(&modIndex,0,lenght-1,"Ingrese el codigo de producto a modificar\n\n","Por favor ingrese un codigo valido\n\n",0);

        for(i=0;i<lenght;i++)
        {
            if(article[i].isEmpty==0 && article[i].serialNumber==modIndex)
            {
                addArticle(article,provider,lenght);
                flagModifyOk = 0;
                break;
            }
        }
        if(flagModifyOk)
        {
            printf("El articulo indicado no existe, por favor intente nuevamente\n");
        }
        else
        {
            printf("El articulo fue modificado con exito\n");
        }
        ret = 0;
    }
    return ret;
}
/**
	Creates the pubmed XML xml document with the advanced metadata (abstract, keywords and references) of the articles parsed and saved in the database.
	@param filename: name to give to the file to generate
	@param filepath: path to the location where the file will be saved
*/
void ExtendedArticlesXMLGenerator::createXML(const string &fileName, const string &filePath, int nMax)
{	
	//Initialize attributes
	aXMLName=fileName;
	aXMLPath=filePath;
	//Start xml doc
	startXMLGeneration();
	
	//Get articles ids from the database
	vector<int> articleIdList;
	DB.getCrawledArticlesIds(articleIdList, nMax);
	uint nArticles=articleIdList.size();

	//Loop getting articles from the database and adding them to the xml doc
	for(uint i=0; i<nArticles; i++){
		string abstract, articleBody;
		vector<string> keywords;
		vector<int> references;
		int articleId=articleIdList[i];
		DB.getArticleExtendedMetadata(articleId,  abstract, articleBody, keywords, references);
		addArticle(articleId,  abstract, articleBody, keywords, references);	
	}

	//End xml doc
	endXMLGeneration();
}
Пример #3
0
void RssFeed::loadItemsFromDisk()
{
  QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
  QHash<QString, QVariant> all_old_items = qBTRSS.value("old_items", QHash<QString, QVariant>()).toHash();
  const QVariantList old_items = all_old_items.value(m_url, QVariantList()).toList();
  qDebug("Loading %d old items for feed %s", old_items.size(), qPrintable(displayName()));

  foreach (const QVariant& var_it, old_items) {
    QVariantHash item = var_it.toHash();
    RssArticlePtr rss_item = hashToRssArticle(this, item);
    if (rss_item)
      addArticle(rss_item);
  }
Пример #4
0
void NewusGui::fetchingNews() {
	_feedMan.fetchArticle();

	const ArticleList& list = _feedMan.getList();

	ArticleList::const_iterator it = list.begin();
	ArticleList::const_iterator ite = list.end();

	while (it != ite) {
		addArticle(*(it->get()));
		++it;
	}
	emit newsFetchted();
}
Пример #5
0
int runFunctionMenu(int menu, Product *article, Suplier *provider, int lenght)
{
    int ret = 1;

    if(article!=NULL && provider!=NULL && lenght>0)
    {
        switch(menu)
        {
            case ADD :
                cleanScreen();
                addArticle(article, provider, lenght);
                pauseScreen();
            break;

            case MODIFY :
                cleanScreen();
                modifyArticle(article, provider, lenght);
                pauseScreen();
            break;

            case DEL :
                cleanScreen();
                delArticle(article, lenght);
                pauseScreen();
            break;

            case LS_PRODUCT :
                cleanScreen();
                listArticle(article, lenght);
                pauseScreen();
            break;

            case LS_ALL :
                cleanScreen();
                listAll(article, provider, lenght);
                pauseScreen();
            break;

            case EXIT :
                ret = 0;
            break;
        }
    }
    else
    {
        ret = -1;
    }
    return ret;
}
Пример #6
0
static void ScanArticle(streamtokenizer *st, rssFeedData *data)
{
  articleData *article = addArticle(&data->articles, &data->rssItem);
  /*rssFeedItem *item = &(data->rssItem);
  char *articleTitle = item->title;
  char *articleURL = item->url;*/

  int numWords = 0;
  char word[1024];
  char longestWord[1024] = {'\0'};

  while (STNextToken(st, word, sizeof(word))) {
    if (strcasecmp(word, "<") == 0) {
      SkipIrrelevantContent(st); // in html-utls.h
    } else {
      RemoveEscapeCharacters(word);
      if (WordIsWellFormed(word)) {
	char *dummy = word;
	if (HashSetLookup(&(data->stopWords), &dummy)==NULL) {
		//not in stop list, index the word
		indexData *entry = addWordRecord(&data->indices, word);
		indexWord(&entry->counters, article);
		numWords++;
		if (strlen(word) > strlen(longestWord))
	  		strcpy(longestWord, word);
	}
      }
    }
  }

  printf("\tWe counted %d well-formed words [including duplicates].\n", numWords);
  printf("\tThe longest word scanned was \"%s\".", longestWord);
  if (strlen(longestWord) >= 15 && (strchr(longestWord, '-') == NULL)) 
    printf(" [Ooooo... long word!]");
  printf("\n");
}
Пример #7
0
int main(int argc, char **argv) {

	CLIENT *cl;
	
    CGI_varlist *varlist;
    int value;
	const char *author = "author";
	const char *title = "title";
	const char *file = "file";
	
	
	
	const char* authorTmp;
	const char* titleTmp;
	CGI_value* fileValue;
	
	char* authorVal;
	char* titleVal;
	char* fileVal;
	
	
    if ((varlist = CGI_get_all("/tmp/cgi-upload-XXXXXX")) == NULL || 
		varlist == 0)
	{
        redirectError("No CGI data received");
        return 0;
    }
	if((varlist = CGI_get_post(varlist, "/tmp/cgi-upload-XXXXXX")) == NULL || 
		varlist == 0)
	{
		redirectError("No CGI post data received");
        return 0;
	}
	
	if(((authorTmp = CGI_lookup(varlist, author)) == NULL) || strlen(authorTmp) == 0)
	{
		redirectError("Did not receive Author data");
		return 0;
	}
	if(((titleTmp = CGI_lookup(varlist, title)) == NULL) || strlen(titleTmp) == 0)
	{
		redirectError("Did not receive Title data ");
		return 0;
	}
	if(((fileValue = CGI_lookup_all(varlist, file)) == NULL))
	{
		redirectError("Did not receive File data");
		return 0;
	}
	if(fileValue == 0 || fileValue[1] == 0){
		redirectError("No file was uploaded");
		return 0;
	}
	
	authorVal 	= (char*) malloc(strlen(authorTmp)*sizeof(char));
	titleVal 	= (char*) malloc(strlen(titleTmp)*sizeof(char));
	fileVal 	= (char*) malloc(strlen(fileValue[0])*sizeof(char));
	
	strcpy(authorVal, authorTmp);
	strcpy(titleVal, titleTmp);
	strcpy(fileVal, fileValue[0]);
	
    CGI_free_varlist(varlist);	

	cl = createClient();
	value = addArticle(cl, authorVal, titleVal, fileVal);
	clnt_destroy(cl);
	if(value < 0){
		redirectError("Add Article Error");
	}
	redirectSuccess(value);
	return value;
}