2 * IR toolkit for tcl/tk
4 * See the file LICENSE for details.
5 * Sebastian Hammer, Adam Dickmeiss
8 * Revision 1.1 1995-08-29 15:38:34 adam
9 * Added grs.c. new version.
20 void ir_tcl_read_grs (Z_GenericRecord *r, IrTcl_GRS_Record **grs_record)
23 struct GRS_Record_entry *e;
28 *grs_record = ir_tcl_malloc (sizeof(**grs_record));
29 if (!((*grs_record)->noTags = r->num_elements))
31 (*grs_record)->entries = NULL;
34 e = (*grs_record)->entries = ir_tcl_malloc (r->num_elements *
36 for (i = 0; i < r->num_elements; i++, e++)
42 e->tagType = *t->tagType;
45 e->tagWhich = t->tagValue->which;
46 if (t->tagValue->which == Z_StringOrNumeric_numeric)
47 e->tagVal.num = *t->tagValue->u.numeric;
49 ir_tcl_strdup (NULL, &e->tagVal.str, t->tagValue->u.string);
50 e->dataWhich = t->content->which;
52 if (t->content->which == Z_ElementData_subtree)
53 ir_tcl_read_grs (t->content->u.subtree, &e->tagData.sub);
54 else if (t->content->which == Z_ElementData_string)
55 ir_tcl_strdup (NULL, &e->tagData.str, t->content->u.string);
59 static int ir_tcl_get_grs_r (Tcl_Interp *interp, IrTcl_GRS_Record *grs_record,
60 int argc, char **argv, int argno)
62 static char tmpbuf[32];
64 struct GRS_Record_entry *e = grs_record->entries;
68 Tcl_AppendResult (interp, "{ ", NULL);
70 for (i = 0; i<grs_record->noTags; i++, e++)
73 Tcl_AppendResult (interp, "{ ", NULL);
74 sprintf (tmpbuf, "%d", e->tagType);
75 Tcl_AppendElement (interp, tmpbuf);
77 if (e->tagWhich == Z_StringOrNumeric_numeric)
79 Tcl_AppendElement (interp, "N");
80 sprintf (tmpbuf, "%d", e->tagVal.num);
81 Tcl_AppendElement (interp, tmpbuf);
85 Tcl_AppendResult (interp, " S ", NULL);
86 Tcl_AppendElement (interp, e->tagVal.str);
88 if (e->dataWhich == Z_ElementData_subtree)
90 Tcl_AppendResult (interp, " R ", NULL);
91 ir_tcl_get_grs_r (interp, e->tagData.sub, argc, argv, argno+1);
95 Tcl_AppendElement (interp, "S");
97 Tcl_AppendElement (interp, e->tagData.str );
99 Tcl_AppendResult (interp, " {} ", NULL);
101 Tcl_AppendResult (interp, " }", NULL);
107 int ir_tcl_get_grs (Tcl_Interp *interp, IrTcl_GRS_Record *grs_record,
108 int argc, char **argv)
110 return ir_tcl_get_grs_r (interp, grs_record, argc, argv, 4);