예제 #1
0
ufs_inode_t* ufs_traverse_path(ufs_t *mount, const char *_path)
{
    uint32_t i;
    uint32_t inum = 2; // 2 == root
    ufs_inode_t *inode = p_alloc(mount->pool, sizeof(ufs_inode_t));
    char *path = p_alloc(mount->pool, strlen(_path)+1);
    strcpy(path, _path);
    
    if (!ufs_load_inode(mount, inode, inum))
        goto fail;
    
    char *last, *elem;
    for (elem = strtok_r(path, "/", &last);
         elem;
         elem = strtok_r(NULL, "/", &last)) {
        
        uint32_t next_inum = 0;
        uint8_t *dir = ufs_read_inode_data(mount, inode);
        if (!dir)
            goto fail;
        
        for (i=0; inode->size; ) {
            ufs_dir_t *entry = (ufs_dir_t*)&dir[i];
            fix_endian(entry->inum);
            fix_endian(entry->len);
            fix_endian(entry->namelen);
            
            if (entry->inum == 0)
                break;
            
            if ((entry->namelen == strlen(elem)) &&
                (strncmp(elem, entry->name, entry->namelen) == 0)) {
                next_inum = entry->inum;
                break;
            }
            
            i += entry->len;
        }
        
        p_free(dir);
        
        if (next_inum == 0) {
            sprintf(mount->error_str, "'%s' in '%s' doesn't exist", elem, _path);
            goto fail;
        }
        
        inum = next_inum;
        if (!ufs_load_inode(mount, inode, inum))
            goto fail;
    }
    
    p_free(path);
    return inode;
    
fail:
    p_free(inode);
    p_free(path);
    return NULL;
}
예제 #2
0
static uint8_t* svfs_read_inode_data(svfs_t *mount, svfs_inode_t *inode)
{
    uint8_t *tmp = p_alloc(mount->pool, mount->blocksize);
    uint8_t *buf = p_alloc(mount->pool, inode->size);
    uint32_t i, len = 0;
    
    // The first 10 block pointers in the inode point to data
    // The addr[10] is a L1 block pointer, [11] is L2, and [12] is L3
    for (i=0; (len < inode->size) && (i < 10); i++) {
        uint32_t chunk_size = inode->size - len;
        if (chunk_size > mount->blocksize)
            chunk_size = mount->blocksize;
        
        if (!svfs_read_block(mount, tmp, inode->addr[i])) {
            sprintf(mount->error_str, "couldn't read svfs block num %u at L0", inode->addr[i]);
            goto fail;
        }
        
        memcpy(buf + len, tmp, chunk_size);
        len += chunk_size;
    }
    
    
    if (!svfs_read_block(mount, tmp, inode->addr[10])) {
        sprintf(mount->error_str, "couldn't read svfs L1 block ptr %u", inode->addr[10]);
        goto fail;
    }
    else if (!svfs_read_level(mount, inode, buf, &len, (uint32_t*)tmp, 1))
        goto fail;
    
    if (!svfs_read_block(mount, tmp, inode->addr[11])) {
        sprintf(mount->error_str, "couldn't read svfs L2 block ptr %u", inode->addr[11]);
        goto fail;
    }
    else if (!svfs_read_level(mount, inode, buf, &len, (uint32_t*)tmp, 2))
        goto fail;
    
    if (!svfs_read_block(mount, tmp, inode->addr[12])) {
        sprintf(mount->error_str, "couldn't read svfs L3 block ptr %u", inode->addr[12]);
        goto fail;
    }
    else if (!svfs_read_level(mount, inode, buf, &len, (uint32_t*)tmp, 3))
        goto fail;
    
    p_free(tmp);
    return buf;
    
fail:
    p_free(tmp);
    p_free(buf);
    return NULL;
}
예제 #3
0
파일: str.c 프로젝트: duzhe/dzsh
struct str *s_dup(struct mempool *pool, const char *c_str)
{
	struct str *str;
	char *data;
	int len;
	str = p_alloc(pool, sizeof(struct str));
	len = strlen(c_str);
	data = p_alloc(pool, len);
	memcpy(data, c_str, len);
	str->len = len;
	str->data = data;
	return str;
}
예제 #4
0
int MFAnyStrPtr(WYSIWYG *wn, CNTRLS *control, int frame, char *data, int to_ac)
{
	if (trace_misc)
		p_info(PI_TRACE, "entering MFAnyStrPtr(p%1d:%#x %s data:%#x)\n",
				  control->off_rel, *(&REL_DATA(frame) p0 + control-> off_rel),
				  to_ac ? "-->" : "<--", data);
	
	if (to_ac)
	{
		if (*(&REL_DATA(frame) p0 + control -> off_rel) && data)
			strcpy(data, *(&REL_DATA(frame) p0 + control -> off_rel));
	}
	else if (data)
	{
		if (*(&REL_DATA(frame) p0 + control -> off_rel))
			*(&REL_DATA(frame) p0 + control -> off_rel) =
				p_realloc(*(&REL_DATA(frame) p0	+ control -> off_rel),
						  strlen(data)+1);
		else
			*(&REL_DATA(frame) p0 + control -> off_rel) =
				p_alloc(strlen(data)+1);
		
		strcpy(*(&REL_DATA(frame) p0 + control -> off_rel), data);
	}
	
	if (trace_misc)
		p_info(PI_TRACE, "leaving MFAnyStrPtr(p%1d:%#x %s data:%#x (%s))\n",
				  control->off_rel, *(&REL_DATA(frame) p0 + control-> off_rel),
				  to_ac ? "-->" : "<--", data, data ? data : "NULL");
	return(0);					/* Just so it returns something */
}
예제 #5
0
CLIP_POINTS *lmt_BuildClipPoints(DRAW_POINT_X_Y *lp, int n_pts)
{
	CLIP_POINTS *start = NULL, *list, *prev = NULL;
	int i;
	
	for (i = 0; i < n_pts; i++)
	{
		list = (CLIP_POINTS *)p_alloc(sizeof(CLIP_POINTS));
		memcpy((char *)&list -> pt,
					 (char *)lp, sizeof(DRAW_POINT_X_Y));
		list -> hard = 1;
		if (prev)
		{
			prev -> next = list;
			list -> prev = prev;
		}
		else
			start = list;
		prev = list;
		lp++;
	}
	prev -> next = start;
	start -> prev = prev;
	return(start);
}
예제 #6
0
static uint8_t* ufs_read_inode_data(ufs_t *mount, ufs_inode_t *inode)
{
    uint32_t i, j;
    uint8_t *block = p_alloc(mount->pool, mount->block_size);
    uint8_t *buf = p_alloc(mount->pool, inode->size);
    uint64_t len = 0;
    
    /* Read in direct blocks */
    for (i=0; (i<12) && (len < inode->size); i++) {
        
        // How many bytes are we reading from this block?
        uint64_t chunk_size = inode->size - len;
        if (chunk_size > mount->block_size) chunk_size = mount->block_size;
        
        // Which block are we reading, and at which byte-offset into it does our data exist
        const uint32_t block_addr = (inode->direct[i] / mount->frag_per_block) * mount->frag_per_block;
        const uint32_t block_offset = (inode->direct[i] - block_addr) * mount->frag_size;
        
        // slog("block_addr=0x%08x, block_offset")
        
        // If the chunk_size is a whole block, then we better be reading in a whole block
        if (chunk_size == mount->block_size)
            assert(block_offset == 0);
        
        if (!ufs_read_block(mount, block, block_addr))
            goto fail;
        
        memcpy(buf + len, block + block_offset, chunk_size);

        len += chunk_size;
        // slog("direct block %u = 0x%08x\n", i, inode->direct[i]);
    }


    for (i=0; i<3; i++) {
        if (!ufs_read_level(mount, inode, buf, &len, inode->indirect[i], i+1))
            goto fail;
    }
    
    
    p_free(block);
    return buf;
fail:
    p_free(block);
    p_free(buf);
    return NULL;
}
예제 #7
0
svfs_inode_t* svfs_traverse_path(svfs_t *mount, const char *_path)
{
    uint32_t i;
    uint16_t inum = 2; // 2 == root
    svfs_inode_t *inode = p_alloc(mount->pool, sizeof(svfs_inode_t));
    char *path = p_alloc(mount->pool, strlen(_path)+1);
    strcpy(path, _path);
    
    if (!svfs_load_inode(mount, inode, inum))
        goto fail;
    
    char *last, *elem;
    for (elem = strtok_r(path, "/", &last);
         elem;
         elem = strtok_r(NULL, "/", &last)) {
        //slog("elem = [%s]\n", elem);
        const uint32_t num_entries = inode->size / 16;
        //slog("inode size = %u\n", inode->size);
        svfs_dir_entry_t *dir = (svfs_dir_entry_t*)svfs_read_inode_data(mount, inode);
        if (!dir)
            goto fail;
        
        for (i=0; i<num_entries; i++) {
            if (strncmp(dir[i].name, elem, 14) == 0) {
                inum = ntohs(dir[i].inum);
                if (!svfs_load_inode(mount, inode, inum)) {
                    p_free(dir);
                    goto fail;
                }
                break;
            }
        }
        p_free(dir);
        if (i == num_entries) {
            sprintf(mount->error_str, "'%s' in '%s' doesn't exist", elem, _path);
            goto fail;
        }
    }
    //slog("final inode size = %u\n", inode->size);
    p_free(path);
    return inode;
    
fail:
    p_free(inode);
    p_free(path);
    return NULL;
}
예제 #8
0
파일: str.c 프로젝트: duzhe/dzsh
struct str *s_make(struct mempool *pool, const char *data, size_t len)
{
	struct str *str;
	str = p_alloc(pool, sizeof(struct str));
	str->len = len;
	str->data = data;
	return str;
}
예제 #9
0
파일: str.c 프로젝트: duzhe/dzsh
struct str *s_new(struct mempool *pool)
{
	struct str *str;
	str = p_alloc(pool, sizeof(struct str));
	str->len = 0;
	str->data = NULL;
	return str;
}
예제 #10
0
파일: str.c 프로젝트: duzhe/dzsh
char *p_sdup(struct mempool *pool, struct str *str)
{
	char *p;
	p = p_alloc(pool, str->len+1);
	memcpy(p, str->data, str->len+1);
	p[str->len] = '\0';
	return p;
}
예제 #11
0
static svfs_t* svfs_mount(partition_t *part)
{
    assert(sizeof(svfs_superblock_t) == 512);
    
    uint32_t i;
    svfs_t *mount = p_alloc(part->pool, sizeof(svfs_t));
    mount->pool = part->pool;
    mount->error_str = part->error_str;
    mount->part = part;
    
    part_get_block(part, (uint8_t*)&mount->superblock, 1);
    
    fix_endian(mount->superblock.isize);
    fix_endian(mount->superblock.fsize);
    fix_endian(mount->superblock.nfree);
    for (i=0; i<50; i++) {
        fix_endian(mount->superblock.free[i]);
    }
    fix_endian(mount->superblock.ninode);
    for (i=0; i<100; i++) {
        fix_endian(mount->superblock.inode[i]);
    }
    fix_endian(mount->superblock.time);
    for (i=0; i<4; i++) {
        fix_endian(mount->superblock.dinfo[i]);
    }
    fix_endian(mount->superblock.tfree);
    fix_endian(mount->superblock.tinode);
    fix_endian(mount->superblock.state);
    fix_endian(mount->superblock.lasti);
    fix_endian(mount->superblock.nbehind);
    fix_endian(mount->superblock.magic);
    fix_endian(mount->superblock.type);
    
    if (mount->superblock.magic != 0xfd187e20) {
        sprintf(part->error_str, "Magic doesn't match svfs");
        goto fail;
    }
    
    // It is SVFS!
    
    const uint32_t type = mount->superblock.type;
    if ((type != 1) && (type != 2) && (type != 4) && (type != 8)) {
        sprintf(part->error_str, "Unknown SVFS type (%u)", type);
        goto fail;
    }
    
    mount->blocksize = 512 * type;
    
    return mount;
    
fail:
    if (mount) p_free(mount);
    
    return NULL;
}
예제 #12
0
Piece
p_make(int file, int pos, int len, Piece prev, Piece next)
{
  Piece p = p_alloc();
  p->file = file;
  p->pos = pos;
  p->len = len;
  p->prev = prev;
  p->next = next;
  return p;
}
예제 #13
0
static uint8_t ufs_load_inode(ufs_t *mount, ufs_inode_t *inode, uint32_t inum)
{
    assert(sizeof(ufs_inode_t) == 128);
    
    /* Which cylinder group is this inode in? */
    const uint32_t group_num = inum / mount->superblock.ipg;
    
    /* Index of this inode in its cylinder group's inode table */
    const uint32_t group_ino_offset = inum % mount->superblock.ipg;
    
    /* Fragment address that contains inode */
    const uint32_t frag_addr = ufs_group_base(mount, group_num) +
                               mount->superblock.iblkno +
                               ((group_ino_offset * 128) / mount->frag_size);
    
    /* Byte offset into the fragment where the inode begins */
    const uint32_t frag_offset = (group_ino_offset * 128) % mount->frag_size;
    
    uint32_t i;
    uint8_t *buf = p_alloc(mount->pool, mount->frag_size);
    
    // slog("group_num = %u, ino_offset=%u, addr = 0x%08x, offset = 0x%08x\n", group_num, group_ino_offset, frag_addr, frag_offset);
    // slog("mount->superblock.iblkno = 0x%08x\n", mount->superblock.iblkno);
    
    if (!ufs_read_frag(mount, buf, frag_addr))
        goto fail;
    
    memcpy(inode, buf + frag_offset, 128);
    
    fix_endian(inode->mode);
    fix_endian(inode->nlink);
    fix_endian(inode->uid);
    fix_endian(inode->gid);
    fix_endian(inode->size_hi);
    fix_endian(inode->size);
    fix_endian(inode->atime);
    fix_endian(inode->mtime);
    fix_endian(inode->ctime);
    for (i=0; i<12; i++)
        fix_endian(inode->direct[i]);
    for (i=0; i<3; i++)
        fix_endian(inode->indirect[i]);
    fix_endian(inode->flags);
    fix_endian(inode->blocks);
    fix_endian(inode->gen);
    
    p_free(buf);
    return 1;
fail:
    if (buf)
        p_free(buf);
    return 0;
}
예제 #14
0
파일: tree.c 프로젝트: NHALX/llio
struct vertex *tree_vertex(struct ctx *x)
{
	struct vertex *v;
	GUARD(v = p_alloc(P_ALLOC_VERTEX));
	memset(v, 0, sizeof *v);

#ifdef DEBUG_VERTEX_INDEX
	v->index = x->vertex_count;
#endif
	x->vertex_count++;
	return v;
}
예제 #15
0
Piece
p_load_file(char *name, Piece prev, Piece next)
{
  Piece p = p_alloc();
  p->file = open(name, O_RDONLY, 0);
  p->len = file_size(p->file);
  p->prev = prev;
  if (prev != NULL) prev->next = p;
  p->next = next;
  if (next != NULL) next->prev = p;
  return p;
}
예제 #16
0
LIST_PT *lmt_AddPtToList(LIST_PT *list_pt, CLIP_POINTS *cur)
{
#ifdef TRACE
	if (trace_lmt)
		p_info(PI_TRACE, "lmt_AddPtToList: x: %d, y: %d\n", cur -> pt.x, cur -> pt.y);
#endif
	cur -> used = 1;
	if (cur -> twin)
		cur -> twin -> used = 1;
	if (!list_pt)
	{
		list_pt = (LIST_PT *)p_alloc(sizeof(LIST_PT));
		list_pt -> min_x = list_pt -> max_x = cur -> pt.x;
		list_pt -> min_y = list_pt -> max_y = cur -> pt.y;
	}
	if (list_pt -> pts_used == list_pt -> total_pts)
	{
		list_pt -> total_pts += NUM_PTS;
		list_pt -> points =
			(DRAW_POINT_X_Y *)p_remalloc((char *)list_pt -> points,
										 sizeof(DRAW_POINT_X_Y) *
										 (list_pt -> total_pts - NUM_PTS),
										 sizeof(DRAW_POINT_X_Y) *
										 list_pt -> total_pts);
	}
	/*
	  if (cur -> twin)
	  p_info(PI_TRACE, "cur -> pt.arc: %#X, cur -> twin -> pt.arc: %#X\n",
	  cur -> pt.arc, cur -> twin -> pt.arc);
	  if (cur -> twin && cur -> twin -> pt.arc)
	  */
	if (0 && cur -> twin)
	{
		p_info(PI_TRACE, "Writing twin\n");
		memcpy((char *)&list_pt -> points[list_pt -> pts_used++],
			   (char *)&cur -> twin -> pt, sizeof(DRAW_POINT_X_Y));
	}
	else
		memcpy((char *)&list_pt -> points[list_pt -> pts_used++],
			   (char *)&cur -> pt, sizeof(DRAW_POINT_X_Y));
	if (cur -> pt.x < list_pt -> min_x)
		list_pt -> min_x = cur -> pt.x;
	else if (cur -> pt.x > list_pt -> max_x)
		list_pt -> max_x = cur -> pt.x;
	if (cur -> pt.y < list_pt -> min_y)
		list_pt -> min_y = cur -> pt.y;
	else if (cur -> pt.y > list_pt -> max_y)
		list_pt -> max_y = cur -> pt.y;
	return(list_pt);
}
예제 #17
0
int parse(const char *pttfile, const struct pt_config *conf)
{
	int errcode;
	struct parser *p;

	p = p_alloc(pttfile, conf);
	if (!p)
		return -err_no_mem;

	errcode = p_open_files(p);
	if (errcode < 0)
		goto error;

	errcode = p_start(p);
	p_close_files(p);

error:
	p_free(p);
	return errcode;
}
예제 #18
0
static uint8_t svfs_read_level(svfs_t *mount,
                               svfs_inode_t *inode,
                               uint8_t *buf,
                               uint32_t *len,
                               uint32_t *indirects,
                               uint32_t level)
{
    uint8_t *tmp = p_alloc(mount->pool, mount->blocksize);
    const uint32_t num_indirects = mount->blocksize / 4;
    uint32_t i;
    
    for (i=0; (i<num_indirects) && (*len < inode->size); i++) {
        uint32_t chunk_size = inode->size - *len;
        if (chunk_size > mount->blocksize)
            chunk_size = mount->blocksize;
        
        const uint32_t addr = ntohl(indirects[i]);
        
        if (!svfs_read_block(mount, tmp, addr)) {
            sprintf(mount->error_str, "couldn't read svfs block num %u at L%u", addr, level);
            goto fail;
        }
        
        if (level == 1) {
            memcpy(buf + *len, tmp, chunk_size);
            *len += chunk_size;
        }
        else {
            if (!svfs_read_level(mount, inode, buf, len, (uint32_t*)tmp, level-1))
                goto fail;
        }
    }
    
    p_free(tmp);
    return 1;
    
fail:
    p_free(tmp);
    return 0;
}
예제 #19
0
static uint8_t ufs_load_cylinder_group(ufs_t *mount, uint32_t frag_offset, ufs_cylinder_group_t *group)
{
    uint32_t numfrags = sizeof(ufs_cylinder_group_t) / mount->frag_size;
    numfrags += ((sizeof(ufs_cylinder_group_t) % mount->frag_size) != 0);
    
    uint8_t *buf = p_alloc(mount->pool, (numfrags+1) * mount->frag_size);
    uint32_t i;
    
    for (i=0; i <= numfrags; i++)
        ufs_read_frag(mount, &buf[i * mount->frag_size], frag_offset + i);
    memcpy(group, buf, sizeof(ufs_cylinder_group_t));
    
    fix_endian(group->link);
    fix_endian(group->rlink);
    fix_endian(group->time);
    fix_endian(group->cgx);
    fix_endian(group->ncyl);
    fix_endian(group->niblk);
    fix_endian(group->ndblk);
    fix_endian(group->csum_ndir);
    fix_endian(group->csum_nbfree);
    fix_endian(group->csum_nifree);
    fix_endian(group->csum_nffree);
    fix_endian(group->rotor);
    fix_endian(group->frotor);
    fix_endian(group->irotor);
    for (i=0; i<8; i++)
        fix_endian(group->frsum[i]);
    for (i=0; i<(32*8); i++)
        fix_endian(group->b[i/8][i%8]);
    fix_endian(group->magic);
    
    p_free(buf);
    return 1;
fail:
    p_free(buf);
    return 0;
}
예제 #20
0
/*************************************************************************
 ** ADD_COLOR	add a specified index to the list. If it exists, gripe	**
 **  and change. Don't change index 0 or 1 **
 *************************************************************************/
void add_color(void)
{
	int temp_cur_tint;
	int ii;

    struct clr_lst *tp = clr_1st[cur_plate]; /* list-walking pointer */
    struct clr_lst *lp = clr_1st[cur_plate]; /* pointer to last link */
    int	not_end = FALSE;		/* never reached the end flag */
    
    if(spot_pass != 1)
		return;					/* built on 1st color pass */
    if( (cur_plate < 0) || (cur_plate >= MAX_CLRS) )
    {
		p_info(PI_WLOG, "Attempt to define an invalid color:(%d, %d, %d, %f, %f, %d)\n",
			   cur_color_id,cur_plate,cur_screen,cur_pct,cur_angle,cur_tint);
		return;					/* not the WORST POSSIBLE case	*/
    }
    while(tp != 0)				/* we're looking for the end  */
    {
#ifdef TRACE
		if (color_trace)
			p_info(PI_TRACE, ".");		/* one dot per entry */
#endif
		lp = tp;				/* save address of latest entry */
		if(tp->color == cur_color_id) /* hey, we've seen this one! */
		{
			if (cur_plate)
				p_info(PI_WLOG, "Redefine a valid color: %d, %d, %d, %f, %f, %d, %d\n",
					   cur_color_id,cur_plate,cur_screen,cur_pct,
					   cur_angle,cur_reverse, cur_tint);
			not_end = TRUE;
			break;
		}
		tp = tp->nxt;			/* move to next one */
    }							/* end while(tp != 0) */
#ifdef TRACE
    if (color_trace)
		p_info(PI_TRACE, ")ptr to last found @ %x\n",(unsigned)lp);
#endif
	if(not_end == FALSE)		/* don't allocate existing one	*/
		tp = (struct clr_lst *) p_alloc(sizeof(struct clr_lst));
	if(tp != 0)
	{
		if(not_end == FALSE)
		{
			if (lp == 0)		/* if this is the first entry */
				clr_1st[cur_plate] = tp; /*   set it up */
			else				/* else there was a previous entry */
				lp->nxt = tp;	/* point prev to new allocation */
			tp->nxt = 0;		/* next allocation hasn't been done yet  */
		}
		temp_cur_tint = cur_tint;
		if ( !temp_cur_tint)
			temp_cur_tint = 100;
		tp->tint = temp_cur_tint;
		tp->color = cur_color_id; /* fill the data in */
		if(cur_screen == 0)
			tp->freq = 6;
		else
			tp->freq = cur_screen;
		tp->density = 1.0 - ( (cur_pct * cur_tint) / 10000.);
		tp->angle = cur_angle;
		strcpy(tp->func, cur_shape);
		tp->reverse = cur_reverse;
		strcpy(tp->op,cur_op);
		strcpy(tp->type,cur_type);
		strcpy(tp->color_name,cur_color_name);

		for (ii=0; ii<4; ii++) {
			tp->cmyk[ii] = cur_cmyk[ii];
		}

		tp->tint = temp_cur_tint;
/*
		for (i=0; i<4; i++)
			tp->cmyk[i] = cur_cmyk[i] = ((cur_cmyk[i] * temp_cur_tint) / 100.);
*/
		if ( !cur_plate && cur_cmyk_flag)
		{
			tp->cmyk_flag = 1;	/* only used for plate 0 if input */
			if (cur_cmyk[3] == 1)
				tp->density = 0.0; /* all black */
			else if ( !cur_cmyk[0] && !cur_cmyk[1] && !cur_cmyk[2] &&
					  !cur_cmyk[3] )
				tp->density = 1.0; /* all white */
			else if ( !cur_cmyk[0] && !cur_cmyk[1] && !cur_cmyk[2] &&
					  cur_cmyk[3] )
				tp->density = 1.0 - cur_cmyk[3]; /* all gray */
			else
				tp->density = 1.0 - (((50 * cur_cmyk[0]) + (75 * cur_cmyk[1]) +
									  (30 * cur_cmyk[2]) +
									  (100 * cur_cmyk[3]) ) / 255.);
		}
		else
			tp->cmyk_flag = 0;
#ifdef TRACE
		if (color_trace)
		{
			p_info(PI_TRACE, "add_color #%d fr:%d, dn:%3.2f, an:%3.2f, fn:%s, rv:%d\n",
				   tp->color, tp->freq, tp->density, tp->angle,
				   tp->func,tp->reverse);
			if (tp->cmyk_flag)
				p_info(PI_TRACE, "add_color CMYK Tint:%d C:%.2f M:%.2f Y:%.2f K:%.2f\n",
					   temp_cur_tint, tp->cmyk[0], tp->cmyk[1],
					   tp->cmyk[2], tp->cmyk[3]);
		}
#endif
    }
    else
    {
#ifdef TRACE
		if (color_trace)
			p_info(PI_TRACE, "NO MEMORY FOR ENTRY\n");
#endif
    }
}								/* end function */
예제 #21
0
void add_to_vlist(float x, float y, float x2, float y3, int fg, int fg_shd,
				  int bg, int bg_shd, uint32 vlist_plates, int bf_flag)
{
    int i;
    struct vid_box *vp;			/* our new entry's pointer */
	uint32 plates_hold;
	uint32  loop_temp;
    
	if ( !KeyOutputType)
		vlist_plates = 1;
#ifdef TRACE
    if(color_trace)
	{
		p_info(PI_TRACE, "add_to_vlist: x= %.2f, y= %.2f, x2= %.2f, y3= %.2f\n",
			   x, y, x2, y3);
		p_info(PI_TRACE, "pg_deg= %d, pg_rot_x= %d, pg_rot_y= %d\n",
			   PageRotationAngle, PageRotationX, PageRotationY);
		p_info(PI_TRACE, "fg= %d %d, bg= %d %d, plates= %lo, rel= %d, ele= %d\n",
			   fg, fg_shd, bg, bg_shd, vlist_plates, CurrentFrame, CurrentEle);
	}
#endif
    for (i=0; i<MAX_CLRS-1; i++)
    {
		plates_hold = ( loop_temp = (1 << i) ) & vlist_plates;
		if(loop_temp > vlist_plates)
			break;
		if ( !plates_hold)
			continue;
		/* allocate an entry */
		vp = (struct vid_box *) p_alloc(sizeof(struct vid_box));
		if(vp != 0)				/* fill in if it's good	*/
		{
			if(vid_1st[i+1] == 0)	/* if list was empty */
			{
				vid_last[i+1] = vid_1st[i+1] = vp; /* last is first also */
				vp->prv = 0;	/* there is no previous entry*/
			}
			else
			{
				vid_last[i+1]->nxt = vp; /* old last points here */
				vp->prv = vid_last[i+1]; /* and old last is there */
				vid_last[i+1] = vp; /* while this is new last */
			}
			vp->x = x;			/* fill the data in */
			vp->y = y;
			vp->x1 = x2;
			vp->y1 = y3;
			vp->page_rotation_angle = -PageRotationAngle;
			vp->rot_x = PageRotationX / HorizontalBase;
			vp->rot_y = (Imageheight - PageRotationY) / VerticalBase;
			vp->fg_color = fg;
			vp->fg_shade = fg_shd;
			vp->bg_color = bg;
			vp->bg_shade = bg_shd;
			vp->rel_index = CurrentFrame;
			vp->ele_index = CurrentEle;
			vp->elem = PsCurRec -> elem;
			vp->cmd_bf_flag = bf_flag;
			vp->nxt  = 0;	/* and re-terminate the list  */
#ifdef TRACE
			if(color_trace)
				p_info(PI_TRACE, "entry made @ %x in color %d\n", (unsigned)vp, i);
#endif
			continue;
		}
		else					/* what, malloc failed? */
			p_info(PI_ELOG, "add_to_vlist:NO MEMORY FOR ENTRY\n");
		return;
    }							/* end for (i=0; i<MAX_CLRS-1; i++)  */
}								/* end ADD_TO_VLIST */
예제 #22
0
static disk_t* open_disk (const char *disk_path, char *error_str)
{
    disk_t *disk;
    uint8_t block[512];
    apple_partition_map_t apm;
    uint32_t i;
    alloc_pool_t *pool = p_new_pool(NULL);
    FILE *f;
    
    disk = p_alloc(pool, sizeof(disk_t));
    
    disk->pool = pool;
    disk->block_size = 512;
    disk->error_str = error_str;
    disk->path = disk_path;
    
    f = fopen(disk_path, "rb");
    if (f == NULL) {
        sprintf(error_str, "Can't open that path");
        goto fail;
    }
    
    disk->f = f;
    
    // Load the driver descriptor record
    
    disk_get_block(disk, block, 0);
    memcpy(&disk->ddr, block, sizeof(disk->ddr));
    
    fix_endian(disk->ddr.sbBlkSize);
    fix_endian(disk->ddr.sbBlkCount);
    fix_endian(disk->ddr.sbDevType);
    fix_endian(disk->ddr.sbDevId);
    fix_endian(disk->ddr.sbData);
    fix_endian(disk->ddr.sbDrvrCount);
    fix_endian(disk->ddr.ddBlock);
    fix_endian(disk->ddr.ddSize);
    fix_endian(disk->ddr.ddType);

    // If the DDR block exists, (it doesn't have to necessarially)
    if (memcmp(disk->ddr.sbSig, "ER", 2) == 0) {
        // Can't handle non-512 byte block sizes
        if (disk->ddr.sbBlkSize != 512) {
            sprintf(error_str, "This disk uses blkSize=%u and I can't handle that",
                    disk->ddr.sbBlkSize);
            goto fail;
        }
    }
    
    // slog("sizeof(apple_part_map_t) = %lu\n", sizeof(apple_partition_map_t));
    
    // Load the partition maps
    
    if (!disk_load_partition_map(disk, &apm, 0))
        goto fail;
    else if ((apm.pmMapBlkCnt > 256) || (apm.pmMapBlkCnt == 0)) {
        sprintf(error_str, "Crazy number of partitions on this disk %u", apm.pmMapBlkCnt);
        goto fail;
    }
    
    disk->num_partitions = apm.pmMapBlkCnt;
    disk->partition_maps = p_alloc(disk->pool, disk->num_partitions * sizeof(apple_partition_map_t));
    disk->partitions = p_alloc(disk->pool, disk->num_partitions * sizeof(partition_t));
    
    for (i=0; i<disk->num_partitions; i++) {
        if (!disk_load_partition_map(disk, &disk->partition_maps[i], i))
            goto fail;
        
        memset(&disk->partitions[i], 0, sizeof(partition_t));
        disk->partitions[i].disk = disk;
        disk->partitions[i].pool = disk->pool;
        disk->partitions[i].error_str = error_str;
        disk->partitions[i].start_block = disk->partition_maps[i].pmPyPartStart;
        disk->partitions[i].num_blocks = disk->partition_maps[i].pmPartBlkCnt;
        
        memcpy(disk->partitions[i].name, disk->partition_maps[i].pmPartName, 32);
        memcpy(disk->partitions[i].type, disk->partition_maps[i].pmPartType, 32);
        
        slog("%u type:%s name:%s\n", i, disk->partitions[i].type, disk->partitions[i].name);
        slog("bz_magic=0x%08x slice=%u\n", disk->partition_maps[i].bz.magic, disk->partition_maps[i].bz.slice);
    }
    
    return disk;
    
fail:
    if (f) fclose(f);
    p_free_pool(pool);
    return NULL;
}
예제 #23
0
static uint8_t ufs_read_level(ufs_t *mount,
                              ufs_inode_t *inode,
                              uint8_t *buf,
                              uint64_t *len,
                              uint32_t indirect_blockno,
                              uint32_t level)
{
    if (inode->size <= *len)
        return 1;
    
    uint32_t *table = p_alloc(mount->pool, mount->block_size);
    uint8_t *block = NULL;
    
    const uint32_t num_pointers = mount->block_size / 4;
    uint32_t i;
    
    if (!ufs_read_block(mount, (uint8_t*)table, indirect_blockno))
        goto fail;
    
    // for (i=0; i<num_pointers; i++)
        // slog("%u 0x%08x\n", i, ntohl(table[i]));
    
    if (level == 1)
        block = p_alloc(mount->pool, mount->block_size);
    
    for (i=0; (i < num_pointers) && (inode->size > *len); i++) {
        const uint32_t blockno = ntohl(table[i]);
        
        if (level == 1) {
            // direct block
            uint64_t chunk_size = inode->size - *len;
            if (chunk_size > mount->block_size) chunk_size = mount->block_size;
            
            // Which block are we reading, and at which byte-offset into it does our data exist
            const uint32_t block_addr = (blockno / mount->frag_per_block) * mount->frag_per_block;
            const uint32_t block_offset = (blockno - block_addr) * mount->frag_size;
            
            slog("L%u: raw_blkno=0x%08x len=0x%08x blockno:0x%08x chunk_size=0x%08x\n", level-1, blockno, (uint32_t)*len, block_addr, (uint32_t)chunk_size);
            
            // If the chunk_size is a whole block, then we better be reading in a whole block
            if (chunk_size == mount->block_size) {
                // slog("block_offset = 0x%x\n", block_offset);
                assert(block_offset == 0);
            }
            
            if (!ufs_read_block(mount, block, block_addr))
                goto fail;
            
            memcpy(buf + *len, block + block_offset, chunk_size);
            (*len) += chunk_size;
        }
        else {
            // indirect block
            if (!ufs_read_level(mount, inode, buf, len, blockno, level-1))
                goto fail;
        }
    }
    
    if (block)
        p_free(block);
    p_free(table);
    return 1;
fail:
    if (block)
        p_free(block);
    p_free(table);
    return 0;
}
예제 #24
0
static ufs_t* ufs_mount(partition_t *part)
{
    ufs_t *mount = p_alloc(part->pool, sizeof(ufs_t));
    uint8_t *buf = p_alloc(part->pool, 32 * 512);
    uint32_t i;
    
    mount->pool = part->pool;
    mount->part = part;
    mount->error_str = part->error_str;
    
    for (i=0; i<4; i++)
        part_get_block(part, &buf[i*512], 16 + i);
    memcpy(&mount->superblock, buf, sizeof(ufs_superblock_t));
    
    fix_endian(mount->superblock.link);
    fix_endian(mount->superblock.rlink);
    fix_endian(mount->superblock.sblkno);
    fix_endian(mount->superblock.cblkno);
    fix_endian(mount->superblock.iblkno);
    fix_endian(mount->superblock.dblkno);
    fix_endian(mount->superblock.cgoffset);
    fix_endian(mount->superblock.cgmask);
    fix_endian(mount->superblock.time);
    fix_endian(mount->superblock.size);
    fix_endian(mount->superblock.dsize);
    fix_endian(mount->superblock.ncg);
    fix_endian(mount->superblock.bsize);
    fix_endian(mount->superblock.fsize);
    fix_endian(mount->superblock.frag);
    fix_endian(mount->superblock.minfree);
    fix_endian(mount->superblock.rotdelay);
    fix_endian(mount->superblock.rps);
    fix_endian(mount->superblock.bmask);
    fix_endian(mount->superblock.fmask);
    fix_endian(mount->superblock.bshift);
    fix_endian(mount->superblock.fshift);
    fix_endian(mount->superblock.maxcontig);
    fix_endian(mount->superblock.maxbpg);
    fix_endian(mount->superblock.fragshift);
    fix_endian(mount->superblock.fsbtodb);
    fix_endian(mount->superblock.sbsize);
    fix_endian(mount->superblock.csmask);
    fix_endian(mount->superblock.csshift);
    fix_endian(mount->superblock.nindir);
    fix_endian(mount->superblock.inopb);
    fix_endian(mount->superblock.nspf);
    fix_endian(mount->superblock.optim);
    fix_endian(mount->superblock.state);
    fix_endian(mount->superblock.id[0]);
    fix_endian(mount->superblock.id[1]);
    fix_endian(mount->superblock.csaddr);
    fix_endian(mount->superblock.cssize);
    fix_endian(mount->superblock.cgsize);
    fix_endian(mount->superblock.ntrak);
    fix_endian(mount->superblock.nsect);
    fix_endian(mount->superblock.spc);
    fix_endian(mount->superblock.ncyl);
    fix_endian(mount->superblock.cpg);
    fix_endian(mount->superblock.ipg);
    fix_endian(mount->superblock.fpg);
    fix_endian(mount->superblock.csum_ndir);
    fix_endian(mount->superblock.csum_nbfree);
    fix_endian(mount->superblock.csum_nifree);
    fix_endian(mount->superblock.csum_nffree);
    fix_endian(mount->superblock.cgrotor);
    fix_endian(mount->superblock.cpc);
    for (i=0; i<(32*8); i++)
        fix_endian(mount->superblock.postbl[i/8][i%8]);
    fix_endian(mount->superblock.magic);
    
    
    if (mount->superblock.magic != 0x00011954) {
        sprintf(part->error_str, "Magic doesn't match ufs");
        goto fail;
    }
    
    // It is UFS!
    
    mount->frag_size = mount->superblock.fsize;
    mount->frag_per_block = mount->superblock.frag;
    mount->block_size = mount->frag_size * mount->frag_per_block;
    assert(mount->block_size == mount->superblock.bsize);
    
    mount->num_groups = mount->superblock.ncg;
    mount->groups = (ufs_cylinder_group_t*)p_alloc(mount->pool,
                                                   mount->num_groups * sizeof(ufs_cylinder_group_t));
    
    for (i=0; i<mount->num_groups; i++) {
        uint32_t group_base = ufs_group_base(mount, i) + mount->superblock.cblkno;
        ufs_load_cylinder_group(mount, group_base, &mount->groups[i]);
        if ((mount->groups[i].cgx != i) || (mount->groups[i].magic != 0x00090255)) {
            sprintf(mount->error_str, "bad cylinder group %u frag_offset=0x%x", i, group_base);
            goto fail;
        }
    }
    
    if (buf)
        p_free(buf);
    return mount;
fail:
    if (mount) {
        if (mount->groups)
            p_free(mount->groups);
        p_free(mount);
    }
    if (buf)
        p_free(buf);
    return NULL;
}
예제 #25
0
/***********************************************************************
 **  POST_PRINT.C mainline.	**
 ***********************************************************************/
void main(int argc, char *argv[])
{
    int num_read, i;
    int one_shot;
    int pipe_in, pipe_out;
    int result;
	char tp_extend[18];
	char *new_Psf_path_ptr;
    char *parse_buff_ptr;

	umask(0);
    set_sigs();					/* get all traces out at end */
    p_init(0);
	lc_init(1);
	memset ( (char *)&ObjPageWn.page_number[0], 0,
			 sizeof (struct obj_pg_wn) );
	obj_wn_count = 0;
    one_shot = 0;

	Current_FgColor = 1;			/*  BUG 594q Initialize current color to black     */
	Current_FgShade = 100;			/*  BUG 594q Initialize current shade to 100%   */
    msg_parse_args(argc, argv, KEYWORD_COUNT, msg);
    pipe_in = atoi(msg[0].answer);
    pipe_out = atoi(msg[1].answer);
    if((pipe_in == 0) && (pipe_out ==0))
		one_shot = 1;			/* don't read from pipe */
    p_info(PI_INFO, "Postprint Startup.\n"); /* log in first message. */
    strcpy (overflow_path,"overflow.pos1"); /* Build name of overflow-text
											   temp file, using ipc suffix.*/
	bmtop = 0;					/* Init dynamic PDF bookmark mem array.  */
	uidtop = 0;					/* Init dynamic PDF bookmark-idrid mem array.  */

/***************************** start of big loop ***************************/
    for(;;)
    {
		if (p_LogFd)
		{
			fclose (p_LogFd);
			p_LogFd = NULL;
		}
		if (TrailerName)
		{
		        fclose(TrailerName);
			TrailerName = NULL;
		}
		if (PrologName)
		{
		        fclose(PrologName);
			PrologName = NULL;
		}

		p_LogCnt = 0;
		if (Fofd)
			p_close(Fofd);
		FoName[0] = 0;
		parse_buff = p_alloc(2048);
		if ( !m_fprintf_size)
		{
			m_fprintf_size = 4096;
			m_fprintf_buff = p_alloc(m_fprintf_size);
		}
		if( !one_shot)
		{						/* read from the pipe */
			num_read = read(pipe_in, parse_buff, 2048);
			switch (num_read)
			{
			  case -1:
				p_info(PI_ELOG, "pipe read failed\n");
				exit(1);
			  case 0:
				p_info(PI_ELOG, "pipe_in EOF\n");
				exit(1);
			  default:
				break;
			}					/* end switch(num_read) */
#ifdef TRACE
			if(debugger_trace)
				p_info(PI_TRACE, "pipe num_read= %d, '%s' \n",num_read,parse_buff);
#endif
			msg_parse(parse_buff, num_read, KEYWORD_COUNT, msg);
        }						/* end of pipe read */
		else
		{						/* read from arg & argv or from file */
			if ((one_shot == 1) && !source_pfd)
			{
			    if ( msg[44].answer[0])
				{				/* KEYWORD 'source', read from file */
					one_shot = 2;
					if((source_pfd = p_open(NO_STRING, OTHER_FILE, NO_STRING,
											msg[44].answer, "r")) == 0)
					{			
						p_info(PI_ELOG, "Failed to open source '%s'\n",msg[44].answer);
						exit(2);
					}
				}
			}
			if ( source_pfd)
			{					/* get next job from source file */
				if (p_fgets(parse_buff, 2048, source_pfd) == 0)
				{
					p_info(PI_ELOG, "source file empty\n");
					exit(3);
				}
				parse_buff_ptr = parse_buff;
				while ( *parse_buff_ptr)
				{
					if ( *parse_buff_ptr == '\012')
					{
						*parse_buff_ptr = 0;
						break;
					}
					parse_buff_ptr++;
				}
				msg_parse (parse_buff, (int)(parse_buff_ptr - parse_buff + 1),
						   KEYWORD_COUNT, msg);
			}
		}
#if LPMfloat
		for (i = 0; i < LPM_MaxOption; i++)
			LPMK[i] = lpm_option(i);
#else
		LPMK = lpm_query(LPM_Options,LPM_CurrRev);
#endif
        result = job_setup();
        p_free(parse_buff);
        if(result)
        {						/* only if setting traces */
			if(!one_shot)
			{
				if((num_read = write(pipe_out, "0", 2))== -1)
				{
					p_info(PI_ELOG, "write to pipe failed\n");
					exit(1);
				}
				else
					continue;	/* traces only, get next pipe message */
			}
			exit(1);
        }
        strcpy(tpname, JobName); /* TP filename. */
		if ( FileType)
		{						/* layout */
			tp_extend[0] = 0;
			if (MasterNameFlag)
				sprintf (tp_extend, ".%s", PageName);
			if ( LYPrintFlag)
				strcat (tp_extend, ".lyp");
			strcat (tpname, tp_extend);
			if ( (FirstPage >= 0) && ( !MasterNameFlag) )
			{
				if (LastPage != FirstPage)
					sprintf(tp_extend, ".%d_%d",FirstPage,LastPage);
				else			/* if equal only use one page number */
					sprintf(tp_extend, ".%d",FirstPage);
				strcat(tpname,tp_extend);
			}
			else if (BookPrint)
			{
				if (LastParentIndex > ParentIndex)
					sprintf(tp_extend, ".u%d_u%d",ParentIndex,LastParentIndex);
				else
					sprintf(tp_extend, ".u%d",ParentIndex);
				strcat(tpname,tp_extend);
			}
		}
		if (EpsFlag)
		   strcpy (logname, p_path(TreeName, EPS_FILE, SubDirName, tpname));
		else if (BookPrint)
		   strcpy (logname, p_path(TreeName, OUTPUT_FILE, ParentDirName, tpname));
		else
		   strcpy (logname, p_path(TreeName, OUTPUT_FILE, SubDirName, tpname));
		strcpy (prologname, logname);
		strcpy (trailername, logname);

		strcat (logname, ".log");
		p_LogFd = fopen (logname, "w+");

		strcat (prologname, ".plog");
		PrologName = fopen(prologname, "w+");

		strcat (trailername,".ptrl");
		TrailerName = fopen(trailername, "w+");

		new_Psf_path_ptr = p_path(TreeName, USERDATA, UserdataPath,
								  PsfTableName);
		if ( strcmp( Psf_path_name, new_Psf_path_ptr) )
		{						/* no match, need a new name and Psftable */
			strcpy(Psf_path_name, new_Psf_path_ptr);
			if ( !Psftable_load_with_name(TreeName, SubDirName,
										  PsfTableName) )
			{					/* bad psftable load, abort */
				p_info(PI_ELOG, "Unable to open file '%s'",Psf_path_name);
				exit(101);
			}
			PsfNameIndex = 0;
			PsfCodeIndex = 0;
			HelveticaFontNumber = 0;
			for (i=0; i<MaxPentaFont; i++)
			{					/* find Helvetica */
				if ( PentaToPsf[i].name)
				{
					if ( !strcmp(PentaToPsf[i].name, "Helvetica") )
						HelveticaFontNumber  = i;
				}
			}
		}						/* psftable loaded */

		if (HdrPNamPrt)
			get_prt_name();  /*  Bug 367p get actual printer name from .psh file */
		else
			PrtNam[0] = 0;
	
		getpgsize();			/* Parse header lines */

		if(lnumbers & 1) {		/* Print line numbers?  */
			if (!FileType) {	/* In galley mode:  */
				OffL += 40;		/* =15pts space at left + 25 for big line number  */
				if (LineStats)
					OffL += 30;	/* =5pts at left + 25 line# + 40 for band & ls  */
			}
			else				/* In page mode:  */
				OffL += 10;		/* just 10 pts of room.  */
		}
/***********************************************************************
 **  Call the PostScript mainline processor.			      **
 ***********************************************************************/
		
		psmain();
		
/***********************************************************************
 **  Wrap it all up.						      **
 ***********************************************************************/
		if (EpsFlag)
		   strcpy (logname, p_path(TreeName, EPS_FILE, SubDirName, tpname));
		else if (BookPrint)
		   strcpy (logname, p_path(TreeName, OUTPUT_FILE, ParentDirName, tpname));
		else
		   strcpy (logname, p_path(TreeName, OUTPUT_FILE, SubDirName, tpname));
		if (PrinterName[0])
		{						/* output to the printer queue */
			fflush (p_LogFd);
			if( !GraphicsPresentFlag)
				result = 0;
			else
				result = 1;

			sprintf(shell_msg,"/usr/local/bin/%s.psh %s %d %d %s %s %d %d %d %d",
                PrinterName, logname, result, FileType, TreeName,
				SubDirName, FirstPage, LastPage, HNJ_LockFailureFlag,
				DistillFlag);
			system(shell_msg);
		}

		/* If user asked for "Distill to PDF" (and there's no H&J lock), then
			test to find the newest .tp, .eps or .ps in the .drawer, and see
			if it's newer than any .pdf file there.
			If so, this means the printer script did NOT create a .pdf, so
			distill the .tp to .pdf using ghostscript's ps2pdf script here.
		*/
		if (DistillFlag && !HNJ_LockFailureFlag)
		{
			struct stat tpstat, psstat, pdfstat;
			int tpind, psind, pdfind, buildpdf;
			char *dotptr;

			strcpy (prologname, logname);
			strcat (prologname, ".pdf");	/* Get stat of *.tp.pdf file:  */
			pdfind = stat(prologname, &pdfstat);
			if (pdfind)						/* If that doesn't exit, alt try:  */
			{
				strcpy (prologname, logname);
				dotptr = strrchr (prologname, '.');
				*dotptr = 0;				/* Strip whatever suffix we have,  */
				strcat (prologname, ".pdf");/*  replace with .pdf.  */
											/* Get stat of that pdf file:  */
				pdfind = stat(prologname, &pdfstat);
			}

			tpind = stat(logname, &tpstat);	/* Get stat of .tp (or .eps) file  */
			psind = 1;						/* (assume unused)  */
			if (!EpsFlag)					/* If we started with .tp file,  */
			{								/*  also get stat of .ps file:  */
				strcpy (prologname, logname);
				strcpy (&prologname[strlen(logname)-3], ".ps");
				psind = stat(prologname, &psstat);
			}

			buildpdf = 0;				/* Assume no need to build a .pdf  */
			if (!tpind &&				/* If .tp (or .eps) exists, and  */
				(psind ||				/*  .ps does not, or .tp is newer, then:  */
				 tpstat.st_mtime > psstat.st_mtime))
			{
				strcpy (prologname, logname);	/* (use .tp name)  */
										/*  if there's no .pdf or it's older,  */
				if (pdfind || tpstat.st_mtime > pdfstat.st_mtime)
					buildpdf = 1;		/*  set flag to distill the .tp file.  */
			}
			else 
			if (!psind &&				/* If .ps exists, and  */
				(tpind ||				/*  .tp does not, or .ps is newer, then:  */
				 tpstat.st_mtime <= psstat.st_mtime))
			{
				strcpy (logname, prologname);	/* (use .ps name)  */
										/*  if there's no .pdf or it's older,  */
				if (pdfind || psstat.st_mtime > pdfstat.st_mtime)
					buildpdf = 1;		/*  set flag to distill the .ps file.  */
			}
			else						/* Neither exist, forget it.   */
				;

			if (buildpdf)				/* If we decided to distill a .pdf, then  */
			{							/* build basename by stripping suffix,  */
				*(dotptr = strrchr (prologname, '.')) = 0;
										/* build little script calling ps2pdf,  */
			  	sprintf (shell_msg,
				"PATH=/usr/local/bin/ghostscript:$PATH; export PATH; ps2pdf  %s %s.pdf",
				logname, prologname);

				p_info(PI_INFO, "Executing distillation to PDF from Postprint\n");
				system(shell_msg);		/* and send it off, wait for done.  */
			}
		}					/* end if (DistillFlag && !HNJ_LockFailureFlag)  */

		p_free(m_fprintf_buff);
		m_fprintf_size = 0;
		if(!one_shot)
		{
			if((num_read =write(pipe_out, "0", 2))== -1)
			{
				p_info(PI_ERROR, "write to pipe failed\n");
				exit(1);
			}
			else
				p_info(PI_INFO, "Post completed for %s \n",tpname);
		}
		else
		{
			if (!source_pfd)
			{
				p_info(PI_INFO, "Post completed for %s, program exit. \n",JobName);
				break;
			}
			else
				p_info(PI_INFO, "Post completed for %s \n",JobName);
		}
    }							/* end of for(;;) */
    exit(ExitError);
}								/* end of PSMAIN */