Пример #1
0
static void
xps_debug_item_imp(xps_item_t *item, int level, int loop)
{
    int i;

    while (item)
    {
        indent(level);

        if (strlen(item->name) == 0)
            dlprintf1("%s\n", item->atts[1]);
        else
        {
            dlprintf1("<%s", item->name);

            for (i = 0; item->atts[i]; i += 2)
                dlprintf2(" %s=\"%s\"", item->atts[i], item->atts[i+1]);

            if (item->down)
            {
                dlprintf(">\n");
                xps_debug_item_imp(item->down, level + 1, 1);
                indent(level);
                dlprintf1("</%s>\n", item->name);
            }
            else
                dlprintf(" />\n");
        }

        item = item->next;

        if (!loop)
            return;
    }
}
Пример #2
0
static int gp_cache_loaditem(FILE *file, gp_cache_entry *item, gp_cache_alloc alloc, void *userdata)
{
    unsigned char version;
    unsigned char *filekey;
    int len, keylen;

    fread(&version, 1, 1, file);
    if (version != GP_CACHE_VERSION) {
#ifdef DEBUG_CACHE
        dlprintf2("pcache file version mismatch (%d vs expected %d)\n", version, GP_CACHE_VERSION);
#endif
        return -1;
    }
    fread(&keylen, 1, sizeof(keylen), file);
    if (keylen != item->keylen) {
#ifdef DEBUG_CACHE
        dlprintf2("pcache file has correct hash but wrong key length (%d vs %d)\n",
                  keylen, item->keylen);
#endif
        return -1;
    }
    filekey = malloc(keylen);
    if (filekey == NULL) {
        dprintf("pcache: couldn't allocate file key!\n");
        return -1;
    }
    fread(filekey, 1, keylen, file);
    if (memcmp(filekey, item->key, keylen)) {
#ifdef DEBUG_CACHE
        dlprintf("pcache file has correct hash but doesn't match the full key\n");
#endif
        free(filekey);
        item->buffer = NULL;
        item->len = 0;
        return -1;
    }
    free(filekey);

    fread(&len, 1, sizeof(len), file);
#ifdef DEBUG_CACHE
    dlprintf2("key matches file with version %d, data length %d\n", version, len);
#endif
    item->buffer = alloc(userdata, len);
    if (item->buffer == NULL) {
        dlprintf("pcache: couldn't allocate buffer for file data!\n");
        item->len = 0;
        return -1;
    }

    item->len = fread(item->buffer, 1, len, file);
    item->dirty = 1;
    item->last_used = time(NULL);

    return 0;
}
Пример #3
0
/* we call this from ps code to instantiate a jbig2_global_context
   object which the JBIG2Decode filter uses if available. The
   pointer to the global context is stored in an astruct object
   and returned that way since it lives outside the interpreters
   memory management */
static int
z_jbig2makeglobalctx(i_ctx_t * i_ctx_p)
{
        void *global = NULL;
        s_jbig2_global_data_t *st;
        os_ptr op = osp;
        byte *data;
        int size;
        int code = 0;

        check_type(*op, t_astruct);
        size = gs_object_size(imemory, op->value.pstruct);
        data = r_ptr(op, byte);

        code = s_jbig2decode_make_global_data(data, size,
                        &global);
        if (size > 0 && global == NULL) {
            dlprintf("failed to create parsed JBIG2GLOBALS object.");
            return_error(e_unknownerror);
        }

        st = ialloc_struct(s_jbig2_global_data_t,
                &st_jbig2_global_data_t,
                "jbig2decode parsed global context");
        if (st == NULL) return_error(e_VMerror);

        st->data = global;
        make_astruct(op, a_readonly | icurrent_space, (byte*)st);

        return code;
}
Пример #4
0
static int
perm_put_params(gx_device *pdev, gs_param_list *plist)
{
    gx_device_perm_t * const dev = (gx_device_perm_t *)pdev;
    gx_device_color_info save_info;
    int code;
    int new_permute = dev->permute;
    int new_mode = dev->mode;

    code = param_read_int(plist, "Permute", &new_permute);
    if (code < 0)
        return code;
    code = param_read_int(plist, "Mode", &new_mode);
    if (code < 0)
        return code;
    if (new_mode < 0 || new_mode >= sizeof(perm_cmapping_procs) / sizeof(perm_cmapping_procs[0])) {
        dlprintf("rangecheck!\n");
        return_error(gs_error_rangecheck);
    }
    dev->permute = new_permute;
    dev->mode = new_mode;
    save_info = pdev->color_info;
    code = perm_set_color_model(dev, dev->mode, dev->permute);
    if (code >= 0)
        code = gdev_prn_put_params(pdev, plist);
    if (code < 0)
        pdev->color_info = save_info;
    return code;
}
Пример #5
0
int fileLoadSHD(const char *filename,Shader_t *shader,void *unused)
{
  lxFSFile_t * fSHD;
  char buf[1024];

  fSHD = FS_open(filename);
  l_SHDData.file = fSHD;
  l_SHDData.shader = shader;
  lprintf("Shader: \t%s\n",filename);

  if(fSHD == NULL)
  {
    lprintf("ERROR shdload: ");
    lnofile(filename);
    return LUX_FALSE;
  }

  lxFS_gets(buf, 255, fSHD);


  if (!sscanf(buf,SHD_HEADER,&l_SHDData.version) || l_SHDData.version < SHD_VER_MINIMUM)
  {
    // wrong header
    lprintf("ERROR shdload: invalid file format or version\n");
    FS_close(fSHD);
    return LUX_FALSE;
  }
  l_SHDData.cgmode = -1;
  shader->numStages = 0;

  l_SHDData.stagesColorInBuffer = 0;
  l_SHDData.stagesTexInBuffer = 0;
  l_SHDData.stagesTexGpuInBuffer = 0;
  l_SHDData.lastVColorStage = 0;
  l_SHDData.stagesGpuInBuffer = 0;
  l_SHDData.bumpStage     = -1;

  l_SHDData.tech        = VID_T_UNSET;

  clearArray(l_SHDData.stagesTex,BUFFERSTAGES);
  l_SHDData.stagesColor = NULL;

  FileParse_setAnnotationList(&l_SHDData.shader->annotationListHead);
  FileParse_start(fSHD,l_defSHD);


  if (!l_SHDData.stagesTexGpuInBuffer && !l_SHDData.stagesColorInBuffer){
    lprintf("WARNING shdload: no stages defined\n");
    FS_close (fSHD);
    return LUX_FALSE;
  }

  shader->tech = l_SHDData.tech;

  ShaderBuildFromBuffer(shader);
  dlprintf("\tColors: %d Textures: %d\n",l_SHDData.stagesColorInBuffer,l_SHDData.stagesTexGpuInBuffer);
  FS_close (fSHD);

  return LUX_TRUE;
}
Пример #6
0
/* Note that we just set the clipping path (internal). */
static void
note_set_clip_path(const gs_state * pgs)
{
    if (gs_debug_c('P')) {
	dlprintf("[P]Clipping path:\n");
	gx_cpath_print(pgs->clip_path);
    }
}
Пример #7
0
int
gs_imager_setmatrix(gs_imager_state * pis, const gs_matrix * pmat)
{
    update_matrix_fixed(pis->ctm, pmat->tx, pmat->ty);
    set_ctm_only(pis, *pmat);
#ifdef DEBUG
    if (gs_debug_c('x'))
        dlprintf("[x]imager_setmatrix:\n"), trace_ctm(pis);
#endif
    return 0;
}
Пример #8
0
int
gs_setmatrix(gs_state * pgs, const gs_matrix * pmat)
{
    update_ctm(pgs, pmat->tx, pmat->ty);
    set_ctm_only(pgs, *pmat);
#ifdef DEBUG
    if (gs_debug_c('x'))
        dlprintf("[x]setmatrix:\n"), trace_ctm(pgs);
#endif
    return 0;
}
Пример #9
0
int
gs_initmatrix(gs_state * pgs)
{
    gs_matrix imat;

    gs_defaultmatrix(pgs, &imat);
    update_ctm(pgs, imat.tx, imat.ty);
    set_ctm_only(pgs, imat);
#ifdef DEBUG
    if (gs_debug_c('x'))
        dlprintf("[x]initmatrix:\n"), trace_ctm(pgs);
#endif
    return 0;
}
Пример #10
0
int
gs_concat(gs_state * pgs, const gs_matrix * pmat)
{
    gs_matrix cmat;
    int code = gs_matrix_multiply(pmat, &ctm_only(pgs), &cmat);

    if (code < 0)
        return code;
    update_ctm(pgs, cmat.tx, cmat.ty);
    set_ctm_only(pgs, cmat);
#ifdef DEBUG
    if (gs_debug_c('x'))
        dlprintf("[x]concat:\n"), trace_matrix(pmat), trace_ctm(pgs);
#endif
    return code;
}
Пример #11
0
/* Used by gschar.c to prepare for a BuildChar or BuildGlyph procedure. */
int
gx_translate_to_fixed(register gs_state * pgs, fixed px, fixed py)
{
    double fpx = fixed2float(px);
    double fdx = fpx - pgs->ctm.tx;
    double fpy = fixed2float(py);
    double fdy = fpy - pgs->ctm.ty;
    fixed dx, dy;
    int code;

    if (pgs->ctm.txy_fixed_valid) {
        dx = float2fixed(fdx);
        dy = float2fixed(fdy);
        code = gx_path_translate(pgs->path, dx, dy);
        if (code < 0)
            return code;
        if (pgs->char_tm_valid && pgs->char_tm.txy_fixed_valid)
            pgs->char_tm.tx_fixed += dx,
                pgs->char_tm.ty_fixed += dy;
    } else {
        if (!gx_path_is_null(pgs->path))
            return_error(gs_error_limitcheck);
    }
    pgs->ctm.tx = fpx;
    pgs->ctm.tx_fixed = px;
    pgs->ctm.ty = fpy;
    pgs->ctm.ty_fixed = py;
    pgs->ctm.txy_fixed_valid = true;
    pgs->ctm_inverse_valid = false;
    if (pgs->char_tm_valid) {	/* Update char_tm now, leaving it valid. */
        pgs->char_tm.tx += fdx;
        pgs->char_tm.ty += fdy;
    }
#ifdef DEBUG
    if (gs_debug_c('x')) {
        dlprintf2("[x]translate_to_fixed %g, %g:\n",
                  fixed2float(px), fixed2float(py));
        trace_ctm(pgs);
        dlprintf("[x]   char_tm:\n");
        trace_matrix_fixed(&pgs->char_tm);
    }
#endif
    gx_setcurrentpoint(pgs, fixed2float(pgs->ctm.tx_fixed), fixed2float(pgs->ctm.ty_fixed));
    pgs->current_point_valid = true;
    return 0;
}
Пример #12
0
/* Note that this may be based on a font other than the current font. */
int
gs_setcharmatrix(gs_state * pgs, const gs_matrix * pmat)
{
    gs_matrix cmat;
    int code = gs_matrix_multiply(pmat, &ctm_only(pgs), &cmat);

    if (code < 0)
        return code;
    update_matrix_fixed(pgs->char_tm, cmat.tx, cmat.ty);
    char_tm_only(pgs) = cmat;
#ifdef DEBUG
    if (gs_debug_c('x'))
        dlprintf("[x]setting char_tm:"), trace_matrix_fixed(&pgs->char_tm);
#endif
    pgs->char_tm_valid = true;
    return 0;
}
Пример #13
0
void *gp_enumerate_fonts_init(gs_memory_t *mem)
{
#ifdef HAVE_FONTCONFIG
    unix_fontenum_t *state;
    FcPattern *pat;
    FcObjectSet *os;

    state = (unix_fontenum_t *)malloc(sizeof(unix_fontenum_t));
    if (state == NULL)
        return NULL;    /* Failed to allocate state */

    state->index     = 0;
    state->fc        = NULL;
    state->font_list = NULL;

    /* Load the fontconfig library */
    state->fc = FcInitLoadConfigAndFonts();
    if (state->fc == NULL) {
        free(state);
        state = NULL;
        dlprintf("destroyed state - fontconfig init failed");
        return NULL;  /* Failed to open fontconfig library */
    }

    /* load the font set that we'll iterate over */
    pat = FcPatternBuild(NULL,
            FC_OUTLINE, FcTypeBool, 1,
            FC_SCALABLE, FcTypeBool, 1,
            NULL);
    os = FcObjectSetBuild(FC_FILE, FC_OUTLINE,
            FC_FAMILY, FC_WEIGHT, FC_SLANT,
            NULL);
    state->font_list = FcFontList(0, pat, os);
    FcPatternDestroy(pat);
    FcObjectSetDestroy(os);
    if (state->font_list == NULL) {
        free(state);
        state = NULL;
        return NULL;  /* Failed to generate font list */
    }
    return (void *)state;
#else
    return NULL;
#endif
}
Пример #14
0
/* <source> <dict> /JPXDecode <file> */
private int
z_jpx_decode(i_ctx_t * i_ctx_p)
{
    os_ptr op = osp;
    ref *sop = NULL;
    stream_jpxd_state state;

    state.jpx_memory = imemory->non_gc_memory;
    if (r_has_type(op, t_dictionary)) {
        check_dict_read(*op);
        if ( dict_find_string(op, "Colorspace", &sop) > 0) {
            dlprintf("found Colorspace parameter (NYI)\n");
        }
    }

    /* we pass npop=0, since we've no arguments left to consume */
    /* we pass 0 instead of the usual rspace(sop) which will allocate storage
       for filter state from the same memory pool as the stream it's coding.
       this causes no trouble because we maintain no pointers */
    return filter_read(i_ctx_p, 0, &s_jpxd_template,
                       (stream_state *) & state, 0);
}
Пример #15
0
static void indent(int n)
{
    while (n--)
        dlprintf("  ");
}
Пример #16
0
int gp_enumerate_fonts_next(void *enum_state, char **fontname, char **path)
{
#ifdef HAVE_FONTCONFIG
    unix_fontenum_t* state = (unix_fontenum_t *)enum_state;
    FcChar8 *file_fc = NULL;
    FcChar8 *family_fc = NULL;
    int outline_fc, slant_fc, weight_fc;
    FcPattern *font;
    FcResult result;

    if (state == NULL) {
        return 0;   /* gp_enumerate_fonts_init failed for some reason */
    }

    if (state->index == state->font_list->nfont) {
        return 0; /* we've run out of fonts */
    }

    /* Bits of the following were borrowed from Red Hat's
     * fontconfig patch for Ghostscript 7 */
    font = state->font_list->fonts[state->index];

    result = FcPatternGetString (font, FC_FAMILY, 0, &family_fc);
    if (result != FcResultMatch || family_fc == NULL) {
        dlprintf ("DEBUG: FC_FAMILY mismatch\n");
        return 0;
    }

    result = FcPatternGetString (font, FC_FILE, 0, &file_fc);
    if (result != FcResultMatch || file_fc == NULL) {
        dlprintf ("DEBUG: FC_FILE mismatch\n");
        return 0;
    }

    result = FcPatternGetBool (font, FC_OUTLINE, 0, &outline_fc);
    if (result != FcResultMatch) {
        dlprintf1 ("DEBUG: FC_OUTLINE failed to match on %s\n", (char*)family_fc);
        return 0;
    }

    result = FcPatternGetInteger (font, FC_SLANT, 0, &slant_fc);
    if (result != FcResultMatch) {
        dlprintf ("DEBUG: FC_SLANT didn't match\n");
        return 0;
    }

    result = FcPatternGetInteger (font, FC_WEIGHT, 0, &weight_fc);
    if (result != FcResultMatch) {
        dlprintf ("DEBUG: FC_WEIGHT didn't match\n");
        return 0;
    }

    /* Gross hack to work around Fontconfig's inability to tell
     * us the font's PostScript name - generate it ourselves.
     * We must free the memory allocated here next time around. */
    makePSFontName((char *)family_fc, weight_fc, slant_fc,
        (char *)&state->name, sizeof(state->name));
    *fontname = (char *)&state->name;

    /* return the font path straight out of fontconfig */
    *path = (char*)file_fc;

    state->index ++;
    return 1;
#else
    return 0;
#endif
}