Exemplo n.º 1
0
// writes changes to a writable book to the bok file.		
void cBooks::readbook_writeable(UOXSOCKET s, P_ITEM pBook, int p, int l)
{
	int ii=0,lines_processed=0,lin=0;
	char line[34],ch;
	unsigned long loopexit=0;
	
	if (a_t) write_title(pBook,s); // if title was changed by writer write the changes "down"
	if (a_t) write_author(pBook,s); // if author was changed by writer write the changes "down" to the bok-file
	
	while (lines_processed<l && (++loopexit < MAXLOOPS) )
	{
		if (ii>511) lines_processed=l; // avoid crash if client sends out inconsitent data
		ch=pagebuffer[s][ii];
		if (lin<33) line[lin]=ch; else line[33]=ch;
		ii++;
		lin++;
		if (ch==0) 
		{
			lines_processed++;
			lin=0;
			
			write_line(pBook, p, lines_processed, line,s);
		}
	}
	
	a_t=0; // dont re-write author and title if not necassairy
}
Exemplo n.º 2
0
void
sql::write_titles(const abstract_mapper_base &mapper, optional<column_id> generated_key) {
    comma_separated_list_scope list_scope(*this);
    mapper.for_each_persistent_column([&](const persistent_column_mapper &p) {
        list_scope.start_item();
        write_title(p, generated_key);
        if (! p.can_be_all_null())  write(" NOT NULL");
    });
}
Exemplo n.º 3
0
/*------------------------------------------------------------------------------
* FUNCTIONS   :
* SYNOPSIS    :
* PARAMETERS  :
* RETURNS     :
* REMARKS     :
* ----------------------------------------------------------------------------*/
void proc_srchmsg()
{
    char        path[MAX_FILENAME_LEN+1], targetDir[MAX_FILENAME_LEN+1];
    char        e_month, e_day;
    time_t      tmp_timet;
    struct tm   *bdtime;
    int         fd;
	int         dRet;
    struct stat statbuf;

	/* 20060921, add(challa) divide for SysName */
	dRet = dFindSysName ( );
	if( dRet == 0 )
		sprintf(path,"%sAAA/%s",HEADLOG_PATH, szSYSNAME);


    if ((SRCHINFO.fp=fopen(SRCHINFO.outfile,"w")) == NULL)
    {
        fprintf(stderr,"ERROR: file(%s) open error(%s)!!!\n",
            SRCHINFO.outfile,strerror(errno));
        exit(1);
    }

    if ((SRCHINFO.err_fp=fopen(SRCHINFO.errfile,"w")) == NULL)
    {
        fprintf(stderr,"ERROR: file(%s) open error(%s)!!!\n",
            SRCHINFO.errfile,strerror(errno));
        exit(1);
    }

    if (SRCHINFO.viewtype == VIEWTYPE_LINE) 
        write_title();
    if (SRCHINFO.srchtype == SRCHTYPE_FILE)
        srch_msg(SRCHINFO.filename);
    else
    {
        bdtime    = localtime(&SRCHINFO.endtime);
        e_month   = bdtime->tm_mon + 1;
        e_day     = bdtime->tm_mday;

        tmp_timet = SRCHINFO.starttime;
        bdtime    = localtime(&tmp_timet);
        while (1)
        {
            sprintf(targetDir,"%s/%02d%02d",path, bdtime->tm_mon+1, bdtime->tm_mday);
            fprintf(stderr,"     : DIRECTORY         : %s\n",targetDir);

            srch_file(targetDir);

            tmp_timet += 86400; 
            bdtime = localtime(&tmp_timet);
            
            if (tmp_timet > SRCHINFO.endtime) break;
        }
    }

    fclose(SRCHINFO.fp);
    fclose(SRCHINFO.err_fp);

    if (stat(SRCHINFO.errfile,&statbuf) != -1)
        if (statbuf.st_size == 0) unlink(SRCHINFO.errfile);

    fprintf(stderr,"     : ------------------------------------------------------------------\n");

    fprintf(stderr,"     : FINAL RESULT      = FILE:%d MESSAGE:%d FOUND:%d WRITTEN:%d\n",
        SRCHINFO.tot_file,SRCHINFO.tot_msg,SRCHINFO.tot_found,SRCHINFO.tot_written);

    if (SRCHINFO.tot_written > 65535)
        fprintf (stderr, "[SPLIT RESULT] split -l 65535 [RESULT_FILE]");

}
Exemplo n.º 4
0
int proc_srchmsg(SRCH_INFO *pSRCHINFO, char *szResBuf)
{
    char        path[MAX_FILENAME_LEN+1], targetDir[MAX_FILENAME_LEN+1];
    char        e_month, e_day;
    time_t      tmp_timet;
    struct tm   *bdtime;
    int         fd;
    struct stat statbuf;
    int         iRet = 0;
	int			dOffset = 0;
	
	dOffset = strlen(szResBuf);
    sprintf(path,"%s",UDRLOG_PATH);

    PASS_EXCEPTION((pSRCHINFO->fp=fopen(pSRCHINFO->outfile,"w")) == NULL,
        FOPEN_FAIL);

    PASS_EXCEPTION((pSRCHINFO->err_fp=fopen(pSRCHINFO->errfile,"w")) == NULL,
        ERR_FOPEN_FAIL);

    if (pSRCHINFO->viewtype == VIEWTYPE_LINE)
    {
        PASS_EXCEPTION(write_title(pSRCHINFO) != 0, TITLE_WRITE_FAIL);
    }

    if (pSRCHINFO->srchtype == SRCHTYPE_FILE)
    {
        PASS_EXCEPTION(srch_msg(pSRCHINFO->filename, pSRCHINFO, szResBuf) != 0,
            SEARCH_FAIL);
    }
    else
    {
        bdtime = localtime(&pSRCHINFO->endtime);
        e_month = bdtime->tm_mon + 1;
        e_day = bdtime->tm_mday;

        tmp_timet = pSRCHINFO->starttime;
        bdtime = localtime(&tmp_timet);
            
        sprintf(targetDir,"%s",path);
        
        PASS_EXCEPTION(srch_file(targetDir, pSRCHINFO, szResBuf)!= 0, SEARCH_FILE_FAIL);

        tmp_timet += 60*60*24;      /* 24½ð£ °æ */
        bdtime = localtime(&tmp_timet);
            
    }

	
	dOffset = strlen(szResBuf);
    sprintf(&szResBuf[dOffset],"    FINAL RESULT = FILE:%d MESSAGE:%d FOUND:%d WRITTEN:%d\n"
							   "    ==========================================================================\n",
        pSRCHINFO->tot_file,pSRCHINFO->tot_msg,pSRCHINFO->tot_found,pSRCHINFO->tot_written);

    if (pSRCHINFO->tot_written > 65535)
        fprintf (stderr, "[SPLIT RESULT] split -l 65535 [RESULT_FILE]");
    
    PASS_CATCH(FOPEN_FAIL)
    fprintf(stderr,"ERROR: file(%s) open error(%s)!!!\n",
        pSRCHINFO->outfile,strerror(errno));
    iRet = -1;
    
    PASS_CATCH(ERR_FOPEN_FAIL)
    fprintf(stderr,"ERROR: file(%s) open error(%s)!!!\n",
        pSRCHINFO->errfile,strerror(errno));
    iRet = -1;
    
    PASS_CATCH(TITLE_WRITE_FAIL)
    fprintf(stderr,"ERROR: file(%s) Write error(%s)!!!\n",
        pSRCHINFO->outfile,strerror(errno));
    iRet = -1;
    
    PASS_CATCH(SEARCH_FAIL)
    fprintf(stderr,"ERROR: SEARCH Fail!!!\n", strerror(errno));
    iRet = -1;
    
    PASS_CATCH(SEARCH_FILE_FAIL)
    fprintf(stderr,"ERROR: SEARCH File Fail!!!\n", strerror(errno));
    iRet = -1;

    PASS_CATCH_END;
    
    fclose(pSRCHINFO->fp);
    fclose(pSRCHINFO->err_fp);

    if (stat(pSRCHINFO->errfile,&statbuf) != -1)
    {
        if (statbuf.st_size == 0) 
        {
            unlink(pSRCHINFO->errfile);
        }
    }

    return iRet;

}
Exemplo n.º 5
0
/* -- output the tune heading -- */
void write_heading(struct abctune *t)
{
	struct SYMBOL *s, *rhythm, *area, *author;
	float lwidth, down1, down2;

	lwidth = ((cfmt.landscape ? cfmt.pageheight : cfmt.pagewidth)
		- cfmt.leftmargin - cfmt.rightmargin) / cfmt.scale;

	if (cfmt.titleformat != 0) {
		write_headform(lwidth);
		bskip(cfmt.musicspace);
		return;
	}

	/* titles */
	for (s = info['T' - 'A']; s != 0; s = s->next)
		write_title(s);

	/* rhythm, composer, origin */
	down1 = cfmt.composerspace + cfmt.font_tb[COMPOSERFONT].size;
	rhythm = (first_voice->key.bagpipe && !cfmt.infoline) ? info['R' - 'A'] : 0;
	if (rhythm) {
		str_font(COMPOSERFONT);
		PUT1("0 %.1f M ",
		     -(cfmt.composerspace + cfmt.font_tb[COMPOSERFONT].size));
		put_inf(rhythm);
		down1 -= cfmt.font_tb[COMPOSERFONT].size;
	}
	area = author = 0;
	if (t->abc_vers < 2)
		area = info['A' - 'A'];
	else	author = info['A' - 'A'];
	if ((s = info['C' - 'A']) != 0 || info['O' - 'A'] || author != 0) {
		float xcomp;
		int align;

		str_font(COMPOSERFONT);
		bskip(cfmt.composerspace);
		if (cfmt.aligncomposer < 0) {
			xcomp = 0;
			align = A_LEFT;
		} else if (cfmt.aligncomposer == 0) {
			xcomp = lwidth * 0.5;
			align = A_CENTER;
		} else {
			xcomp = lwidth;
			align = A_RIGHT;
		}
		down2 = down1;
		if (author != 0) {
			for (;;) {
				bskip(cfmt.font_tb[COMPOSERFONT].size);
				down2 += cfmt.font_tb[COMPOSERFONT].size;
				PUT0("0 0 M ");
				put_inf(author);
				if ((author = author->next) == 0)
					break;
			}
		}
		if ((s = info['C' - 'A']) != 0 || info['O' - 'A']) {
			if (cfmt.aligncomposer >= 0
			    && down1 != down2)
				bskip(down1 - down2);
			for (;;) {
				bskip(cfmt.font_tb[COMPOSERFONT].size);
				PUT1("%.1f 0 M ", xcomp);
				put_inf2r(s,
					  (s == 0 || s->next == 0) ? info['O' - 'A'] : 0,
					  align);
				if (s == 0)
					break;
				if ((s = s->next) == 0)
					break;
				down1 += cfmt.font_tb[COMPOSERFONT].size;
			}
			if (down2 > down1)
				bskip(down2 - down1);
		}

		rhythm = rhythm ? 0 : info['R' - 'A'];
		if ((rhythm || area) && cfmt.infoline) {

			/* if only one of rhythm or area then do not use ()'s
			 * otherwise output 'rhythm (area)' */
			str_font(INFOFONT);
			bskip(cfmt.font_tb[INFOFONT].size + cfmt.infospace);
			PUT1("%.1f 0 M ", lwidth);
			put_inf2r(rhythm, area, A_RIGHT);
			down1 += cfmt.font_tb[INFOFONT].size + cfmt.infospace;
		}
		down2 = 0;
	} else	down2 = cfmt.composerspace + cfmt.font_tb[COMPOSERFONT].size;

	/* parts */
	if (info['P' - 'A']) {
		down1 = cfmt.partsspace + cfmt.font_tb[PARTSFONT].size - down1;
		if (down1 > 0)
			down2 += down1;
		if (down2 > 0.01)
			bskip(down2);
		str_font(PARTSFONT);
		PUT0("0 0 M ");
		put_inf(info['P' - 'A']);
		down2 = 0;
	}
	bskip(down2 + cfmt.musicspace);
}