/* ---------------------------------------------------------------------- */ Bool xsforall(ps_context_t *pscontext) { register OBJECT *theo ; UNUSED_PARAM(ps_context_t *, pscontext) ; theo = stackindex( 1 , & executionstack ) ; if ( ! theLen(*theo)) { npop( 3 , & executionstack ) ; return TRUE ; } if ( ! stack_push_integer(( int32 )*oString(*theo), &operandstack) ) return FALSE ; if ( --theLen(*theo) == 0 ) oString(*theo) = NULL ; else ++oString(*theo) ; theo = stackindex( 2 , & executionstack ) ; if ( oExecutable(*theo) ) return push( theo , & executionstack ) ; else return push( theo , & operandstack ) ; }
/* ---------------------------------------------------------------------------- function: exit_() author: Andrew Cave creation date: 22-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 154. ---------------------------------------------------------------------------- */ Bool exit_(ps_context_t *pscontext) { register OBJECT *o1 ; execStackSizeNotChanged = FALSE ; while ( ! isEmpty( executionstack )) { o1 = theTop( executionstack ) ; switch ( oType(*o1) ) { case OARRAY: /* This case used to be explicitly represented as the first if-branch. Presumably it was explicitly different to the default for efficiency reasons, but that seems a bit spurious now. */ pop( & executionstack ) ; break ; case ONOTHING: /* Represents a looping context if len non-zero */ if ( theLen(*o1)) { npop( theLen(*o1), & executionstack ) ; return TRUE ; } pop( & executionstack ) ; break ; case ONULL : switch ( theLen(*o1)) { case ISINTERPRETEREXIT: oInteger(*o1) = NAME_exit; return TRUE; case ISPATHFORALL : path_free_list(thePathOf(*(PATHFORALL *)oOther(*o1)), mm_pool_temp) ; free_forallpath(oOther(*o1)) ; npop( 5 , & executionstack ) ; return TRUE ; } pop( & executionstack ) ; break ; case OMARK : /* Represents a stopped mark */ return error_handler( INVALIDEXIT ) ; case OFILE : /* Represents a run object - if length set to special value */ currfileCache = NULL ; if ( IsRunFile( o1 )) return error_handler( INVALIDEXIT ) ; default: pop( & executionstack ) ; } } return quit_(pscontext) ; }
/* ---------------------------------------------------------------------------- function: cmap_lookup() author: Eric Penfold creation date: 10-Jul-1997 last modification: ##-###-#### arguments: lots description: Top level Lookup function to return char id/cid for input data On input, the charsel object must be of type OSTRING, with the clist ptr pointing to an area of memory which may be used to store the result of an basefont character code mapping (OSTRING mapping type - see below). The size of this memory (given by the 'len' field) must be at least CMAP_MAX_CODESPACE_LEN bytes. The fontid parameter will be updated with id of the font corresponding to the mapping The charsel object passed will be updated to reflect the mapping type: OINTEGER => mapped to a CID font CID OSTRING => mapped to a basefont character code. This may refer to a composite font (check font type using fontid) - in which case this could be a multi-byte string. ONAME => mapped to a glyph name ONULL => no mapping. This can happen if the input str does not start with a valid character code (i.e. within any of the defined codespace ranges). stringo should a pointer to the string to parse -> this pointer will be incremented by the number of bytes which were used for the cmap lookup, and the len parameter will be decremented by this number. Characters may still be consumed if no matching or valid mapping exists. Returns FALSE on error. ---------------------------------------------------------------------------- */ Bool cmap_lookup(OBJECT *cmapdict, OBJECT *stringo, int32 *fontid, OBJECT *charsel) { OBJECT mapstring = OBJECT_NOTVM_NOTHING, *cmap; uint8 mapcode[CMAP_MAX_CODESPACE_LEN]; static NAMETYPEMATCH codemapmatch[] = { /* Use the enum below to index this match */ { NAME_codespacerangeblock, 1, { OARRAY }}, { NAME_mappingblock, 1, { OARRAY }}, { NAME_notdefrangeblock | OOPTIONAL, 1, { OARRAY }}, DUMMY_END_MATCH } ; enum { codemapmatch_codespacerangeblock, codemapmatch_mappingblock, codemapmatch_notdefrangeblock } ; if ( oType(*cmapdict) != ODICTIONARY ) return error_handler(TYPECHECK) ; cmap = fast_extract_hash_name(cmapdict, NAME_CodeMap); if ( !cmap ) return error_handler(TYPECHECK); if (!dictmatch(cmap, codemapmatch)) return FALSE; theTags(mapstring) = OSTRING | LITERAL | UNLIMITED ; theLen(mapstring) = CMAP_MAX_CODESPACE_LEN ; oString(mapstring) = mapcode ; if (!cmap_codeget(codemapmatch[codemapmatch_codespacerangeblock].result, stringo, &mapstring)) return FALSE; if ( theLen(mapstring) == 0 ) { /* Invalid char string */ object_store_null(charsel) ; return TRUE ; } if ( !cmap_cidlookup_local(codemapmatch[codemapmatch_mappingblock].result, &mapstring, fontid, charsel) ) return FALSE ; if ( oType(*charsel) != ONULL ) /* Found a character mapping */ return TRUE ; theTags(*charsel) = OINTEGER | LITERAL; /* Notdef mapping must be CID */ return cmap_notdeflookup_local(codemapmatch[codemapmatch_notdefrangeblock].result, &mapstring, fontid, charsel); }
static void current_jobname(corejob_t *job) { OBJECT* statusdict; OBJECT* jobname; /* Extract jobname from statusdict for now */ statusdict = fast_extract_hash_name(&systemdict, NAME_statusdict); jobname = fast_extract_hash_name(statusdict, NAME_jobname); if (oType(*jobname) == OSTRING && theLen(*jobname) > 0 ) { corejob_name(job, oString(*jobname), theLen(*jobname)); } else { corejob_name(job, NAME_AND_LENGTH("UnSpecified JobName")); } }
/* Do a file stat for a psdev uri. */ Bool stat_from_psdev_uri( /*@in@*/ /*@notnull@*/ hqn_uri_t* uri, /*@out@*/ /*@notnull@*/ Bool* exists, /*@out@*/ /*@notnull@*/ STAT* stat) { uint8 *ps_filename; uint32 ps_filename_len ; int32 status; /* Create PS filename from URI */ if ( !psdev_uri_to_ps_filename(uri, &ps_filename, &ps_filename_len) ) { return(FALSE); } /* Stat the PS filename */ oString(snewobj) = ps_filename; theLen(snewobj) = CAST_TO_UINT16(ps_filename_len); status = file_stat(&snewobj, exists, stat); /* Must free memory used for ps filename */ mm_free_with_header(mm_xml_pool, ps_filename); return(status); } /* stat_from_psdev_uri */
/* ---------------------------------------------------------------------------- function: cmap_getfontmatrix author: Eric Penfold creation date: 13-Aug-1997 last modification: ##-###-#### arguments: cmapdict (Input) fontid (Input) matrix (Output) description: Obtains the font matrix from the CMap to use with the specified descendant font. If no matrices are defined at all, or no matrix is defined for this fontid, then 'matrix' will be set to a null object. Returns FALSE if the object in the matrix array is not a valid matrix, or if the fontid is invalid (i.e. the matrix array has fewer entries); TRUE is otherwise returned. ---------------------------------------------------------------------------- */ Bool cmap_getfontmatrix(OBJECT *cmapdict, int32 fontid, OBJECT *matrix) { OBJECT *cmap, *matblk; OMATRIX omat; /* Extract CMap */ if ( oType(*cmapdict) != ODICTIONARY ) return FAILURE(FALSE); /* Error - Invalid dictionary */ cmap = fast_extract_hash_name(cmapdict, NAME_CodeMap); /* Extract matrix block */ if ( oType(*cmap) != ODICTIONARY ) return FAILURE(FALSE); /* Error - Invalid dictionary */ matblk = fast_extract_hash_name(cmap, NAME_usematrixblock); if ( !matblk ) { object_store_null(matrix); /* No usematrix defined, use defaults */ } else if ( oType(*matblk) != OARRAY || theLen(*matblk) <= fontid || !is_matrix(oArray(*matblk) + fontid, &omat) ) { return FAILURE(FALSE); /* usematrix definition is not valid (for this fontid) */ } else Copy(matrix, oArray(*matblk) + fontid); return TRUE; }
Bool xml_map_namespace(const xmlGIStr *from_uri, const xmlGIStr **to_uri) { XMLExecContext *p_xmlexec_context; OBJECT *theo ; HQASSERT(from_uri != NULL, "from_uri is NULL") ; HQASSERT(to_uri != NULL, "to_uri is NULL") ; p_xmlexec_context = SLL_GET_HEAD(&xml_context.sls_contexts, XMLExecContext, sll); HQASSERT(p_xmlexec_context != NULL, "p_xmlexec_context is NULL") ; oName(nnewobj) = (NAMECACHE *)&(from_uri->name) ; if ( (theo = p_xmlexec_context->map_uri_data) == NULL || (theo = extract_hash(theo, &nnewobj)) == NULL ) { *to_uri = from_uri ; /* No mapping possible or present. */ return TRUE ; } switch ( oType(*theo) ) { case ONAME: *to_uri = (xmlGIStr *)oName(*theo) ; return TRUE ; case OSTRING: if ( intern_create(to_uri, oString(*theo), theLen(*theo)) ) return TRUE ; /*@fallthrough@*/ default: break ; } return error_handler(UNDEFINED) ; }
/* ---------------------------------------------------------------------------- function: myfloor_() author: Andrew Cave creation date: 08-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 157. ---------------------------------------------------------------------------- */ Bool myfloor_(ps_context_t *pscontext) { int32 ssize ; OBJECT *theo ; UNUSED_PARAM(ps_context_t *, pscontext) ; ssize = theStackSize( operandstack ) ; if ( EmptyStack( ssize )) return error_handler( STACKUNDERFLOW ) ; theo = TopStack( operandstack , ssize ) ; if ( oType(*theo) == OREAL ) { int32 iarg ; SYSTEMVALUE arg ; arg = ( SYSTEMVALUE )oReal(*theo) ; if ( !intrange(arg) ) return TRUE ; iarg = ( int32 )arg ; if ( iarg <= 0 && arg < 0.0 && ( SYSTEMVALUE )iarg - arg != 0.0 ) --iarg ; oReal(*theo) = ( USERVALUE )iarg ; theLen(*theo) = 0 ; return TRUE ; } else if ( oType(*theo) == OINTEGER || oType(*theo) == OINFINITY ) return TRUE ; else return error_handler( TYPECHECK ) ; }
/** * \brief Open a config file with appriopiate flags. * * \param[in] pt * XPS PrintTicket handler * \param[in] file_type * Type of config file, either \c "S" or \c "E". * \param[in] open_flags * Flags to open file on device with. * \param[in] ps_flags * PS opten flags (should be equivalent of \c open_flags) * \param[out] ofile * Pointer to returned PS file object. * * \returns * \c TRUE if opened the config file, else \c FALSE. */ static Bool pt_open_config_file( /*@in@*/ /*@notnull@*/ XPS_PT* pt, /*@in@*/ /*@notnull@*/ uint8* file_type, int32 open_flags, int32 ps_flags, /*@out@*/ /*@notnull@*/ OBJECT* ofile) { uint8 pt_filename[LONGESTDEVICENAME + 16]; static uint8* pt_scope[] = { NULL, (uint8*)"J", (uint8*)"D", (uint8*)"P" }; HQASSERT((pt != NULL), "pt_open_config_file: state pointer NULL"); HQASSERT((file_type != NULL), "pt_open_config_file: file type NULL"); HQASSERT((ofile != NULL), "pt_open_config_file: pointer to returned OBJECT NULL"); /* Create PT device filename based on scope and start/end type */ swcopyf(pt_filename, (uint8*)"%%%s%%%s%s", theIDevName(pt->device), pt_scope[pt->scope], file_type); oString(snewobj) = pt_filename; theLen(snewobj) = CAST_UNSIGNED_TO_UINT16(strlen((char*)pt_filename)); return file_open(&snewobj, open_flags, ps_flags, FALSE, 0, ofile) ; } /* pt_open_config_file */
Bool pdf_matrix( PDFCONTEXT *pdfc , OBJECT *theo) { register OBJECT *olist ; PDFXCONTEXT *pdfxc ; int i ; PDF_CHECK_MC( pdfc ) ; PDF_GET_XC( pdfxc ) ; HQASSERT( theo , "theo NULL in pdf_matrix." ) ; if ( NULL == ( olist = ( OBJECT * )PDF_ALLOCOBJECT( pdfxc , 6 ))) return error_handler( VMERROR ) ; theTags(*theo) = OARRAY | LITERAL | UNLIMITED ; SETGLOBJECTTO(*theo, FALSE) ; theLen(*theo) = 6 ; oArray(*theo) = olist ; for ( i=0; i<6; i++ ) { theTags( olist[i] ) = OREAL | LITERAL ; oReal(olist[i]) = (i % 3 == 0) ? 1.0f : 0.0f ; } return TRUE ; }
Bool pdf_create_string( PDFCONTEXT *pdfc , int32 len , OBJECT *thestring ) { uint8 *string ; PDFXCONTEXT *pdfxc ; PDF_CHECK_MC( pdfc ) ; PDF_GET_XC( pdfxc ) ; HQASSERT( thestring , "thestring NULL in pdf_create_string." ) ; if ( len < 0 ) return error_handler( RANGECHECK ) ; if ( len > MAXPSSTRING ) return error_handler( LIMITCHECK ) ; if ( len > 0 ) { string = PDF_ALLOCSTRING( pdfxc, len ) ; if ( ! string ) return error_handler( VMERROR ) ; } else string = NULL ; theTags(*thestring) = OSTRING | UNLIMITED | LITERAL ; SETGLOBJECTTO(*thestring, FALSE) ; /* string itself is local */ theLen(*thestring) = ( uint16 )len ; oString(*thestring) = string ; return TRUE ; }
Bool pdf_create_array( PDFCONTEXT *pdfc , int32 len , OBJECT *thearray ) { OBJECT *array ; PDFXCONTEXT *pdfxc ; PDF_CHECK_MC( pdfc ) ; PDF_GET_XC( pdfxc ) ; HQASSERT( thearray , "thearray NULL in pdf_create_array." ) ; if ( len < 0 ) return error_handler( RANGECHECK ) ; if ( len > MAXPSARRAY ) return error_handler( LIMITCHECK ) ; if ( len > 0 ) { array = PDF_ALLOCOBJECT( pdfxc, len ) ; if ( ! array ) return error_handler( VMERROR ) ; } else array = NULL ; theTags(*thearray) = OARRAY | UNLIMITED | LITERAL ; SETGLOBJECTTO(*thearray, FALSE) ; /* array itself is local */ theLen(*thearray) = ( uint16 )len ; oArray(*thearray) = array ; return TRUE ; }
OBJECT *pdf_objmemallocfunc(int32 numobjs, void * param) { PDFXCONTEXT *pdfxc = param ; OBJECT* obj ; /* allocate some local PDF VM for an object of the given size */ HQASSERT(pdfxc != NULL, "PDF object memory pool NULL") ; HQASSERT(numobjs > 0, "Should be at least one object to allocate") ; obj = (OBJECT*)mm_alloc(pdfxc->mm_object_pool, sizeof(OBJECT) * numobjs, MM_ALLOC_CLASS_PDF_PSOBJECT); if (obj != NULL) { OBJECT *slot ; OBJECT transfer ; theMark(transfer) = (int8)(ISNOTVM | ISLOCAL | pdfxc->savelevel) ; theTags(transfer) = ONULL ; theLen(transfer) = 0 ; for ( slot = obj ; numobjs > 0 ; ++slot, --numobjs ) { OBJECT_SET_D0(*slot, OBJECT_GET_D0(transfer)) ; /* Set slot properties */ OBJECT_SCRIBBLE_D1(*slot) ; } } return obj; }
Bool open_file_from_psdev_uri( hqn_uri_t *uri, OBJECT *ofile, Bool implicit_close_file) { uint8 *ps_filename; uint32 ps_filename_len ; OBJECT ostr_filename ; Bool status ; HQASSERT(uri != NULL, "uri is NULL") ; if (! psdev_uri_to_ps_filename(uri, &ps_filename, &ps_filename_len)) return FALSE ; if (ps_filename_len > LONGESTFILENAME) { mm_free_with_header(mm_xml_pool, ps_filename) ; return error_handler(LIMITCHECK) ; } theTags(ostr_filename) = OSTRING|UNLIMITED|LITERAL ; theLen(ostr_filename) = CAST_TO_UINT16(ps_filename_len) ; oString(ostr_filename) = ps_filename ; if (implicit_close_file) { status = file_open(&ostr_filename, SW_RDONLY, READ_FLAG, FALSE, 0, ofile) ; } else { status = xml_file_open(&ostr_filename, ofile) ; } mm_free_with_header(mm_xml_pool, ps_filename) ; return status ; }
mps_res_t MPS_CALL ps_scan(mps_ss_t scan_state, mps_addr_t base, mps_addr_t limit) { register OBJECT *obj; OBJECT *obj_limit; register mps_addr_t ref; size_t len = 0; obj_limit = limit; MPS_SCAN_BEGIN( scan_state ) for ( obj = base; obj < obj_limit; obj++ ) { ref = (mps_addr_t)oOther( *obj ); switch ( oType( *obj )) { case ONAME: MPS_RETAIN( (mps_addr_t *)&oName( *obj ), TRUE ); continue; case OSAVE: continue; case ODICTIONARY: NOTREACHED; break; case OSTRING: { mps_addr_t ref_limit; ref_limit = ADDR_ADD( ref, theLen(*obj)); /* ref could point into the middle of a string, so align it. */ ref = PTR_ALIGN_DOWN( mps_addr_t, ref, MM_PS_ALIGNMENT ); len = ADDR_OFFSET( ref, ref_limit ); } break; case OFILE: NOTREACHED; break; case OARRAY: case OPACKEDARRAY: len = theLen(*obj) * sizeof( OBJECT ); break; case OGSTATE: case OLONGSTRING: NOTREACHED; break; default: continue; /* not a composite object */ } PS_MARK_BLOCK( scan_state, ref, len ); } MPS_SCAN_END(scan_state); return MPS_RES_OK; }
/*----------------------------------------------------------------------------*/ void gsc_rcbequiv_handle_detectop(OBJECT *key, OBJECT *value) { int32 *equivlevel; EQUIVCOLOR *equivs; int32 len; OBJECT *olist; NAMECACHE *sepname; HQASSERT(key, "key NULL"); HQASSERT(value, "value NULL"); HQASSERT(oType(*key) == ONAME, "name expected"); /* Currently should only get /spots from freehand */ HQASSERT(oName(*key) == system_names + NAME_spots, "unexpected name"); if ( oType(*value) != OARRAY && oType(*value) != OPACKEDARRAY ) return; len = theILen(value); if ( ! len ) return; /* Got an array, does it look like we expect: contain arrays of length 6 */ olist = oArray(*value); for ( key = olist + len ; olist < key; ++olist ) { int32 type = oType(*olist); if ( type != OARRAY && type != OPACKEDARRAY ) return; if ( theILen(olist) != 6 ) return; } olist -= len; /* The array looks like it might be a freehand spots array, so lets risk it as long as a higher priority method hasn't set these values already */ rcbn_current_equiv_details(&equivlevel, &equivs); if ( (*equivlevel) >= GSC_EQUIV_LVL_FREEHANDSPOTS ) return; /* Get real name of current sep */ sepname = rcbn_sepnmActual(rcbn_iterate(NULL)); if ( ! sepname ) return; for ( /* key set above */ ; olist < key; ++olist ) { OBJECT *sublist = oArray(*olist); if ( oType(sublist[4]) != OSTRING ) return; if ( sepname == cachename(oString(sublist[4]), theLen(sublist[4])) && read_colors_array(olist, *equivs) ) { *equivlevel = GSC_EQUIV_LVL_FREEHANDSPOTS; return; } } }
/* Set the current blend mode. This can be a single name (e.g. Normal), or an * array of names. The names are not validated - we don't really know what * blend modes are supported at this stage. */ Bool pdf_setBlendMode(PDFCONTEXT* pdfc, OBJECT object) { PDF_CHECK_MC(pdfc); /* Resolve any indirect references */ if (!pdf_resolvexrefs(pdfc, &object)) { return FAILURE(FALSE) ; } /* Validate the type of the parameter - it must be a name or name array */ switch (oType(object)) { case OARRAY: case OPACKEDARRAY: if (theLen(object) <= 0) { return error_handler(RANGECHECK) ; } else { int32 i; OBJECT *list = oArray(object); /* Ensure that each object in the array is a name */ for (i = 0; i < theLen(object); i ++) { if (oType(list[i]) != ONAME) { return error_handler(TYPECHECK) ; } } } break; case ONAME: /* A name is ok */ break; default: /* Any other type is unacceptable */ return error_handler(TYPECHECK) ; } tsSetBlendMode(gsTranState(gstateptr), object, gstateptr->colorInfo); return TRUE; }
int32 MessageWindow::DCCIn (void *arg) { MessageWindow *mWin ((MessageWindow *)arg); BMessenger sMsgr (mWin->sMsgr); BMessenger mMsgr (mWin); struct sockaddr_in remoteAddy; socklen_t theLen (sizeof (struct sockaddr_in)); mWin->acceptSocket = accept(mWin->mySocket, (struct sockaddr*)&remoteAddy, &theLen); mWin->dConnected = true; BMessage msg (M_DISPLAY); mWin->PackDisplay (&msg, "Connected!\n", 0); mWin->PostMessage (&msg); char tempBuffer[2]; BString inputBuffer; while(mWin->dConnected) { snooze(10000); while (mWin->dConnected && mWin->DataWaiting()) { if (recv(mWin->acceptSocket, tempBuffer, 1, 0) == 0) { BMessage msg (M_DISPLAY); mWin->dConnected = false; mWin->PackDisplay (&msg, "DCC chat terminated.\n", 0); mWin->PostMessage (&msg); goto outta_there; // I hate goto, but this is a good use. } if (tempBuffer[0] == '\n') { mWin->ChannelMessage (inputBuffer.String()); inputBuffer = ""; } else inputBuffer.Append(tempBuffer[0],1); } } outta_there: // GOTO MARKER close (mWin->mySocket); close (mWin->acceptSocket); return 0; }
/* For xaforall, the execution stack contains: 0 ONOTHING len=size of this block (3 or 5) oOp = xaforall 1 OARRAY len=elements left to deliver oArray=next element to deliver or OEXTENDED len=0 oArray = trampoline below 2 OARRAY - the proc to run For long arrays: 3 OARRAY len=0 oArray = next element to deliver 4 OINTEGER len=0 oInteger = remaining elements */ Bool xaforall(ps_context_t *pscontext) { register OBJECT *theo ; UNUSED_PARAM(ps_context_t *, pscontext) ; theo = stackindex( 1 , & executionstack ) ; if ( ! theXLen(*theo)) { npop( theLen(*theTop(executionstack)) , & executionstack ) ; return TRUE ; } if ( oType(*theo) == OEXTENDED ) { /* Long arrays */ if ( !push(oLongArray(*theo), &operandstack) ) return FALSE ; if (--oLongArrayLen(*theo) == 0) oLongArray(*theo) = NULL ; else ++oLongArray(*theo) ; } else { /* Normal arrays */ if ( ! push(oArray(*theo) , & operandstack )) return FALSE ; if ( --theLen(*theo) == 0 ) oArray(*theo) = NULL ; else ++oArray(*theo) ; } theo = stackindex( 2 , & executionstack ) ; if ( oExecutable(*theo) ) return push( theo , & executionstack ) ; else return push( theo , & operandstack ) ; }
/* If a character is on disk, pull it into the CID data cache. */ static Bool cid0_begin_char(FONTinfo *fontInfo, charcontext_t *context) { CID0_CACHE *cid_font ; HQASSERT(fontInfo, "No font info") ; HQASSERT(context, "No character context") ; HQASSERT(theIFontType(fontInfo) == CIDFONTTYPE0, "Not in a CID Type 0") ; HQASSERT(context->chartype == CHAR_Type1 || context->chartype == CHAR_Type2, "Not a Type 1/2 charstring") ; if ( (cid_font = cid0_set_font(fontInfo)) == NULL ) return FALSE ; VERIFY_OBJECT(cid_font, CID0_CACHE_NAME) ; if ( (cid_font->font_data = fontdata_open(cid_font->source, cid_font->fdmethods)) == NULL ) return FALSE ; if ( oType(context->definition) == ONULL ) { /* cid0_lookup_char creates a special ONULL object containing an integer offset and a length. This is now converted into a string by opening a fontdata frame. */ if ( (oString(context->definition) = fontdata_frame(cid_font->font_data, cid_font->offset + oInteger(context->definition), theLen(context->definition), sizeof(uint8))) == NULL ) { fontdata_close(&cid_font->font_data) ; return FALSE ; } theTags(context->definition) = OSTRING | LITERAL | READ_ONLY ; } HQASSERT(oType(context->definition) == OSTRING, "Definition of CID character is wrong type") ; context->methods = &cid_font->cid0methods ; /* cid0_get_info is based on ps1_get_info, which uses the fontInfo to extract information. Save the current font info between begin_char and end_char; this means we cannot call CID0 fonts recursively. */ HQASSERT(cid_font->fontInfo == NULL, "Should not call CID0 recursively.") ; cid_font->fontInfo = fontInfo ; return TRUE ; }
/** Preserve the blob data if possible by storing the filename in a global string. */ static OBJECT *blobdata_file_restored(const OBJECT *file, blobdata_private_t *data, int32 savelevel) { DEVICELIST *dev ; FILELIST *flptr ; UNUSED_PARAM(blobdata_private_t *, data) ; HQASSERT(file, "No blob data source") ; VERIFY_OBJECT(data, BLOBDATA_PRIVATE_NAME) ; if ( NUMBERSAVES(savelevel) > MAXGLOBALSAVELEVEL && oType(*file) == OFILE && (flptr = oFile(*file)) != NULL && (dev = theIDeviceList(flptr)) != NULL ) { int32 devlen = strlen_int32((char *)theIDevName(dev)) ; int32 length = devlen + theINLen(flptr) + 2 ; OBJECT *string ; /* We're in a local save levels. We can re-use the file if it is a real device file. Store the full filename (including device name) in global memory. */ if ( (string = get_gomemory(1)) != NULL ) { uint8 *smem ; if ( (smem = get_gsmemory(length)) != NULL ) { smem[0] = '%' ; HqMemCpy(smem + 1, theIDevName(dev), devlen) ; smem[devlen + 1] = '%' ; if ( theINLen(flptr) ) HqMemCpy(smem + devlen + 2, theICList(flptr), theINLen(flptr)) ; oString(*string) = smem ; theTags(*string) = OSTRING | LITERAL | READ_ONLY ; theLen(*string) = CAST_UNSIGNED_TO_UINT16(length); SETGLOBJECTTO(*string, TRUE) ; return string ; } /* Got object memory, but no string memory. Forget the global object, it will get restored soon enough. */ theTags(*string) = ONULL ; } } /* Forget about it, we can't save the data any more */ return NULL ; }
static Bool runOPI(Bool *rendered) { /* try to ensure that operand stack does not accumulate junk, whether opi * is run or not. Stack clean up in error case is in Postscript, as we * cannot be 100% sure of state stack is in, when error occurs. */ char *runOPI = "mark exch /HqnOPI /ProcSet resourcestatus {\n" " pop pop\n" " <<>> /HqnOPI /ProcSet findresource /HqnOPIimage get exec\n" " { cleartomark true } { cleartomark false } ifelse " "} {\n" " cleartomark false\n" "} ifelse"; OBJECT obj = OBJECT_NOTVM_NOTHING ; theTags( obj ) = OSTRING | EXECUTABLE | READ_ONLY ; theLen ( obj ) = strlen_uint16( runOPI ) ; oString( obj ) = ( uint8 * )runOPI ; execStackSizeNotChanged = FALSE ; *rendered = FALSE ; if ( push( & obj , & executionstack )) { if ( interpreter( 1 , NULL )) { if ( theStackSize( operandstack ) > EMPTY_STACK ) { OBJECT *theo = theTop( operandstack ) ; if ( oType( *theo ) != OBOOLEAN ) return error_handler( TYPECHECK ) ; *rendered = oBool( *theo ) ; pop( & operandstack ) ; } else return error_handler( STACKUNDERFLOW ) ; } else return FALSE; } return TRUE ; }
/** Match the same underlying file, and device files with the same name. */ static Bool blobdata_file_same(const OBJECT *newo, const OBJECT *cached) { FILELIST *newflptr ; HQASSERT(newo && cached, "Objects missing for file comparison") ; HQASSERT(oType(*newo) == OFILE, "Blob data source is not a file") ; HQASSERT(oType(*cached) == OFILE || oType(*cached) == OSTRING, "Blob data source is not a file or a filename") ; newflptr = oFile(*newo) ; HQASSERT(newflptr, "No filelist in file object") ; /* Object identity has already been checked. The file is the same if: 1) The file pointers are the same 2) The file names and devices of the files are the same 3) The file name and device of the new file match a filename */ if ( oType(*cached) == OFILE ) { FILELIST *oldflptr = oFile(*cached) ; if ( oldflptr == newflptr ) return TRUE ; if ( theIDeviceList(oldflptr) != NULL && theIDeviceList(oldflptr) == theIDeviceList(newflptr) && HqMemCmp(theICList(oldflptr), theINLen(oldflptr), theICList(newflptr), theINLen(newflptr)) == 0 ) return TRUE ; } else if ( oType(*cached) == OSTRING ) { if ( theIDeviceList(newflptr) != NULL ) { uint8 *filename, *devicename ; /* file_open stores the filename in a FILELIST as a C-string (zero terminated), so we can use strcmp to compare it. */ if ( parse_filename(oString(*cached), theLen(*cached), &devicename, &filename) == DEVICEANDFILE && strcmp((const char *)theIDevName(theIDeviceList(newflptr)), (const char *)devicename) == 0 && strcmp((const char *)theICList(newflptr), (const char *)filename) == 0 ) return TRUE ; } } return FALSE ; }
static Bool obFontDecodeBuffer(FILELIST *filter, int32 *ret_bytes) { uint8 *ptr,*obs; FILELIST *uflptr; int32 count, c, i; HQASSERT(filter, "filter NULL in obFontDecodeBuffer."); uflptr = theIUnderFile(filter); obs = ptr = theIBuffer(filter); HQASSERT(uflptr, "uflptr NULL in obFontDecodeBuffer."); HQASSERT(ptr, "ptr NULL in obFontDecodeBuffer."); count = 0; for (i=0; i < OBFONTBUFFSIZE; i++) { if ( (c=Getc(uflptr)) == EOF ) { count=-count; break; } else { *ptr++ = (uint8) c; count++; } } if ( count && theIFilterPrivate(filter) ) { /* first fill of the buffer, so deobfuscate the first 32 bytes */ int32 i,j=0; uint8 * string = oString(*(OBJECT*)theIFilterPrivate(filter)); int32 ext = theLen(*(OBJECT*)theIFilterPrivate(filter)) ; while ( ext > 0 && string[--ext] != '.' ) EMPTY_STATEMENT() ; for ( i = 0; i < 32; ++i ) { uint8 l; if ( i % 16 == 0 ) j=ext; l = get_prev_hex_digit(string, &j); obs[i] ^= ( get_prev_hex_digit(string, &j)<<4 | l); } theIFilterPrivate(filter) = 0; } *ret_bytes = count; return TRUE; }
/* ---------------------------------------------------------------------------- function: repeat_() author: Andrew Cave creation date: 22-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 202. ---------------------------------------------------------------------------- */ Bool repeat_(ps_context_t *pscontext) { register OBJECT *o1 , *o2 ; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( theStackSize( operandstack ) < 1 ) return error_handler( STACKUNDERFLOW ) ; o2 = theTop( operandstack ) ; o1 = ( & o2[ -1 ] ) ; if ( ! fastStackAccess( operandstack )) o1 = stackindex( 1 , & operandstack ) ; if ( oType(*o1) != OINTEGER ) return error_handler( TYPECHECK ) ; switch ( oType(*o2) ) { case OARRAY : case OPACKEDARRAY : break ; default: return error_handler( TYPECHECK ) ; } if ( ! oExecutable(*o2) && !object_access_override(o2) ) return error_handler( INVALIDACCESS ) ; if ( oInteger(*o1) < 0 ) return error_handler( RANGECHECK ) ; else if ( oInteger(*o1) == 0 || theLen(*o2) == 0 ) { npop( 2 , & operandstack ) ; return TRUE ; } if ( ! push( o1 , & executionstack )) return FALSE ; if ( ! push( o2 , & executionstack )) return FALSE ; if ( ! xsetup_operator( NAME_xrepeat , 3 )) return FALSE ; npop( 2 , & operandstack ) ; return TRUE ; }
static Bool cid0_select_subfont(FONTinfo *fontInfo, charcontext_t *context) { OBJECT *fdict, *theo ; HQASSERT(fontInfo, "No font info") ; HQASSERT(context, "No context") ; HQASSERT(theIFontType(fontInfo) == CIDFONTTYPE0, "Not in a CID Type 0") ; /* Now we've got the font number, check that it's within the bounds of the FDArray and have a go at setting the fontinfo */ /* Extract the FD_Array. */ theo = fast_extract_hash_name(&theMyFont(*fontInfo), NAME_FDArray); if ( !theo ) return error_handler(INVALIDFONT); if ( oType(*theo) != OARRAY && oType(*theo) != OPACKEDARRAY ) return error_handler(INVALIDFONT); if ( theFDIndex(*fontInfo) >= theLen(*theo) ) return error_handler(INVALIDFONT); /* And finally get our hands on the font dictionary */ fdict = oArray(*theo) + theFDIndex(*fontInfo) ; if ( oType(*fdict) != ODICTIONARY ) return error_handler(INVALIDFONT); /* Then do the necessary for the sub-dictionary. Currently, this concatenates the sub fonts matrix onto the font matrix, and sets the charstring type. */ if ( !set_cid_subfont(fontInfo, fdict) ) return FALSE ; context->chartype = CHAR_Type1 ; return TRUE ; }
static Bool dostopped(ps_context_t *pscontext, Bool super) { int32 temp ; OBJECT omark = OBJECT_NOTVM_MARK ; temp = theStackSize( operandstack ) ; if ( temp < 0 ) return error_handler( STACKUNDERFLOW ) ; theLen(omark) = CAST_SIGNED_TO_UINT16(super) ; /* Represents a stopped mark */ if ( ! push(&omark, &executionstack) ) return FALSE ; if ( ! myexec_(pscontext)) /* Indicates stackoverflow. */ return FALSE ; if ( theStackSize( operandstack ) == temp ) { pop( & executionstack ) ; return push( & fnewobj , & operandstack ) ; } return TRUE ; }
/* ---------------------------------------------------------------------------- function: mysqrt_() author: Andrew Cave creation date: 08-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 224. ---------------------------------------------------------------------------- */ Bool mysqrt_(ps_context_t *pscontext) { register int32 ssize ; register OBJECT *theo ; register SYSTEMVALUE arg ; UNUSED_PARAM(ps_context_t *, pscontext) ; ssize = theStackSize( operandstack ) ; if ( EmptyStack( ssize )) return error_handler( STACKUNDERFLOW ) ; theo = TopStack( operandstack , ssize ) ; /* Do NOT use object_get_numeric, because of different behaviour with OINFINITY. */ switch ( oType(*theo)) { case OREAL : arg = ( SYSTEMVALUE )oReal(*theo) ; break ; case OINTEGER : arg = ( SYSTEMVALUE )oInteger(*theo) ; break ; case OINFINITY : return TRUE ; default: return error_handler( TYPECHECK ) ; } /* Check for validity of argument. */ if ( arg < 0.0 ) return error_handler( RANGECHECK ) ; theTags(*theo) = OREAL | LITERAL ; oReal(*theo) = ( USERVALUE )sqrt(( double )arg ) ; theLen(*theo) = 0 ; return TRUE ; }
/* ---------------------------------------------------------------------------- function: anchorsearch_() author: Andrew Cave creation date: 09-Oct-1987 last modification: ##-###-#### arguments: none. description: See PostScript reference manual page 116. ---------------------------------------------------------------------------- */ Bool anchorsearch_(ps_context_t *pscontext) { int32 stringsize , postsize , matchsize ; OBJECT *o1 , *o2 ; uint8 tags1 , tags2 ; uint8 *str , *seek ; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( theStackSize( operandstack ) < 1 ) return error_handler( STACKUNDERFLOW ) ; /* Check types. */ o1 = stackindex( 1 , & operandstack ) ; o2 = theTop( operandstack ) ; tags1 = theTags(*o1) ; tags2 = theTags(*o2) ; if ( oType(*o1) != OSTRING || oType(*o2) != OSTRING ) return error_handler( TYPECHECK ) ; /* Check access requirements. */ if ( (!oCanRead(*o1) && !object_access_override(o1)) || (!oCanRead(*o2) && !object_access_override(o2)) ) return error_handler( INVALIDACCESS ) ; /* Extract the locations of seek & string, and their lengths.*/ seek = oString(*o2) ; str = oString(*o1) ; matchsize = theLen(*o2) ; stringsize = theLen(*o1) ; /* Remove the trivial cases. */ postsize = stringsize - matchsize ; if ( postsize < 0 ) { Copy(o2, &fnewobj) ; return TRUE ; } if ( matchsize == 0 ) { if ( ! push( & tnewobj , & operandstack )) return FALSE ; theTags(*o2) = tags1 ; SETGLOBJECTTO(*o2, oGlobalValue(*o1)); return TRUE ; } /* Compare initial sub-string of string (of length match_size) with seek. If initial sub-string matches, then setup post & match, and boolean true. */ if ( HqMemCmp( str , matchsize , seek , matchsize) == 0 ) { if ( ! push( & tnewobj , & operandstack )) return FALSE ; theTags(*o2) = tags1 ; theLen(*o2) = ( uint16 )matchsize ; oString(*o2) = str ; SETGLOBJECTTO(*o2, oGlobalValue(*o1)); theLen(*o1) = ( uint16 )postsize ; oString(*o1) = ( postsize != 0 ? str + matchsize : NULL ) ; return TRUE ; } /* Else no match occurred, so push boolean false. */ Copy(o2, &fnewobj) ; return TRUE ; }
/* ---------------------------------------------------------------------------- function: search_() author: Andrew Cave creation date: 09-Oct-1987 last modification: ##-###-#### arguments: none. description: See PostScript reference manual page 211. ---------------------------------------------------------------------------- */ Bool search_(ps_context_t *pscontext) { int32 postsize , matchsize , presize ; OBJECT *o1 , *o2 ; uint8 *str ; uint8 tags1 , tags2 ; uint8 *seek ; int32 stringsize ; OBJECT newobject = OBJECT_NOTVM_NOTHING ; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( theStackSize( operandstack ) < 1 ) return error_handler( STACKUNDERFLOW ) ; /* Check types. */ o1 = stackindex( 1 , & operandstack ) ; o2 = theTop( operandstack ) ; tags1 = theTags(*o1) ; tags2 = theTags(*o2) ; if ( oType(*o1) != OSTRING || oType(*o2) != OSTRING ) return error_handler( TYPECHECK ) ; /* Check access requirements. */ if ( (!oCanRead(*o1) && !object_access_override(o1)) || (!oCanRead(*o2) && !object_access_override(o2)) ) return error_handler( INVALIDACCESS ) ; /* Extract the location of seek & string, and their lengths. */ seek = oString(*o2) ; str = oString(*o1) ; matchsize = theLen(*o2) ; stringsize = theLen(*o1) ; /* Remove the trivial cases. */ if ( stringsize == 0 ) { Copy(o2, &fnewobj) ; return TRUE ; } if ( matchsize == 0 ) { theTags( newobject ) = tags1 ; theLen( newobject ) = 0 ; oString( newobject ) = NULL ; SETGLOBJECTTO(newobject, oGlobalValue(*o1)); if ( ! push2(&newobject, &tnewobj, &operandstack) ) return FALSE ; theTags(*o2) = tags1 ; SETGLOBJECTTO(*o2, oGlobalValue(*o1)); return TRUE ; } postsize = stringsize - matchsize ; presize = 0 ; /* Compare sub-strings of string (of length match_size) with seek, until no sub-string left that is that long, or have found match. */ while ( postsize >= 0 ) { /* If matched up sub-string, then setup post, match & pre. */ if ( ! HqMemCmp( & str[ presize ] , matchsize , seek , matchsize )) { theTags( newobject ) = tags1 ; theLen( newobject ) = ( uint16 )presize ; oString( newobject ) = ( presize != 0 ? str : NULL ) ; SETGLOBJECTTO(newobject, oGlobalValue(*o1)); if ( ! push2(&newobject, &tnewobj, &operandstack) ) return FALSE ; theTags(*o2) = tags1 ; theLen(*o2) = ( uint16 )matchsize ; oString(*o2) = str + presize ; SETGLOBJECTTO(*o2, oGlobalValue(*o1)); theLen(*o1) = ( uint16 )postsize ; oString(*o1) = ( postsize != 0 ? str + presize + matchsize : NULL ) ; return TRUE ; } /* Otherwise look at next sub-string. */ ++presize ; --postsize ; } /* No match occurred, so push the boolean false. */ Copy(o2, &fnewobj) ; return TRUE ; }