Esempio n. 1
0
bool    free_resources( errno_t in_errno )
{
    if( in_errno == ENOMEM) g_err( err_no_memory );
    else g_err( err_no_handles );
    err_count++;
    return( false );
}
Esempio n. 2
0
uschar *
tls_cert_ext_by_oid(void * cert, uschar * oid, int idx)
{
    uschar * cp1 = NULL;
    uschar * cp2;
    uschar * cp3;
    size_t siz = 0;
    unsigned int crit;
    int ret;

    ret = gnutls_x509_crt_get_extension_by_oid ((gnutls_x509_crt_t)cert,
            oid, idx, cp1, &siz, &crit);
    if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
        return g_err("ge0", __FUNCTION__, ret);

    cp1 = store_get(siz*4 + 1);

    ret = gnutls_x509_crt_get_extension_by_oid ((gnutls_x509_crt_t)cert,
            oid, idx, cp1, &siz, &crit);
    if (ret < 0)
        return g_err("ge1", __FUNCTION__, ret);

    /* binary data, DER encoded */

    /* just dump for now */
    for(cp3 = cp2 = cp1+siz; cp1 < cp2; cp3 += 3, cp1++)
        sprintf(cp3, "%.2x ", *cp1);
    cp3[-1]= '\0';

    return cp2;
}
Esempio n. 3
0
static  bool    free_inc_fp( void )
{
    inputcb *   ip;
    filecb  *   cb;
    int         rc;

    ip = input_cbs;
    while( ip != NULL ) {              // as long as input stack is not empty
        if( ip->fmflags & II_file ) {   // if file (not macro)
            if( (cb = ip->s.f) != NULL ) {
                if( (cb->flags & FF_open) ) {   // and file is open
                    rc = fgetpos( cb->fp, &cb->pos );
                    if( rc != 0 ) {
                        strerror_s( buff2, buf_size, errno );
                        g_err( err_file_io, buff2, cb->filename );
                        err_count++;
                        g_suicide();
                    }
                    rc = fclose( cb->fp );
                    if( rc != 0 ) {
                        strerror_s( buff2, buf_size, errno );
                        g_err( err_file_io, buff2, cb->filename );
                        err_count++;
                        g_suicide();
                    }
                    cb->flags &= ~FF_open;
                    return( true );
                }
            }
        }
        ip = ip->prev;                  // next higher input level
    }
    return( false );                    // nothing to close
}
Esempio n. 4
0
static void reopen_inc_fp( filecb *cb )
{
    int         rc;
    errno_t     erc;
    errno_t     erc2;

    if( ! cb->flags & FF_open ) {
        for( ;; ) {
            erc = fopen_s( &cb->fp, cb->filename, "rb" );
            if( erc == 0 ) break;
            erc2 = errno;
            if( errno != ENOMEM && errno != ENFILE && errno != EMFILE ) break;
            if( !free_inc_fp() ) break; // try closing an include file
        }
        if( erc == 0 ) {
            rc = fsetpos( cb->fp, &cb->pos );
            if( rc != 0 ) {
                strerror_s( buff2, buf_size, errno );
                g_err( err_file_io, buff2, cb->filename );
                err_count++;
                g_suicide();
            }
            cb->flags |= FF_open;
        } else {
            strerror_s( buff2, buf_size, erc2 );
            g_err( err_file_io, buff2, cb->filename );
            err_count++;
            g_suicide();
        }
    }
    return;
}
Esempio n. 5
0
void    lay_widow( lay_tag ltag )
{
    char        *   p;
    condcode        cc;
    int             k;
    lay_att         curr;
    att_args        l_args;
    int             cvterr;

    ltag = 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_widow ) {
        ProcFlags.lay_xxx = el_widow;
    }
    cc = get_lay_sub_and_value( &l_args );  // get one with value
    while( cc == pos ) {
        cvterr = -1;
        for( k = 0, curr = widow_att[k]; curr > 0; k++, curr = widow_att[k] ) {

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

                switch( curr ) {
                case   e_threshold:
                    cvterr = i_uint8( p, curr, &layout_work.widow.threshold );
                    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;
}
Esempio n. 6
0
void    val_parse_err( const char * pa, bool tag )
{
    err_count++;
    if( tag ) {
        g_err( err_inv_att_val );
    } else {
        g_err( err_inv_cw_op_val );
    }
    file_mac_info();
    show_line_error( pa );
    return;
}
Esempio n. 7
0
void    numb_err( void )
{
    char    linestr[MAX_L_AS_STR];

    err_count++;
    if( input_cbs->fmflags & II_macro ) {
        ultoa( input_cbs->s.m->lineno, linestr, 10 );
        g_err( ERR_PU_NUM, linestr, "macro", input_cbs->s.m->mac->name );
    } else {
        ultoa( input_cbs->s.f->lineno, linestr, 10 );
        g_err( ERR_PU_NUM, linestr, "file", input_cbs->s.f->filename );
    }
    show_include_stack();
    return;
}
Esempio n. 8
0
void insert_page_width( doc_element * a_element )
{
    uint32_t    depth;

    /* depth is used to update t_page.cur_depth and so must be kept separate */

    if( !ProcFlags.page_started ) {
        depth = a_element->top_skip;
        ProcFlags.page_started = true;
    } else {
        depth = a_element->subs_skip;
    }
    depth += a_element->depth;

    /****************************************************************/
    /*  Does the first line minimum apply here? If so, it needs to  */
    /*  be implemented. Note that cur_el->depth does not reflect it */
    /*  because there is no way to tell if it will apply when the   */
    /*  is computed.                                                */
    /****************************************************************/

    switch( a_element->type ) {
    // TOP FIG processing goes here
    case el_text :                      // section heading: must go on t_page
        if( (depth + t_page.cur_depth) <= t_page.max_depth ) {
            if( t_page.page_width == NULL ) {   // must be empty
                t_page.page_width = a_element;
                t_page.last_col_main = t_page.page_width;
                t_page.cur_depth += depth;
                if( bin_driver->y_positive == 0 ) {
                    t_page.main_top -= depth;
                } else {
                    t_page.main_top += depth;
                }
            } else {        // discard second section heading
                g_err( err_intern, __FILE__, __LINE__ );
            }        
        } else {
            xx_err( err_heading_too_deep );
            g_suicide();    // it won't fit on any page if not on this
        }
        break;
    default:
        g_err( err_intern, __FILE__, __LINE__ );
    }

    return;
}
Esempio n. 9
0
void    gml_index( gml_tag gtag )
{
    gtag = gtag;
    if( ProcFlags.doc_sect_nxt == doc_sect_egdoc ) {
        xx_line_err( err_eof_expected, tok_start );
        return;
    }

    if( ProcFlags.doc_sect_nxt == doc_sect_index ) {// duplicate :INDEX tag

        scan_start = scan_stop;         // ignore this call
        return;                         // wgml4 OS/2 crashes with page fault
    }

    if( !((ProcFlags.doc_sect == doc_sect_backm) ||
          (ProcFlags.doc_sect_nxt == doc_sect_backm)) ) {
        xx_line_err( err_doc_sec_expected_1, tok_start );
        return;
    }
    if( !GlobalFlags.index ) {          // index option not active
        g_err( wng_index_opt );         // give hint to activate index
        scan_start = scan_stop;
        return;
    }
    gml_doc_xxx( doc_sect_index );

    gen_index();                        // output the formatted index

}
Esempio n. 10
0
void clear_doc_element( doc_element * element )
{
    doc_element *   cur_el;
    text_line   *   cur_line;
    text_line   *   save;

    for( cur_el = element; cur_el != NULL; cur_el = cur_el->next ) {
        switch( cur_el->type ) {
        case el_binc :
        case el_graph :
            break;      // should be nothing to do
        case el_text :
            cur_line = cur_el->element.text.first;
            while( cur_line != NULL ) {
                add_text_chars_to_pool( cur_line );
                save = cur_line->next;
                add_text_line_to_pool( cur_line );
                cur_line = save;
            }
            break;
        default :
            g_err( err_intern, __FILE__, __LINE__ );
        }
    }

    return;
}
Esempio n. 11
0
void    tag_name_missing_err( void )
{
    err_count++;
    g_err( err_missing_name, "" );
    file_mac_info();
    return;
}
Esempio n. 12
0
void    nottag_err( void )
{
    err_count++;
    g_err( err_user_tag, tagname );
    file_mac_info();
    return;
}
Esempio n. 13
0
void    parm_extra_err( char * cw, char * pa )
{
    err_count++;
    g_err( err_extra_ignored, cw, pa );
    file_mac_info();
    return;
}
Esempio n. 14
0
void    parm_miss_err( char *pa )
{
    err_count++;
    g_err( err_parm_missing, pa );
    file_mac_info();
    return;
}
Esempio n. 15
0
void    xx_tag_err( const msg_ids errid, char const * cw )
{
    err_count++;
    g_err( errid, cw );
    file_mac_info();
    return;
}
Esempio n. 16
0
bool    i_place( char * p, lay_att curr, bf_place * tm )
{
    bool        cvterr;

    curr = curr;
    cvterr = false;
    if( !strnicmp( "topeven", p, 7 ) ) {
        *tm = topeven_place;
    } else if( !strnicmp( "bottom", p, 6 ) ) {
        *tm = bottom_place;
    } else if( !strnicmp( "inline", p, 6 ) ) {
        *tm = inline_place;
    } else if( !strnicmp( "topodd", p, 6 ) ) {
        *tm = topodd_place;
    } else if( !strnicmp( "top", p, 3 ) ) {// check for top later than topXXX
        *tm = top_place;
    } else if( !strnicmp( "botodd", p, 6 ) ) {
        *tm = botodd_place;
    } else if( !strnicmp( "boteven", p, 7 ) ) {
        *tm = boteven_place;
    } else {
        err_count++;
        g_err( err_att_val_inv );
        file_mac_info();
        cvterr = true;
    }
    return( cvterr );
}
Esempio n. 17
0
bool    i_pouring( char * p, lay_att curr, reg_pour * tm )
{
    bool        cvterr;

    curr = curr;
    cvterr = false;
    if( !strnicmp( "none", p, 4 ) ) {
        *tm = no_pour;
    } else if( !strnicmp( "last", p, 4 ) ) {
        *tm = last_pour;
    } else if( !strnicmp( "head0", p, 5 ) ) {
        *tm = head0_pour;
    } else if( !strnicmp( "head1", p, 5 ) ) {
        *tm = head1_pour;
    } else if( !strnicmp( "head2", p, 5 ) ) {
        *tm = head2_pour;
    } else if( !strnicmp( "head3", p, 5 ) ) {
        *tm = head3_pour;
    } else if( !strnicmp( "head4", p, 5 ) ) {
        *tm = head4_pour;
    } else if( !strnicmp( "head5", p, 5 ) ) {
        *tm = head5_pour;
    } else if( !strnicmp( "head6", p, 5 ) ) {
        *tm = head6_pour;
    } else {
        err_count++;
        g_err( err_att_val_inv );
        file_mac_info();
        cvterr = true;
    }
    return( cvterr );
}
Esempio n. 18
0
static void g_err_doc_sect( doc_section  ds )
{
    static  char const  sect[14][9] =
        {                               // same sequence as doc_section enum
            "NONE",
            "GDOC",
            "FRONTM",
            "TITLEP",
            "eTITLEP",
            "ABSTRACT",
            "PREFACE",
            "TOC",
            "FIGLIST",
            "BODY",
            "APPENDIX",
            "BACKM",
            "INDEX",
            "eGDOC"
        };

    err_count++;
    scan_err = true;
    g_err( err_doc_sect, sect[ds] );
    file_mac_info();
}
Esempio n. 19
0
void    gml_sf( const gmltag * entry )
{
    char    *   p;
    char    *   pe;
    long        font;

    p = scan_start;
    p++;
    while( *p == ' ' ) {
        p++;
    }
    if( !strnicmp( "font=", p, 5 ) ) {
        p += 5;
        font = strtol( p, &pe, 10 );
        scan_start = pe;
        if( (font < 0) || (font >= wgml_font_cnt) ) {// invalid font use default
            font = 0;
        }
        gml_hp_sf_common( entry, font, t_SF );
    } else {
        err_count++;
        // AT-001 Required attribute not found
        g_err( err_att_missing );
        file_mac_info();
    }
    scan_start = scan_stop + 1;
    return;
}
Esempio n. 20
0
void    xx_err( const msg_ids errid )
{
    err_count++;
    g_err( errid );
    file_mac_info();
    return;
}
Esempio n. 21
0
static  void    get_macro_line( void )
{
    macrocb *   cb;

    if( input_cbs->fmflags & II_file ) {// current input is file not macro
        g_err( err_logic_mac );
        show_include_stack();
        err_count++;
        g_suicide();
    }
    cb = input_cbs->s.m;

    if( cb->macline == NULL ) {         // no more macrolines
        input_cbs->fmflags |= II_eof;
        input_cbs->fmflags &= ~(II_sol | II_eol);
        cb->flags          |= FF_eof;
        *buff2              = '\0';
    } else {
        cb->lineno++;
        cb->flags          &= ~FF_eof;
        input_cbs->fmflags &= ~II_eof;
        input_cbs->fmflags |= (II_sol | II_eol);
        strcpy_s( buff2, buf_size, cb->macline->value );
        cb->macline         = cb->macline->next;
    }
}
Esempio n. 22
0
doc_element * alloc_doc_el(  element_type type )
{
    doc_element *   curr;
    doc_element *   prev;
    int             k;

    curr = doc_el_pool;
    if( curr != NULL ) {                // there is one to use
        doc_el_pool = curr->next;
    } else {                            // pool is empty
        curr = mem_alloc( sizeof( doc_element ) );

        doc_el_pool = mem_alloc( sizeof( *prev ) );
        prev = doc_el_pool;
        for( k = 0; k < 10; k++ ) {     // alloc 10 doc_els if pool empty
            prev->next = mem_alloc( sizeof( *prev ) );
            prev = prev->next;
        }
        prev->next = NULL;
    }

    curr->next = NULL;
    curr->blank_lines = 0;
    curr->depth = 0;
    curr->subs_skip = 0;
    curr->top_skip = 0;
    curr->type = type;

    switch( type ) {
    case el_binc :
        curr->element.binc.cur_left = 0;
        curr->element.binc.depth = 0;
        curr->element.binc.y_address = 0;
        curr->element.binc.at_top = false;
        curr->element.binc.has_rec_type = false;
        curr->element.binc.file[0] = '\0';
        break;
    case el_graph :
        curr->element.graph.cur_left = 0;
        curr->element.graph.depth = 0;
        curr->element.graph.scale = 0;
        curr->element.graph.width = 0;
        curr->element.graph.y_address = 0;
        curr->element.graph.xoff = 0;
        curr->element.graph.yoff = 0;
        curr->element.graph.at_top = false;
        curr->element.graph.file[0] = '\0';
        break;
    case el_text :
        curr->element.text.overprint = false;
        curr->element.text.spacing = 0;
        curr->element.text.first = NULL;
        break;
    default :
        g_err( err_intern, __FILE__, __LINE__ );
    }

    return( curr );
}
Esempio n. 23
0
void    tag_text_req_err( char * tagname )
{
//****ERROR**** SC--039: Tag text must be specified with the 'xxx' tag
    err_count++;
    g_err( err_att_text_req, tagname );
    file_mac_info();
    return;
}
Esempio n. 24
0
uschar *
tls_cert_subject(void * cert, uschar * mod)
{
    uschar * cp = NULL;
    int ret;
    size_t siz = 0;

    if ((ret = gnutls_x509_crt_get_dn(cert, cp, &siz))
            != GNUTLS_E_SHORT_MEMORY_BUFFER)
        return g_err("gs0", __FUNCTION__, ret);

    cp = store_get(siz);
    if ((ret = gnutls_x509_crt_get_dn(cert, cp, &siz)) < 0)
        return g_err("gs1", __FUNCTION__, ret);

    return mod ? tls_field_from_dn(cp, mod) : cp;
}
Esempio n. 25
0
void    att_val_err( char * attname )
{
//****ERROR**** SC--045: Value 'xxx' for the 'yyy' attribute is not defined
    err_count++;
    g_err( err_att_val, token_buf, attname );
    file_mac_info();
    return;
}
Esempio n. 26
0
void    auto_att_err( void )
{
//****ERROR**** SC--041: Cannot specify the automatic attribute 'xxx'
    err_count++;
    g_err( err_auto_att, token_buf );
    file_mac_info();
    return;
}
Esempio n. 27
0
void    cw_err( void )
{
// SC--006: Unrecognized control word
    err_count++;
    g_err( err_cw_unrecognized, token_buf );
    file_mac_info();
    return;
}
Esempio n. 28
0
void    tag_text_err( char * tagname )
{
//****ERROR**** SC--038: Tag text may not be specified for the 'xxx' tag
    err_count++;
    g_err( err_att_text, tagname );
    file_mac_info();
    return;
}
Esempio n. 29
0
void    xx_line_err( const msg_ids errid, char *pa )
{
    err_count++;
    g_err( errid );
    file_mac_info();
    show_line_error( pa );
    return;
}
Esempio n. 30
0
void    xx_opt_err( char *cw, char *pa )
{
    err_count++;
    g_err( err_xx_opt, cw, pa );
    file_mac_info();
    show_line_error( pa );
    return;
}