|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T p
Length: 5079 (0x13d7) Types: TextFile Names: »parse.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z« └─⟦de7628f85⟧ └─⟦this⟧ »isode-6.0/quipu/parse.c«
/* parse.c - */ #ifndef lint static char *rcsid = "$Header: /f/osi/quipu/RCS/parse.c,v 7.0 89/11/23 22:17:56 mrose Rel $"; #endif /* * $Header: /f/osi/quipu/RCS/parse.c,v 7.0 89/11/23 22:17:56 mrose Rel $ * * * $Log: parse.c,v $ * Revision 7.0 89/11/23 22:17:56 mrose * Release 6.0 * */ /* * NOTICE * * Acquisition, use, and distribution of this module and related * materials are subject to the restrictions of a license agreement. * Consult the Preface in the User's Manual for the full terms of * this agreement. * */ #include "quipu/util.h" #include "quipu/entry.h" #include "quipu/ds_error.h" #include "quipu/malloc.h" #define PARSE_BUFFER 10000 static char parse_buffer [PARSE_BUFFER]; Entry database_root; int local_master_size = 0; int local_slave_size = 0; int local_cache_size = 0; extern time_t time (); char * getline (file) FILE * file; { extern int parse_line; char * ptr; extern char * TidyString (); while ( fgets (parse_buffer,PARSE_BUFFER,file) != NULLCP) { parse_line++; ptr = SkipSpace (parse_buffer); if (*ptr != '#') return (TidyString(ptr)); } return (NULLCP); } Attr_Sequence get_attributes_aux (file) FILE * file; { Attr_Sequence as = NULLATTR; Attr_Sequence as_combine (); char * ptr; if ((ptr = getline (file)) == NULLCP) return (NULLATTR); while ( *ptr != 0 ) { as = as_combine (as,ptr); if ((ptr = getline (file)) == NULLCP) break; } return (as); } Attr_Sequence get_attributes (file) FILE * file; { extern int parse_status; extern int parse_line; parse_status = 0; parse_line = 0; return (get_attributes_aux (file)); } Entry get_entry_aux (file,parent,dtype) FILE * file; Entry parent; int dtype; { Entry eptr; char * ptr; extern RDN parse_rdn; struct DSError err; extern int print_parse_errors; extern int parse_line; int save; extern PS opt; char check = TRUE; DATABASE_HEAP; eptr = get_default_entry (parent); eptr->e_data = dtype; if ((ptr = getline (file)) == NULLCP) { GENERAL_HEAP; return (NULLENTRY); } while (*ptr == 0) if ((ptr = getline (file)) == NULLCP) { GENERAL_HEAP; return (NULLENTRY); } if ((eptr->e_name = str2rdn (ptr)) == NULLRDN) { parse_error ("invalid rdn %s",ptr); check = FALSE; } parse_rdn = eptr->e_name; eptr->e_attributes = get_attributes_aux (file); if (check) { save = parse_line; parse_line = 0; if (unravel_attribute (eptr,&err,FALSE) != OK) { parse_error ("Error in entry ending line %d...",(char *) save); if (print_parse_errors) ds_error (opt,&err); } if (check_schema (eptr,NULLATTR,&err,FALSE) != OK) { parse_error ("Schema error in entry ending line %d...",(char *) save); if (print_parse_errors) ds_error (opt,&err); } parse_line = save; } parse_rdn = NULLRDN; GENERAL_HEAP; switch (dtype) { case E_TYPE_SLAVE: local_slave_size++; break; case E_DATA_MASTER: local_master_size++; break; case E_TYPE_CACHE_FROM_MASTER: eptr->e_age = time ((time_t *)0); local_cache_size++; break; } return (eptr); } Entry get_entry (file,parent,dtype) FILE * file; Entry parent; int dtype; { extern int parse_status; extern int parse_line; parse_status = 0; parse_line = 0; return (get_entry_aux (file,parent,dtype)); } Entry new_constructor (parent) Entry parent; { Entry constructor; constructor = get_default_entry (parent); constructor->e_leaf = FALSE; constructor->e_complete = FALSE; constructor->e_data = E_TYPE_CONSTRUCTOR; constructor->e_acl = acl_alloc (); constructor->e_acl->ac_child = acl_dflt (); constructor->e_acl->ac_entry = acl_dflt (); constructor->e_acl->ac_default = acl_dflt (); constructor->e_acl->ac_attributes = NULLACL_ATTR; return (constructor); } Entry make_path (dn) DN dn; { Entry ptr; register RDN a_rdn, b_rdn; if ((database_root == NULLENTRY) || (database_root->e_child == NULLENTRY)) { database_root = new_constructor(NULLENTRY); ptr = database_root; for (; dn!= NULLDN; dn=dn->dn_parent) { ptr->e_child = new_constructor(ptr); ptr = ptr->e_child; ptr->e_name = rdn_cpy (dn->dn_rdn); } return (ptr); } else { /* follow links as far as poss, then add new bits */ if (dn == NULLDN) return (database_root); ptr = database_root->e_child; b_rdn = dn->dn_rdn; a_rdn = ptr->e_name ; for(;;) { /* return out */ while (rdn_cmp (a_rdn, b_rdn) != OK) { if (ptr->e_sibling == NULLENTRY) { for (; dn!= NULLDN; dn=dn->dn_parent) { ptr->e_sibling = new_constructor(ptr->e_parent); ptr = ptr->e_sibling; ptr->e_name = rdn_cpy (dn->dn_rdn); } return (ptr); } ptr = ptr->e_sibling; a_rdn = ptr->e_name ; } if ( dn->dn_parent == NULLDN) return (ptr); dn = dn->dn_parent; b_rdn = dn->dn_rdn; if ( ptr->e_child == NULLENTRY) { for (; dn!= NULLDN; dn=dn->dn_parent) { ptr->e_child = new_constructor(ptr); ptr = ptr->e_child; ptr->e_name = rdn_cpy (dn->dn_rdn); } return (ptr); } ptr = ptr->e_child; a_rdn = ptr->e_name; } } /* NOTREACHED */ }