File: sendfont.c

package info (click to toggle)
cti-ifhp 2.1.8-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 932 kB
  • ctags: 845
  • sloc: ansic: 6,036; sh: 1,524; makefile: 318
file content (51 lines) | stat: -rw-r--r-- 1,311 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**************************************************************************
 * LPRng IFHP Filter
 * Copyright 1994-1997 Patrick Powell, San Diego, CA <papowell@sdsu.edu>
 *
 * Based on the CTI printer filters.
 *  See COPYRIGHT for details.
 *
 * $Id: sendfont.c,v 2.1 1997/01/05 18:41:45 papowell Exp $
 */

#include "portable.h"
#include "common.h"
#include "hp4.h"


int sendfont(fontfilename)
char *fontfilename;
{
	FILE *ffp;
	int n;
	char buffer[128];

	log(4,"sendfont: sending font '%s'", fontfilename );


	if ((ffp=fopen(fontfilename,"r")) == NULL) {
		logerr(1,"sendfont: cannot open file '%s'",fontfilename);
		return(1);
	}

	log(4,"sendfont: sending ASSIGN string '%s'", ASSIGN );

	write_check(STDOUT, ASSIGN, "sendfont: cannot send ASSIGN font string", DIE);

	while ((n = fread( buffer, 1, sizeof(buffer), ffp)) > 0 ){
		if( writecn( STDOUT, buffer, n ) != n ){
			errorcode = JABORT;
			fatal( "cannot load font file '%s' to printer", fontfilename );
		}
	}
	fclose(ffp);

	write_check(STDOUT, PGRESET, "Cannot send PGRESET font string", DIE);
	write_check(STDOUT, ASSIGN, "Cannot send ASSIGN string", DIE);
	write_check(STDOUT, MKPRIM, "Cannot send MKPRIM string", DIE);
	write_check(STDOUT, MKPERM, "Cannot send MKPERM string", DIE);

	log(4,"sendfont: done");
	return(0); /* success */
};