コード例 #1
0
ファイル: file.c プロジェクト: bhanug/harvey
int
openfaxfile(Modem *m, char *file)
{
	if((m->bp = Bopen(file, OREAD)) == 0)
		return seterror(m, Esys);
	m->valid &= ~(Vtype);

	if(gsopen(m) == Eok)
		return Eok;
	return picopen(m);
}
コード例 #2
0
ファイル: pictures.c プロジェクト: aksr/heirloom
void
picture (
    char *buf		/* stuff following 'x X PI' command */
)


{


    int		poffset;	/* page offset */
    int		indent;		/* indent */
    int		length;		/* line length  */
    int		totrap;		/* distance to next trap */
    char	name[4096];	/* picture file and page string */
    char	hwo[4096], *p;	/* height, width and offset strings */
    char	flags[4096];	/* miscellaneous stuff */
    int		page = 1;	/* page number pulled from name[] */
    double	frame[4];	/* height, width, y, and x offsets from hwo[] */
    char	units;		/* scale indicator for frame dimensions */
    int		whiteout = 0;	/* white out the box? */
    int		outline = 0;	/* draw a box around the picture? */
    int		scaleboth = 0;	/* scale both dimensions? */
    double	adjx = 0.5;	/* left-right adjustment */
    double	adjy = 0.5;	/* top-bottom adjustment */
    double	rot = 0;	/* rotation in clockwise degrees */
    FILE	*fp_in;		/* for *name */
    int		i;		/* loop index */


/*
 *
 * Called from devcntrl() after an 'x X PI' command is found. The syntax of that
 * command is:
 *
 *	x X PI:args
 *
 * with args separated by colons and given by:
 *
 *	poffset
 *	indent
 *	length
 *	totrap
 *	file[(page)]
 *	height[,width[,yoffset[,xoffset]]]
 *	[flags]
 *
 * poffset, indent, length, and totrap are given in machine units. height, width,
 * and offset refer to the picture frame in inches, unless they're followed by
 * the u scale indicator. flags is a string that provides a little bit of control
 * over the placement of the picture in the frame. Rotation of the picture, in
 * clockwise degrees, is set by the a flag. If it's not followed by an angle
 * the current rotation angle is incremented by 90 degrees, otherwise the angle
 * is set by the number that immediately follows the a.
 *
 */


    if ( picflag == OFF )		/* skip it */
	return;

    endtext();

    flags[0] = '\0';			/* just to be safe */
    if ( sscanf(buf, "%d:%d:%d:%d:%[^:]:%[^:]:%[^:]", &poffset, &indent,
		&length, &totrap, name, hwo, flags) < 6 )  {
	    error(NON_FATAL, "too few arguments to specify picture");
	    return;
    }	/* End if */

    if ( sscanf(name, "%*[^(](%d", &page) == 1 )	/* grab the page number */
	strtok(name, "(");			/* and separate it from the name */

    if ( (fp_in = picopen(name)) == NULL ) {
	error(NON_FATAL, "can't open picture file %s", name);
	return;
    }	/* End if */

    frame[0] = frame[1] = -1;		/* default frame height, width */
    frame[2] = frame[3] = 0;		/* and y and x offsets */

    for ( i = 0, p = hwo-1; i < 4 && p != NULL; i++, p = strchr(p, ',') )
	if ( sscanf(++p, "%lf%c", &frame[i], &units) == 2 )
	    if ( units == 'i' || units == ',' || units == '\0' )
		frame[i] *= res;

    if ( frame[0] <= 0 )		/* check what we got for height */
	frame[0] = totrap;

    if ( frame[1] <= 0 )		/* and width - check too big?? */
	frame[1] = length - indent;

    frame[3] += poffset + indent;	/* real x offset */

    for ( i = 0; flags[i]; i++ )
	switch ( flags[i] )  {
	    case 'c': adjx = adjy = 0.5; break;	/* move to the center */
	    case 'l': adjx = 0; break;		/* left */
	    case 'r': adjx = 1; break;		/* right */
	    case 't': adjy = 1; break;		/* top */
	    case 'b': adjy = 0; break;		/* or bottom justify */
	    case 'o': outline = 1; break;	/* outline the picture */
	    case 'w': whiteout = 1; break;	/* white out the box */
	    case 's': scaleboth = 1; break;	/* scale both dimensions */
	    case 'a': if ( sscanf(&flags[i+1], "%lf", &rot) != 1 )
			  rot += 90;
	}   /* End switch */

    fprintf(tf, "save mark\n");
    fprintf(tf, "[ /NamespacePush pdfmark\n");

    ps_include(name, fp_in, tf, page, whiteout, outline, scaleboth,
		frame[3]+frame[1]/2, -vpos-frame[2]-frame[0]/2, frame[1], frame[0], adjx, adjy, -rot);

    fprintf(tf, "[ /NamespacePop pdfmark\n");
    fprintf(tf, "cleartomark restore\n");
    xymove(hpos, vpos);
    t_sf(1);

    fclose(fp_in);

}   /* End of picture */