|
|
1.1 ! root 1: #include "quipu/util.h" ! 2: #include "quipu/name.h" ! 3: ! 4: dn_print (ps,dn,format) ! 5: DN dn; ! 6: PS ps; ! 7: int format; ! 8: { ! 9: register DN eptr; ! 10: ! 11: if (dn == NULLDN) { ! 12: if (format == READOUT) ! 13: ps_print (ps,"NULL DN"); ! 14: return ; ! 15: } ! 16: ! 17: if (format == UFNOUT) { ! 18: ufn_dn_print (ps, dn, 1); ! 19: return; ! 20: } ! 21: ! 22: dn_comp_print (ps,dn,format); ! 23: if (dn->dn_parent != NULLDN) ! 24: for (eptr = dn->dn_parent; eptr != NULLDN; eptr = eptr->dn_parent) { ! 25: switch (format) { ! 26: case DIROUT: ps_print (ps,"/"); break; ! 27: case FILEOUT: ! 28: case RDNOUT: ! 29: case EDBOUT: ps_print (ps,"@"); break; ! 30: case READOUT: ps_print (ps,"\n\t\t\t"); break; ! 31: } ! 32: dn_comp_print (ps,eptr,format); ! 33: } ! 34: } ! 35: ! 36: /* */ ! 37: ! 38: static DN localdn = NULLDN; ! 39: extern char * local_dit; ! 40: ! 41: ufn_dn_print (ps,dn,multiline) ! 42: PS ps; ! 43: DN dn; ! 44: int multiline; ! 45: { ! 46: if (dn == NULLDN) ! 47: return; ! 48: ! 49: if (localdn == NULLDN) ! 50: localdn = str2dn (local_dit); ! 51: ! 52: (void) ufn_dn_print_aux (ps,dn,localdn,multiline); ! 53: } ! 54: ! 55: ! 56: int ufn_indent = 16; ! 57: ! 58: ufn_dn_print_aux (ps,dn,marker,multiline) ! 59: PS ps; ! 60: DN dn; ! 61: DN marker; ! 62: int multiline; ! 63: { ! 64: DN next = NULLDN; ! 65: char res = 0; ! 66: char this_one = TRUE; ! 67: ! 68: if ((marker != NULLDN) && (dn_comp_cmp(dn,marker) == 0)) { ! 69: next = marker->dn_parent; ! 70: if (dn->dn_parent != NULLDN) ! 71: this_one = FALSE; ! 72: } ! 73: ! 74: if (dn->dn_parent != NULLDN) ! 75: res = ufn_dn_print_aux (ps,dn->dn_parent,next,multiline); ! 76: ! 77: if (this_one) { ! 78: if (res) { ! 79: if (multiline < 0 || (multiline && res > 1)) { ! 80: ps_printf (ps,",\n"); ! 81: if (ufn_indent > 0) ! 82: ps_printf (ps, "%*s", ufn_indent, ""); ! 83: } else ! 84: ps_print (ps,", "); ! 85: } ! 86: ufn_rdn_print (ps,dn->dn_rdn); ! 87: } ! 88: return ++res; ! 89: } ! 90: ! 91: ! 92: ufn_rdn_print (ps,rdn) ! 93: RDN rdn; ! 94: PS ps; ! 95: { ! 96: register RDN eptr; ! 97: ! 98: if (rdn == NULLRDN) ! 99: return; ! 100: ! 101: AttrV_print (ps,&rdn->rdn_av,READOUT); ! 102: ! 103: if (rdn->rdn_next != NULLRDN) ! 104: for (eptr=rdn->rdn_next; eptr!=NULLRDN; eptr=eptr->rdn_next) { ! 105: ps_print (ps," + "); ! 106: AttrV_print (ps,&eptr->rdn_av,READOUT); ! 107: } ! 108: ! 109: } ! 110: ! 111: static PS ps = NULLPS; ! 112: ! 113: char *dn2str (dn) ! 114: DN dn; ! 115: { ! 116: char *cp; ! 117: ! 118: if (ps == NULL ! 119: && ((ps = ps_alloc (str_open)) == NULLPS) ! 120: || str_setup (ps, NULLCP, BUFSIZ, 0) == NOTOK) { ! 121: if (ps) ! 122: ps_free (ps), ps = NULLPS; ! 123: ! 124: return NULLCP; ! 125: } ! 126: ! 127: dn_print (ps, dn, EDBOUT); ! 128: ps_print (ps, " "); ! 129: *--ps -> ps_ptr = NULL, ps -> ps_cnt++; ! 130: ! 131: cp = ps -> ps_base; ! 132: ! 133: ps -> ps_base = NULL, ps -> ps_cnt = 0; ! 134: ps -> ps_ptr = NULL, ps -> ps_bufsiz = 0; ! 135: ! 136: return cp; ! 137: } ! 138: ! 139: char *dn2ufn (dn,multiline) ! 140: DN dn; ! 141: int multiline; ! 142: { ! 143: char *cp; ! 144: ! 145: if (ps == NULL ! 146: && ((ps = ps_alloc (str_open)) == NULLPS) ! 147: || str_setup (ps, NULLCP, BUFSIZ, 0) == NOTOK) { ! 148: if (ps) ! 149: ps_free (ps), ps = NULLPS; ! 150: ! 151: return NULLCP; ! 152: } ! 153: ! 154: ufn_dn_print (ps, dn, multiline); ! 155: ps_print (ps, " "); ! 156: *--ps -> ps_ptr = NULL, ps -> ps_cnt++; ! 157: ! 158: cp = ps -> ps_base; ! 159: ! 160: ps -> ps_base = NULL, ps -> ps_cnt = 0; ! 161: ps -> ps_ptr = NULL, ps -> ps_bufsiz = 0; ! 162: ! 163: return cp; ! 164: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.