⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 psapi.c

📁 用汇编语言或高级语言编写的源程序翻译成机器可执行的机器语言程序的工具称为“语言处理程序.
💻 C
📖 第 1 页 / 共 4 页
字号:
            attrlen = 0;
	attrlen += srclen;

	if ((g_length + attrlen) > 80)		// Only output 80 chars/line
	{
	    PDAdd1Char(restext, 13, &reslen);
	    g_length = attrlen;
	}
	else
	{
	    g_length += attrlen;
	    PDAdd1Char(restext, ' ', &reslen);
	}

	if (styles && !(styles == P_UNDERLINE))
	{
	    if (bufflen)
	    {
	        _MemMove(restext + reslen, buff, bufflen);
		reslen += bufflen;
	    }
	    if (stlen)
	    {
	        _MemMove(restext + reslen, startchars, stlen);
		reslen += stlen;
	    }
	}

	if (srclen)
	{
	    _MemMove(restext + reslen, srctext, srclen);
	    reslen += srclen;
	}

	if (styles && !(styles == P_UNDERLINE))
	{
	    if (endlen)
	    {
	        _MemMove(restext + reslen, endchars, endlen);
		reslen += endlen;
	    }
	}

	_HUnLock(mhand);
	_FreeHand(mhand);

	_HUnLock(reshand);

	_SetHandSize(reshand, reslen);

	retval.ev_type   = 'C';			// Setup the value structure
	retval.ev_handle = reshand;		// for the returning string
	retval.ev_length = reslen;
    }
    else
    {
	retval.ev_type   = 'C';			// Return a handle to Nothing
	retval.ev_handle = _AllocHand(0);
        if (retval.ev_handle == BADHANDLE)
            _Error(182);

	retval.ev_length = 0;
    }

    ParseExtern(28, &retval);			// Call the object's User Proc.

    _RetVal(&retval);				// Return the object and code.
}


/*----------------------------------------------------------------------+
 |  At the beginning of each document, this procedure must be called.   |
 |  This procedure is what initializes the global variables, and        |
 |  sends the supporting code (Postscript procedures) which will be     |
 |  used throughout the printing of the document.  If this procedure    |
 |  is never called, then the Postscript procedures which are referenced|
 |  in outputting text will not be defined and thus, will cause an      |
 |  error in the report.                                                |
 +----------------------------------------------------------------------*/
FAR pddocst(ParamBlk FAR *pblk)
{
    int		i=0;
    TEXT        buff[PDALLOCSIZE], lineext[5];
    double	rval, doclen, scale, lineheight, leading;
    MHANDLE	reshand;
    TEXT FAR	*restext;
    USHORT	reslen=0;
    Value	val;

    g_length = 0;
    g_lmargin = pdNval(11);		// Get the Left Margin

    pdCval(21, buff, &i);		// Get the actual font size

/*----------------------------------------------------------------------+
 |  Determine the line height and the amount of leading.                |
 +----------------------------------------------------------------------*/
    lineheight = StrToNum(buff, i) + pdNval(35);

    rval = pdNval(36) - (g_lmargin * 2);
    lineheight =  pdNval(37) - (pdNval(7) * 2);;

    rval = mydiv(rval,((double)(pblk->p[1].val.ev_long)));
    lineheight = mydiv(lineheight, ((double)pblk->p[0].val.ev_long));

    if (rval < lineheight)
        lineheight = rval;


    i = RealNumToStr(lineheight, buff, 4);
    pdStoreCVal(9, buff, i, NO);

    leading = pdNval(4);

    pdCval(21, buff, &i);
    rval = StrToNum(buff, i);

    leading = mydiv(leading, rval);

/*----------------------------------------------------------------------+
 |  Store the Scaled Superscript fontsize and Scaled Subscript fontsize |
 +----------------------------------------------------------------------*/
    i = RealNumToStr(mydiv(pdNval(22), lineheight), buff, 1);
    pdStoreCVal(19, buff, i, YES);

    i = RealNumToStr(mydiv(pdNval(23), lineheight), buff, 1);
    pdStoreCVal(20, buff, i, YES);

    pdCval(21, buff, &i);
    rval = StrToNum(buff, i);
    rval = mydiv(rval,lineheight);
    pdStoreNVal(34, rval);		// Store the Scaled fontsize

    if ((rval + leading) > 1)		// Store the value to extend lines by
        RealNumToStr(rval + leading - 1, lineext, 3);
    else
    {
        lineext[0] = 48;
        lineext[1] = 00;
    }

    i = RealNumToStr(rval, buff, 4);
    pdStoreCVal(3, buff, i, YES);	// Store the character Scaled fontsize

    if ((reshand = _AllocHand(PDALLOCSIZE * 5)) == BADHANDLE)
        _Error(182);			// Insufficient memory

/* PATCH  :   22/4/92    Enable high ASCII characters to be printed
      by  :   Justin Nye
              Fox Software (UK) Ltd.
*/
    if ((reshand = _AllocHand(PDALLOCSIZE * 10)) == BADHANDLE)
        _Error(182);            // Insufficient memory
/*  <<<< End of Patch >>>> */

/*----------------------------------------------------------------------+
 |  Begin putting together the string which make up the PostScript      |
 |  procedures which will be used later.                                |
 +----------------------------------------------------------------------*/
    _HLock(reshand);
    restext = _HandToPtr(reshand);

    PDAddCharsandCR(restext, "%!PS-Adobe-1.0",				&reslen);
    PDAddCharsandCR(restext, "%%Creator: FoxPro Postscript driver, C Version 1.0", &reslen);
    PDAddCharsandCR(restext, "%%Title:", 				&reslen);

    PDAddChars(restext, "%%Creation Date: ",			   	&reslen);
    if (!_Evaluate(&val, "DTOC(DATE())"))
    {
        _MemMove(restext + reslen, _HandToPtr(val.ev_handle), val.ev_length);
	reslen += val.ev_length;

	_FreeHand(val.ev_handle);
    }

    PDAddChars(restext, "         ",			   	   	&reslen);
    if (!_Evaluate(&val, "TIME()"))
    {
        _MemMove(restext + reslen, _HandToPtr(val.ev_handle), val.ev_length);
	reslen += val.ev_length;

	_FreeHand(val.ev_handle);
	val.ev_handle = BADHANDLE;
    }
    PDAdd1Char(restext, 13, 			         	   	&reslen);


/*----------------------------------------------------------------------+
 |  First the Postscript codes for formfeeds, new lines,                |
 |  displaying an object, and resetting of the font to the default	|
 |  font.                                                               |
 +----------------------------------------------------------------------*/

    PDAddCharsandCR(restext, "/ff {outputflag 0 ne {showpage} if",	&reslen);
    PDAddCharsandCR(restext, "            setupsave restore",		&reslen);
    PDAddCharsandCR(restext, "            /setupsave save def ",	&reslen);
    PDAddCharsandCR(restext, "            0 linepos moveto",            &reslen);
    PDAddCharsandCR(restext, "            /lineno 0 def} def",            &reslen);

    PDAddChars(restext, "/nl {newpath linepos ", 		   	&reslen);
    RealNumToStr((pdNval(10) * rval), buff, 0);
    PDAddChars(restext, buff,						&reslen);
    PDAddCharsandCR(restext, " lt",					&reslen);

    PDAddCharsandCR(restext, "         {ff}",				&reslen);
    PDAddChars(restext, "     {lineno ",                             &reslen);
    NumToStr(pblk->p[0].val.ev_long, buff);
    PDAddChars(restext, buff,						&reslen);
    PDAddCharsandCR(restext, " ge {ff} {/linepos linepos lineheight sub def} ifelse}", &reslen);
    PDAddCharsandCR(restext, "     ifelse",				&reslen);
    PDAddCharsandCR(restext, "     /lineno lineno 1 add def",             &reslen);
    PDAddCharsandCR(restext, "     0 linepos moveto} def",		&reslen);

    PDAddCharsandCR(restext, "/say { show",				&reslen);
    PDAddCharsandCR(restext, "      /outputflag 1 def} def",		&reslen);

    PDAddChars(restext, "/norm {", 			           	&reslen);
    LocalpdCval(18, restext, 						&reslen);
    PDAddCharsandCR(restext, " findfont ",				&reslen);

    PDAddChars(restext, "     ",					&reslen);
    LocalpdCval(3, restext, 						&reslen);
    PDAddCharsandCR(restext, " scalefont setfont} def",			&reslen);

    PDAddCharsandCR(restext, "/slw {0 setlinewidth} def",		&reslen);
    PDAddCharsandCR(restext, "/rmt {rmoveto} def",			&reslen);
    PDAddCharsandCR(restext, "/xy {/objx cp pop def /objy cp exch pop def} def", &reslen);
    PDAddCharsandCR(restext, "/mtxy {objx objy moveto} def",		&reslen);
/* PATCH  :   22/4/92    Enable high ASCII characters to be printed
      by  :   Justin Nye
              Fox Software (UK) Ltd.
*/
    PDAddCharsandCR(restext, "/encoding", &reslen );
    PDAddCharsandCR(restext, "{/newcodes exch def /newfname exch def", &reslen );
    PDAddCharsandCR(restext, " /basefname exch def /basefdict basefname findfont def", &reslen );
    PDAddCharsandCR(restext, " /newfont basefdict maxlength dict def   ", &reslen );
    PDAddCharsandCR(restext, " basefdict", &reslen );
    PDAddCharsandCR(restext, " { exch dup /FID ne { dup /Encoding eq", &reslen );
    PDAddCharsandCR(restext, "   { exch dup length array copy newfont 3 1 roll put }", &reslen );
    PDAddCharsandCR(restext, "   { exch newfont 3 1 roll put }", &reslen );
    PDAddCharsandCR(restext, " ifelse } { pop pop } ifelse } forall", &reslen );
    PDAddCharsandCR(restext, " newfont /FontName newfname put", &reslen );
    PDAddCharsandCR(restext, " newcodes aload pop newcodes length 2 idiv", &reslen );
    PDAddCharsandCR(restext, " { newfont /Encoding get 3 1 roll put} repeat", &reslen );
    PDAddCharsandCR(restext, "newfname newfont definefont pop } def", &reslen );

    PDAddCharsandCR(restext, "/intl [ 21 /section 39 /quotesingle 96 /grave 128 /Ccedilla 129 /udieresis", &reslen );
    PDAddCharsandCR(restext, " 130 /eacute 131 /acircumflex 132 /adieresis 133 /agrave", &reslen );
    PDAddCharsandCR(restext, " 134 /aring 135 /ccedilla 136 /ecircumflex 137 /edieresis", &reslen );
    PDAddCharsandCR(restext, " 138 /egrave 139 /idieresis 140 /icircumflex 141 /igrave", &reslen );
    PDAddCharsandCR(restext, " 142 /Adieresis 143 /Aring 144 /Eacute 145 /ae 146 /AE", &reslen );
    PDAddCharsandCR(restext, " 147 /ocircumflex 148 /odieresis 149 /ograve", &reslen );
    PDAddCharsandCR(restext, " 150 /ucircumflex 151 /ugrave 152 /ydieresis 153 /Odieresis", &reslen );
    PDAddCharsandCR(restext, " 154 /Udieresis 155 /cent 156 /sterling 157 /yen", &reslen );
    PDAddCharsandCR(restext, " 158 /fi 159 /florin 160 /aacute 161 /iacute 162 /oacute 163 /uacute", &reslen );
    PDAddCharsandCR(restext, " 164 /ntilde 165 /Ntilde 166 /ordfeminine 167 /ordmasculine", &reslen );
    PDAddCharsandCR(restext, " 168 /questiondown 170 /logicalnot", &reslen );
    PDAddCharsandCR(restext, " 173 /exclamdown 174 /guillemotleft 175 /guillemotright", &reslen );
    PDAddCharsandCR(restext, " 225 /germandbls 248 /degree", &reslen );

    PDAddCharsandCR(restext, " 226 /Gamma 228 /Sigma", &reslen );
    PDAddCharsandCR(restext, " 224 /alpha 227 /pi 243 /lessequal 236 /infinity", &reslen );
    PDAddCharsandCR(restext, " 241 /plusminus 242 /greaterequal 246 /divide 240 /equivalence", &reslen );
    PDAddCharsandCR(restext, " 247 /approxequal 239 /intersection 238 /element 251 /radical", &reslen );
    PDAddCharsandCR(restext, " ] def", &reslen );
    PDAddCharsandCR(restext, " /Courier /Courier intl encoding", &reslen );
    PDAddCharsandCR(restext, " /Courier-Oblique /Courier-Oblique intl encoding", &reslen );
    PDAddCharsandCR(restext, " /Courier-Bold /Courier-Bold intl encoding", &reslen );
    PDAddCharsandCR(restext, " /Courier-BoldOblique /Courier-BoldOblique intl encoding", &reslen );
    PDAddCharsandCR(restext, " /Helvetica /Helvetica intl encoding", &reslen );
    PDAddCharsandCR(restext, " /Helvetica-Oblique /Helvetica-Oblique intl encoding", &reslen );
    PDAddCharsandCR(restext, " /Helvetica-Bold /Helvetica-Bold intl encoding", &reslen );
    PDAddCharsandCR(restext, " /Helvetica-BoldOblique /Helvetica-BoldOblique intl encoding", &reslen );
    PDAddCharsandCR(restext, " /Times-Roman /Times-Roman intl encoding", &reslen );
    PDAddCharsandCR(restext, " /Times-Italic /Times-Italic intl encoding", &reslen );
    PDAddCharsandCR(restext, " /Times-Bold /Times-Bold intl encoding", &reslen );
    PDAddCharsandCR(restext, " /Times-BoldItalic /Times-BoldItalic intl encoding", &reslen );
/****** end Patch *********/

    PDAddCharsandCR(restext, "/trim {{( ) anchorsearch {pop} {exit} ifelse} loop} def",	&reslen);

    PDAddCharsandCR(restext, "/strw {dup length /strwidth exch def} def",&reslen);

/*----------------------------------------------------------------------+
 |  Second, will be the Postscript codes for pushing the 		|
 |  currentpoint on the stack, moving to a point on the page, 	        |
 |  changing the font, manipulating the stack, and underlining 	        |
 |  an object. Some of these are one command procedures which is 	|
 |  done inorder to minimize the output of the printer driver.	        |
 +----------------------------------------------------------------------*/

    PDAddCharsandCR(restext, "/numwidth {dup stringwidth pop strwidth exch sub} def", &reslen);
    PDAddCharsandCR(restext, "/jfy {strw trim numwidth} def",				&reslen);
    PDAddCharsandCR(restext, "/rj {jfy 0 rmt xy} def",				&reslen);
    PDAddCharsandCR(restext, "/ctr {jfy 2 div 0 rmt xy} def",				&reslen);
    PDAddCharsandCR(restext, "/cp {currentpoint} def", 			&reslen);
    PDAddCharsandCR(restext, "/mt {moveto} def", 			&reslen);
    PDAddCharsandCR(restext, "/font {findfont exch scalefont setfont} def", &reslen);
    PDAddCharsandCR(restext, "/rol {cp 3 -1 roll} def", 			&reslen);
    PDAddCharsandCR(restext, "/mv {rol exch mt pop} def", 		&reslen);
    PDAddCharsandCR(restext, "/up {rol add mt} def", 			&reslen);
    PDAddCharsandCR(restext, "/dn {rol sub mt} def", 			&reslen);

    PDAddChars(restext, "/u1 {xy 0 ",			 		&reslen);
    LocalpdCval(3, restext, 						&reslen);
    PDAddCharsandCR(restext, " -.1 mul rmt} def", 			&reslen);

    PDAddCharsandCR(restext, "/u2 {dup stringwidth",			&reslen);

    PDAddChars(restext, "     ", 			        	&reslen);
    RealNumToStr(pdNval(34) * 0.04, buff, 2);
    PDAddChars(restext, buff, 						&reslen);
    PDAddCharsandCR(restext, " setlinewidth", 				&reslen);

    PDAddCharsandCR(restext, "      rlineto gsave stroke grestore", 	&reslen);
    PDAddCharsandCR(restext, "      mtxy slw say} def", 		&reslen);


/*----------------------------------------------------------------------+
 |  Third will be the Postscript codes to handle the graphical 	        |
 |  characters in range of ASCII 179 to 218.  Each character is	        |
 |  handled sepearately.						|
 +----------------------------------------------------------------------*/

    PDAddCharsandCR(restext, "/gcp {mt 1 0 rmt} def", 			&reslen);

    PDAddChars(restext, "/l1 {dup 0 le {",                              &reslen);
    PDAddChars(restext, lineext,                                        &reslen);
    PDAddChars(restext, " sub} {",						&reslen);
    PDAddChars(restext, lineext,                                        &reslen);
    PDAddCharsandCR(restext, " add} ifelse 0 exch rlineto} def",	&reslen);

    PDAddCharsandCR(restext, "/l2 {0 rlineto} def", 			&reslen);
    PDAddCharsandCR(restext, "/dhl {0 .4 rmt l2 0 .2 rmt l2} def", 	&reslen);
    PDAddCharsandCR(restext, "/dvl {.4 0 rmt l1 .2 0 rmt l1} def", 	&reslen);
    PDAddCharsandCR(restext, "/lm {rol 0 rmt} def", 			&reslen);
    PDAddCharsandCR(restext, "/ulc {mt cp 0 .6 rmt .4 l2 .4 l1} def", 	&reslen);
    PDAddCharsandCR(restext, "/blc {mt cp 0 .4 rmt .4 l2 -.4 l1} def", 	&reslen);
    PDAddCharsandCR(restext, "/urc {mt cp 1 .6 rmt -.4 l2 .4 l1} def", 	&reslen);
    PDAddCharsandCR(restext, "/brc {mt cp 1 .4 rmt -.4 l2 -.4 l1} def",	&reslen);
    PDAddCharsandCR(restext, "/trc {mt cp 0 .6 rmt .6 l2 -.6 l1} def", 	&reslen);
    PDAddCharsandCR(restext, "/lrc {mt cp 0 .4 rmt .6 l2 .6 l1} def", 	&reslen);
    PDAddCharsandCR(restext, "/tlc {mt cp 1 .4 rmt -.6 l2 .6 l1} def", 	&reslen);

    PDAddCharsandCR(restext, "/llc {mt cp 1 .6 rmt -.6 l2 -.6 l1} def",	&reslen);
    PDAddCharsandCR(restext, "/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -