Annotation of 43BSDReno/contrib/isode-beta/quipu/entry_dump.c, revision 1.1

1.1     ! root        1: /* entry_dump.c - routines to dump the database */
        !             2: 
        !             3: #ifndef lint
        !             4: static char *rcsid = "$Header: /f/osi/quipu/RCS/entry_dump.c,v 7.0 89/11/23 22:17:31 mrose Rel $";
        !             5: #endif
        !             6: 
        !             7: /*
        !             8:  * $Header: /f/osi/quipu/RCS/entry_dump.c,v 7.0 89/11/23 22:17:31 mrose Rel $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       entry_dump.c,v $
        !            12:  * Revision 7.0  89/11/23  22:17:31  mrose
        !            13:  * Release 6.0
        !            14:  * 
        !            15:  */
        !            16: 
        !            17: /*
        !            18:  *                                NOTICE
        !            19:  *
        !            20:  *    Acquisition, use, and distribution of this module and related
        !            21:  *    materials are subject to the restrictions of a license agreement.
        !            22:  *    Consult the Preface in the User's Manual for the full terms of
        !            23:  *    this agreement.
        !            24:  *
        !            25:  */
        !            26: 
        !            27: 
        !            28: #include "quipu/util.h"
        !            29: #include "quipu/entry.h"
        !            30: #include <errno.h>
        !            31: #include "tailor.h"
        !            32: 
        !            33: extern LLog * log_dsap;
        !            34: extern RDN parse_rdn;
        !            35: extern char * new_version();
        !            36: 
        !            37: static header_print (psa,edb)
        !            38: PS psa;
        !            39: Entry edb;
        !            40: {
        !            41:        switch (edb->e_data) {
        !            42:                case E_DATA_MASTER:
        !            43:                        ps_print (psa,"MASTER\n");
        !            44:                        break;
        !            45:                case E_TYPE_SLAVE :
        !            46:                        ps_print (psa,"SLAVE\n");
        !            47:                        break;
        !            48:                default:
        !            49:                        ps_print (psa,"CACHE\n");
        !            50:                        break;
        !            51:                }
        !            52:        if (edb->e_parent != NULLENTRY)
        !            53:                ps_printf (psa,"%s\n",edb->e_parent->e_edbversion);
        !            54:        else
        !            55:                ps_printf (psa,"%s\n",new_version());
        !            56: }
        !            57: 
        !            58: static entry_print (psa,entryptr)
        !            59: PS psa;
        !            60: Entry entryptr;
        !            61: {
        !            62:        if (entryptr == NULLENTRY)
        !            63:                return;
        !            64: 
        !            65:        rdn_print (psa,entryptr->e_name,EDBOUT);
        !            66:        parse_rdn = entryptr->e_name;
        !            67:        ps_print (psa,"\n");
        !            68:        as_print (psa,entryptr->e_attributes,EDBOUT);
        !            69:        parse_rdn = NULLRDN;
        !            70: }
        !            71: 
        !            72: 
        !            73: static entry_block_print (psa,block)
        !            74: PS psa;
        !            75: Entry block;
        !            76: {
        !            77: Entry ptr;
        !            78: 
        !            79:        if (block != NULLENTRY) {
        !            80:                header_print (psa,block);
        !            81:                for ( ptr = block; ptr != NULLENTRY; ptr = ptr->e_sibling) {
        !            82:                        entry_print (psa,ptr);
        !            83:                ps_print (psa,"\n");
        !            84:                }
        !            85: 
        !            86:        }
        !            87: }
        !            88: 
        !            89: write_edb (ptr,filename)
        !            90: Entry ptr;
        !            91: char * filename;
        !            92: {
        !            93: int um;
        !            94: FILE * fptr;
        !            95: PS entryps;
        !            96: extern char * parse_file;
        !            97: extern int errno;
        !            98: 
        !            99:        um = umask (0177);
        !           100:        if ((fptr = fopen (filename,"w")) == (FILE *) NULL) {
        !           101:                LLOG (log_dsap,LLOG_EXCEPTIONS,("file_open failed: \"%s\" (%d)",filename,errno));
        !           102:                return NOTOK;
        !           103:        }
        !           104:        (void) umask (um);
        !           105: 
        !           106:        if ((entryps = ps_alloc (std_open)) == NULLPS) {
        !           107:                LLOG (log_dsap,LLOG_EXCEPTIONS,("ps_alloc failed"));
        !           108:                (void) fclose (fptr);
        !           109:                return NOTOK;
        !           110:        }
        !           111:        if (std_setup (entryps,fptr) == NOTOK) {
        !           112:                LLOG (log_dsap,LLOG_EXCEPTIONS,("std_setup failed"));
        !           113:                (void) fclose (fptr);
        !           114:                return NOTOK;
        !           115:        }
        !           116: 
        !           117:        parse_file = filename;
        !           118: 
        !           119:        entry_block_print (entryps,ptr);
        !           120: 
        !           121:        if (entryps->ps_errno != PS_ERR_NONE) {
        !           122:                LLOG (log_dsap,LLOG_EXCEPTIONS,("write_edb ps error: %s",ps_error(entryps->ps_errno)));
        !           123:                (void) fclose (fptr);
        !           124:                return NOTOK;
        !           125:        }
        !           126:        ps_free (entryps);
        !           127: 
        !           128:        if (fflush (fptr) != 0) {
        !           129:                LLOG (log_dsap,LLOG_EXCEPTIONS,("write_edb flush error: %d",errno));
        !           130:                return NOTOK;
        !           131:        }
        !           132:        if (fsync (fileno(fptr)) != 0) {
        !           133:                LLOG (log_dsap,LLOG_EXCEPTIONS,("write_edb fsync error: %d",errno));
        !           134:                return NOTOK;
        !           135:        }
        !           136:        if (fclose (fptr) != 0) {
        !           137:                LLOG (log_dsap,LLOG_EXCEPTIONS,("write_edb EDB close error: %d",errno));
        !           138:                return NOTOK;
        !           139:        }
        !           140: 
        !           141:        LLOG (log_dsap,LLOG_NOTICE,("Written %s",filename));
        !           142: 
        !           143:        return (OK);
        !           144: }

unix.superglobalmegacorp.com

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