Back to index

tetex-bin  3.0
Functions
special.h File Reference
#include "xdvi-config.h"
#include "xdvi.h"
#include "events.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Boolean scan_special (char *str, int str_len, void *data)
void applicationDoSpecial (char *str, size_t len)
void geom_do_special (struct scan_info *, char *, double)
void color_special (const char *colorspec)
void init_prescan (void)
void reset_papersize_special (void)
Boolean have_papersize_special (void)

Function Documentation

void applicationDoSpecial ( char *  str,
size_t  len 
)

Definition at line 2357 of file special.c.

{
    char *p;

    if (globals.debug & DBG_DVI)
       printf("          `%s'\n", cp);

    while (isspace((int)*cp))
       ++cp;

    /* Ignore initial "xdvi:" */
    if (memcmp(cp, "xdvi:", 5) == 0) {
       cp += 5;
       while (isspace((int)*cp))
           ++cp;
    }
       
    /* PostScript specials */
#ifdef MAGICK
    if (resource.useMAGICK) {
       if (Magick_parse_special(cp))
           return;
    }
#endif

    if (*cp == '"') {
       quote_special(cp);
       return;
    }
    if (memicmp(cp, "ps:", 3) == 0) {
       cp += 3;
       psfig_special(cp);
       /* check for hdvips hyperlinks */
       if (memicmp(cp, "sdict begin ", strlen("sdict begin ")) == 0) {
           static Boolean warned_hypertex_too_old = False;
           char *match = NULL;
           if (warned_hypertex_too_old) /* don't continue evaluating links in this case */
              return;
           cp += strlen("sdict begin ");
           if (memcmp(cp, "H.S", 3) == 0
              || memcmp(cp, "H.R", 3) == 0
              || memcmp(cp, "H.B", 3) == 0
              /* following 2 conditions could be more restrictive: between `begin' and H.A/H.L,
                 there should be a single number (baselineskip in pt) */
              || (match = strstr(cp, "H.A")) != NULL
              || (match = strstr(cp, "H.L")) != NULL
              || (match = strstr(cp, "/Action")) != NULL
              || (match = strstr(cp, "/Link")) != NULL
              || (match = strstr(cp, "/View")) != NULL) {
              if (match != NULL)
                  htex_do_special(match, len - 3 - (match - cp) - strlen("sdict begin "));
              else
                  htex_do_special(cp, len - strlen("sdict begin "));
           }
           else if (!warned_hypertex_too_old && strstr(cp, "HyperStart") != NULL) {
              popup_message(globals.widgets.top_level,
                           MSG_WARN, NULL,
                           "This DVI was created with a too old version of the `dvips' hyperref driver - "
                           "disabling hyperlinks.\n"
                           "To fix this, you should either upgrade to a current version of hyperref "
                           "(see http://www.tug.org/applications/hyperref/), "
                           "or use the `hypertex' package option, like this:\n\\usepackage[hypertex]{hyperref}\n"
                           "(Be aware though that this option won't work for PS->PDF conversion!)");
              warned_hypertex_too_old = True;
           }
       }
       else {
           /* When not ignoring SDict entries, the distiller and pagecolor
              code in lshort.dvi from CTAN:info/lshort/russian/lshrtdvi.zip
              causes a failed assertion for 'color_bot_size > 0' in dvi-draw.c;
              there's something wrong with the parsing order/event handling here
              (see bug #856547).
              But we also don't want those entries to trigger erasepage_gs(), so
              it's correct to ignore them here.
           */
#if PS_GS && GS_PIXMAP_CLEARING_HACK
           had_ps_specials = True;
#endif
       }
       return;
    }
    if (memicmp(cp, "psfile", 6) == 0 && (p = endofcommand(cp + 6)) != NULL) {
       epsf_special(p);
#if PS_GS && GS_PIXMAP_CLEARING_HACK
       had_ps_specials = True;
#endif
       return;
    }
    if (memicmp(cp, "html:", 5) == 0) {
       htex_do_special(cp + 5, len - 5);
       return;
    }

#if COLOR
    if (memicmp(cp, "color ", 6) == 0) {
/*     fprintf(stderr, "------------- color special\n"); */
       if (resource.use_color)
           color_special(cp + 6);
       return;
    }
#endif
    
    /* these should have been scanned */
    if (*cp == '!'
       || (memicmp(cp, "header", 6) == 0 && endofcommand(cp + 6) != NULL)) {
#ifdef PS
       if (resource.postscript != 0 && scanned_page_reset >= 0) {
           /* turn on scanning and redraw the page */
           scanned_page = scanned_page_ps = scanned_page_reset = -1;
# if COLOR
           scanned_page_color = scanned_page;
# endif
           globals.ev.flags |= EV_NEWPAGE;              /* force a redraw */
           longjmp(globals.ev.canit, 1);
       }
#endif /* PS */
       return;
    }

    if (memicmp(cp, "background ", 11) == 0) {
#if COLOR
       if (resource.use_color && scanned_page_reset >= 0) {
           /* turn on scanning and redraw the page */
           scanned_page = scanned_page_color = scanned_page_reset = -1;
# if PS
           scanned_page_ps = scanned_page;
# endif
/*         fprintf(stderr, "forcing redraw!\n"); */
           globals.ev.flags |= EV_NEWPAGE;              /* force a redraw */
           longjmp(globals.ev.canit, 1);
       }
#endif /* COLOR */
       return;
    }

    if (memcmp(cp, "papersize", 9) == 0 && endofcommand(cp + 9) != NULL) {
       m_have_papersize_special = True;
       if (scanned_page_reset >= 0) {
           /* turn on scanning and redraw the page */
           scanned_page = scanned_page_reset = -1;
#if PS
           scanned_page_ps = scanned_page;
#endif
#if COLOR
           scanned_page_color = scanned_page;
#endif
           globals.ev.flags |= EV_NEWPAGE; /* force a redraw */
           longjmp(globals.ev.canit, 1);
       }
       return;
    }

    /* tpic specials */

    if (*cp >= 'a' && *cp <= 'z' && cp[1] >= 'a' && cp[1] <= 'z' &&
       (isspace((int)cp[2]) || cp[2] == '\0')) {
       switch (CMD(*cp, cp[1])) {
       case CMD('p', 'n'):
           set_pen_size(cp + 2);
           return;
       case CMD('f', 'p'):
           flush_path();
           return;
       case CMD('d', 'a'):
           flush_dashed(cp + 2, False);
           return;
       case CMD('d', 't'):
           flush_dashed(cp + 2, True);
           return;
       case CMD('p', 'a'):
           add_path(cp + 2);
           return;
       case CMD('a', 'r'):
           arc(cp + 2, False);
           return;
       case CMD('i', 'a'):
           arc(cp + 2, True);
           return;
       case CMD('s', 'p'):
           flush_spline();
           return;
       case CMD('s', 'h'):
           shade_last();
           return;
       case CMD('w', 'h'):
           whiten_last();
           return;
       case CMD('b', 'k'):
           blacken_last();
           return;
       case CMD('i', 'p'):  /* throw away the path -- jansteen */
           path_len = 0;
           return;
       }
    }

    if (memcmp(cp, "src:", 4) == 0) {
       have_src_specials = True;
    }
    else if (globals.warn_spec_now)
       XDVI_WARNING((stderr, "Special \"%s\" not implemented.", cp));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void color_special ( const char *  colorspec)
void geom_do_special ( struct scan_info ,
char *  ,
double   
)

Definition at line 2677 of file special.c.

{
    const char *p;
    struct geom_info *g_info = (struct geom_info *)info->data;
    
    UNUSED(current_dimconv);
    
    while (isspace((int)*cp))
       ++cp;

    /* Ignore initial "xdvi:" */
    if (memcmp(cp, "xdvi:", 5) == 0) {
       cp += 5;
       while (isspace((int)*cp))
           ++cp;
    }

    if (memicmp(cp, "psfile", 6) == 0 && (p = endofcommand(cp + 6)) != NULL) {
       /* compute epsf bounding box */
       char c;
       int flags = 0;
       double keyval[6];

       c = *p;
       if (c == '\'' || c == '"') {
           do
              ++p;
           while (*p != '\0' && *p != c);
       }
       else
           while (*p != '\0' && !isspace((int)*p))
              ++p;
       while (isspace((int)*p))
           ++p;
       while (*p != '\0') {
           const char *p1 = p;
           size_t keyno;

           while (*p1 != '=' && !isspace((int)*p1) && *p1 != '\0')
              ++p1;
           for (keyno = 0; keyno < NKEYS; ++keyno) {
              if (memcmp(p, keytab[keyno], p1 - p) == 0) {
                  if (keyno >= N_ARGLESS_KEYS) {
                     while (isspace((int)*p1))
                         ++p1;
                     if (*p1 == '=') {
                         ++p1;
                         while (isspace((int)*p1))
                            ++p1;
                     }
                     if (keyno < N_ARGLESS_KEYS + 6) {
                         keyval[keyno - N_ARGLESS_KEYS] = atof(p1);
                         flags |= (1 << (keyno - N_ARGLESS_KEYS));
                     }
                     while (!isspace((int)*p1) && *p1 != '\0')
                         ++p1;
                  }
                  break;
              }
           }
           p = p1;
           while (!isspace((int)*p) && *p != '\0')
              ++p;
           while (isspace((int)*p))
              ++p;
       }

       if ((flags & 0x30) == 0x30 || ((flags & 0x30) && (flags & 0xf) == 0xf)) {
           long x = G_PXL_H;
           long y = PXL_V;
           long bbox_w;
           long bbox_h;

           bbox_w = 0.1 * ((flags & 0x10) ? KEY_RWI
                         : KEY_RHI * (KEY_URX - KEY_LLX) / (KEY_URY -
                                                        KEY_LLY)) *
              dimconv + 0.5;
           bbox_h =
              0.1 * ((flags & 0x20) ? KEY_RHI : KEY_RWI *
                     (KEY_URY - KEY_LLY) / (KEY_URX - KEY_LLX))
              * dimconv + 0.5;

           g_info->geom_box(info, x, y - bbox_h, x + bbox_w, y);
       }
    }
    else if (memicmp(cp, "ps::[begin]", 11) == 0) {
       /* compute psfig bounding box */
       long bbox_w, bbox_h;

       if (sscanf(cp + 11, "%ld %ld\n", &bbox_w, &bbox_h) >= 2) {
           long x = G_PXL_H;
           long y = PXL_V;

           bbox_w = xpixel_conv(spell_conv(bbox_w));
           bbox_h = xpixel_conv(spell_conv(bbox_h));

           g_info->geom_box(info, x, y, x + bbox_w, y + bbox_h);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 1343 of file special.c.

{
#if PS
    struct tickrec   *tikp;
#endif

    scanned_page = scanned_page_reset = resource.prescan ? -1 : total_pages + 1;
#if PS
    scanned_page_ps = scanned_page_ps_bak = scanned_page;
#if COLOR
    scanned_page_color = scanned_page;
#endif /* COLOR */
#endif /* PS */

    TRACE_FILES((stderr, "init_prescan: scanned_page = %d", scanned_page));
#if PS
    if (resource.postscript == 0)
       scanned_page_ps = total_pages + 1;

    for (tikp = tickhead; tikp != NULL; tikp = tikp->next)
       tikp->pageno = -1;
    psp.newdoc();
#endif

#if COLOR
    if (!resource.use_color)
       scanned_page_color = total_pages + 1;
#endif

    if (ignore_papersize_specials) {
#if PS && COLOR
       scanned_page = scanned_page_ps < scanned_page_color ? scanned_page_ps : scanned_page_color;
#elif PS
       scanned_page = scanned_page_ps;
#elif COLOR
       scanned_page = scanned_page_color;
#else
       scanned_page = total_pages + 1;
#endif
    }
}

Here is the caller graph for this function:

Here is the caller graph for this function:

Boolean scan_special ( char *  str,
int  str_len,
void data 
)

Definition at line 2564 of file special.c.

{
    char *p;
    Boolean dummy_ret = True; /* currently unused;
                             FIXME: use return value to avoid redundant calls (instead of longjmp()) */
    UNUSED(cp_len); /* TODO: could probably utilize this in call to htex_prescan_special() */
    ASSERT(data != NULL, "Must pass a data pointer when using HTEX");
    
    if (globals.debug & DBG_PS)
       printf("Scanning special `%s'.\n", cp);

    while (isspace((int)*cp))
       ++cp;
    
    /* Ignore initial "xdvi:" */
    if (memcmp(cp, "xdvi:", 5) == 0) {
       cp += 5;
       while (isspace((int)*cp))
           ++cp;
    }

    if (memicmp(cp, "ps:", 3) == 0) {
       Boolean found;
       cp += 3;
       /* check for hdvips hyperlinks */
       if (memicmp(cp, "sdict begin ", strlen("sdict begin ")) == 0) {
           static Boolean hypertex_too_old = False;
           char *match = NULL;
           cp += strlen("sdict begin ");

           if (strstr(cp, "HyperStart") != NULL)
              hypertex_too_old = True;
           if (hypertex_too_old)
              return False;
           
           if (memcmp(cp, "H.S", 3) == 0
              || memcmp(cp, "H.R", 3) == 0
              || memcmp(cp, "H.B", 3) == 0
              /* following 2 conditions could be more restrictive: between `begin' and H.A/H.L,
                 there should be a single number (baselineskip in pt) */
              || (match = strstr(cp, "H.A")) != NULL
              || (match = strstr(cp, "H.L")) != NULL
              || (match = strstr(cp, "/Action")) != NULL
              || (match = strstr(cp, "/Link")) != NULL
              || (match = strstr(cp, "/View")) != NULL) {
              if (match != NULL)
                  found = htex_prescan_special(match, cp_len, data);
              else
                  found = htex_prescan_special(cp, cp_len, data);
           }
       }
           
    }
    else if (memicmp(cp, "html:", strlen("html:")) == 0) {
       Boolean found;
       size_t offset = strlen("html:");
       found = htex_prescan_special(cp + offset, cp_len - offset, data);
       /* if searching for a specific string, return as soon as it's found - not yet implemented */
#if 0
       if (my_data != NULL && my_data->scan_type == HTEX_ANCHOR_STRING && found) {
           return True;
       }
#endif
    }
    /* do the following only if not searching for an anchor string */
    if (((struct htex_prescan_data *)data)->scan_type != HTEX_ANCHOR_STRING) {
#if PS
# if COLOR
       if (scanned_page_ps <= scanned_page)
# endif
           {
              if (*cp == '!') {
                  scan_bang(cp);
                  return dummy_ret;
              }
              else if (memicmp(cp, "header", 6) == 0 && (p = endofcommand(cp + 6)) != NULL) {
                  scan_header(p);
                  return dummy_ret;
              }
           }
#endif /* PS */
       
#if COLOR
# if PS
       if (scanned_page_color <= scanned_page)
# endif
           {
              if (memicmp(cp, "background ", 11) == 0) {
                  scan_bg_color(cp);
                  return dummy_ret;
              }
              else if (memicmp(cp, "color ", 6) == 0) {
                  scan_color(cp);
                  return dummy_ret;
              }
           }
#endif /* COLOR */
       if (memcmp(cp, "papersize", 9) == 0 && (p = endofcommand(cp + 9)) != NULL) {
           m_have_papersize_special = True;
           scan_papersize(p);
           return dummy_ret;
       }
    }
    return dummy_ret;
}

Here is the call graph for this function:

Here is the caller graph for this function: