Annotation of 43BSDReno/contrib/isode-beta/dsap/common/file_enc.c, revision 1.1.1.1

1.1       root        1: #include "quipu/util.h"
                      2: #include "quipu/attrvalue.h"
                      3: 
                      4: extern LLog * log_dsap;
                      5: 
                      6: PE grab_filepe (av)
                      7: AttributeValue av;
                      8: {
                      9: FILE * fptr;
                     10: struct file_syntax * fs;
                     11: sntx_table *tbl, * get_syntax_table();
                     12: PE ret_pe, grab_pe();
                     13: 
                     14: 
                     15:        fs = (struct file_syntax *) av->av_struct;
                     16: 
                     17:        if (fs->fs_attr != NULLAttrV)
                     18:                return (grab_pe (fs->fs_attr));
                     19: 
                     20:        if (fs->fs_name == NULLCP) 
                     21:                return (NULLPE);        /* should never happen */
                     22: 
                     23:        if ((fptr = fopen (fs->fs_name,"r")) != NULL) {
                     24:                tbl = get_syntax_table (fs->fs_real_syntax);
                     25:                if (tbl->s_parse == NULLIFP) { /* treat as pure asn */
                     26:                        PS fps;
                     27:                        fps = ps_alloc (std_open);
                     28:                        if ((std_setup (fps,fptr)) == NOTOK) {
                     29:                                (void) fclose (fptr);
                     30:                                ps_free (fps);
                     31:                                return (NULLPE);
                     32:                        }
                     33:                        if ((ret_pe = ps2pe (fps)) == NULLPE)
                     34:                                LLOG (log_dsap,LLOG_EXCEPTIONS,("invalid ASN if file %s",fs->fs_name));
                     35:                        (void) fclose (fptr);
                     36:                        ps_free (fps);
                     37:                } else {
                     38:                        char buffer [LINESIZE];
                     39:                        AttributeValue newav;
                     40:                        extern char * TidyString ();
                     41:        
                     42:                        (void) fread (buffer,LINESIZE,1,fptr);
                     43:                        (void) fclose (fptr);
                     44:                        if ((newav = str2AttrV (TidyString(buffer),fs->fs_real_syntax)) == NULLAttrV){
                     45:                                LLOG (log_dsap,LLOG_EXCEPTIONS,("invalid format in file %s",fs->fs_name));
                     46:                        }
                     47:                        ret_pe = grab_pe (newav);
                     48:                        AttrV_free (newav);
                     49:                }
                     50:        } else  {
                     51:                LLOG(log_dsap,LLOG_EXCEPTIONS,("Can't open %s",fs->fs_name));
                     52:                /* Return the PE containing NULL 
                     53:                /* a NULLPE will cause the encode to fail, thus make the
                     54:                /* operation fail.
                     55:                /* Real solution is to remove the attribute at the encode 
                     56:                /* stage - but that is tricky... 
                     57:                */
                     58: 
                     59:                return (pe_alloc (PE_CLASS_UNIV, PE_FORM_PRIM, PE_PRIM_NULL));
                     60:        }
                     61:        return (ret_pe);
                     62: 
                     63: }
                     64: 
                     65: 
                     66: file_decode (x)
                     67: AttributeValue x;
                     68: {
                     69: struct file_syntax * fs;
                     70: 
                     71:        fs = (struct file_syntax *) smalloc (sizeof(struct file_syntax));
                     72:        fs->fs_ref = 1;
                     73:        fs->fs_real_syntax = x->av_syntax - AV_WRITE_FILE;
                     74:        fs->fs_name = NULLCP;
                     75:        fs->fs_mode = FS_DEFAULT;
                     76: 
                     77:        fs->fs_attr = AttrV_alloc ();
                     78:        fs->fs_attr->av_syntax = x->av_syntax - AV_WRITE_FILE;
                     79:        fs->fs_attr->av_struct = x->av_struct;
                     80:                
                     81:        x->av_syntax = AV_FILE;
                     82:        x->av_struct = (caddr_t)fs;
                     83: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.