コード例 #1
0
ファイル: xmlops.c プロジェクト: S0043640wipro/RiCRiPInt
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) ;
}
コード例 #2
0
ファイル: dictbld.c プロジェクト: S0043640wipro/RiCRiPInt
/** Sometimes it's useful to do a dictmatch, followed perhaps by some processing
 * of the results, followed by a dictbuild. An example of this is the PDF world
 * where we need to decant parameters from a PS dict, check/munge them and then
 * store them in a PDF dict, outside of PSVM.
 */
Bool dictmatchbuild( OBJECT *dict ,
                     NAMETYPEMATCH build_objects[] ,
                     OBJECT * (*alloc_func)(int32 size, void * params),
                     void * alloc_params  )
{
  HQASSERT(object_asserts(), "Object system not initialised or corrupt") ;
  HQASSERT( dict , "dict NULL in dictmatchbuild." ) ;
  HQASSERT( oType(*dict) == ODICTIONARY ,
            "dict not a dictionary in dictmatchbuild." ) ;
  HQASSERT( build_objects , "build_objects NULL in dictmatchbuild." ) ;

  while ( build_objects->name != DUMMY_END_NAME ) {
    if ( build_objects->result ) {
      oName(nnewobj) = system_names + ( build_objects->name & ~OOPTIONAL ) ;

      if ( !insert_hash_with_alloc( dict ,
                                    &nnewobj ,
                                    build_objects->result ,
                                    INSERT_HASH_NAMED,
                                    alloc_func,
                                    alloc_params))
        return FALSE ;
    }

    ++build_objects ;
  }

  return TRUE ;
}
コード例 #3
0
ファイル: dictbld.c プロジェクト: S0043640wipro/RiCRiPInt
/** Populate the dictionary from the given build objects. */
Bool dictbuild( OBJECT *dict ,
                NAMETYPEBUILD build_objects[],
                OBJECT * (*alloc_func)(int32 size, void * params),
                void * alloc_params )
{
  HQASSERT(object_asserts(), "Object system not initialised or corrupt") ;
  HQASSERT( dict , "dict NULL in dictbuild." ) ;
  HQASSERT( oType(*dict) == ODICTIONARY ,
            "dict not a dictionary in dictbuild." ) ;
  HQASSERT( build_objects , "build_objects NULL in dictbuild." ) ;

  while ( build_objects->name != DUMMY_END_NAME ) {
    if ( oType(build_objects->value) != ONULL ) {
      oName(nnewobj) = system_names + build_objects->name ;

      HQASSERT(( build_objects->name & OOPTIONAL ) == 0 ,
               "OOPTIONAL flag not allowed in dictbuild." ) ;

      if ( !insert_hash_with_alloc( dict ,
                                    &nnewobj ,
                                    &build_objects->value,
                                    INSERT_HASH_NAMED,
                                    alloc_func,
                                    alloc_params))
        return FALSE ;
    }

    ++build_objects ;
  }

  return TRUE ;
}
コード例 #4
0
ファイル: gscequiv.c プロジェクト: S0043640wipro/RiCRiPInt
/*----------------------------------------------------------------------------*/
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;
    }
  }
}
コード例 #5
0
ファイル: gscequiv.c プロジェクト: S0043640wipro/RiCRiPInt
/*----------------------------------------------------------------------------*/
static Bool try_cmykcustom_color_comments(GS_COLORinfo *colorInfo,
                                          NAMECACHE *sepname,
                                          EQUIVCOLOR equivs,
                                          Bool *foundEquivs,
                                          EXTRADATA *extraData)
{
  OBJECT *dict;
  OBJECT *convert;
  OBJECT nameobj = OBJECT_NOTVM_NOTHING;

  /* Get statusdict from systemdict */
  dict = fast_extract_hash_name(&systemdict, NAME_statusdict);
  if (dict == NULL)
    return FALSE;

  /* Get CMYKCustomColors dictionary from statusdict */
  dict = fast_extract_hash_name(dict, NAME_CMYKCustomColors);
  if (dict == NULL)
    return TRUE;    /* Not an error */

  if ( oType(*dict) != ODICTIONARY )
    return FALSE;

  /* Look up the separation name in CMYKCustomColors. If the colorant doesn't
   * exist it's not an error.
   */
  theTags(nameobj) = ONAME | LITERAL;
  oName(nameobj) = sepname;
  convert = fast_extract_hash(dict, &nameobj);
  if (convert == NULL)
    return TRUE;    /* Not an error */

  if (!read_colors_array(convert, equivs))
    return FALSE;


  if (extraData->outputSpaceId != SPACE_DeviceCMYK) {
    /* Install as the current colorspace and invoke it to RGB.
     * This call should always work, so any error are treated as fatal.
     */
    if (!gsc_setcolorspacedirect(colorInfo, extraData->equivColorType, SPACE_DeviceCMYK) ||
        !gsc_setcolordirect(colorInfo, extraData->equivColorType, equivs) ||
        !gsc_invokeChainTransform(colorInfo, extraData->equivColorType,
                                  extraData->outputSpaceId, FALSE,
                                  equivs)) {
      return FALSE;
    }
  }

  *foundEquivs = TRUE;
  return TRUE;
}
コード例 #6
0
ファイル: gpparam.cpp プロジェクト: Mileslee/wxgis
void wxGISGPParameter::SetSelDomainValue(int nNewSelection)
{
    m_bHasBeenValidated = false;
	m_nSelection = nNewSelection;
	if(m_pDomain)
	{
		switch(m_DataType)
		{
		case enumGISGPParamDTBool:
		case enumGISGPParamDTInteger:
		case enumGISGPParamDTDouble:
		case enumGISGPParamDTText:
		case enumGISGPParamDTSpatRef:
		case enumGISGPParamDTQuery:
        case enumGISGPParamDTFieldAnyChoice:
        case enumGISGPParamDTFieldStringChoice:
        case enumGISGPParamDTFieldIntegerChoice:
        case enumGISGPParamDTFieldRealChoice:
        case enumGISGPParamDTFieldDateChoice:
        case enumGISGPParamDTFieldTimeChoice:
        case enumGISGPParamDTFieldDateTimeChoice:
        case enumGISGPParamDTFieldBinaryChoice:
            SetValue(m_pDomain->GetValue(nNewSelection));
			break;
		case enumGISGPParamDTStringList:
		case enumGISGPParamDTPathArray:
		case enumGISGPParamDTPath:
            {
                //change m_Value ext to filters
                wxString sData = GetValue();
                wxGISGPGxObjectDomain* poDomain = wxDynamicCast(GetDomain(), wxGISGPGxObjectDomain);
                if(poDomain)
                {
                    wxFileName oName(sData);
                    if(oName.IsOk())
                    {
                        if(!oName.HasExt()) //set sel domain
                        {
                            wxGxObjectFilter* poFilter = poDomain->GetFilter(GetSelDomainValue());
                            oName.SetExt(poFilter->GetExt());
                            SetValue(wxVariant(oName.GetFullPath(), wxT("path")));
                        }
                    }
                }
            }
			break;        
		case enumGISGPParamDTUnknown:
		default:
			break;        
		}
	}
}
コード例 #7
0
ファイル: AfcLog.cpp プロジェクト: nightstyles/focp
bool CLogManager::HaveModule(const char* sModuleName)
{
	bool bHave = false;
	CModuleName oName(sModuleName);
	if(oName.Empty())
		return true;
	CRbTreeNode* pEnd = m_oLogAttr.End();
	m_oMutex.Enter();
	CRbTreeNode* pIt = m_oLogAttr.Find(oName);
	if(pIt != pEnd)
		bHave = true;
	m_oMutex.Leave();
	return bHave;
}
コード例 #8
0
ファイル: fmtpstst.c プロジェクト: S0043640wipro/RiCRiPInt
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;
}
コード例 #9
0
ファイル: gpdomain.cpp プロジェクト: GimpoByte/nextgismanager
int wxGISGPGxObjectDomain::GetPosByValue(const wxVariant &oVal) const
{
    if(!oVal.IsNull())
    {
		wxFileName oName(oVal.GetString());
        for(size_t i = 0; i < m_asoData.size(); ++i)
        {
            wxGxObjectFilter* poFilter = GetFilter(i);
            if(poFilter)
            {
                if( oName.GetExt().IsSameAs(poFilter->GetExt(), false) || poFilter->GetExt().IsEmpty() )
                {
                    return i;
                }
            }
        }
    }
	return wxNOT_FOUND;
}
コード例 #10
0
ファイル: pdfmc.c プロジェクト: S0043640wipro/RiCRiPInt
Bool pdfop_DP( PDFCONTEXT *pdfc )
{
  STACK *stack ;
  OBJECT *tag ;
  OBJECT *properties ;
  PDF_IMC_PARAMS *imc ;

  PDF_CHECK_MC( pdfc ) ;
  PDF_GET_IMC( imc ) ;

  stack = ( & imc->pdfstack ) ;
  if ( theIStackSize( stack ) < 1 )
    return error_handler( RANGECHECK ) ;

  tag = stackindex( 1 , stack ) ;
  if ( oType(*tag) != ONAME )
    return error_handler( TYPECHECK ) ;

  properties = theITop( stack ) ;
  if ( oType(*properties) != ODICTIONARY &&
       oType(*properties) != ONAME )
    return error_handler( TYPECHECK ) ;

  /* an OC tag will set the OC context to a given group
     directly. Currently this is only cleared by a similar
     tag or an OC tag from BDC
  */
  switch (oName(*tag) - system_names) {
    case NAME_OC:
      imc->mc_DP_oc_status = TRUE;
      if (!pdf_oc_getstate_fromprops(pdfc, properties, & imc->mc_DP_oc_status))
        return FALSE;

      if (! imc->mc_DP_oc_status) {
        if (!change_optional_content_on(FALSE))
          return FALSE;
      }
      break;
  }

  npop( 2 , stack ) ;
  return TRUE ;
}
コード例 #11
0
ファイル: gscequiv.c プロジェクト: S0043640wipro/RiCRiPInt
/** check_colorants_dictionary takes a DeviceN colorspace and
    returns a pointer to the Colorants dictionary if there is one. */
static Bool check_colorants_dictionary(
  /*@notnull@*/                        const OBJECT *PSColorSpace,
  /*@notnull@*/ /*@out@*/              OBJECT **colorantsDict)
{
  OBJECT* theo;
  int32 len;

  *colorantsDict = NULL;

  theo = oArray(*PSColorSpace) ;  /* DeviceN array */

  /* Ignore non-DeviceN color spaces */
  if (oName(*theo) != system_names + NAME_DeviceN)
    return TRUE;

  HQASSERT(colorantsDict != NULL,
           "null colorants dictionary pointer" );

  *colorantsDict = NULL;

  len = theILen( PSColorSpace );

  if (len == 5) {
    /* we should have an attributes dictionary */

    theo += 4 ;         /* attributes dict */

    if ( oType(*theo) != ODICTIONARY ) {
      return error_handler( TYPECHECK );
    }

    *colorantsDict = fast_extract_hash_name(theo, NAME_Colorants);

    /* if simply not found, ignore the fact */
    if (*colorantsDict != NULL) {
      if ( oType(**colorantsDict) != ODICTIONARY ) {
        return error_handler( TYPECHECK );
      }
    }
  }
  return TRUE;
}
コード例 #12
0
ファイル: TabSequence.cpp プロジェクト: rickcowan/xLights
void xLightsFrame::SaveAsSequence()
{
   if (SeqData.NumFrames() == 0)
    {
        wxMessageBox("You must open a sequence first!", "Error");
        return;
    }
    wxString NewFilename;
    wxFileDialog fd(this,
                    "Choose filename to Save Sequence:",
                    CurrentDir,
                    CurrentSeqXmlFile->GetName(),
                    strSequenceSaveAsFileTypes,
                    wxFD_SAVE | wxFD_OVERWRITE_PROMPT);

    bool ok = false;
    do
    {
        if (fd.ShowModal() != wxID_OK)
        {
            return;
        }
        // validate inputs
        NewFilename=fd.GetPath();
        NewFilename.Trim();
        ok=true;
        if (NewFilename.IsEmpty())
        {
            ok=false;
            wxMessageBox(_("File name cannot be empty"), _("ERROR"));
        }
    }
    while (!ok);
    wxFileName oName(NewFilename);
    oName.SetExt("fseq");
    DisplayXlightsFilename(oName.GetFullPath());

    oName.SetExt("xml");
    CurrentSeqXmlFile->SetPath(oName.GetPath());
    CurrentSeqXmlFile->SetFullName(oName.GetFullName());
    SaveSequence();
}
コード例 #13
0
ファイル: pdfmem.c プロジェクト: S0043640wipro/RiCRiPInt
static Bool dictwalk_destroy_dictionary( OBJECT *poKey ,
                                         OBJECT *poValue ,
                                         void *data )
{
  corecontext_t *context = data;

  UNUSED_PARAM( OBJECT * , poValue ) ;

  /* Invalidate shallow cache entry. */
  if ( oType(*poKey) == ONAME ) {
    NAMECACHE *nptr = oName(*poKey) ;
    HQASSERT( nptr->dictval != NULL ,
              "Got this entry from a dict so reset must be non-NULL" ) ;
    if ( context->savelevel <= SAVELEVELINC )
      nptr->dictcpy = NULL ;        /* Invalidate reset */
    nptr->dictobj = NULL ;
  }

  return TRUE ;
}
コード例 #14
0
ファイル: gscequiv.c プロジェクト: S0043640wipro/RiCRiPInt
/** lookup_colorants_dictionary looks up the given separation name in the given
    Colorants dictionary */
static Bool lookup_colorants_dictionary(
  /*@notnull@*/                       const OBJECT *colorantsDict,
  /*@notnull@*/                       NAMECACHE *sepname,
  /*@notnull@*/ /*@out@*/             OBJECT **separationCSA)
{
  OBJECT colorant;

  HQASSERT( sepname != NULL, "null separation name");
  HQASSERT( separationCSA != NULL, "null separationCSA flag");
  HQASSERT(oType(*colorantsDict) == ODICTIONARY,
           "colorantsDict is not a dictionary");

  theTags(colorant) = ONAME | LITERAL;
  oName(colorant) = sepname;

  /* separation should be an array, e.g. [/Separation /MyPink /DeviceCMYK {tinttransform}] */
  *separationCSA = fast_extract_hash(colorantsDict, &colorant);

  return *separationCSA != NULL;
}
コード例 #15
0
ファイル: pdfxref.c プロジェクト: S0043640wipro/RiCRiPInt
Bool pdf_xrefexplicitaccess_dictmatch( PDFXCONTEXT *pdfxc ,
                                       NAMETYPEMATCH *match ,
                                       OBJECT *dict , Bool permanent )
{
  int i ;

  for ( i = 0 ; ( int32 )( match[ i ].name ) != END_MATCH_MARKER ; i++ ) {
    OBJECT key = OBJECT_NOTVM_NAME( NAME_PDF , LITERAL ) ;
    OBJECT *theo ;

    oName( key ) = theIMName( & match[ i ]) ;
    theo = fast_extract_hash( dict , & key ) ;
    if ( theo != NULL && oType( *theo ) == OINDIRECT ) {
      if ( ! pdf_xrefexplicitaccess( pdfxc , oXRefID( *theo ) , permanent )) {
        return FALSE ;
      }
    }
  }

  return TRUE ;
}
コード例 #16
0
ファイル: gscequiv.c プロジェクト: S0043640wipro/RiCRiPInt
/*----------------------------------------------------------------------------*/
static Bool try_CMYKEquivalents(GS_COLORinfo *colorInfo,
                                NAMECACHE *sepname,
                                EQUIVCOLOR equivs,
                                Bool *foundEquivs,
                                EXTRADATA *extraData)
{
  OBJECT *dict;
  OBJECT *convert;
  OBJECT nameobj = OBJECT_NOTVM_NOTHING;

  UNUSED_PARAM(GS_COLORinfo *, colorInfo);
  UNUSED_PARAM(void *, extraData);

  /* Get statusdict from systemdict */
  dict = fast_extract_hash_name(&systemdict, NAME_statusdict);
  if (dict == NULL)
    return FALSE;

  /* Get CMYKEquivalents dictionary from statusdict */
  dict = fast_extract_hash_name(dict, NAME_CMYKEquivalents);
  if (dict == NULL)
    return TRUE;    /* Not an error */

  if (oType(*dict) != ODICTIONARY)
    return FALSE;

  /* Look up the separation name in CMYKEquivalents */
  theTags(nameobj) = ONAME | LITERAL;
  oName(nameobj) = sepname;
  convert = fast_extract_hash(dict, &nameobj);
  if (convert == NULL)
    return TRUE;    /* Not an error */

  if (!read_colors_array(convert, equivs))
    return FALSE;

  *foundEquivs = TRUE;
  return TRUE;
}
コード例 #17
0
ファイル: TabSequence.cpp プロジェクト: rickcowan/xLights
void xLightsFrame::SaveSequence()
{
    if (SeqData.NumFrames() == 0)
    {
        wxMessageBox("You must open a sequence first!", "Error");
        return;
    }

    wxCommandEvent playEvent(EVT_STOP_SEQUENCE);
    wxPostEvent(this, playEvent);

    if (xlightsFilename.IsEmpty())
    {
        int saved_text_entry_context = mTextEntryContext;
        mTextEntryContext = TEXT_ENTRY_DIALOG;
        wxString NewFilename;

        wxFileDialog fd(this,
                        "Choose filename to Save Sequence:",
                        CurrentDir,
                        CurrentSeqXmlFile->GetName(),
                        strSequenceSaveAsFileTypes,
                        wxFD_SAVE | wxFD_OVERWRITE_PROMPT);

        bool ok = false;
        do
        {
            if (fd.ShowModal() != wxID_OK)
            {
                return;
            }
            // validate inputs
            NewFilename=fd.GetPath();
            NewFilename.Trim();
            ok=true;
            if (NewFilename.IsEmpty())
            {
                ok=false;
                wxMessageBox(_("File name cannot be empty"), _("ERROR"));
            }
        }
        while (!ok);
        wxFileName oName(NewFilename);
        oName.SetExt("fseq");
        DisplayXlightsFilename(oName.GetFullPath());

        oName.SetExt("xml");
        CurrentSeqXmlFile->SetPath(oName.GetPath());
        CurrentSeqXmlFile->SetFullName(oName.GetFullName());

        mTextEntryContext = saved_text_entry_context;
    }

    EnableSequenceControls(false);
    wxStopWatch sw; // start a stopwatch timer
    StatusBar1->SetStatusText(_("Saving ")+xlightsFilename);

    CurrentSeqXmlFile->Save(mSequenceElements);
    if (mRenderOnSave) {
        RenderIseqData(true); // render ISEQ layers below the Nutcracker layer
        RenderGridToSeqData();
        RenderIseqData(false);  // render ISEQ layers above the Nutcracker layer
    }
    WriteFalconPiFile(xlightsFilename);
    DisplayXlightsFilename(xlightsFilename);
    float elapsedTime = sw.Time()/1000.0; // now stop stopwatch timer and get elapsed time. change into seconds from ms
    wxString displayBuff = wxString::Format(_("%s     Updated in %7.3f seconds"),xlightsFilename,elapsedTime);
    CallAfter(&xLightsFrame::SetStatusText, displayBuff);
    EnableSequenceControls(true);
    mSavedChangeCount = mSequenceElements.GetChangeCount();
}
コード例 #18
0
ファイル: main.cpp プロジェクト: CplusHua/fpdns
int main(int argc, char** argv) {
    int retries = 1;
    int timeout = 5;

    if (argc == 1) {
        fprintf(stdout, "Usage: \n\nresponse_collector \"$DNS_SERVER_NAME\" $SERVER_IP_ADDRESS [timeout=5] [retries=1]\n\nor\n\n");
        fprintf(stdout, "response_collector \"$VENDOR | $PRODUCT | $VERSION\" $SERVER_IP_ADDRESS [timeout=5] [retries=1]\n\nor\n\n");
        fprintf(stdout, "response_collector --show-queries\n\n\n");

        exit(1);
    }

    bool showQueries = (strcmp(argv[1], "--show-queries") == false);
    if (argc == 2 && !showQueries) {
        fprintf(stderr, "Error: Invalid command line argument\n");

        exit(1);
    }

    unsigned int ip_address;
    if (argc > 2) {
        ip_address = str_to_ip(argv[2]);
        
        //0.0.0.0 address will always fail
        if (ip_address == 0) {
            exit(1);
        }
        if (argc >= 4) {
            timeout = atoi(argv[3]);
            if (argc >= 5) {
                retries = atoi(argv[4]);
            }
        }
    }


    DnsResolver oRes;
    oRes.setRetries(retries);
    oRes.setTimeout(timeout);

    if (!showQueries) {
        oRes.setNameserver(ip_address);
    }
    std::string sA = ".";
    DnsName oName(sA);

    DnsRR *pQuestionRR = DnsRR::question(oName, DNS_RR_A);
    pQuestionRR->set_class(DNS_CLASS_IN);

    DnsPacket oQuest(true, -1);
    oQuest.addQuestion(*pQuestionRR);

    int count = 0;
    unsigned opcode;
    unsigned aa;
    unsigned tc;
    unsigned rd;
    unsigned ra;
    unsigned z;
    unsigned ad;
    unsigned cd;
    unsigned rcode_index;
    rcode_t rcodes[NUM_RCODE] = {DNS_NOERROR, DNS_NOTIMP};


    if (showQueries) {
        fprintf(stdout, "ver %s\n", RESPONSE_COLLECTOR_VERSION);
    } else {
        fprintf(stdout, "%s\n", argv[1]);
    }

    for (opcode = 0; opcode < NUM_OPCODE; opcode++) {
        for (aa = 0; aa < NUM_AA; aa++) {
            for (tc = 0; tc < NUM_TC; tc++) {
                for (rd = 0; rd < NUM_RD; rd++) {
                    for (ra = 0; ra < NUM_RA; ra++) {
                        for (z = 0; z < NUM_Z; z++) {
                            for (ad = 0; ad < NUM_AD; ad++) {
                                for (cd = 0; cd < NUM_CD; cd++) {
                                    for (rcode_index = 0; rcode_index < NUM_RCODE; rcode_index++) {
                                        DnsPacket oResp(true);

                                        oQuest.getHeader().setOpcode(opcode);
                                        oQuest.getHeader().set_aa(aa);
                                        oQuest.getHeader().set_tc(tc);
                                        oQuest.getHeader().set_rd(rd);
                                        oQuest.getHeader().set_ra(ra);
                                        oQuest.getHeader().set_z(z);
                                        oQuest.getHeader().set_ad(ad);
                                        oQuest.getHeader().set_cd(cd);
                                        oQuest.getHeader().set_rcode(rcodes[rcode_index]);

                                        if (showQueries) {
                                            printHeader(oQuest.getHeader());
                                            printNameClassType(oQuest);
                                            continue;
                                        }

                                        oRes.send(oQuest, oResp);
                                        if (!oResp.getHeader().getResponse()) {
                                            printHeader(oQuest.getHeader());
                                        } else {
                                            printHeader(oResp.getHeader());
                                        }
                                        count++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }


    std::string qnames[NUM_QNAME] = {".", "jjjjjjjjjjjj"};
    unsigned qclasses[NUM_QCLASS] = {DNS_CLASS_RESERVED, DNS_CLASS_IN,
        DNS_CLASS_UNASSIGNED, DNS_CLASS_CH, DNS_CLASS_HS, DNS_CLASS_NONE,
        DNS_CLASS_ANY, DNS_CLASS_RESERVED_PRIVATE, DNS_CLASS_RESERVED1};
    unsigned qtypes[NUM_QTYPE] = {DNS_RR_A, DNS_RR_NS, DNS_RR_MD, DNS_RR_CNAME,
        DNS_RR_SOA, DNS_RR_HINFO, DNS_RR_AAAA, DNS_RR_NXT, DNS_RR_A6, DNS_RR_DNAME,
        DNS_RR_SINK, DNS_RR_SSHFP, DNS_RR_RRSIG, DNS_RR_NSEC, DNS_RR_DNSKEY,
        DNS_RR_NSEC3, DNS_RR_NSEC3PARAM, DNS_RR_TKEY, DNS_RR_TSIG, DNS_RR_IXFR,
        DNS_RR_AXFR, DNS_RR_UNASSIGNED, DNS_RR_PRIVATE, DNS_RR_RESERVED};


    for (int i = 0; i < NUM_QNAME; i++) {
        for (int j = 0; j < NUM_QCLASS; j++) {
            for (int k = 0; k < NUM_QTYPE; k++) {

                DnsPacket oResp(true);
                DnsPacket oQuest(true, -1);

                DnsResolver oRes;
                oRes.setRetries(retries);
                oRes.setTimeout(timeout);
                if (!showQueries) {
                    oRes.setNameserver(str_to_ip(argv[2]));
                }
                std::string sA = qnames[i];
                DnsName oName(sA);

                DnsRR *pQuestionRR = DnsRR::question(oName, qtypes[k]);
                pQuestionRR->set_class(qclasses[j]);
                oQuest.addQuestion(*pQuestionRR);

                if (showQueries) {
                    printHeader(oQuest.getHeader());
                    printNameClassType(oQuest);
                    continue;
                }


                oRes.send(oQuest, oResp);
                if (!oResp.getHeader().getResponse()) {
                    printHeader(oQuest.getHeader());
                } else {
                    printHeader(oResp.getHeader());
                }
                count++;
            }
        }
    }


    return 0;
}
コード例 #19
0
ファイル: Sys.cpp プロジェクト: 0rel/NobodyShooter
// http://www.gamedev.net/community/forums/topic.asp?topic_id=132523
// http://ubuntuforums.org/archive/index.php/t-659718.html
bool CSys::GetFilesInDir_( const char* pcDir, const char *pcFile, CArray<CStr> *poArray )
{
	CStr oDir( pcDir );
	CArray<CStr> oArrToken;
	
	if( oDir[oDir.GetSize() - 1] != '/' )
		oDir += '/';
	
	DIR * poDir = ::opendir( pcDir );
	if( !poDir )
	{
		::fprintf( stderr, "Unable to open the directory.\n" );
		return false;
	}
	
	struct dirent *d = 0;
	while( ( d = ::readdir( poDir ) ) != 0 )
	{
		CStr oName( d->d_name );
		if ( oName == "." || oName == ".." ) 
			continue;
		if ( d->d_type == 4 ) // skip directories
			continue;
		
		const char *wild = pcFile;
		const char *string = oName.GetData();
		//static int wild_test( const char *wild, const char *string )
		{
			const char *cp = NULL, *mp = NULL;

			while( (*string) && (*wild != '*'))
			{
				if( ( *wild != *string ) && (*wild != '?') )
				{
					return 0;
				}
				++wild;
				++string;
			}
			while (*string)
			{
				if (*wild == '*') {
					if (!*++wild) {
						return 1;
				}
				mp = wild;
				cp = string+1;
				} else if ((*wild == *string) || (*wild == '?')) {
					wild++;
				string++;
				} else {
					wild = mp;
					string = cp++;
				}
			}

			while (*wild == '*') {
				++wild;
			}
			
			//return !*wild;
			if( !*wild )
				poArray->Append( oDir + oName );
		}
	}
	
	::closedir( poDir );
	return true;
}
コード例 #20
0
ファイル: filters.c プロジェクト: S0043640wipro/RiCRiPInt
/* ----------------------------------------------------------------------------
   function:            filter_()            author:              Paul Attridge
   creation date:       26-Jun-1991          last modification:   ##-###-####
   arguments:           none .
   description:

   See PostScript reference manual second edition page 416.

---------------------------------------------------------------------------- */
Bool filter_(ps_context_t *pscontext)
{
  FILELIST *flptr ;
  OBJECT nameo = OBJECT_NOTVM_NOTHING ;
  OBJECT fileo = OBJECT_NOTVM_NOTHING ;
  uint8  *filter_name ;
  int32  name_length ;
  int32  find_error ;
#if defined( ASSERT_BUILD )
  int32  stack_size ;
#endif

  UNUSED_PARAM(ps_context_t *, pscontext) ;

  if ( theStackSize( operandstack ) < 1 )
    return error_handler( STACKUNDERFLOW ) ;

  Copy(&nameo, theTop(operandstack)) ;

  if ( oType(nameo) == ONAME ) {
    filter_name = theICList(oName(nameo)) ;
    name_length = theINLen(oName(nameo)) ;
  } else if ( oType(nameo) == OSTRING ) {
    /* undocumented - but they allow strings as an argument */
    filter_name = oString(nameo) ;
    name_length = theLen(nameo) ;
  } else
    return error_handler( TYPECHECK ) ;

  /* find the filter name in the external or standard filter table */
  flptr = filter_external_find(filter_name, name_length, &find_error, TRUE) ;
  if ( flptr == NULL ) {
    if ( find_error != NOT_AN_ERROR)
      return error_handler( find_error );
    flptr = filter_standard_find(filter_name, name_length) ;
    if ( flptr == NULL )
      return error_handler( UNDEFINED ) ;
  }

  /* sanity check */
  HQASSERT(isIFilter(flptr), "Not a filter") ;

  /* Create our own copy of this filter - reusing a previous (dead) one if
   * possible; otherwise will actually alloc a new one.
   */
  pop(&operandstack) ; /* Don't want name on stack during filter init */

#if defined( ASSERT_BUILD )
  /* The init routine removes the arguments it needs, including the underlying
     source/target from the stack. Check that it actually did remove
     something. */
  stack_size = theStackSize(operandstack) ;
#endif

  if ( ! filter_create_object(flptr, &fileo, NULL, &operandstack) ) {
    (void)push(&nameo, &operandstack) ; /* Restore name for error reporting */
    return FALSE ;
  }

  HQASSERT(theStackSize(operandstack) <= stack_size - 1,
           "Filter init routine should have removed underlying source/target") ;

  return push(&fileo, &operandstack) ;
}
コード例 #21
0
ファイル: AfcLog.cpp プロジェクト: nightstyles/focp
CAfcLogAttr& CLogManager::GetLogAttr(const char* sModuleName)
{
	CModuleName oName(sModuleName);
	CRbTreeNode* pEnd = m_oLogAttr.End();
	CRbTreeNode* pIt = m_oLogAttr.Find(oName);
	if(pIt != pEnd)
		return m_oLogAttr.GetItem(pIt);

	CAfcLogAttr& oAttr = m_oLogAttr[oName];
	if(oName.Empty())
	{
		const char* s = GetEnvVar("FocpLogLevel");
		if(!s)
			oAttr.nLevel = FOCP_LOG_ERROR;
		else
		{
			oAttr.nLevel = atoi(s);
			if(oAttr.nLevel < FOCP_LOG_ERROR)
				oAttr.nLevel = FOCP_LOG_ERROR;
			else if(oAttr.nLevel > FOCP_LOG_DEBUG)
				oAttr.nLevel = FOCP_LOG_DEBUG;
		}
		s = GetEnvVar("FocpLogMode");
		if(!s)
			oAttr.nMode = FOCP_LOG_SCREEN;
		else
		{
			uint32 nMode = atoi(s);
			oAttr.nMode = 0;
			if(nMode & FOCP_LOG_SCREEN)
				oAttr.nMode |= FOCP_LOG_SCREEN;
			if(nMode & FOCP_LOG_FILE)
				oAttr.nMode |= FOCP_LOG_FILE;
			if(nMode & FOCP_LOG_SERVER)
				oAttr.nMode |= FOCP_LOG_SERVER;
		}
		s = GetEnvVar("FocpLogFilter");
		if(!s)
			oAttr.nFilter = 14;
		else
		{
			uint32 nFilter = atoi(s);
			if(!nFilter)
				nFilter = 14;
			oAttr.nFilter = 0;
			if(nFilter & FOCP_LOG_HOST)
				oAttr.nFilter |= FOCP_LOG_HOST;
			if(nFilter & FOCP_LOG_DATE)
				oAttr.nFilter |= FOCP_LOG_DATE;
			if(nFilter & FOCP_LOG_APPN)
				oAttr.nFilter |= FOCP_LOG_APPN;
			if(nFilter & FOCP_LOG_MODU)
				oAttr.nFilter |= FOCP_LOG_MODU;
			if(nFilter & FOCP_LOG_TASK)
				oAttr.nFilter |= FOCP_LOG_TASK;
			if(nFilter & FOCP_LOG_SRCF)
				oAttr.nFilter |= FOCP_LOG_SRCF;
			if(nFilter & FOCP_LOG_FUNC)
				oAttr.nFilter |= FOCP_LOG_FUNC;
		}
	}
	else
		oAttr = GetLogAttr("");
	return oAttr;
}
コード例 #22
0
ファイル: gscequiv.c プロジェクト: S0043640wipro/RiCRiPInt
/*----------------------------------------------------------------------------*/
static Bool named_colors_common(GS_COLORinfo *colorInfo,
                                NAMECACHE *sepname,
                                EQUIVCOLOR equivs,
                                Bool *foundEquivs,
                                COLORSPACE_ID outputSpaceId,
                                int32 equivColorType)
{
  OBJECT colorSpaceObj = OBJECT_NOTVM_NOTHING;
  OBJECT separationSpace[4];
  OBJECT tintTransform[1];
  STACK_POSITIONS stackPositions;

  /* Create a Separation colorspace for sepname that can be invoked to get
   * equivalent cmyk values from invoking the color chain. We only want to know
   * about equivalents from the current named color database, so deliberately
   * set the tint transform to an illegal procedure that will cause an error
   * if an attempt were made to execute it in the event of sepname not being
   * found in the named color databases.
   * NB. This is a temporary color space that only exists for the duration of
   * this function. The color space MUST be restored in the client.
   */
  theTags(colorSpaceObj) = OARRAY | LITERAL | UNLIMITED;
  theLen(colorSpaceObj) = 4;
  oArray(colorSpaceObj) = separationSpace;

  object_store_name(object_slot_notvm(&separationSpace[0]), NAME_Separation, LITERAL);
  separationSpace[1] = onothing;         /* Struct copy to initialise slot properties */
  theTags(separationSpace[1]) = ONAME | LITERAL;
  oName(separationSpace[1]) = sepname;
  object_store_name(object_slot_notvm(&separationSpace[2]), NAME_DeviceGray, LITERAL);
  separationSpace[3] = onothing;         /* Struct copy to initialise slot properties */
  theTags(separationSpace[3]) = OARRAY | EXECUTABLE | EXECUTE_ONLY;
  theLen(separationSpace[3]) = 1;
  oArray(separationSpace[3]) = tintTransform;

  object_store_null(object_slot_notvm(&tintTransform[0]));  /* The illegal procedure */

  saveStackPositions(&stackPositions);

  /* Install as the current colorspace and invoke it. The colorspace will be
   * restored away by the client.
   * The color value required are the default solid for a Separation space.
   */
  if (!push(&colorSpaceObj, &operandstack) ||
      !gsc_setcolorspace(colorInfo, &operandstack, equivColorType))
    return FALSE;

  /* The color value required are the default solid for a Separation space. */
  if (!gsc_invokeChainTransform(colorInfo, equivColorType,
                                outputSpaceId, FALSE,
                                equivs)) {
    /* We didn't find sepname in these databases, so clear any error and roll the
     * stacks back to what they were.
     */
    error_clear();
    if ( !restoreStackPositions(&stackPositions, FALSE) )
      return error_handler(STACKUNDERFLOW) ;

    return TRUE ;
  }

  *foundEquivs = TRUE;
  return TRUE;
}
コード例 #23
0
ファイル: TrackletAODdNdeta.C プロジェクト: ktf/AliPhysics
  /** 
   * Make script to collect final
   * @f$\mathrm{d}N_{\mathrm{ch}}/\mathrm{d}\eta@f$ from this and
   * other pass.
   * 
   */
  void SaveCollect()
  {
    std::ofstream o("Collect.C");
    if (!o) { 
      Error("TrackletAODdNdeta::SavePost", "Failed to open Collect.C");
      return;
    }
    o << "// Created by " << ClassName() << "\n"
      << "// Will draw dN/deta results from produced files\n"
      << "// \n"
      << "// Arguments:\n"
      << "//   other     Directory of other result (MC or real)\n"
      << "//   output    Optional output directory name\n"
      << "//   proc      Bit mask of processing options\n"
      << "//             - 0x1  Unit normalisation of C\n"
      << "//             - 0x2  Constant normalisation of C\n"
      << "//             - 0x4  eta-dependent normalisation of C\n"
      << "//             - 0x8  (eta,IPz)-dependent normalisation of C\n"
      << "//   viz       Bit mask of visualisation options\n"
      << "//             - 0x0001  General information\n"
      << "//             - 0x0002  Parameters used\n"
      << "//             - 0x0004  Show weights if used\n"
      << "//             - 0x0008  Show dN/deta \n"
      << "//             - 0x0010  Show species\n"
      << "//             - 0x0020  Show delta distribtions\n"
      << "//             - 0x0040  Show details of the calculation\n"
      << "//             - 0x0080  Reserved\n"
      << "//             - 0x0100  Generate PDF and PNGs\n"
      << "//             - 0x0200  Pause after each page\n"
      << "//             - 0x0400  Generate plots in landscape orientation\n"
      << "//             - 0x0800  Use an alternate marker\n"
      << "//   n         Number of centrality bins to process\n" 
      << "// \n"
      << "// Output is generated in the sub-directory\n"
      << "// \n";
    if (fRailway->IsMC()) 
      o << "//    " << fEscapedName << "_<other>\n";
    else
      o << "//    <other>_" << fEscapedName << "\n";
    o << "//\n"
      << "// where <other> is the first argument given\n"
      << "void Collect(const char* other,\n"
      << "             const char* output=0\n"
      << "             UInt_t      proc=0x2,\n"
      << "             UInt_t      viz=0x32f,\n"
      << "             UInt_t      n=10)\n"
      << "{\n"
      << "  TString fwd=\n"
      << "    \"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/dndeta/tracklets3\";\n"
      << "  gSystem->AddIncludePath(Form(\"-I%s\",fwd.Data()));\n"
      << "  gROOT->LoadMacro(Form(\"%s/AliTrackletAODUtils.C+g\",fwd.Data()));"
      << "\n"
      << "  gROOT->LoadMacro(Form(\"%s/AliTrackletdNdeta2.C+g\",fwd.Data()));"
      << "\n";
    TString oName(fEscapedName); oName.Append("/AnalysisResults.root");
    if (fRailway->IsMC()) 
      o << "  TString realFile = Form(\"%s/AnalysisResults.root\",other);\n"
	<< "  TString simFile  = \"" << oName << "\";\n"
	<< "  TString outFile  = Form(\""<<fEscapedName <<"_%s\",other);\n";
    else
      o << "  TString realFile = \"" << oName << "\";\n"
	<< "  TString simFile  = Form(\"%s/AnalysisResults.root\",other);\n"
	<< "  TString outFile  = Form(\"%s_"<<fEscapedName <<"\",other);\n";
    o << "  if (output && output[0] != '\0') outFile = output;\n"
      << "  AliTrackletdNdeta2* p = new AliTrackletdNdeta2;\n"
      << "  if (proc & 0x1) outFile.Append(\"_unit\");\n"
      << "  if (proc & 0x2) outFile.Append(\"_const\");\n"
      << "  if (proc & 0x4) outFile.Append(\"_eta\");\n"
      << "  if (proc & 0x8) outFile.Append(\"_etaipz\");\n"
      << "  \n"
      << "  p->Run(proc,viz,n,realFile,simFile,outFile);\n"
      << "  \n"
      << "  gROOT->LoadMacro(Form(\"%s/ExtractGSE2.C\",fwd.Data()));\n"
      << "  ExtractGSE2(outFile);\n"
      << "}\n"
      << "// EOF\n"
      << std::endl;
    o.close();
  }
コード例 #24
0
ファイル: pdfopi.c プロジェクト: S0043640wipro/RiCRiPInt
Bool pdfOPI_dispatch( PDFCONTEXT *pdfc , OBJECT *dict , Bool *rendered )
{
  PDFXCONTEXT *pdfxc ;
  PDF_IXC_PARAMS *ixc ;
  Bool result = FALSE ;
  OBJECT *pdfXdict = NULL ;
  USERVALUE version;
  OBJECT dictPS = OBJECT_NOTVM_NOTHING ;

  PDF_CHECK_MC( pdfc ) ;
  PDF_GET_XC( pdfxc ) ;
  PDF_GET_IXC( ixc ) ;

  HQASSERT( dict , "dict NULL in pdfform_dispatch." ) ;
  HQASSERT( oType( *dict ) == ODICTIONARY,
            "dict must be an ODICTIONARY." ) ;

  if (! pdfxOPIDetected(pdfc))
    return FALSE;

  /* Read the OPI version dictionary. */
  if ( ! pdf_dictmatch( pdfc , dict , pdfOPImatch ))
    return FALSE ;

  if ( pdfOPImatch[ e_opi_point3 ].result ) {
    /* Check the contents of the 1.3 dictionary. */

    if ( ! pdf_dictmatch( pdfc , pdfOPImatch[ e_opi_point3 ].result , pdfOPI13match ))
      return FALSE ;

    /* If the type isn't "OPI" then return a TypeCheck. */

    if ( pdfOPI13match[ e_opi13_type ].result != NULL &&
         theINameNumber(oName( *pdfOPI13match[ e_opi13_type ].result )) != NAME_OPI )
      return error_handler ( TYPECHECK ) ;

    /* If the version isn't 1.3, then we don't know what to do. */
    if (oType(*pdfOPI13match[ e_opi13_version ].result) != OREAL)
      return error_handler ( RANGECHECK ) ;

    version = oReal( *pdfOPI13match[ e_opi13_version].result );

    if ( ( version <= 1.2 ) || ( version >= 1.4 ) )
      return error_handler ( UNDEFINEDRESULT ) ;

    pdfXdict = pdfOPImatch[ e_opi_point3 ].result ;
  }

  if ( pdfOPImatch[ e_opi_point0 ].result ) {
    /* Check the contents of the 2.0 dictionary. */

    if ( ! pdf_dictmatch( pdfc , pdfOPImatch[ e_opi_point0 ].result , pdfOPI20match ))
      return FALSE ;

    /* If the type isn't "OPI" then return a TypeCheck. */

    if ( pdfOPI20match[ e_opi20_type ].result != NULL &&
         theINameNumber( oName( *pdfOPI20match[ e_opi20_type ].result )) != NAME_OPI )
      return error_handler ( TYPECHECK ) ;

    /* If the version isn't 2.0, then we don't know what to do. */

    if ( oType( *pdfOPI20match[ e_opi20_version ].result ) == OREAL ) {
      if ( fabs( oReal( *pdfOPI20match[ e_opi20_version ].result ) - 2.0 ) > EPSILON )
        return error_handler ( UNDEFINEDRESULT ) ;
    }
    else {
      if ( oInteger( *pdfOPI20match[ e_opi20_version ].result ) != 2 )
        return error_handler ( UNDEFINEDRESULT ) ;
    }

    pdfXdict = pdfOPImatch[ e_opi_point0 ].result ;
  }

  /* It might be that the dictionary contained neither a 1.3 or a 2.0
   * subdictionary. Intentionally I'll pass it on to the ProcSet with
   * no checking rather than failing, on the grounds that this gives
   * us the best chance of upward compatibility.
   */

  if ( ! pdf_resolvexrefs( pdfc , dict ))
    return FALSE ;

  if ( ! pdf_copyobject( NULL, dict, &dictPS ) ||
       ! push( &dictPS , & operandstack ))
    return FALSE ;

  result = runOPI( rendered ) ;

  return result ;
}
コード例 #25
0
ファイル: pdfstrm.c プロジェクト: S0043640wipro/RiCRiPInt
/* pdf_createfilter
 * ----------------
 * Call this to create a new filter (of a certain type), on top of an
 * underlying file.
 *
 * Pass the underlying file object in "file".
 *
 * Pass the name of the desired filter-type in "name".
 *
 * Pass filter-creation arguments in the "args" dictionary.
 * This dictionary gets saved in theIParamDict of the returned flptr.
 *
 * Pass whether the close source/target flag should be set (for
 * non-StreamDecode filters) in the "cst" flag.
 *
 * Returns:
 * The return value is a boolean indicating success/failure. "file" is updated
 * with the new filter id and filelist.
 *
 * The filter created is in the pdf world, attached to the pdf context
 * with a corresponding lifetime -- it is not affected by save/restore.
 *
 * **** Note: Used for PDF Out as well as PDF input ***
 */
Bool pdf_createfilter( PDFCONTEXT *pdfc , OBJECT *file ,
                       OBJECT *name , OBJECT *args , int32 cst )
{
  int32 name_length ;
  int32 find_error ;
  uint8 *filter_name ;
  NAMECACHE *nptr ;
  FILELIST *flptr ;
  FILELIST *nflptr ;
  PDFXCONTEXT *pdfxc ;
  PDF_IXC_PARAMS *ixc ;
  OBJECT params_dict = OBJECT_NOTVM_NOTHING ;
  SFRAME myframe ;
  STACK mystack = { EMPTY_STACK, NULL, FRAMESIZE, STACK_TYPE_OPERAND } ;

  mystack.fptr = &myframe ;

  PDF_CHECK_MC( pdfc ) ;
  PDF_GET_XC( pdfxc ) ;
  PDF_GET_IXC( ixc ) ;

  HQASSERT(file, "no file object") ;
  HQASSERT( name , "name NULL in pdf_createfilter" ) ;
  HQASSERT( args , "args NULL in pdf_createfilter" ) ;

  HQASSERT( oType(*name) == ONAME , "bad OBJECT type in pdf_createfilter" ) ;
  nptr = oName(*name) ;

  /* handle possible abbreviations */
  switch ( theINameNumber(nptr) ) {
  case NAME_A85:
    nptr = system_names + NAME_ASCII85Decode;
    break;
  case NAME_AHx:
    nptr = system_names + NAME_ASCIIHexDecode;
    break;
  case NAME_CCF:
    nptr = system_names + NAME_CCITTFaxDecode;
    break;
  case NAME_DCT:
    nptr = system_names + NAME_DCTDecode;
    break;
  case NAME_Fl:
    nptr = system_names + NAME_FlateDecode;
    break;
  case NAME_LZW:
    nptr = system_names + NAME_LZWDecode;
    break;
  case NAME_RL:
    nptr = system_names + NAME_RunLengthDecode;
    break;
  }

  name_length = theINLen( nptr ) ;
  filter_name = theICList( nptr ) ;

  /* find the filter name in the external or standard filter table */
  nflptr = filter_external_find( filter_name, name_length,
                                  & find_error, TRUE ) ;
  if ( nflptr == NULL ) {
    if ( find_error != NOT_AN_ERROR)
      return error_handler( find_error );

    if ( NULL == ( nflptr = filter_standard_find( filter_name , name_length )))
      return error_handler( UNDEFINED ) ;
  }

  /* Sanity check. */
  HQASSERT(isIFilter(nflptr), "Not a filter") ;

  if ( isIInputFile( nflptr )) {
    if ( theINameNumber(nptr) == NAME_JPXDecode ) {
      /* JPXDecode can automatically layer an RSD underneath itself, but that
         RSD would be allocated from PostScript memory. To make sure that the
         RSD is allocated from PDF memory, we allocate it here. We force the
         cst flag TRUE on the JPXDecode, because the caller may not be
         expecting the RSD in the chain (this will make JPXDecode close the
         RSD, the RSD will close the underlying file if necessary). */
      OBJECT rsdname = OBJECT_NOTVM_NAME(NAME_ReusableStreamDecode, LITERAL) ;
      OBJECT rsdargs = OBJECT_NOTVM_NULL ;
      if ( !pdf_createfilter(pdfc, file, &rsdname, &rsdargs, cst) )
        return FALSE ;

      cst = TRUE ;
    } else if ( theINameNumber( nptr ) == NAME_FlateDecode ) {
      /* If we're creating a FlateDecode filter, add the
       * ErrorOnFlateChecksumFailure flag to the params.
       */
      OBJECT paramName = OBJECT_NOTVM_NAME(NAME_ErrorOnChecksumFailure, LITERAL) ;

      if ( oType(*args) != ODICTIONARY ) {
        /* The args object wasn't a dictionary - must be an ONULL
         * otherwise it doesn't make sense. Make a new dict - a length
         * of 4 should be enough to make sure it never needs to grow.
         */

        HQASSERT(oType(*args) == ONULL , "Expecting null args." ) ;

        if ( ! pdf_create_dictionary( pdfc , 4 , & params_dict ))
          return FALSE ;

        args = & params_dict ;
      }

      if ( ! pdf_fast_insert_hash( pdfc , args , & paramName ,
                                   pdfxc->ErrorOnFlateChecksumFailure ?
                                   & tnewobj : & fnewobj  ))
        return FALSE ;
    }
  }

  /* If we have an underlying file, put it on the stack for the init routine,
     and set the new filter id and file pointer for the return object. */
  if ( !push(file, &mystack) )
    return FALSE ;

  /* Provide an empty list to prevent the function scanning for a closed file -
   * for jobs with a very large number of pages the linear search can become
   * significant.
   */
  flptr = NULL;
  if ( !filter_create_with_alloc(nflptr, &flptr,
                                 args, &mystack, pdfxc->id,
                                 pdf_createfilter_alloc,
                                 pdfxc->mm_structure_pool) )
    return FALSE ;

  /* Add new filter to head of chain */
  flptr->next = pdfxc->streams;
  pdfxc->streams = flptr;

  /* promote streams to save level of pdf context */
  flptr->sid = CAST_UNSIGNED_TO_UINT8(pdfxc->savelevel) ;

  /* Only PDF Input filters are (initially at least) marked as rewindable */
  if ( isIInputFile( nflptr ))
    SetIRewindableFlag( flptr ) ;

  /* If cst is true set the "close source/target" flag. */
  if ( cst ) {
    HQASSERT( theINameNumber(nptr) != NAME_StreamDecode ,
              "Setting CST on a stream would mean the real file gets closed." ) ;
    SetICSTFlag( flptr ) ;
  }

  /* Prepare the return file object. The input file object's executability is
     retained. */
  file_store_object(file, flptr, CAST_UNSIGNED_TO_UINT8(oExec(*file))) ;

  /* We should be setting this on file close, but we don't have easy access to
     that, so use this file creation as a proxy. */
  pdfxc->lowmemRedoStreams = TRUE;

  return TRUE ;
}
コード例 #26
0
ファイル: cmap.c プロジェクト: S0043640wipro/RiCRiPInt
/* ----------------------------------------------------------------------------
   function:            cmap_cidlookup_local()    author:          Eric Penfold
   creation date:       10-Jul-1997            last modification:   07-Aug-1997

   Internal lookup function to obtain character selector for input character
   code.

   On input, the charsel's string field 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

   Returns FALSE on error.
   ---------------------------------------------------------------------------- */
static Bool cmap_cidlookup_local(OBJECT *mapping, OBJECT *codestr,
                                 int32 *fontid, OBJECT *charsel)
{
  int32   num_block;
  int32   num_entry;
  int32   idx_block;
  int32   idx_entry;
  OBJECT *rd_block;
  OBJECT *rd_entry;
  uint8  *code ;

  HQASSERT(charsel && oType(*charsel) == OSTRING,
           "charsel parameter must be a string object");
  HQASSERT(codestr && oType(*codestr) == OSTRING,
           "codestr parameter must be a string object");

  code = oString(*codestr) ;

  HQASSERT(oType(*mapping) == OARRAY, "CMap mapping block is not an array") ;
  num_block = theLen(*mapping);
  if (num_block < 1)
    return error_handler(RANGECHECK);

  /* For each mapping definition block */
  for (idx_block = 0; idx_block < num_block; idx_block+=3) {
    int32 map_type;
    rd_block = oArray(*mapping) + idx_block + 2;

    /* Extract fontid and mapping type */
    HQASSERT(oType(rd_block[-2]) == OINTEGER,
             "CMap mapping fontid is not an integer") ;
    *fontid  = oInteger(rd_block[-2]);
    HQASSERT(oType(rd_block[-1]) == OINTEGER,
             "CMap mapping type is not an integer") ;
    map_type = oInteger(rd_block[-1]);
    HQASSERT(map_type == MAP_CID || map_type == MAP_BF,
             "Invalid CMap mapping type") ;

    /* For each entry in that block */
    HQASSERT(oType(*rd_block) == OARRAY,
             "CMap mapping sub-block is not an array") ;
    num_entry = theLen(*rd_block);
    for (idx_entry = 0; idx_entry < num_entry; idx_entry++) {
      OBJECT *rd_mbyte;
      int32   idx_byte;
      int32   len_entry;
      int32   offset_vector[CMAP_MAX_CODESPACE_LEN];
      uint8  *rstart;
      uint8  *rend;
      uint8  *inbyte;
      rd_entry  = oArray(*rd_block) + idx_entry;
      HQASSERT(oType(*rd_entry) == OARRAY,
               "CMap mapping block entry is not an array") ;
      rd_mbyte  = oArray(*rd_entry);
      HQASSERT(oType(rd_mbyte[0]) == OSTRING && oType(rd_mbyte[1]) == OSTRING,
               "CMap mapping range entry is not a string") ;
      HQASSERT( theLen(*rd_mbyte) == theLen(rd_mbyte[1]),
                "mapping range start/end are of different length" );
      len_entry = theLen(*rd_mbyte);

      /* If the range is of a different dimension to the code, then skip */
      if (len_entry != theLen(*codestr))
        continue;

      /* Extract range_start and range_end */
      rstart = oString(rd_mbyte[0]);
      rend   = oString(rd_mbyte[1]);
      inbyte = code;

      /* Process each byte of the range */
      for (idx_byte = 0; idx_byte < len_entry; idx_byte++) {
        if (*inbyte < *rstart)
          break; /* Below range start */
        if (*inbyte > *rend)
          break; /* Above range end */

        /* Build position vector for this mapping */
        *(offset_vector + idx_byte) = (*inbyte - *rstart);

        /* Next range start/end bytes */
        rstart++;
        rend++;
        inbyte++;
      }

      if (idx_byte == len_entry) { /* Stop after first match */
        int32 i, j;
        OBJECT *base = rd_mbyte + 2;

        /* Process third parameter, depending on mapping type */
        if ((map_type == MAP_BF) && oType(*base) == OSTRING) {
          /* character code */
          uint8 *baselist = oString(*base);
          int32 baselen = theLen(*base);

          /* Check that mem ptr passed in to store result */
          HQASSERT(oString(*charsel),
                   "char selector string clist field must be ptr to valid memory to store result");
          /* Check that string memory provided is large enough */
          if (baselen > theLen(*charsel)) {
            HQFAIL("Insufficient memory passed to store multi-byte string result");
            return error_handler(RANGECHECK);
          }
          theLen(*charsel) = (uint16)baselen;

          i = j = 0 ;

          if ( len_entry < baselen ) {
            do {
              oString(*charsel)[i] = baselist[i] ;
              ++i ;
            } while ( len_entry + i < baselen ) ;
          } else if ( len_entry > baselen ) {
            do { /* Check that we're not stuffing too large a value */
              if ( offset_vector[j] != 0 )
                return error_handler(RANGECHECK) ;
              ++j ;
            } while ( baselen + j < len_entry ) ;
          }

          /* Add our vector offset components to the base character code */
          while ( i < baselen ) {
            oString(*charsel)[i] = (uint8)(baselist[i] + offset_vector[j]);
            ++i, ++j ;
          }
        }
        else if ( map_type == MAP_BF && oType(*base) == ONAME ) {
          theTags(*charsel) = ONAME | LITERAL ;
          oName(*charsel) = oName(*base) ;
        }
        else {
          int32 res;
          /* This is the complex bit since mapping can be multibyte i.e
           * multidimensional.
           * Assuming: n bytes, In = input byte n
           *           Sn = Range start byte n, En = Range end byte n
           * Calculation is:
           *   1.  rvec = [I1-S1, I2-S2, ..., In-Sn]
           *   2.  rvec[i] *= Prod(j=i+1...n) (Ej-Sj+1)
           *   3.  result = offset + Sum(i=1...n) (rvec[i])
           *
           * Note that we use the offset_vector array from above which
           * contains a position vector from mapping start to our point
           * (i.e. =rvec of Calculation_Stage1)
           */
          /* 2 */
          rstart = oString(rd_mbyte[0]);
          rend   = oString(rd_mbyte[1]);
          for (i = 0; i < len_entry; i++) {
            for (j = i+1; j < len_entry; j++)
              *(offset_vector + i) *= *(rend + j) - *(rstart + j) + 1;
          }
          /* 3 */
          for (i = 0, res = 0; i < len_entry; i++)
            res += *(offset_vector + i);

          if (map_type == MAP_CID) { /* Offset by CID base */
            if ( oType(*base) == OINTEGER ) {
              object_store_integer(charsel, oInteger(*base) + res);
            } else
              return error_handler(TYPECHECK);
          } else if (map_type == MAP_BF) {
            if ( oType(*base) == OARRAY ) { /* => array of glyph names */
              theTags(*charsel) = ONAME | LITERAL ;
              oName(*charsel) = oName(oArray(*base)[res]);
            } else
              return error_handler(TYPECHECK);
          } else
            return error_handler(RANGECHECK);
        }
        return TRUE ;
      }
    }
  }

  /* No mapping made, but no error */
  object_store_null(charsel) ;
  return TRUE;
}
コード例 #27
0
ファイル: cidfont.c プロジェクト: S0043640wipro/RiCRiPInt
static Bool set_cid_subfont(FONTinfo *fontInfo, OBJECT *dict)
{
  CID0_CACHE *cid_font ;
  OBJECT *theo;
  OMATRIX matrix ;

  enum { mch_subdict_Private, mch_subdict_FontMatrix, mch_subdict_dummy };
  static NAMETYPEMATCH mch_subdict[mch_subdict_dummy + 1] = {
    /* Use the enum above to index these */
    { NAME_Private,              1, { ODICTIONARY }},
    { NAME_FontMatrix,           2, { OARRAY, OPACKEDARRAY }},
    DUMMY_END_MATCH
  };

  enum { mch_private_Subrs, mch_private_SubrMapOffset, mch_private_SubrCount,
         mch_private_SDBytes, mch_private_RunInt, mch_private_dummy };
  static NAMETYPEMATCH mch_private[mch_private_dummy + 1] = {
    /* Use the enum above to index these */
    { NAME_Subrs | OOPTIONAL,         2, { OARRAY, OPACKEDARRAY }},
    { NAME_SubrMapOffset | OOPTIONAL, 1, { OINTEGER }},
    { NAME_SubrCount | OOPTIONAL,     1, { OINTEGER }},
    { NAME_SDBytes | OOPTIONAL,       1, { OINTEGER }},
    { NAME_RunInt | OOPTIONAL,        1, { ONAME }},
    DUMMY_END_MATCH
  };

  HQASSERT(fontInfo, "No font info") ;
  HQASSERT(dict, "No CID sub-dict") ;

  if ( (cid_font = cid0_set_font(fontInfo)) == NULL )
    return FALSE ;

  VERIFY_OBJECT(cid_font, CID0_CACHE_NAME) ;

  /* Extract the necessary font parameters */
  if ( !dictmatch(dict, mch_subdict) ||
       !dictmatch(mch_subdict[mch_subdict_Private].result, mch_private) )
    return error_handler(INVALIDFONT);

  if ( mch_private[mch_private_Subrs].result ) {
    cid_font->subrs = mch_private[mch_private_Subrs].result ;
    cid_font->subrcount = theLen(*cid_font->subrs) ;
    cid_font->subrmapoffset = cid_font->sdbytes = 0 ;
  } else {
    /* No Subrs, look for SubrMap details. We don't enforce requiring the
       offsets if there is no SubrCount or it is zero. */
    cid_font->subrs = NULL ;

    if ( (theo = mch_private[mch_private_SubrCount].result) != NULL ) {
      if ( oInteger(*theo) < 0 )
        return error_handler(INVALIDFONT) ;

      cid_font->subrcount = (uint32)oInteger(*theo) ;
    }

    if ( (theo = mch_private[mch_private_SDBytes].result) != NULL ) {
      if ( oInteger(*theo) < 0 || oInteger(*theo) > 4 )
        return error_handler(INVALIDFONT) ;

      cid_font->sdbytes = (uint32)oInteger(*theo) ;
    }

    if ( (theo = mch_private[mch_private_SubrMapOffset].result) != NULL ) {
      if ( oInteger(*theo) < 0 )
        return error_handler(INVALIDFONT) ;

      cid_font->subrmapoffset = (uint32)oInteger(*theo) ;
    }
 }

  /* No Encoding array. */
  theTags(theEncoding(*fontInfo)) = ONULL;

  /* No charstring dictionary. */
  theCharStrings(*fontInfo) = NULL;

  /* Metrics dictionary will be inherited from the top level CIDFont, so don't
     do anything with theMetrics and theMetrics2. */

  /* Test if it's a Morisawa or ATL encypted CID font */
  isEncrypted(*fontInfo) = PROTECTED_NONE ;
  theo = mch_private[mch_private_RunInt].result;
  if ( theo ) {
    if ( oName(*theo) == &system_names[ NAME_SpecialRun ] )
      isEncrypted(*fontInfo) = PROTECTED_MRSWA ;
    else if ( oName(*theo) == &system_names[ NAME_eCCRun ] )
      isEncrypted(*fontInfo) = PROTECTED_ATL ;
  }

  theSubsCount(*fontInfo) = 0;

  if ( !is_matrix(mch_subdict[mch_subdict_FontMatrix].result, &matrix) )
    return FALSE;

  /* Multiply this by the current fontmatrix to give a new one */
  matrix_mult(&matrix, &theFontMatrix(*fontInfo), &theFontMatrix(*fontInfo));
  matrix_mult(&matrix, &theFontCompositeMatrix(*fontInfo),
              &theFontCompositeMatrix(*fontInfo));

  /* gotFontMatrix is still set, from the set_font call preceding this. Leave
     theLookupFont set if it was already, since the FID in the parent
     dictionary is still valid. The matrix has changed though, so clear the
     lookup matrix. */
  theLookupMatrix(*fontInfo) = NULL ;

  /* Finally, install the FDArray subdict as the source for Private
     information */
  Copy(&fontInfo->subfont, dict) ;

  return TRUE;
}
コード例 #28
0
ファイル: filters.c プロジェクト: S0043640wipro/RiCRiPInt
Bool externalfilter_(ps_context_t *pscontext)
{
  OBJECT *o1, *o2 ;
  int32 dev_number, name_length ;
  uint8 *filter_name ;

  UNUSED_PARAM(ps_context_t *, pscontext) ;

  HQTRACE( debug_filters , ( "Welcome to externalfilter" )) ;

  /* externalfilter is always called with two args on the stack, even if
     the second one isn't used */
  if ( theStackSize( operandstack ) < 1 )
    return error_handler( STACKUNDERFLOW ) ;

  o1 = theTop( operandstack ) ;   /* integer code or dictionary */

  switch ( oType(*o1) ) {
  case OINTEGER:
    dev_number = oInteger(*o1);
    break ;
  case ODICTIONARY:
    o2 = stackindex( 1, &operandstack ) ; /* filter name */
    return filter_external_define( o1 , o2 );  /* device to be added */
  default:
    return error_handler(TYPECHECK) ;
  }

  if ( dev_number == -3 ) {            /* resourceforall */
    pop( &operandstack ) ;
    return filter_external_forall(&operandstack);
  }

  o2 = stackindex(1, &operandstack ) ;         /* filter name */

  switch ( oType(*o2) ) {
  case ONAME:
    filter_name = theICList(oName(*o2)) ;
    name_length = theINLen(oName(*o2)) ;
    break ;
  case OSTRING:
    /* undocumented - but they allow strings as an argument */
    filter_name = oString(*o2) ;
    name_length = theLen(*o2) ;
    break ;
  default:
    return error_handler( TYPECHECK ) ;

  }

  switch ( dev_number ) {
  case -2: /* findresource */
    if ( filter_external_exists(filter_name, name_length) ) {
      Copy(o1, &tnewobj) ;
    } else {
      Copy(o1, &fnewobj) ;
    }
    return TRUE ;
  case -1: /* undefineresource */
    npop(2, &operandstack) ;

    return filter_external_undefine(filter_name, name_length);
  }

  return error_handler(RANGECHECK) ;
}