示例#1
0
void    show_ifcb( char * txt, ifcb * cb ) {
    if( cb->if_level ) {
        out_msg( "%-8s %dL%d %c%c %s %s %s cw(l,i,te,d) %d,%d,%d,%d kp %d\n",
             txt,
             inc_level,
             cb->if_level,
             cb->if_flags[cb->if_level].iftrue?'t':' ',
             cb->if_flags[cb->if_level].iffalse?'f':' ',

             cb->if_flags[cb->if_level].ifthen?"th":"  ",
             cb->if_flags[cb->if_level].ifelse?"el":"  ",
             cb->if_flags[cb->if_level].ifdo?"do":"  ",
             cb->if_flags[cb->if_level].iflast,
             cb->if_flags[cb->if_level].ifcwif,
             cb->if_flags[cb->if_level].ifcwte,
             cb->if_flags[cb->if_level].ifcwdo,
             ProcFlags.keep_ifstate
          );
    }
}
示例#2
0
void g_banner( void )
{
    if( !(GlobalFlags.bannerprinted | GlobalFlags.quiet) ) {
        out_msg( banner1w( "Script/GML", _WGML_VERSION_ ) CRLF );
        out_msg( banner2a() CRLF );
        out_msg( banner3 CRLF );
        out_msg( banner3a CRLF );
        out_msg( "Compiled with WATCOMC "xmystr(__WATCOMC__)
                 " "__DATE__" "__TIME__ CRLF);
#ifdef  TRMEM
        out_msg( "Compiled with TRMEM memory tracker (trmem)" CRLF );
#endif
        GlobalFlags.bannerprinted = 1;
    }
}
示例#3
0
char    *scr_single_funcs( char * in, char * end, char * * result )
{
    char            *   pw;

    if( *(in + 2) == '\'' ) {
        switch( *(in + 1) ) {
        case  'E' :                     // exist function
        case  'e' :                     // exist function
            pw = scr_single_func_e( in, end, result );
            break;
        case  'L' :                     // length function
        case  'l' :                     // length function
            pw = scr_single_func_l( in, end, result );
            break;
        case  'S' :                     // superscript
            pw = scr_single_func_sS( in, end, result, function_superscript );
            break;
        case  's' :                     // subscript
            pw = scr_single_func_sS( in, end, result, function_subscript );
            break;
        case  'U' :                     // upper function
        case  'u' :                     // upper function
            pw = scr_single_func_u( in, end, result );
            break;
        case  'W' :                     // width function
        case  'w' :                     // width function
            pw = scr_single_func_w( in, end, result );
            break;
        default:
            pw = scr_single_func_unsupport( in, result );
            wng_count++;
            break;
        }
    } else {
        out_msg( "ERR_Logic error in gsfunelu.c\n" );
        err_count++;
        g_suicide();
    }
    ProcFlags.substituted = true;
    return( pw );
}
示例#4
0
int scan_seg(uint segno, int msgs)
{
    // See descripton at _scan_seg().

    uint saved_seg = TPR.TSR;
    fault_gen_no_fault = 1;
    addr_modes_t amode = get_addr_mode();
    set_addr_mode(APPEND_mode);

    int saved_debug = opt_debug;
    opt_debug = 0;
    t_stat ret = _scan_seg(segno, msgs);
    if (ret > 1 && msgs)
        out_msg("xseginfo: Error processing request.\n");

    opt_debug = saved_debug;
    TPR.TSR = saved_seg;
    fault_gen_no_fault = 0;
    set_addr_mode(amode);
    return ret;
}
示例#5
0
void on_message_load_photo (struct tgl_state *TLS, void *extra, int success, char *filename) {
  gchar *data = NULL;
  size_t len;
  GError *err = NULL;
  g_file_get_contents (filename, &data, &len, &err);
  int imgStoreId = purple_imgstore_add_with_id (g_memdup(data, (guint)len), len, NULL);
    
  char *image = format_img_full(imgStoreId);
  struct tgl_message *M = extra;
  switch (tgl_get_peer_type (M->to_id)) {
    case TGL_PEER_CHAT:
      debug ("PEER_CHAT\n");
      if (!our_msg(TLS, M)) {
        chat_add_message (TLS, M, image);
      }
      break;
      
    case TGL_PEER_USER:
      debug ("PEER_USER\n");
      if (out_msg(TLS, M)) {
        p2tgl_got_im (TLS, M->to_id, image, PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_IMAGES, M->date);
      } else {
        p2tgl_got_im (TLS, M->from_id, image, PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_IMAGES, M->date);
      }
      break;
      
    case TGL_PEER_ENCR_CHAT:
      break;
      
    case TGL_PEER_GEO_CHAT:
      break;
  }
 
  g_free (image);
  telegram_conn *conn = TLS->ev_base;
  conn->updated = 1;
}
示例#6
0
static  void    print_att_entry( gaentry *wk )
{
    gavalentry      *   gaval;
    unsigned            flags;
    int                 find;
    char                opt[256];
    static const char   a_txt[7] [11] =
                    {
                        { "default "   },
                        { "range "     },
                        { "automatic " },
                        { "any "       },
                        { "required "  },
                        { "uppercase " },
                        { "off "       },
                    };

    if( wk == NULL ) {
        return;                         // nothing to print
    }
    opt[0] = '\0';
    flags = wk->attflags & ~att_proc_all;   // clear processing flags
    find = 0;
    while( flags > 0 ) {
        if( flags & 1 ) {
            strcat( opt, a_txt[find] );
        }
        find++;
        flags >>= 1;
    }
    out_msg( "att:     %-13.13s %s\n", wk->name, opt );
    for( gaval = wk->vals; gaval != NULL; gaval = gaval->next ) {
        print_val_entry( gaval );
    }
    return;
}
示例#7
0
void    lay_banner( const gmltag * entry )
{
    char        *   p;
    condcode        cc;
    int             k;
    lay_att         curr;
    att_args        l_args;
    bool            cvterr;
 
    p = scan_start;
    cvterr = false;
 
    if( !GlobalFlags.firstpass ) {
        scan_start = scan_stop + 1;
        eat_lay_sub_tag();
        return;                         // process during first pass only
    }
    if( ProcFlags.lay_xxx != el_banner ) {
        ProcFlags.lay_xxx = el_banner;
        ProcFlags.banner = true;
        init_banner_wk( &wk );
    } else {
        if( !strnicmp( ":banner", buff2, sizeof( ":banner" ) ) ) {
            err_count++;                // nested :banner
            g_err( err_nested_tag, entry->tagname );
            file_mac_info();
 
            while( !ProcFlags.reprocess_line  ) {
                eat_lay_sub_tag();
                if( strnicmp( ":ebanner", buff2, sizeof( ":ebanner" ) ) ) {
                    ProcFlags.reprocess_line = false;  // not :ebanner, go on
                }
            }
            return;
        }
    }
    cc = get_lay_sub_and_value( &l_args );  // get att with value
    while( cc == pos ) {
        cvterr = true;
        for( k = 0; k < att_count; k++ ) {
            curr = banner_att[k];
 
            if( !strnicmp( att_names[curr], l_args.start[0], l_args.len[0] ) ) {
                p = l_args.start[1];
 
                if( count[k] ) {
                    cvterr = 1;         // attribute specified twice
                } else {
                    count[k] += 1;
                    sum_count++;
                    switch( curr ) {
                    case   e_left_adjust:
                        cvterr = i_space_unit( p, curr, &wk.left_adjust );
                        break;
                    case   e_right_adjust:
                        cvterr = i_space_unit( p, curr, &wk.right_adjust );
                        break;
                    case   e_depth:
                        cvterr = i_space_unit( p, curr, &wk.depth );
                        break;
                    case   e_place:
                        cvterr = i_place( p, curr, &wk.place );
                        break;
                    case   e_docsect:
                        cvterr = i_docsect( p, curr, &wk.docsect );
                        break;
                    case   e_refplace:  // not stored in banner struct
                        cvterr = i_place( p, curr, &refplace );
                        break;
                    case   e_refdoc:    // not stored in banner struct
                        cvterr = i_docsect( p, curr, &refdoc );
                        break;
                    default:
                        out_msg( "WGML logic error.\n");
                        cvterr = true;
                        break;
                    }
                }
                break;                  // break out of for loop
            }
        }
        if( cvterr ) {                  // there was an error
            err_count++;
            g_err( err_att_val_inv );
            file_mac_info();
        }
        cc = get_lay_sub_and_value( &l_args );  // get att with value
    }
    scan_start = scan_stop + 1;
    return;
}
示例#8
0
static int _scan_seg(uint segno, int msgs)
{

    // Dump the linkage info for an in-memory segment.
    // Can be invoked by an interactive command.
    // Also invoked by the CPU to discover entrypoint names and locations so
    // that the CPU can display location information.
    // Any entrypoints found are passed to seginfo_add_linkage().
    //
    // Caller should preserve TPR.TSR -- only scan_seg() should call _scan_seg()

    t_uint64 word0, word1;

    if (opt_debug) log_msg(DEBUG_MSG, "scan-seg", "Starting for seg %#o\n", segno);

    /* Locate and report the last non-zero word of the segment */
    if (msgs) {
        /* Get last word of segment -- but in-memory copy may be larger than original, so search for last non-zero word */
        TPR.TSR = segno;
        if (fetch_word(0, &word0) != 0) {
            if (msgs)
                out_msg("xseginfo: Cannot read first word of segment %#o.\n", segno);
        }
        SDW_t *sdwp = get_sdw();        // Get SDW for TPR.TSR
        if (sdwp == 0) {
            out_msg("xseginfo: Cannot find SDW segment descriptor word for segment %#o.\n", segno);
        } else {
            out_msg("SDW segment descriptor word for %#o: %s\n", segno, sdw2text(sdwp));
            int bound = 16 * (sdwp->bound + 1);
            t_uint64 last = 0;
            for (bound -= 2; bound > 0; bound -= 2) {
                if (fetch_pair(bound, &word0, &word1) != 0) {
                    out_msg("xseginfo: Error reading %#o|%#o/2\n", segno, bound);
                    break;
                }
                // don't stop for 'b' 'k' 'p' 't'
                if (word0 != 0 && word0 != 0142153160164) {
                    last = word0;
                    break;
                }
                if (word1 != 0 && word1 != 0142153160164) {
                    last = word1;
                    ++ bound;
                    break;
                }
            }
            if (bound > 0) {
                out_msg("Last non-zero word might be at %#o|%#o: %012llo\n", segno, bound, last);
            }
        }
    }
    
    /* Read LOT, definitions pointer from linkage section, link pair info */
    AR_PR_t linkage;
    uint first_link;
    uint last_link;
    AR_PR_t defs;
    int ret = get_linkage(msgs, segno, &linkage, &first_link, &last_link, &defs);
    if (ret == -1)
        return 0;
    if (ret != 0)
        return ret;

    TPR.TSR = defs.PR.snr;

    /* Definitions */

    ret = scan_seg_defs(segno, &defs, 0, msgs);
    if (ret != 0)
        return ret;

    /* Linkage Section */

    if (msgs && first_link != 0 && last_link != 0) {
        out_msg("\n");
        out_msg("Linkage section:\n");
        for (int link = first_link; link <= last_link; link += 2) {
            TPR.TSR = linkage.PR.snr;
            if (fetch_pair(linkage.wordno + link, &word0, &word1) != 0)
                return 2;
            if ((word0 & 077) == 043) {
                // snapped link
                AR_PR_t pr;
                if (words2its(word0, word1, &pr) != 0)
                    out_msg("Link pair at %#o: %012llo %012llo: snapped link -- bad ptr\n", link, word0, word1);
                else
                    out_msg("Link pair at %#o: %012llo %012llo: snapped link %o|%#o\n", link, word0, word1, pr.PR.snr, pr.wordno);
            } else if ((word0 & 077) == 046) {
                // unsnapped link
                uint exp_ptr = word1 >> 18;
                // out_msg("Link pair at %#o: %012llo %012llo: unsnapped link with exp-ptr %#o.\n", link, word0, word1, exp_ptr);
                out_msg("Link pair at %#o: %#o|%#04o: unsnapped link ", link, TPR.TSR, linkage.wordno + link);
                t_uint64 word2;
                TPR.TSR = defs.PR.snr;
                if (fetch_word(defs.wordno + exp_ptr, &word2) != 0) {
                    out_msg("Cannot read expression word at %o|%o\n", TPR.TSR, defs.wordno + exp_ptr);
                    return 2;
                }
                uint offset = word2 >> 18;
                t_uint64 a, q;
                if (fetch_word(defs.wordno + offset, &a) != 0) {
                    out_msg("... exp-word at %o|%o: %012llo: offset %o|%o => <error>\n", linkage.PR.snr, exp_ptr, word2, TPR.TSR, offset);
                    return 2;
                }
                if (fetch_word(defs.wordno + offset + 1, &q) != 0) {
                    out_msg("... exp-word at %o|%o: %012llo: offset %o|%o => <error>\n", linkage.PR.snr, exp_ptr, word2, TPR.TSR, offset);
                    return 2;
                }
                // out_msg("\texp-word %012llo: offset %o => type-pair (%#llo,%#llo)\n", word2, offset, a, q);
                int exp_offset = word2 & MASK18;
                int typ = a >> 18;
                if (typ == 0 || typ > 6) {
                    out_msg("of unknown type %d.\n", typ);
                    continue;
                } else if (typ == 1 || typ == 2 || typ == 5) {
                    out_msg("of Type %d.\n", typ);
                    continue;
                } else {
                    // types 3, 4, and 6
                    char sname[513];
                    char ename[513];
                    int ql = q & MASK18;
                    int qu = q >> 18;
                    if (qu == 0)
                        *sname = 0;
                    else if (fetch_acc(defs.wordno + qu, sname) != 0)
                        return 2;
                    if (ql == 0)
                        *ename = 0;
                    else if (fetch_acc(defs.wordno + ql, ename) != 0)
                        return 2;
                    if (exp_offset == 0)
                        out_msg("of type %d to %s$%s\n", typ, sname, ename);
                    else
                        out_msg("of type %d to %s$%s%+d\n", typ, sname, ename, exp_offset);
                }
            } else {
 pr2_msgs::PressureState restamp(const pr2_msgs::PressureState& in_msg)
 {
   pr2_msgs::PressureState out_msg(in_msg);
   out_msg.header.stamp = ros::Time::now(); 
   return out_msg;
 }
示例#10
0
void    lay_ix( const gmltag * entry )
{
    char            *   p;
    condcode            cc;
    int                 k;
    lay_att             curr;
    att_args            l_args;
    int                 cvterr;
    int                 ix_l;

    p = scan_start;

    if( !GlobalFlags.firstpass ) {
        scan_start = scan_stop + 1;
        eat_lay_sub_tag();
        return;                         // process during first pass only
    }
    switch( entry->tagname[1] ) {
    case   '1':
        ix_l = el_i1;
        break;
    case   '2':
        ix_l = el_i2;
        break;
    default:
        ix_l = el_i3;
        break;
    }
    if( ProcFlags.lay_xxx != ix_l ) {
        ProcFlags.lay_xxx = ix_l;
    }

    ix_l = entry->tagname[1] - '1';     // construct Ix level  0 - 2
    if( ix_l > 2 ) {
        ix_l = 2;
        out_msg( "WGML logic error in glix.c\n" );
        err_count++;
    }

    cc = get_lay_sub_and_value( &l_args );  // get att with value
    while( cc == pos ) {
        cvterr = -1;
        for( k = 0, curr = ix_att[k]; curr > 0; k++, curr = ix_att[k] ) {

            if( !strnicmp( att_names[curr], l_args.start[0], l_args.len[0] ) ) {
                p = l_args.start[1];

                switch( curr ) {
                case   e_pre_skip:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.ix[ix_l].pre_skip );
                    break;
                case   e_post_skip:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.ix[ix_l].post_skip );
                    break;
                case   e_skip:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.ix[ix_l].skip );
                    break;
                case   e_font:
                    cvterr = i_int8( p, curr, &layout_work.ix[ix_l].font );
                    if( layout_work.ix[ix_l].font >= wgml_font_cnt ) {
                        layout_work.ix[ix_l].font = 0;
                    }
                    break;
                case   e_indent:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.ix[ix_l].indent );
                    break;
                case   e_wrap_indent:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.ix[ix_l].wrap_indent );
                    break;
                case   e_index_delim:
                    cvterr = i_xx_string( p, curr,
                                          &layout_work.ix[ix_l].index_delim );
                    break;
                case   e_string_font:
                    if( ix_l < 2 ) {
                        cvterr = i_int8( p, curr,
                                         &layout_work.ix[ix_l].string_font );
                    if( layout_work.ix[ix_l].string_font >= wgml_font_cnt ) {
                        layout_work.ix[ix_l].string_font = 0;
                    }
                    }
                    break;
                default:
                    out_msg( "WGML logic error.\n");
                    cvterr = true;
                    break;
                }
                if( cvterr ) {          // there was an error
                    err_count++;
                    g_err( err_att_val_inv );
                    file_mac_info();
                }
                break;                  // break out of for loop
            }
        }
        if( cvterr < 0 ) {
            err_count++;
            g_err( err_att_name_inv );
            file_mac_info();
        }
        cc = get_lay_sub_and_value( &l_args );  // get att with value
    }
    scan_start = scan_stop + 1;
    return;
}
示例#11
0
void    lay_date( const gmltag * entry )
{
    char            *   p;
    condcode            cc;
    int                 k;
    lay_att             curr;
    att_args            l_args;
    int                 cvterr;

    entry = entry;
    p = scan_start;
    cvterr = false;

    if( !GlobalFlags.firstpass ) {
        scan_start = scan_stop + 1;
        eat_lay_sub_tag();
        return;                         // process during first pass only
    }
    if( ProcFlags.lay_xxx != el_date ) {
        ProcFlags.lay_xxx = el_date;
    }
    cc = get_lay_sub_and_value( &l_args );  // get att with value
    while( cc == pos ) {
        cvterr = -1;
        for( k = 0, curr = date_att[k]; curr > 0; k++, curr = date_att[k] ) {

            if( !strnicmp( att_names[curr], l_args.start[0], l_args.len[0] ) ) {
                p = l_args.start[1];

                switch( curr ) {
                case   e_date_form:
                    p = l_args.start[0] + l_args.len[0];
                    cvterr = i_date_form( p, curr, layout_work.date.date_form );
                    break;
                case   e_left_adjust:
                    cvterr = i_space_unit( p, curr, &layout_work.date.left_adjust );
                    break;
                case   e_right_adjust:
                    cvterr = i_space_unit( p, curr, &layout_work.date.right_adjust );
                    break;
                case   e_page_position:
                    cvterr = i_page_position( p, curr, &layout_work.date.page_position );
                    break;
                case   e_font:
                    cvterr = i_font_number( p, curr, &layout_work.date.font );
                    if( layout_work.date.font >= wgml_font_cnt ) {
                        layout_work.date.font = 0;
                    }
                    break;
                case   e_pre_skip:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.date.pre_skip );
                    break;
                default:
                    out_msg( "WGML logic error.\n");
                    cvterr = true;
                    break;
                }
                if( cvterr ) {          // there was an error
                    err_count++;
                    g_err( err_att_val_inv );
                    file_mac_info();
                }
                break;                  // break out of for loop
            }
        }
        if( cvterr < 0 ) {
            err_count++;
            g_err( err_att_name_inv );
            file_mac_info();
        }
        cc = get_lay_sub_and_value( &l_args );  // get att with value
    }
    scan_start = scan_stop + 1;
    return;
}
示例#12
0
char *  format_num( uint32_t n, char * r, size_t rsize, num_style ns )
{
    size_t      pos;
    size_t      pos1;
    char    *   p;
    char    *   rp;
    char        temp[MAX_L_AS_STR + 3]; // +3 for () and decimal point
    char        a1;
    char        a2;
    char        charbase;


    p = temp;
    pos = 0;
    if( ns & xpa_style ) {
        *p++ = '(';                     // start number with left paren
        if( ++pos >= rsize ) {
            return( NULL );             // result field overflow
        }
    }
    if( ns & (a_style | b_style) ) {    // alphabetic limit 2 'digits'
    /************************************************************************/
    /*  Arbitrary limit Value 728 = 2 characters    extend if needed    TBD */
    /************************************************************************/
        if( n >= 27*27 || (n < 1) ) {   // only 2 letters supported
            return( NULL );             // and numbers > zero
        }
        if( ns & a_style ) {
            charbase = 'a' - 1;
        } else {
            charbase = 'A' - 1;
        }
    }
    switch( ns & char1_style ) {
    case a_style :                      // lower case alphabetic
    case b_style :                      // UPPER case alphabetic
        a1 = n / 27;
        a2 = n % 27;
        if( a1 > 0 ) {
            *p++ = charbase + a1;
            if( ++pos >= rsize ) {
                return( NULL );         // result field overflow
            }
            *p++ = charbase + 1 + a2;
            if( ++pos >= rsize ) {
                return( NULL );         // result field overflow
            }
        } else {
            *p++ = charbase + a2;
            if( ++pos >= rsize ) {
                return( NULL );         // result field overflow
            }
        }
        break;
    case h_style :                      // arabic
        ultoa( n, p, 10 );
        pos1 = strlen( p );
        pos += pos1;
        if( pos >= rsize ) {
            return( NULL );             // result field overflow
        }
        p += pos1;
        break;
    case r_style :                      // lower case roman
        rp = int_to_roman( n, p, rsize - pos );
        if( rp == NULL ) {
            return( NULL );             // field overflow
        }
        pos1 = strlen( rp );
        p += pos1;
        break;
    case c_style :                      // UPPER case roman
        rp = int_to_roman( n, p, rsize - pos );
        if( rp == NULL ) {
            return( NULL );             // field overflow
        }
        strupr( p );
        pos1 = strlen( rp );
        p += pos1;
        break;
    default:
        out_msg( "Logic error in gutil.c int_to_roman()\n" );
        err_count++;
        g_suicide();
        break;
    }

    if( ns & xd_style ) {
        *p++ = '.';                     // decimalpoint follows
        if( ++pos >= rsize ) {
            return( NULL );             // result field overflow
        }
    }
    if( ns & xpb_style ) {
        *p++ = ')';                     // right paren follows
        if( ++pos >= rsize ) {
            return( NULL );             // result field overflow
        }
    }
    *p = '\0';                          // terminate string
    strcpy( r, temp );                  // copy temp string to result
    return( r );
}
示例#13
0
static  void    print_val_entry( gavalentry *wk )
{
    unsigned            flags;
    int                 find;
    char                opt[256];
    static const char   v_txt[8] [11] =
                    {
                        { "default "   },
                        { "any "       },
                        { "length "    },
                        { "range "     },
                        { ""           },   // value
                        { ""           },   // valptr
                        { "automatic " },
                        { "reset "     },
                    };

    if( wk == NULL ) {
        return;                         // nothing to print
    }
    opt[0] = '\0';
    flags = wk->valflags;
    find = 0;
    while( flags > 0 ) {
        if( flags & 1 ) {
            strcat( opt, v_txt[find] );
        }
        find++;
        flags >>= 1;
    }
//    out_msg( "val:        %-10.10s %s\n", "jaja", opt );
    flags = wk->valflags;

    if( flags & val_range ) {
        if( flags & val_def ) {
            sprintf( opt, "default=%d %d min=%d max=%d",
                     wk->a.range[2], wk->a.range[3],
                     wk->a.range[0], wk->a.range[1] );
        } else {
            sprintf( opt, "min=%d max=%d", wk->a.range[0],
                     wk->a.range[1] );
        }
        out_msg( "val:        %-10.10s %s\n", " ", opt );

    } else if( flags & val_length ) {

        sprintf( opt, "length=%d\n", wk->a.range[0] );
        out_msg( "val:        %-10.10s %s\n", " ", opt );

    } else if( flags & val_any ) {

        if( flags & val_value ) {

            out_msg( "val:        %-10.10s any use='%s'\n", "", wk->a.value );

        } else if( flags & val_valptr ) {

            out_msg( "val:        %-10.10s any use='%s'\n", " ", wk->a.valptr );
        }
    } else if( flags & val_auto ) {

        if( flags & val_value ) {

            out_msg( "val:        %-10.10s automatic use='%s'\n", "", wk->a.value );

        } else if( flags & val_valptr ) {

            out_msg( "val:        %-10.10s automatic use='%s'\n", " ", wk->a.valptr );
        }
    } else if( flags & val_value ) {

        if( flags & val_def ) {
            strcpy( opt, "default" );
        } else {
            opt[0] = '\0';
        }
        out_msg( "val:        %-10.10s %s\n", wk->a.value, opt );

    } else if( flags & val_valptr ) {

        if( flags & val_def ) {
            strcpy( opt, "default" );
        } else {
            opt[0] = '\0';
        }
        out_msg( "val:        %-10.10s %s '%s'\n", " ", opt, wk->a.valptr );

    }
    return;
}
示例#14
0
void    init_page_geometry( void )
{
    int         k;
    uint32_t    page_depth_org;
    uint32_t    net_top_margin;
    uint32_t    net_y_start;
    uint32_t    rm_test;
    uint32_t    top_margin;
    uint32_t    y_start_correction;
#if 0                                   // activate for multi column TBD
    uint32_t    offset;
#endif


    g_resh = bin_device->horizontal_base_units; // hor resolution  &sysresh
    g_resv = bin_device->vertical_base_units;   // vert resolution &sysresv

    spacing = layout_work.defaults.spacing;

    g_cur_threshold = layout_work.widow.threshold;

    g_max_char_width = 0;
    g_max_line_height = 0;
    for( k = 0; k < wgml_font_cnt; k++ ) {
        if( g_max_char_width < wgml_fonts[k].default_width )
            g_max_char_width = wgml_fonts[k].default_width;
        if( g_max_line_height < wgml_fonts[k].line_height )
            g_max_line_height = wgml_fonts[k].line_height;
    }
    g_curr_font = layout_work.defaults.font;

    lm = conv_hor_unit( &layout_work.page.left_margin )
         - bin_device->x_offset;        // left margin &syspagelm
    if( lm < 0 ) {                      // wgml 4.0 limits value
        lm = 0;
    }

    rm = conv_hor_unit( &layout_work.page.right_margin )
         - bin_device->x_offset;        // right margin &syspagerm

    rm_test = bin_device->horizontal_base_units / 4;
    if( (bin_device->horizontal_base_units % 4) > 0 ) {
        rm_test++;                          // round up if any remainder
    }
    if( rm < rm_test ) {                    // wgml 4.0 limits value
        xx_err( err_right_margin_2_small ); // candidate Severe Error
        g_suicide();                        // no recovery possible
    }

    g_page_left_org = lm + bin_device->x_start;
    if( g_page_left_org < bin_device->x_start )
        g_page_left_org = bin_device->x_start;
    g_page_left = g_page_left_org;
    g_cur_left = g_page_left;               // set initial value

    g_page_right_org = rm + bin_device->x_start;
    if( g_page_right_org > bin_device->page_width )
        g_page_right_org = bin_device->page_width;
    g_page_right = g_page_right_org;

    if( g_page_right > bin_device->page_width ) {// output must appear on page
        xx_err( err_margins_inverted );     // candidate Severe Error
        g_suicide();                        // no recovery possible
    }

    if( g_page_left >= g_page_right ) {     // margins cannot be inverted
        xx_err( err_margins_inverted );     // candidate Severe Error
        g_suicide();                        // no recovery possible
    }

    g_net_page_width = rm - lm;
    g_ll = g_net_page_width * CPI / bin_device->horizontal_base_units; // &sysll

    top_margin = conv_vert_unit( &layout_work.page.top_margin, 1 );

    page_depth_org = conv_vert_unit( &layout_work.page.depth, 1 );
    if( bin_device->y_offset > page_depth_org ) {
        xx_err( err_page_depth_too_small ); // candidate Severe Error
        g_suicide();                        // no recovery possible
    } else {
        g_page_depth = page_depth_org - bin_device->y_offset;  // &syspaged
    }
    if( bin_device->y_offset < top_margin ) {
        net_top_margin = top_margin - bin_device->y_offset;
    } else {
        net_top_margin = 0;
    }
    if( bin_driver->y_positive == 0 ) {
        g_page_top = bin_device->y_start - net_top_margin;
        if( g_page_depth > bin_device->y_start ) {
            /* see Wiki for discussion, wgml 4.0 differs here */
            xx_err( err_page_depth_too_big );   // candidate Severe Error
            g_suicide();                        // no recovery possible
        } else {
            g_page_bottom = bin_device->y_start - g_page_depth;// end of text area
        }
        g_net_page_depth = g_page_top - g_page_bottom;

        lcmax = 1 + (g_net_page_depth + bin_device->y_offset)
                 / wgml_fonts[g_curr_font].line_height;   // usable no of lines
    } else {
        net_y_start = bin_device->y_start;
        if( net_y_start < net_top_margin )
            net_y_start = net_top_margin;
        if( bin_device->y_start > net_top_margin ) {
            y_start_correction = bin_device->y_start - net_top_margin;
            if( y_start_correction > wgml_fonts[g_curr_font].line_height ) {
                y_start_correction = wgml_fonts[g_curr_font].line_height;
            }
        } else {
            y_start_correction = 0;
        }
        g_page_top = net_y_start - y_start_correction;
        g_page_bottom = g_page_top + g_page_depth;

        g_net_page_depth = g_page_bottom - g_page_top;
        lcmax = g_net_page_depth;
    }

    g_page_bottom_org = g_page_bottom;// save for possible bot banner calculation
    g_page_top_org = g_page_top;// save top for possible bot banner calculation

    g_cd = layout_work.defaults.columns;// no of columns   &syscd
    g_gutter = conv_hor_unit( &layout_work.defaults.gutter );   // &sysgutter

#if 0                                   // activate for multi column TBD
    if( g_cd > 1 ) {                    // multi column layout
        if( g_cd > 9 ) {
                                        // no more than 9 columns
            g_cd = 9;                   // this limit is found in script_tso.txt
                                        // for .cd control word
        }
        g_cl = (g_net_page_width - (g_cd - 1) * g_gutter )
                / (g_cd - 1);           // column length
        offset = g_page_left;
        for( k = 0; k < g_cd; ++k ) {
            g_offset[k] = offset;       // start of each column
            offset += g_cl + g_gutter;
        }
        for( ; k < 9; ++k ) {
            g_offset[k] = 0;            // dummy start of undefined columns
        }
    } else {
        g_cl = g_ll;
    }
#else
    g_cl = g_ll;                        // column length &syscl
                // This is what wgml 4 does, even if in multi column mode TBD
#endif

//  if( GlobalFlags.firstpass && GlobalFlags.research ) {  // show values TBD
    if( GlobalFlags.firstpass                         ) {
        out_msg( "\ntm:%d lm:%d rm:%d top margin:%d depth:%d\n\n", tm, lm, rm,
                 top_margin, g_page_depth );

        out_msg( "dev:%s page_w:%d page_d:%d hor_u:%d ver_u:%d x_s:%d y_s:%d"
                 " x_o:%d y_o:%d\n\n",
                 bin_device->driver_name,
                 bin_device->page_width,
                 bin_device->page_depth,
                 bin_device->horizontal_base_units,
                 bin_device->vertical_base_units,
                 bin_device->x_start,
                 bin_device->y_start,
                 bin_device->x_offset,
                 bin_device->y_offset
               );
        out_msg( "default font number:%d font_count:%d\n", g_curr_font,
                 wgml_font_cnt );
        for( k = 0; k < wgml_font_cnt; ++k ) {
            out_msg( "font:%d def_width:%d em:%d font_h:%d font_s:%d"
                     " line_h:%d line_s:%d spc_w:%d\n",
                     k,
                     wgml_fonts[k].default_width,
                     wgml_fonts[k].em_base,
                     wgml_fonts[k].font_height,
                     wgml_fonts[k].font_space,
                     wgml_fonts[k].line_height,
                     wgml_fonts[k].line_space,
                     wgml_fonts[k].spc_width
                   );
        }
        out_msg( "\npage top:%d bottom:%d left:%d right:%d lines:%d\n",
                 g_page_top, g_page_bottom, g_page_left, g_page_right, lcmax );
        out_msg(
           "page net depth:%d width:%d line height:%d char width:%d\n\n",
                  g_net_page_depth, g_net_page_width, g_max_line_height,
                  g_max_char_width );
    }
    g_indent = 0;
    g_indentr = 0;

    init_nest_cb();
}
示例#15
0
static  void    gml_hx_common( gml_tag gtag, int hx_lvl )
{
    char    *   p;
    char    *   headp;
    bool        idseen;
    bool        stitleseen;
    int         rc;
    int         k;
    size_t      headlen;
    size_t      txtlen;
    char        hnumstr[64];
    ref_entry   *   re;
    ref_entry   *   rwk;
    static char hxstr[4] = ":HX";
    static char htextx[8] = "$htextX";
    static char headx[7]  = "$headX";

    gtag = gtag;

    *(hxstr + 2) = '0' + hx_lvl;
    htextx[6] = '0' + hx_lvl;
    hnumx[5] = '0' + hx_lvl;
    headx[5] = '0' + hx_lvl;

    switch( hx_lvl ) {
    case   0:
        if( !((ProcFlags.doc_sect == doc_sect_body) ||
            (ProcFlags.doc_sect_nxt == doc_sect_body)) ) {

            g_err( err_tag_wrong_sect, hxstr, ":BODY section" );
            err_count++;
            file_mac_info();
        }
        break;
    case  1:
        if( !((ProcFlags.doc_sect >= doc_sect_body) ||
            (ProcFlags.doc_sect_nxt >= doc_sect_body)) ) {

            g_err( err_tag_wrong_sect, hxstr, ":BODY :APPENDIX :BACKM sections" );
            err_count++;
            file_mac_info();
        }
        break;
    default:
        if( !((ProcFlags.doc_sect >= doc_sect_abstract) ||
            (ProcFlags.doc_sect_nxt >= doc_sect_abstract)) ) {

            g_err( err_tag_wrong_sect, hxstr, ":ABSTRACT section or later" );
            err_count++;
            file_mac_info();
        }
        break;
    }
    if( layout_work.hx[hx_lvl].number_form != num_none ) {
        layout_work.hx[hx_lvl].headn++;
    }

    idseen = false;
    stitleseen = false;
    p = scan_start;
    re = NULL;

    /***********************************************************************/
    /*  Scan attributes  for :Hx                                           */
    /*  id=                                                                */
    /*  stitle=                                                            */
    /***********************************************************************/

    for( ;; ) {
        while( *p == ' ' ) {
            p++;
        }
        if( *p == '\0' || *p == '.'  ) {
            break;                      // tag end found
        }
        if( !strnicmp( "stitle=", p, 7 ) ) {
            p += 6;
            stitleseen = true;

            /***************************************************************/
            /*  Although unsupported scan stitle='xxx'                     */
            /***************************************************************/
            g_warn( wng_unsupp_att, "stitle" );
            wng_count++;
            file_mac_info();

            p = get_att_value( p );

            scan_start = p;
            if( !ProcFlags.tag_end_found ) {
                continue;
            }
            break;
        }

        /*******************************************************************/
        /*  ID='xxxxxxxx'                                                  */
        /*******************************************************************/

        if( !strnicmp( "id=", p, 3 ) ) {
            p += 2;

            p = get_refid_value( p );

            if( val_len > 0 ) {
                idseen = true;          // valid id attribute found
                *(val_start + val_len) = '\0';

                if( re == NULL ) {      // prepare reference entry
                    re = mem_alloc( sizeof( ref_entry ) );
                    init_ref_entry( re, val_start, val_len );
                } else {
                    fill_id( re, val_start, val_len );
                }
            }
            scan_start = p;
            if( !ProcFlags.tag_end_found ) {
                continue;
            }
            break;
        }

        /*******************************************************************/
        /* no more valid attributes, process remaining input as header text*/
        /*******************************************************************/
        break;
    }
    if( *p == '.' ) {                   // tag end ?
        p++;
    }

    /************************************************************************/
    /*  set the global vars $headx, $headnumx, $htextx                      */
    /*    perhaps text translated to upper or lower case                    */
    /************************************************************************/
    while( *p == ' ' ) {                // ignore leading blanks
        p++;
    }
    if( *p ) {                          // text exists
        if( layout_work.hx[hx_lvl].cases == case_lower ) {
            strlwr( p );
        } else if( layout_work.hx[hx_lvl].cases == case_upper ) {
            strupr( p );
        }
    }
    rc = add_symvar( &global_dict, htextx, p, no_subscript, 0 );

    update_headnumx( hx_lvl, hnumstr, sizeof( hnumstr ) );

    txtlen = strlen( p );
    headlen = strlen( hnumstr) + txtlen + 2;
    headp = mem_alloc( headlen );
    if( layout_work.hx[hx_lvl].number_form != num_none ) {
        strcpy( headp, hnumstr); // numbered header
        strcat( headp, " " );
    } else {
        *headp = '\0';
    }
    strcat( headp, p );
    rc = add_symvar( &global_dict, headx, headp, no_subscript, 0 );

    out_msg( " %s\n", headp );          // always verbose output ? TBD

    mem_free( headp );

    /***********************************************************************/
    /*  if id  specified add it to reference dict                          */
    /***********************************************************************/
    if( idseen ) {
        rwk = find_refid( ref_dict, re->id );
        if( !rwk ) {                    // new entry
            if( txtlen > 0 ) {          // text line not empty
                re->u.info.text_cap = mem_alloc( txtlen + 1 );
                strcpy( re->u.info.text_cap, p );
            }
            add_ref_entry( &ref_dict, re );
            re = NULL;                  // free will be done via dictionary
        } else {
            /***************************************************************/
            /*  test for duplicate id                                      */
            /*  it is done with comparing line no only, in the hope that   */
            /*  two identical ids are not specified in different files on  */
            /*  the same line no.                                          */
            /***************************************************************/
            if( re->lineno != rwk->lineno ) {
                g_err( wng_id_xxx, re->id );
                g_info( inf_id_duplicate );
                file_mac_info();
                err_count++;
            }
            if( re->u.info.text_cap != NULL ) {
                mem_free( re->u.info.text_cap );
            }
            mem_free( re );
        }
    }

    if( layout_work.hx[hx_lvl].number_reset ) {
        for( k = hx_lvl + 1; k < 7; k++ ) {
            layout_work.hx[k].headn = 0;// reset following levels
            if( layout_work.hx[k].headnsub != NULL ) {
                *(layout_work.hx[k].headnsub->value) = '\0';
            }
        }
    }

    /***********************************************************************/
    /*  creation of actual heading                                         */
    /***********************************************************************/

    /***********************************************************************/
    /*  eject page(s) if specified                                         */
    /***********************************************************************/
    if( layout_work.hx[hx_lvl].page_eject != ej_no ) {

        if( ProcFlags.page_started ) {
            do_page_out();
            reset_t_page();
        }

        if( !ProcFlags.start_section ) {
            start_doc_sect();
        }
        set_headx_banners( hx_lvl );        // set possible banners
        reset_t_page();                     // and adjust page margins


        if( (layout_work.hx[hx_lvl].page_eject == ej_odd) && (page & 1) ) {
            do_page_out();              // next page would be even
            reset_t_page();
        } else if( (layout_work.hx[hx_lvl].page_eject == ej_even) && !(page & 1) ) {
            do_page_out();              // next page would be odd
            reset_t_page();
        }
    }

    if( layout_work.hx[hx_lvl].display_heading ) {

        hx_header( hx_lvl, hnumstr, p );
    }

    scan_start = scan_stop;
    return;
}
示例#16
0
static void do_el_list_out( doc_element * array, uint8_t count )
{
    doc_element *   cur_el;
    doc_element *   save;
    int             i;
    text_line   *   cur_line;

    /*  Advise the user that multiple columns are not, in fact, implemented */

    if( count > 1 ) {
        out_msg( "Multi-column output not implemented" );
    }

    /*  The array should have the doc_elements in linked-list form in the   */
    /*  same order as the columns they came from were linked together.      */
    /*  The columns should no longer point to these doc_element lists.      */

    for( i = 0; i < count; i++ ) {
        cur_el = &array[i];
        while( cur_el != NULL ) {
            if( i == 0 ) {      // restrict output to first column, for now
                switch( cur_el->type ) {
                case el_binc :
                    if( GlobalFlags.lastpass ) {
                        ob_binclude( &cur_el->element.binc );
                    }
                    break;
                case el_dbox :  // should only be found if DBOX block exists
                    if( GlobalFlags.lastpass ) {
                        fb_dbox( &cur_el->element.dbox );
                    }
                    break;
                case el_graph :
                    if( GlobalFlags.lastpass ) {
                        if( ProcFlags.ps_device ) {   // only available to PS device
                            ob_graphic( &cur_el->element.graph );
                        }
                    }
                    break;
                case el_hline :  // should only be found if HLINE block exists
                    if( GlobalFlags.lastpass ) {
                        fb_hline( &cur_el->element.hline );
                    }
                    break;
                case el_text :
                    if( GlobalFlags.lastpass ) {
                        for( cur_line = cur_el->element.text.first; cur_line != NULL; cur_line = cur_line ->next ) {
                            fb_output_textline( cur_line );
                        }
                    }
                    break;
                case el_vline :  // should only be found if VLINE block exists
                    if( GlobalFlags.lastpass ) {
                        fb_vline( &cur_el->element.vline );
                    }
                    break;
                default :
                    internal_err( __FILE__, __LINE__ );
                }
            }
            save = cur_el->next;
            cur_el->next = NULL;            // clear only current element
            clear_doc_element( cur_el );
            add_doc_el_to_pool( cur_el ); 
            cur_el = save;
        }
    }    

    return;
}
示例#17
0
void    scr_if( void )
{
    ifcb            *   cb;             // if stack ptr

    condcode        cct1;
    condcode        cct2;
    condcode        ccrelop;
    termcb          t1;                 // first argument
    termcb          t2;                 // second argument
    relop           relation;           // the relation between t1 and t2
    logop           logical;            // if more than 1 condition
    bool            ifcond;             // current condition
    bool            totalcondition;     // resultant condition
    bool            firstcondition;     // first comparison .if

    scan_err = false;

    firstcondition = true;              // first 2 terms to compare
    garginit();                         // find end of control word

    cb = input_cbs->if_cb;              // get .if control block
    cb->if_flags[cb->if_level].ifcwif = false;  // reset cwif switch

    for( ;; ) {                         // evaluate if conditions

        cct1    = gargterm( &t1 );      // get term 1
        ccrelop = gargrelop( &relation );   // get relation operator
        cct2    = gargterm( &t2 );      // get term 2

        if( (cct1 == no) || (cct2 == no) ) {
            scan_err = true;
            err_count++;
            g_err( err_if_term );
            g_info_inp_pos();
            show_include_stack();
            return;
        }
        if( ccrelop != pos ) {
            scan_err = true;
            err_count++;
            g_err( err_if_relop );
            g_info_inp_pos();
            show_include_stack();
            return;
        }

        // terms and operator ok now compare
        ifcond = ifcompare( &t1, relation, &t2 );
        mem_free( t1.term_string );     // don't need the strings anymore
        mem_free( t2.term_string );
        if( firstcondition ) {
            firstcondition = false;
            if( cb->if_level < MAX_IF_LEVEL ) {
                cb->if_level++;
                memset( &cb->if_flags[cb->if_level], '\0',
                        sizeof( cb->if_flags[cb->if_level] ) );
                cb->if_flags[cb->if_level].iflast = true;
                cb->if_flags[cb->if_level].ifcwte = false;  // no .th .el yet
                cb->if_flags[cb->if_level].iftrue = false;  // cond not yet true
                cb->if_flags[cb->if_level].iffalse = false; // cond not yet false
            } else {
                scan_err = true;
                g_err( err_if_nesting );
                g_info_inp_pos();
                show_include_stack();
                err_count++;
                return;
            }
            totalcondition = ifcond;
        } else {
            // resultant condition
            if( logical == AND ) {
                totalcondition &= ifcond;
            } else {
                totalcondition |= ifcond;
            }
        }

        if( totalcondition ) {          // set if true / false flags
            cb->if_flags[cb->if_level].iftrue = true;
            cb->if_flags[cb->if_level].iffalse = false;
        } else {
            cb->if_flags[cb->if_level].iffalse = true;
            cb->if_flags[cb->if_level].iftrue = false;
        }

        while( *scan_start == ' ' ) {
            scan_start++;
        }

/*
 * test logical condition if not line end
 *         .if a = b or c GT d
 *                   ^^
 */
        if( *scan_start ) {
            if( *scan_start == SCR_char ) {
                break;                  // .xx can't be logical operator
            }
            if( *(scan_start + 1) == ' ' ) {// single char + blank
                if( *scan_start  == '&' ) {
                    logical = AND;
                    scan_start += 2;
                    continue;           // do next conditions
                } else if( *scan_start == '|' ) {
                    logical = OR;
                    scan_start += 2;
                    continue;           // do next conditions
                }
            } else {
                if( !strnicmp( scan_start, "and ", 4 ) ) {
                    logical = AND;
                    scan_start += 4;
                    continue;           // do next conditions
                } else if( !strnicmp( scan_start, "or ", 3 ) ) {
                        logical = OR;
                        scan_start += 3;
                        continue;       // do next conditions
                }
            }

        }
        break;                          // no more operators / conditions
    }


    if( cb->if_level > 1 ) {            // nested if
        if( cb->if_flags[cb->if_level - 1].ifthen ) { // object of .th
            if( cb->if_flags[cb->if_level - 1].iffalse ) {// last .if false

                cb->if_flags[cb->if_level].iftrue = true;// process nothing
                cb->if_flags[cb->if_level].iffalse = true;
            }
        } else {
            if( cb->if_flags[cb->if_level - 1].ifelse // object of .el
                && cb->if_flags[cb->if_level - 1].iftrue ) {// last .if true

                cb->if_flags[cb->if_level].iftrue = true;// process nothing
                cb->if_flags[cb->if_level].iffalse = true;
            }
        }
    }
    if( input_cbs->fmflags & II_research && GlobalFlags.firstpass ) {
          show_ifcb( "if", cb );
#if 0
          out_msg( "\t.if is %s Level %d\n"
                 "\t.ifcb iftrue %d, iffalse %d\n",
                 totalcondition ? "true " : "false",
                 cb->if_level,
                 cb->if_flags[cb->if_level].iftrue,
                 cb->if_flags[cb->if_level].iffalse );
#endif
    }

    if( *scan_start ) {                 // rest of line is not empty
        split_input(  buff2, scan_start, false );   // split and process next
    }
    scan_restart = scan_stop;
    return;
}
示例#18
0
void    lay_tochx( const gmltag * entry )
{
    char        *   p;
    condcode        cc;
    int             k;
    lay_att         curr;
    att_args        l_args;
    int             cvterr;
    int             hx_l;

    p = scan_start;

    if( !GlobalFlags.firstpass ) {
        scan_start = scan_stop + 1;
        eat_lay_sub_tag();
        return;                         // process during first pass only
    }
    switch( entry->tagname[4] ) {
    case   '0':
        hx_l = el_toch0;
        break;
    case   '1':
        hx_l = el_toch1;
        break;
    case   '2':
        hx_l = el_toch2;
        break;
    case   '3':
        hx_l = el_toch3;
        break;
    case   '4':
        hx_l = el_toch4;
        break;
    case   '5':
        hx_l = el_toch5;
        break;
    case   '6':
        hx_l = el_toch6;
        break;
    default:
        hx_l = el_toch6;
        break;
    }
    if( ProcFlags.lay_xxx != hx_l ) {
        ProcFlags.lay_xxx = hx_l;
    }

    hx_l = entry->tagname[4] - '0';     // construct TOCHx level
    if( hx_l > 6 ) {
        hx_l = 6;
        out_msg( "WGML logic error in glhx.c\n" );
        err_count++;
    }

    cc = get_lay_sub_and_value( &l_args );  // get one with value
    while( cc == pos ) {
        cvterr = -1;
        for( k = 0, curr = tochx_att[k]; curr > 0; k++, curr = tochx_att[k] ) {

            if( !strnicmp( att_names[curr], l_args.start[0], l_args.len[0] ) ) {
                p = l_args.start[1];

                switch( curr ) {
                case   e_group:
                    cvterr = i_int8( p, curr, &layout_work.tochx[hx_l].group );
                    break;
                case   e_indent:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.tochx[hx_l].indent );
                    break;
                case   e_skip:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.tochx[hx_l].skip );
                    break;
                case   e_pre_skip:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.tochx[hx_l].pre_skip );
                    break;
                case   e_post_skip:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.tochx[hx_l].post_skip );
                    break;
                case   e_font:
                    cvterr = i_font_number( p, curr, &layout_work.tochx[hx_l].font );
                    if( layout_work.tochx[hx_l].font >= wgml_font_cnt ) {
                        layout_work.tochx[hx_l].font = 0;
                    }
                    break;
                case   e_align:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.tochx[hx_l].align );
                    break;
                case   e_display_in_toc:
                    cvterr = i_yes_no( p, curr,
                                     &layout_work.tochx[hx_l].display_in_toc );
                    break;
                default:
                    out_msg( "WGML logic error.\n");
                    cvterr = true;
                    break;
                }
                if( cvterr ) {          // there was an error
                    err_count++;
                    g_err( err_att_val_inv );
                    file_mac_info();
                }
                break;                  // break out of for loop
            }
        }
        if( cvterr < 0 ) {
            err_count++;
            g_err( err_att_name_inv );
            file_mac_info();
        }
        cc = get_lay_sub_and_value( &l_args );  // get one with value
    }
    scan_start = scan_stop + 1;
    return;
}
示例#19
0
cop_font * parse_font( FILE * in_file, char const * in_name )
{

    /* The cop_font instance. */

    cop_font *          out_font          = NULL;

    /* Used to acquire string attributes. */

    uint8_t             length;
    char *              string_ptr          = NULL;

    /* Used to acquire numeric attributes. */

    uint16_t            designator;

    /* Used to acquire the CharacterDescriptionBlock. */

    uint8_t *           byte_ptr            = NULL;
    uint8_t             data_count;
    uint16_t            i;
    uint8_t             intrans_flag;
    uint8_t *           outtrans_data       = NULL;
    uint8_t             outtrans_data_size;
    uint8_t             outtrans_flag;
    outtrans_block *    outtrans_ptr        = NULL;
    translation *       translation_ptr     = NULL;
    uint8_t *           translation_start   = NULL;
    uint8_t             uint8_array[0x100];
    uint16_t            uint16_array[0x100];
    uint8_t             width_data_size;
    uint8_t             width_flag;
    uint32_t *          width_ptr;

    /* Used for count and other values. */

    uint8_t             count8;

    /* Ensure in_name contains a value. */

    length = strnlen_s( in_name, TYPE_MAX );
    if( (in_name == NULL) || (length == 0) ) {
        out_msg( "Defined name missing for desired font\n" );
        err_count++;
        g_suicide();
    }

    /* Initialize the out_font. */

    out_font = (cop_font *) mem_alloc( START_SIZE );

    out_font->next_font = NULL;
    out_font->allocated_size = START_SIZE;
    out_font->next_offset = sizeof( cop_font );

    /* Note: The various pointers must be entered, initially, as offsets
     * and then converted to pointers before returning because out_font
     * may be reallocated at any point and that invalidates actual pointers.
     */

    /* Incorporate the defined name. */

    length++;
    if( out_font->allocated_size < (out_font->next_offset + length) ) {
        out_font = resize_cop_font( out_font, length );
    }

    string_ptr = (char *) out_font + out_font->next_offset;
    strcpy_s( string_ptr, length, in_name );

    out_font->defined_name = (char *) out_font->next_offset;
    out_font->next_offset += length;


    /* Get the font_out_name1. */

    fread( &length, sizeof( length ), 1, in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    if( length > 0 ) {

        if( out_font->allocated_size < (out_font->next_offset + length) ) {
            out_font = resize_cop_font( out_font, length );
        }

        string_ptr = (char *) out_font + out_font->next_offset;

        fread( string_ptr, length, 1, in_file );
        if( ferror( in_file ) || feof( in_file ) ) {
            mem_free( out_font );
            out_font = NULL;
            return( out_font );
        }
        out_font->font_out_name1 = (char *) out_font->next_offset;
        out_font->next_offset += length;
        string_ptr[length] = '\0';
        ++out_font->next_offset;
    } else {
        out_font->font_out_name1 = NULL;
    }

    /* Get the font_out_name2. */

    fread( &length, sizeof( length ), 1, in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    if( length > 0 ) {
        if( out_font->allocated_size < (out_font->next_offset + length) ) {
            out_font = resize_cop_font( out_font, length );
        }

        string_ptr = (char *) out_font + out_font->next_offset;

        fread( string_ptr, length, 1, in_file );
        if( ferror( in_file ) || feof( in_file ) ) {
            mem_free( out_font );
            out_font = NULL;
            return( out_font );
        }

        out_font->font_out_name2 = (char *) out_font->next_offset;
        out_font->next_offset += length;
        string_ptr[length] = '\0';
        ++out_font->next_offset;
    } else {
        out_font->font_out_name2 = NULL;
    }

    /* Get the designator and ensure it is 0x1D00. */

    fread( &designator, sizeof( designator ), 1, in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    if( designator != 0x1D00 ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    /* Get the line_height. */

    fread( &out_font->line_height, sizeof( out_font->line_height), 1, \
        in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    /* Get the line_space. */

    fread( &out_font->line_space, sizeof( out_font->line_space ), 1, in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    /* Get the scale_basis. */

    fread( &out_font->scale_basis, sizeof( out_font->scale_basis ), 1, \
        in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    /* Get the scale_min. */

    fread( &out_font->scale_min, sizeof( out_font->scale_min ), 1, in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    /* Get the scale_max. */

    fread( &out_font->scale_max, sizeof( out_font->scale_max ), 1, in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    /* Get the char_width. */

    fread( &out_font->char_width, sizeof( out_font->char_width ), 1, in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    /* Get the CharacterDescriptionBlock. */

    /* Get the size_flag, which is not needed. */

    fread( &count8, sizeof( count8 ), 1, in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    /* Get the data_count and the flags. */

    fread( &width_flag, sizeof( width_flag ), 1, in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    fread( &data_count, sizeof( data_count ), 1, in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    fread( &outtrans_flag, sizeof( outtrans_flag ), 1, in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    fread( &intrans_flag, sizeof( intrans_flag ), 1, in_file );
    if( ferror( in_file ) || feof( in_file ) ) {
        mem_free( out_font );
        out_font = NULL;
        return( out_font );
    }

    /* Get the IntransBlock, if present. */

    if( intrans_flag == 0 ) {
        out_font->intrans = NULL;
    } else {

        /* Get the designator and verify it contains 0x81. */

        fread( &count8, sizeof( count8 ), 1, in_file );
        if( ferror( in_file ) || feof( in_file ) ) {
           mem_free( out_font );
           out_font = NULL;
           return( out_font );
        }

        if( count8 != 0x81 ) {
           mem_free( out_font );
           out_font = NULL;
           return( out_font );
        }

        /* Get the count and verify that it contains 0x00. */

        fread( &count8, sizeof( count8 ), 1, in_file );
        if( ferror( in_file ) || feof( in_file ) ) {
           mem_free( out_font );
           out_font = NULL;
           return( out_font );
        }

        if( count8 != 0x00 ) {
            mem_free( out_font );
            out_font = NULL;
            return( out_font );
        }

        /* Get the data into the array. */

        if( out_font->allocated_size < (out_font->next_offset + \
                                        sizeof( out_font->intrans->table )) ) {
            out_font = resize_cop_font( out_font, \
                                        sizeof( out_font->intrans->table ) );
        }

        byte_ptr = (uint8_t *) out_font + out_font->next_offset;

        fread( byte_ptr, sizeof( out_font->intrans->table ), 1, in_file );
        if( ferror( in_file ) || feof( in_file ) ) {
           mem_free( out_font );
           out_font = NULL;
           return( out_font );
        }

        out_font->intrans = (intrans_block *) out_font->next_offset;
        out_font->next_offset += sizeof( out_font->intrans->table );
    }

    /* Get the OuttransBlock, if present. */

    if( outtrans_flag == 0 ) {
        out_font->outtrans = NULL;
    } else {

        /* Get the next byte, which indicates the OuttransBlock data size. */
        /* The name of the variable does not match the Wiki. */

        fread( &outtrans_data_size, sizeof( outtrans_data_size ), 1, in_file );
        if( ferror( in_file ) || feof( in_file ) ) {
           mem_free( out_font );
           out_font = NULL;
           return( out_font );
        }

        /* Read the count. */

        fread( &count8, sizeof( count8 ), 1, in_file );
        if( ferror( in_file ) || feof( in_file ) ) {
            mem_free( out_font );
            out_font = NULL;
            return( out_font );
        }

        /* The file is positioned at the start of the data. */

        /* Note: each translation is added individually; however, taken
         * together, they constitute the field "translations" in the Wiki.
         */

        switch( outtrans_data_size) {
        case 0x81:

            /* The count should be 0x00. */

            if( count8 != 0x00 ) {
                mem_free( out_font );
                out_font = NULL;
                return( out_font );
            }

            /* Get the data into the local buffer. */

            fread( &uint8_array, sizeof( uint8_array ), 1, in_file );
            if( ferror( in_file ) || feof( in_file ) ) {
                mem_free( out_font );
                out_font = NULL;
                return( out_font );
            }

            /* Reserve space for the outtrans_block. */

            if( out_font->allocated_size < (out_font->next_offset + \
                                        sizeof( out_font->outtrans->table )) ) {
                out_font = resize_cop_font( out_font, \
                                        sizeof( out_font->outtrans->table ) );
            }

            out_font->outtrans = (outtrans_block *) out_font->next_offset;
            out_font->next_offset += sizeof( out_font->outtrans->table );

            outtrans_ptr = (outtrans_block *) ((char *) out_font + \
                (size_t) out_font->outtrans);

            /* Build the actual table, which requires actual pointers in
             * place of the offsets recorded in *out_font:
             *      outtrans_ptr is the pointer version of out_font->outtrans.
             *      for each iteration:
             *          translation_ptr is the pointer version of
             *              outtrans->ptr->table[i].
             *          byte_ptr is the pointer version of
             *              translation_ptr->ptr.data.
             */

            for( i = 0; i < 0x100; i++ ) {

                /* If the first byte matches the index, there is no translation. */

                if( uint8_array[i] == i) {
                    outtrans_ptr->table[i] = NULL;
                } else {

                    /* Reserve space for the translation. */

                    if( out_font->allocated_size < (out_font->next_offset + \
                                                        sizeof( translation )) ) {
                        out_font = resize_cop_font( out_font, \
                                                        sizeof( translation ) );
                        outtrans_ptr = (outtrans_block *) ((uint8_t *) out_font \
                                                + (size_t) out_font->outtrans);
                    }

                    outtrans_ptr->table[i] = (translation *) \
                                                            out_font->next_offset;
                    out_font->next_offset += sizeof( translation );

                    /* Get the translation for the current character. */

                    translation_ptr = (translation *) ((char *) out_font + \
                                                (size_t) outtrans_ptr->table[i] );

                    /* The translation always contains exactly one character. */

                    translation_ptr->count = 1;

                    if( out_font->allocated_size < (out_font->next_offset + \
                                                    translation_ptr->count ) ) {
                        out_font = resize_cop_font( out_font, \
                                                        translation_ptr->count  );
                        outtrans_ptr = (outtrans_block *) ((uint8_t *) \
                                        out_font + (size_t) out_font->outtrans);
                        translation_ptr = (translation *) ((uint8_t *) out_font \
                                            + (size_t) outtrans_ptr->table[i] );
                    }

                    translation_ptr->data = (uint8_t *) out_font->next_offset;
                    out_font->next_offset += translation_ptr->count;

                    byte_ptr = (uint8_t *) out_font + (size_t) \
                                                            translation_ptr->data;

                    /* The translation character is the value in the input array. */

                    *byte_ptr = uint8_array[i];
                }
            }
            break;

        case 0x82:

            /* The count should be equal to the data_count. */

            if( count8 != data_count ) {
                mem_free( out_font );
                out_font = NULL;
                return( out_font );
            }

            /* Get the outtrans array into the local array. */

            fread( &uint16_array, sizeof( uint16_array ), 1, in_file );
            if( ferror( in_file ) || feof( in_file ) ) {
                mem_free( out_font );
                out_font = NULL;
                return( out_font );
            }

            /* Allocate a buffer and read the translation characters into it. */

            outtrans_data = (uint8_t *) mem_alloc( data_count );

            fread( outtrans_data, sizeof( *outtrans_data ), data_count, \
                in_file );
            if( ferror( in_file ) || feof( in_file ) ) {
                mem_free( outtrans_data );
                outtrans_data = NULL;
                mem_free( out_font );
                out_font = NULL;
                return( out_font );
            }

            /* Initialize outtrans_ptr and the outtrans pointer in out_font. */

            if( out_font->allocated_size < (out_font->next_offset + \
                                        sizeof( out_font->outtrans->table )) ) {
                out_font = resize_cop_font( out_font, \
                                            sizeof( out_font->outtrans->table ) );
            }

            out_font->outtrans = (outtrans_block *) out_font->next_offset;
            out_font->next_offset += sizeof( out_font->outtrans->table );

            outtrans_ptr = (outtrans_block *) ((char *) out_font + \
                                                    (size_t) out_font->outtrans);

            /* Convert the data in uint16_array to our format, which requires
             * actual pointers in place of the offsets recorded in *out_font:
             *      outtrans_ptr is the pointer version of out_font->outtrans.
             *      for each iteration:
             *          translation_ptr is the pointer version of
             *              outtrans->ptr->table[i].
             *          byte_ptr is the pointer version of
             *              translation_ptr->ptr.data.
             */

            for( i = 0; i < 0x100; i++ ) {

                /* If the first byte matches the index, there is no translation. */

                if( uint16_array[i] == i) {
                    outtrans_ptr->table[i] = NULL;
                } else {

                    /* Reserve space for the translation. */

                    if( out_font->allocated_size < (out_font->next_offset + \
                                                    sizeof( translation )) ) {
                        out_font = resize_cop_font( out_font, \
                                                    sizeof( translation ) );
                        outtrans_ptr = (outtrans_block *) ((uint8_t *) out_font \
                                                + (size_t) out_font->outtrans);
                    }

                    outtrans_ptr->table[i] = (translation *) \
                                                            out_font->next_offset;
                    out_font->next_offset += sizeof( translation );

                    /* Get the translation for the current character. */

                    translation_ptr = (translation *) ((char *) out_font + \
                                                (size_t) outtrans_ptr->table[i] );

                    /* If the first byte at uint16_array[i] is 00, then the
                     * second byte is the one-byte translation. Otherwise, the
                     * second byte is an offset. For little-endian computers,
                     * at least!
                     */

                    /* Set the count correctly. */

                    if( (uint16_array[i] & 0xff00) == 0x00 ) {
                        translation_ptr->count = 1;
                    } else {
                        translation_start = outtrans_data + \
                                                    (uint16_array[i] & 0x00ff);
                        translation_ptr->count = *translation_start;
                    }

                    /* Allocate space and perform other common operations. */

                    if( out_font->allocated_size < (out_font->next_offset + \
                                                    translation_ptr->count ) ) {
                        out_font = resize_cop_font( out_font, \
                                                        translation_ptr->count );
                        outtrans_ptr = (outtrans_block *) ((uint8_t *) out_font \
                                                + (size_t) out_font->outtrans);
                        translation_ptr = (translation *) ((uint8_t *) out_font \
                                            + (size_t) outtrans_ptr->table[i] );
                    }

                    translation_ptr->data = (uint8_t *) out_font->next_offset;
                    out_font->next_offset += translation_ptr->count;

                    byte_ptr = (uint8_t *) out_font + (size_t) \
                                                        translation_ptr->data;

                    /* Put the data into the buffer. */

                    if( (uint16_array[i] & 0xff00) == 0x00 ) {
                        *byte_ptr = (uint16_array[i] & 0x00ff);
                    } else {
                        ++translation_start;
                        memcpy_s( byte_ptr, translation_ptr->count, \
                                    translation_start, translation_ptr->count );
                    }
                }
            }
            mem_free( outtrans_data );
            outtrans_data = NULL;
            break;

        default:
           mem_free( out_font );
           out_font = NULL;
           return( out_font );
        }
    }

    /* Get the WidthBlock, if present. */

    if( width_flag != 0 ) {
        out_font->width = NULL;
    } else {

        /* Reserve the space for width. */

        if( out_font->allocated_size < (out_font->next_offset + \
                                        sizeof( out_font->width->table )) ) {
            out_font = resize_cop_font( out_font, \
                                        sizeof( out_font->width->table ) );
        }

        width_ptr = (uint32_t *) ((uint8_t *) out_font + out_font->next_offset);

        out_font->width = (width_block *) out_font->next_offset;
        out_font->next_offset += sizeof( out_font->width->table );

        /* Get the designator, which indicates the WidthBlock data size. */
        /* The variable name does not match the field name in the Wiki. */

        fread( &width_data_size, sizeof( width_data_size ), 1, in_file );
        if( ferror( in_file ) || feof( in_file ) ) {
            mem_free( out_font );
            out_font = NULL;
            return( out_font );
        }

        /* This byte's value is checked below. */

        fread( &count8, sizeof( count8 ), 1, in_file );
        if( ferror( in_file ) || feof( in_file ) ) {
            mem_free( out_font );
            out_font = NULL;
            return( out_font );
        }

        /* The file is now positioned at the start of the data. */

        switch ( width_data_size ) {
        case 0x81:

            /* The WidthBlock has one-byte elements. */

            /* The count should be 0x00. */

            if( count8 != 0x00 ) {
                mem_free( out_font );
                out_font = NULL;
                return( out_font );
            }

            /* Get the width data array into an array of bytes.
             * It cannot be read in directly because the field is
             * an array of uint32_t entries.
             */

            fread( &uint8_array, sizeof( uint8_array ), 1, in_file );
            if( ferror( in_file ) || feof( in_file ) ) {
                mem_free( out_font );
                out_font = NULL;
                return( out_font );
            }

            /* Copy the data into the cop_font instance. */

            for( i = 0; i < 0x100; i++ ) {
                width_ptr[i] = uint8_array[i];
            }

            break;

        case 0x84:

            /* The WidthBlock has four-byte elements. */

            /* The count should be 0x01. */

            if( count8 != 0x01 ) {
                mem_free( out_font );
                out_font = NULL;
                return( out_font );
            }

            /* Get the width data array directly into the cop_font instance. */

            fread( width_ptr, sizeof( out_font->width->table ), 1, in_file );
            if( ferror( in_file ) || feof( in_file ) ) {
                mem_free( out_font );
                out_font = NULL;
                return( out_font );
            }
            break;

        default:
            mem_free( out_font );
            out_font = NULL;
            return( out_font );
        }
    }

    /* Convert non-NULL offsets to pointers. */

    if( out_font->defined_name != NULL ) {
        string_ptr = (char *) out_font + (size_t) out_font->defined_name;
        out_font->defined_name = string_ptr;
    }

    if( out_font->font_out_name1 != NULL ) {
        string_ptr = (char *) out_font + (size_t) out_font->font_out_name1;
        out_font->font_out_name1 = string_ptr;
    }

    if( out_font->font_out_name2 != NULL ) {
        string_ptr = (char *) out_font + (size_t) out_font->font_out_name2;
        out_font->font_out_name2 = string_ptr;
    }

    if( out_font->intrans != NULL ) {
        byte_ptr = (uint8_t *) out_font + (size_t) out_font->intrans;
        out_font->intrans = (intrans_block *) byte_ptr;
    }

    if( out_font->outtrans != NULL ) {
        byte_ptr = (uint8_t *) out_font + (size_t) out_font->outtrans;
        out_font->outtrans = (outtrans_block *) byte_ptr;

        for( i = 0; i < sizeof( outtrans_block ) / sizeof( translation * ); \
                                                                        i++ ) {
            if( out_font->outtrans->table[i] != NULL ) {
                byte_ptr = (uint8_t *) out_font + \
                                            (size_t) out_font->outtrans->table[i];
                out_font->outtrans->table[i] = (translation *) byte_ptr;
                if( out_font->outtrans->table[i]->data != NULL ) {
                    byte_ptr = (uint8_t *) out_font + (size_t) \
                                            out_font->outtrans->table[i]->data;
                    out_font->outtrans->table[i]->data = byte_ptr;
                }
            }
        }
    }

    if( out_font->width != NULL ) {
        byte_ptr = (uint8_t *) out_font + (size_t) out_font->width;
        out_font->width = (width_block *) byte_ptr;
    }

    return( out_font );
}
示例#20
0
void    lay_figcap( const gmltag * entry )
{
    char        *   p;
    condcode        cc;
    int             k;
    lay_att         curr;
    att_args        l_args;
    int             cvterr;

    p = scan_start;
    cvterr = false;

    if( !GlobalFlags.firstpass ) {
        scan_start = scan_stop + 1;
        eat_lay_sub_tag();
        return;                         // process during first pass only
    }
    if( ProcFlags.lay_xxx != el_figcap ) {
        ProcFlags.lay_xxx = el_figcap;
    }
    cc = get_lay_sub_and_value( &l_args );  // get att with value
    while( cc == pos ) {
        cvterr = -1;
        for( k = 0, curr = figcap_att[k]; curr > 0; k++, curr = figcap_att[k] ) {

            if( !strnicmp( att_names[curr], l_args.start[0], l_args.len[0] ) ) {
                p = l_args.start[1];

                switch( curr ) {
                case   e_pre_lines:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.figcap.pre_lines );
                    break;
                case   e_font:
                    cvterr = i_font_number( p, curr, &layout_work.figcap.font );
                    if( layout_work.figcap.font >= wgml_font_cnt ) {
                        layout_work.figcap.font = 0;
                    }
                    break;
                case   e_figcap_string:
                    cvterr = i_xx_string( p, curr,
                                            &layout_work.figcap.string );
                    break;
                case   e_string_font:
                    cvterr = i_font_number( p, curr, &layout_work.figcap.string_font );
                    if( layout_work.figcap.string_font >= wgml_font_cnt ) {
                        layout_work.figcap.string_font = 0;
                    }
                    break;
                case   e_delim:
                    cvterr = i_char( p, curr, &layout_work.figcap.delim );
                    break;
                default:
                    out_msg( "WGML logic error.\n");
                    cvterr = true;
                    break;
                }
                if( cvterr ) {          // there was an error
                    err_count++;
                    g_err( err_att_val_inv );
                    file_mac_info();
                }
                break;                  // break out of for loop
            }
        }
        if( cvterr < 0 ) {
            err_count++;
            g_err( err_att_name_inv );
            file_mac_info();
        }
        cc = get_lay_sub_and_value( &l_args );  // get att with value
    }
    scan_start = scan_stop + 1;
    return;
}
示例#21
0
void    lay_xmp( lay_tag ltag )
{
    char        *   p;
    condcode        cc;
    int             k;
    lay_att         curr;
    att_args        l_args;
    int             cvterr;

    /* unused parameters */ (void)ltag;

    p = scan_start;

    if( !GlobalFlags.firstpass ) {
        scan_start = scan_stop;
        eat_lay_sub_tag();
        return;                         // process during first pass only
    }
    if( ProcFlags.lay_xxx != el_xmp ) {
        ProcFlags.lay_xxx = el_xmp;
    }
    cc = get_lay_sub_and_value( &l_args );  // get one with value
    while( cc == pos ) {
        cvterr = -1;
        for( k = 0, curr = xmp_att[k]; curr > 0; k++, curr = xmp_att[k] ) {

            if( !strnicmp( att_names[curr], l_args.start[0], l_args.len[0] ) ) {
                p = l_args.start[1];

                switch( curr ) {
                case   e_left_indent:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.xmp.left_indent );
                    break;
                case   e_right_indent:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.xmp.right_indent );
                    break;
                case   e_pre_skip:
                    cvterr = i_space_unit( p, curr, &layout_work.xmp.pre_skip );
                    break;
                case   e_post_skip:
                    cvterr = i_space_unit( p, curr, &layout_work.xmp.post_skip );
                    break;
                case   e_spacing:
                    cvterr = i_int8( p, curr, &layout_work.xmp.spacing );
                    break;
                case   e_font:
                    cvterr = i_font_number( p, curr, &layout_work.xmp.font );
                    if( layout_work.xmp.font >= wgml_font_cnt ) {
                        layout_work.xmp.font = 0;
                    }
                    break;
                default:
                    out_msg( "WGML logic error.\n");
                    cvterr = true;
                    break;
                }
                if( cvterr ) {          // there was an error
                    err_count++;
                    g_err( err_att_val_inv );
                    file_mac_info();
                }
                break;                  // break out of for loop
            }
        }
        if( cvterr < 0 ) {
            err_count++;
            g_err( err_att_name_inv );
            file_mac_info();
        }
        cc = get_lay_sub_and_value( &l_args );  // get one with value
    }
    scan_start = scan_stop;
    return;
}
示例#22
0
void    scr_gt( void )
{
    char        *   p;
    char        *   pn;
    char            savetag;
    int             k;
    int             len;
    char            macname[MAC_NAME_LENGTH + 1];
    condcode        cc;
    gtentry     *   wk;
    gtflags         tag_flags;
    enum {
        f_add       = 1,
        f_change,
        f_delete,
        f_off,
        f_on,
        f_print
    } function;

    garginit();                         // find end of CW

    /***********************************************************************/
    /*  isolate tagname   or use previous if tagname *                     */
    /***********************************************************************/

    cc = getarg();                      // Tagname

    if( cc == omit ) {
        // no operands
        tag_name_missing_err();
        return;
    }

    p = tok_start;

    if( *p == '*' ) {                   // single * as tagname
        if( arg_flen > 1 ) {
            xx_err( err_tag_name_inv );
            return;
        }
        savetag = '*';         // remember for possible global delete / print
        if( GlobalFlags.firstpass && input_cbs->fmflags & II_research ) {
            if( tag_entry != NULL ) {
                out_msg("  using tagname %s %s\n", tagname, tag_entry->name );
            }
        }
    } else {
        savetag = ' ';               // no global function for delete / print

        init_tag_att();            // forget previous values for quick access
        attname[0] = '*';

        pn      = tagname;
        len     = 0;

        while( *p && is_macro_char( *p ) ) {
            if( len < TAG_NAME_LENGTH ) {
                *pn++ = tolower( *p++ );// copy lowercase tagname
                *pn   = '\0';
            } else {
                break;
            }
            len++;
        }
        for( k = len; k < TAG_NAME_LENGTH; k++ ) {
            tagname[k] = '\0';
        }
        tagname[TAG_NAME_LENGTH] = '\0';

        if( len < arg_flen ) {
            xx_err( err_tag_name_inv );
            return;
        }
    }


    /***********************************************************************/
    /* get function operand  add, change, ...                              */
    /***********************************************************************/

    cc = getarg();

    if( cc == omit ) {
        xx_err( err_tag_func_inv );
        return;
    }

    p = tok_start;
    function = 0;
    switch( tolower( *p ) ) {
    case   'a':
        if( !strnicmp( "ADD ", p, 4 ) ) {

            function = f_add;
        }
        break;
    case 'c' :
        if( (arg_flen > 2) && (arg_flen < 7)
            && !strnicmp( "CHANGE", p, arg_flen ) ) {

            function = f_change;
        }
        break;
    case 'o' :
        if( !strnicmp( "OFF", p, 3 ) ) {

            function = f_off;
        } else {
            if( !strnicmp( "ON", p, 2 ) ) {

                function = f_on;
            }
        }
        break;
    case 'd' :
        if( (arg_flen > 2) && (arg_flen < 7)
            && !strnicmp( "DELETE", p, arg_flen ) ) {

            function = f_delete;
        }
        break;
    case 'p' :
        if( (arg_flen > 1) && (arg_flen < 6)
            && !strnicmp( "PRINT", p, arg_flen ) ) {

            function = f_print;
        }
        break;
    default:
        // nothing
        break;
    }
    if( function == 0 ) {               // no valid function specified
        xx_err( err_tag_func_inv );
        return;
    }

    cc = getarg();                      // get possible next parm

    /***********************************************************************/
    /*  for add and change    get macroname                                */
    /***********************************************************************/

    if( function == f_add || function == f_change ) {   // need macroname
        if( cc == omit ) {
            xx_err( err_tag_mac_name );
            return;
        }
        p = tok_start;

        pn      = macname;
        len     = 0;

        while( *p && is_macro_char( *p ) ) {
            if( len < MAC_NAME_LENGTH ) {
                *pn++ = tolower( *p++ );    // copy lowercase macroname
                *pn   = '\0';
            } else {
                break;
            }
            len++;
        }
        for( k = len; k < MAC_NAME_LENGTH; k++ ) {
            macname[k] = '\0';
        }
        macname[MAC_NAME_LENGTH] = '\0';

        tag_flags = 0;

        if( function == f_add ) {       // collect tag options
            cc = scan_tag_options( &tag_flags );
            if( cc != omit ) {          // not all processed error
               xx_err( err_tag_opt_inv );
            }
            tag_entry = add_tag( &tag_dict, tagname, macname, tag_flags );  // add to dictionary
            // if tag_entry is now NULL, error (+ msg) was output in add_tag
        } else {                        // is function change
            tag_entry = change_tag( &tag_dict, tagname, macname );
        }
    } else {

    /***********************************************************************/
    /*  after delete, off, on, print nothing allowed                       */
    /***********************************************************************/

        if( cc != omit ) {
            xx_err( err_tag_toomany );  // nothing more allowed
        }

        switch( function ) {
        case f_print :
            if( savetag == '*' ) {
                print_tag_dict( tag_dict );
            } else {
                print_tag_entry( find_tag( &tag_dict, tagname ) );
            }
            break;
        case f_delete :
            if( savetag == '*' ) {
                free_tag_dict( &tag_dict );
            } else {
                free_tag( &tag_dict, find_tag( &tag_dict, tagname ) );
            }
            break;
        case f_off :
            if( savetag == '*' && tag_entry != NULL ) {// off for last defined
                tag_entry->tagflags |= tag_off;
            } else {
                wk = find_tag( &tag_dict, tagname );
                if( wk != NULL ) {
                    wk->tagflags |= tag_off;
                }
            }
            break;
        case f_on :
            if( savetag == '*' && tag_entry != NULL ) {// on for last defined
                tag_entry->tagflags |= tag_off;
            } else {
                wk = find_tag( &tag_dict, tagname );
                if( wk != NULL ) {
                    wk->tagflags &= ~tag_off;
                }
            }
            break;
        default:
            break;
        }
    }
    scan_restart = scan_stop +1;
    return;
}
示例#23
0
static void update_message_received (struct tgl_state *TLS, struct tgl_message *M) {
  debug ("received message\n");
  telegram_conn *conn = TLS->ev_base;
  conn->updated = 1;

  if (M->service) {
    debug ("service message, skipping...\n");
    char *text = format_service_msg (TLS, M);
    if (text) {
      switch (tgl_get_peer_type (M->to_id)) {
        case TGL_PEER_CHAT:
          chat_add_message (TLS, M, text);
          break;
          
        case TGL_PEER_USER:
          p2tgl_got_im (TLS, M->from_id, text, PURPLE_MESSAGE_SYSTEM, M->date);
          break;
      }
      g_free (text);
    }
    conn->updated = 1;
    return;
  }
  
  if ((M->flags & (FLAG_MESSAGE_EMPTY | FLAG_DELETED)) || !(M->flags & FLAG_CREATED)) {
    return;
  }
  if (!tgl_get_peer_type (M->to_id)) {
    warning ("Bad msg\n");
    return;
  }

  if (M->media.type == tgl_message_media_photo) {
    tgl_do_load_photo (TLS, &M->media.photo, on_message_load_photo, M);
    return;
  }

  if (!M->message) {
    return;
  }

  char *text = purple_markup_escape_text (M->message, strlen (M->message));
  switch (tgl_get_peer_type (M->to_id)) {
    case TGL_PEER_CHAT:
      debug ("PEER_CHAT\n");
      if (!our_msg(TLS, M)) {
        chat_add_message (TLS, M, text);
      }
      break;
      
    case TGL_PEER_USER:
      debug ("PEER_USER\n");
      
      // p2tgl_got_im (TLS, M->to_id, text, PURPLE_MESSAGE_SEND, M->date);
      // :TODO: figure out how to add messages from different devices to history
      if (!our_msg(TLS, M)) {
        if (out_msg(TLS, M)) {
          p2tgl_got_im (TLS, M->to_id, text, PURPLE_MESSAGE_SEND, M->date);
        } else {
          p2tgl_got_im (TLS, M->from_id, text, PURPLE_MESSAGE_RECV, M->date);
        }
      }
      break;
      
    case TGL_PEER_ENCR_CHAT:
      break;
      
    case TGL_PEER_GEO_CHAT:
      break;
  }
  
  g_free (text);
}
示例#24
0
/* ifcompare compare if condition as numeric integer or string
 *           depending whether both terms are integers
 *
 */
static bool ifcompare( termcb * t1, relop r, termcb * t2 )
{
    bool        result;
    long        term1;
    long        term2;

    term1 = t1->term_number;            // assume integers
    term2 = t2->term_number;

    if( !t1->numeric || !t2->numeric ) { // string compare
        char    *   p1 = t1->term_string;
        char    *   p2 = t2->term_string;
        size_t      length;

        length = t1->term_length;
        if( length > t2->term_length )
            length = t2->term_length;
        while( length > 0 ) {           // try to find a difference
            if( *p1 != *p2 ) {
                break;                  // found
            } else {
                p1++;
                p2++;
            }
            --length;
        }

        term1 = *p1;                    // unequal chars or
        term2 = *p2;                    // corresponding chars of shorter string

        if( length == 0 ) {             // compared parts are equal
            if( t1->term_length == t2->term_length ) {
                term1 = term2;              // make compare equal true
            } else {
                if( t1->term_length < t2->term_length ) {
                    term1 = LONG_MIN;       // shorter is smaller
                } else {
                    term2 = LONG_MIN;
                }
            }
        }
    }

    switch( r ) {                       // now set compare result
    case  EQ :
        result = (term1 == term2);
        break;
    case  NE :
        result = (term1 != term2);
        break;
    case  LT :
        result = (term1 <  term2);
        break;
    case  GT :
        result = (term1 >  term2);
        break;
    case  LE :
        result = (term1 <= term2);
        break;
    case  GE :
        result = (term1 >= term2);
        break;

    default:
        result = false;
        if( input_cbs->fmflags & II_tag_mac ) {
            out_msg( "ERR_ifcompare internal logic error\n"
                     "\t\t\tLine %d of macro '%s'\n",
                     input_cbs->s.m->lineno, input_cbs->s.m->mac->name );
        } else {
            out_msg( "ERR_ifcompare internal logic error\n"
                     "\t\t\tLine %d of file '%s'\n",
                     input_cbs->s.f->lineno, input_cbs->s.f->filename );
        }
        show_include_stack();
        err_count++;
        break;
    }
    return( result );
}
示例#25
0
void    lay_abspref( lay_tag ltag )
{
    char            *   p;
    condcode            cc;
    int                 k;
    lay_att             curr;
    att_args            l_args;
    int                 cvterr;
    lay_sub             x_tag;
    abspref_lay_tag *   ap;

    p = scan_start;
    cvterr = false;

    if( !GlobalFlags.firstpass ) {
        scan_start = scan_stop;
        eat_lay_sub_tag();
        return;                         // process during first pass only
    }
    switch( ltag ) {
    case LAY_TAG_ABSTRACT:
        x_tag = el_abstract;
        ap = &layout_work.abstract;
        break;
    case LAY_TAG_PREFACE:
        x_tag = el_preface;
        ap = &layout_work.preface;
        break;
    default:
        out_msg( "WGML logic error glabsprf.c.\n");
        file_mac_info();
        err_count++;
        break;
    }
    if( ProcFlags.lay_xxx != x_tag ) {
        ProcFlags.lay_xxx = x_tag;
    }
    cc = get_lay_sub_and_value( &l_args );  // get att with value
    while( cc == pos ) {
        cvterr = -1;
        for( k = 0, curr = abspref_att[k]; curr > 0; k++, curr = abspref_att[k] ) {

            if( !strnicmp( att_names[curr], l_args.start[0], l_args.len[0] ) ) {
                p = l_args.start[1];

                switch( curr ) {
                case   e_post_skip:
                    cvterr = i_space_unit( p, curr, &(ap->post_skip) );
                    break;
                case   e_pre_top_skip:
                    cvterr = i_space_unit( p, curr, &(ap->pre_top_skip) );
                    break;
                case   e_font:
                    cvterr = i_font_number( p, curr, &(ap->font) );
                    if( ap->font >= wgml_font_cnt ) ap->font = 0;
                    break;
                case   e_spacing:
                    cvterr = i_int8( p, curr, &(ap->spacing) );
                    break;
                case   e_header:
                    cvterr = i_yes_no( p, curr, &(ap->header) );
                    break;
                case   e_abstract_string:
                    if( x_tag == el_abstract ) {
                        cvterr = i_xx_string( p, curr, ap->string );
                    }
                    break;
                case   e_preface_string:
                    if( x_tag == el_preface ) {
                        cvterr = i_xx_string( p, curr, ap->string );
                    }
                    break;
                case   e_page_eject:
                    cvterr = i_page_eject( p, curr, &(ap->page_eject) );
                    break;
                case   e_page_reset:
                    cvterr = i_yes_no( p, curr, &(ap->page_reset) );
                    break;
                case   e_columns:
                    cvterr = i_int8( p, curr, &(ap->columns) );
                    break;
                default:
                    out_msg( "WGML logic error.\n");
                    cvterr = true;
                    break;
                }
                if( cvterr ) {          // there was an error
                    err_count++;
                    g_err( err_att_val_inv );
                    file_mac_info();
                }
                break;                  // break out of for loop
            }
        }
        if( cvterr < 0 ) {
            err_count++;
            g_err( err_att_name_inv );
            file_mac_info();
        }
        cc = get_lay_sub_and_value( &l_args );  // get one with value
    }
    scan_start = scan_stop;
    return;
}
示例#26
0
static void tgp_msg_display (struct tgl_state *TLS, struct tgp_msg_loading *C) {
  connection_data *conn = TLS->ev_base;
  struct tgl_message *M = C->msg;
  char *text = NULL;
  int flags = 0;
  
  // Filter message updates and deletes, are not created and
  // all messages in general that were already displayed, or shouldn't be displayed
  if ((M->flags & (FLAG_MESSAGE_EMPTY | FLAG_DELETED)) ||
      !(M->flags & FLAG_CREATED) ||
      !M->message ||
      our_msg (TLS, M) ||
      !tgl_get_peer_type (M->to_id)) {
    return;
  }
  
  
  if (M->service) {
    text = format_service_msg (TLS, M);
    flags |= PURPLE_MESSAGE_SYSTEM;
  }
  else if (M->media.type == tgl_message_media_document) {
    char *who = p2tgl_strdup_id (M->from_id);
    if (! out_msg(TLS, M)) {
      tgprpl_recv_file (conn->gc, who, &M->media.document);
    }
    g_free (who);
    return;
  }
  else if (M->media.type == tgl_message_media_document_encr) {
    char *who = p2tgl_strdup_id (M->from_id);
    if (! out_msg(TLS, M)) {
      tgprpl_recv_encr_file (conn->gc, who, &M->media.encr_document);
    }
    g_free (who);
  }
  else if (M->media.type == tgl_message_media_photo) {
    char *filename = C->data;
    int imgStoreId = p2tgl_imgstore_add_with_id (filename);
    if (imgStoreId <= 0) {
      failure ("Cannot display picture message, adding to imgstore failed.");
      return;
    }
    used_images_add (conn, imgStoreId);
    text = format_img_full (imgStoreId);
    flags |= PURPLE_MESSAGE_IMAGES;
  }
  else {
    text = format_message (M);
    flags |= PURPLE_MESSAGE_RECV;
  }
  
  
  if (! text || ! *text) {
    warning ("No text to display");
    return;
  }
  switch (tgl_get_peer_type (M->to_id)) {
    case TGL_PEER_CHAT: {
      if (chat_show (conn->gc, tgl_get_peer_id (M->to_id))) {
        p2tgl_got_chat_in (TLS, M->to_id, M->from_id, text, flags, M->date);
      }
      pending_reads_add (conn->pending_reads, M->to_id);
      break;
    }
    case TGL_PEER_ENCR_CHAT: {
      p2tgl_got_im (TLS, M->to_id, text, flags, M->date);
      pending_reads_add (conn->pending_reads, M->to_id);
      break;
    }
    case TGL_PEER_USER: {
      if (out_msg (TLS, M)) {
        flags |= PURPLE_MESSAGE_SEND;
        flags &= ~PURPLE_MESSAGE_RECV;
        p2tgl_got_im_combo (TLS, M->to_id, text, flags, M->date);
      } else {
        p2tgl_got_im (TLS, M->from_id, text, flags, M->date);
        pending_reads_add (conn->pending_reads, M->from_id);
      }
      break;
    }
  }
  
  
  if (p2tgl_status_is_present (purple_account_get_active_status (conn->pa))) {
    pending_reads_send_all (conn->pending_reads, conn->TLS);
  }

  
  g_free (text);
}
示例#27
0
static void g_msg_var( msg_ids errornum, int sev, va_list arglist )
/*****************************************************************/
{
    bool                supp_line = false;
    int                 len;
    const char      *   prefix;
    char            *   save;
    char            *   start;
    char            *   end;

    switch( sev ) {
#if 0
    case SEV_INFO:
        prefix = "Info:";
        break;
#endif
    case SEV_WARNING:
        prefix = "Warning!";
        msg_indent = 0;
        break;
    case SEV_ERROR:
        prefix = "Error!";
        msg_indent = 0;
        break;
    case SEV_FATAL_ERR:
        prefix = "Fatal Error!";
        msg_indent = 0;
        break;
    default:
        prefix = "";
        supp_line = true;
        break;
    }

    switch( errornum ) {
    case ERR_STR_NOT_FOUND:
        /* this message means the error strings cannot be obtained from
         * the exe so its text is hard coded */
        sprintf( err_buf, "%s %d: %nResource strings not found", prefix,
                    errornum, &len );
        break;
    case ERR_DUMMY:
        /* dont print anything */
        return;
    default:
        get_msg( errornum, err_buf, sizeof( err_buf ) );
        vsprintf( str_buf, err_buf, arglist );
        if( *prefix == '\0' ) {
            // no prefix and errornumber
            sprintf( err_buf, "%n%s", &len, str_buf );
        } else {
            sprintf( err_buf, "%s %d: %n%s", prefix, errornum, &len, str_buf );
        }
        break;
    }

    if( !supp_line ) {    // save points to the ":" or is NULL
        save = strchr( err_buf, ':' );
    }

    start = err_buf;
    if( supp_line ) {
        if( (msg_indent > 0) && (start[0] == '\t') ) {
            start++;    // skip initial tab in favor of msg_indent
        }
        out_msg( "%*s%s\n", msg_indent, "", start );
    } else {
        while( strlen( start ) > MAX_LINE_LEN - msg_indent ) {
            end = start + MAX_LINE_LEN - msg_indent;
            while( !isspace( *end ) && end > start ) end--;
            if( end != start )  {
                *end = '\0';
            } else {
                break;
            }
            out_msg( "%*s%s\n", msg_indent, "", start );
            start = end + 1;
            msg_indent = len;
        }
        out_msg( "%*s%s\n", msg_indent, "", start );
        if( save != NULL ) {    // set msg_indent for follow-on line
            save++;             // step over the ":"
            while( isspace( *save ) ) save++;   // step over any spaces
            msg_indent = save - err_buf;
        }
    }
}
示例#28
0
void    scr_do( void )
{
    ifcb    *   cb = input_cbs->if_cb;
    condcode    cc;

    scan_err = false;
    garginit();                         // find end of control word
    cc = getarg();

    cb->if_flags[cb->if_level].ifcwdo = false;
    if( cc == omit || !strnicmp( tok_start, "begin", 5 )) {

        if( !(cb->if_flags[cb->if_level].ifthen
              || cb->if_flags[cb->if_level].ifelse)
            || cb->if_flags[cb->if_level].ifdo ) {

            scan_err = true;
            g_err( err_if_do );
            g_info_inp_pos();
            show_ifcb( "dobegin", cb );
            show_include_stack();
            err_count++;
            return;
        }
        cb->if_flags[cb->if_level].ifdo = true;
        if( input_cbs->fmflags & II_research && GlobalFlags.firstpass ) {
            show_ifcb( "dobegin", cb );
        }
        scan_restart = scan_stop;
        return;
    } else {
        if( !strnicmp( tok_start, "end", 3 )) {
            if( input_cbs->fmflags & II_research && GlobalFlags.firstpass ) {
                show_ifcb( "doend", cb );
            }
            do {                            // loop for last active .do begin

                if( cb->if_flags[cb->if_level].ifdo ) {

                    cb->if_flags[cb->if_level].ifdo = false;
                    if( input_cbs->fmflags & II_research &&
                        GlobalFlags.firstpass ) {
                        show_ifcb( "doend", cb );
                    }
                    scan_restart = scan_stop;
                    return;
                }
                if( cb->if_flags[cb->if_level].ifthen
                    || cb->if_flags[cb->if_level].ifelse
                    || !(cb->if_flags[cb->if_level].iftrue
                         || cb->if_flags[cb->if_level].iffalse) ) {

                    scan_err = true;
                    g_err( err_if_do_end );
                    g_info_inp_pos();
                    show_ifcb( "doend", cb );
                    show_include_stack();
                    err_count++;
                    return;
                }

            } while( cb->if_level-- > 0 );
#if 0
            if( input_cbs->fmflags & II_research && GlobalFlags.firstpass ) {
                out_msg( "\t.do end Level %d\n"
                         "\t.ifcb iftrue %d, iffalse %d\n",
                         cb->if_level,
                         cb->if_flags[cb->if_level].iftrue,
                         cb->if_flags[cb->if_level].iffalse );
            }
#endif
        } else {
            scan_err = true;
            g_err( err_if_do_fun );
            g_info_inp_pos();
            show_include_stack();
            err_count++;
            return;
        }
    }
    if( input_cbs->fmflags & II_research && GlobalFlags.firstpass ) {
        show_ifcb( "do xx", cb );
    }
    scan_restart = scan_stop;
    return;
}
示例#29
0
void    lay_page( lay_tag ltag )
{
    char        *   p;
    condcode        cc;
    int             k;
    lay_att         curr;
    att_args        l_args;
    int             cvterr;

    ltag = ltag;
    p = scan_start;
    cvterr = false;

    if( !GlobalFlags.firstpass ) {
        scan_start = scan_stop;
        eat_lay_sub_tag();
        return;                         // process during first pass only
    }
    if( ProcFlags.lay_xxx != el_page ) {
        ProcFlags.lay_xxx = el_page;
    }
    cc = get_lay_sub_and_value( &l_args );  // get one with value
    while( cc == pos ) {
        cvterr = -1;
        for( k = 0, curr = page_att[k]; curr > 0; k++, curr = page_att[k] ) {

            if( !strnicmp( att_names[curr], l_args.start[0], l_args.len[0] ) ) {
                p = l_args.start[1];

                switch( curr ) {
                case   e_top_margin:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.page.top_margin );
                    break;
                case   e_left_margin:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.page.left_margin );
                    break;
                case   e_right_margin:
                    cvterr = i_space_unit( p, curr,
                                           &layout_work.page.right_margin );
                    break;
                case   e_depth:
                    cvterr = i_space_unit( p, curr, &layout_work.page.depth );
                    break;
                default:
                    out_msg( "WGML logic error.\n");
                    cvterr = true;
                    break;
                }
                if( cvterr ) {          // there was an error
                    err_count++;
                    g_err( err_att_val_inv );
                    file_mac_info();
                }
                break;                  // break out of for loop
            }
        }
        if( cvterr < 0 ) {
            err_count++;
            g_err( err_att_name_inv );
            file_mac_info();
        }
        cc = get_lay_sub_and_value( &l_args );  // get one with value
    }
    scan_start = scan_stop;
    return;
}
示例#30
0
void    lay_appendix( const gmltag * entry )
{
    char            *   p;
    condcode            cc;
    int                 k;
    lay_att             curr;
    att_args            l_args;
    int                 cvterr;

    p = scan_start;
    cvterr = false;

    if( !GlobalFlags.firstpass ) {
        scan_start = scan_stop + 1;
        eat_lay_sub_tag();
        return;                         // process during first pass only
    }
    if( ProcFlags.lay_xxx != el_appendix ) {
        ProcFlags.lay_xxx = el_appendix;
    }
    cc = get_lay_sub_and_value( &l_args );  // get att with value
    while( cc == pos ) {
        cvterr = -1;
        for( k = 0, curr = appendix_att[k]; curr > 0; k++, curr = appendix_att[k] ) {

            if( !strnicmp( att_names[curr], l_args.start[0], l_args.len[0] ) ) {
                p = l_args.start[1];

                switch( curr ) {
                case   e_indent:
                    cvterr = i_space_unit( p, curr,
                                    &layout_work.hx.hx_head[hds_appendix].indent );
                    break;
                case   e_pre_top_skip:
                    cvterr = i_space_unit( p, curr,
                                &layout_work.hx.hx_sect[hds_appendix].pre_top_skip );
                    break;
                case   e_pre_skip:
                    cvterr = i_space_unit( p, curr,
                                    &layout_work.hx.hx_head[hds_appendix].pre_skip );
                    break;
                case   e_post_skip:
                    cvterr = i_space_unit( p, curr,
                                    &layout_work.hx.hx_sect[hds_appendix].post_skip );
                    break;
                case   e_spacing:
                    cvterr = i_int8( p, curr,
                                    &layout_work.hx.hx_sect[hds_appendix].spacing );
                    break;
                case   e_font:
                    cvterr = i_font_number( p, curr,
                                        &layout_work.hx.hx_sect[hds_appendix].text_font );
                    if( layout_work.hx.hx_sect[hds_appendix].text_font >= wgml_font_cnt ) {
                        layout_work.hx.hx_sect[hds_appendix].text_font = 0;
                    }
                    break;
                case   e_number_font:
                    cvterr = i_font_number( p, curr,
                                &layout_work.hx.hx_head[hds_appendix].number_font );
                    if( layout_work.hx.hx_head[hds_appendix].number_font >= wgml_font_cnt ) {
                        layout_work.hx.hx_head[hds_appendix].number_font = 0;
                    }
                    break;
                case   e_number_form:
                    cvterr = i_number_form( p, curr,
                                &layout_work.hx.hx_head[hds_appendix].number_form );
                    break;
                case   e_page_position:
                    cvterr = i_page_position( p, curr,
                                &layout_work.hx.hx_head[hds_appendix].line_position );
                    break;
                case   e_number_style:
                    cvterr = i_number_style( p, curr,
                                &layout_work.hx.hx_head[hds_appendix].number_style );
                    break;
                case   e_page_eject:
                    cvterr = i_page_eject( p, curr,
                                &layout_work.hx.hx_head[hds_appendix].page_eject );
                    break;
                case   e_line_break:
                    cvterr = i_yes_no( p, curr,
                                &layout_work.hx.hx_head[hds_appendix].line_break );
                    break;
                case   e_display_heading:
                    cvterr = i_yes_no( p, curr,
                            &layout_work.hx.hx_head[hds_appendix].display_heading );
                    break;
                case   e_number_reset:
                    cvterr = i_yes_no( p, curr,
                                &layout_work.hx.hx_head[hds_appendix].number_reset );
                    break;
                case   e_case:
                    cvterr = i_case( p, curr,
                                     &layout_work.hx.hx_head[hds_appendix].hd_case );
                    break;
                case   e_align:
                    cvterr = i_space_unit( p, curr,
                                        &layout_work.hx.hx_head[hds_appendix].align );
                    break;
                case   e_header:
                    cvterr = i_yes_no( p, curr,
                                       &layout_work.hx.hx_sect[hds_appendix].header );
                    break;
                case   e_appendix_string:
                    cvterr = i_xx_string( p, curr, &layout_work.appendix.string );
                    break;
                case   e_page_reset:
                    cvterr = i_yes_no( p, curr, &layout_work.appendix.page_reset );
                    break;
                case   e_section_eject:
                    cvterr = i_page_eject( p, curr,
                                                &layout_work.appendix.section_eject );
                    break;
                case   e_columns:
                    cvterr = i_int8( p, curr, &layout_work.appendix.columns );
                    break;
                default:
                    out_msg( "WGML logic error.\n");
                    cvterr = true;
                    break;
                }
                if( cvterr ) {          // there was an error
                    err_count++;
                    g_err( err_att_val_inv );
                    file_mac_info();
                }
                break;                  // break out of for loop
            }
        }
        if( cvterr < 0 ) {
            err_count++;
            g_err( err_att_name_inv );
            file_mac_info();
        }
        cc = get_lay_sub_and_value( &l_args );  // get att with value
    }
    scan_start = scan_stop + 1;
    return;
}