summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc/port/i18n/gettext_util.c
blob: d11f71a80dcc3c72535c972c88eee81671316b58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#include "lint.h"
#include "mtlib.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/mman.h>
#include <langinfo.h>
#include "libc.h"
#include "_loc_path.h"
#include "msgfmt.h"
#include "gettext.h"

#ifdef GETTEXT_DEBUG
#include "plural_parser.h"
#include <stdarg.h>
#endif

static const char	*category_name[] = {
	"LC_CTYPE",
	"LC_NUMERIC",
	"LC_TIME",
	"LC_COLLATE",
	"LC_MONETARY",
	"LC_MESSAGES"
};

static const int	category_name_len[] = {
	8,
	10,
	7,
	10,
	11,
	11
};

/*
 * mk_msgfile
 *
 * INPUT
 * mp -	uses the following members:
 *	msgfile  - buffer to store the pathname to the message file
 *	binding  - directory pathname bound to specified domain
 *	cblen    - length of binding
 *	locale   - locale name
 *	domain   - domain name
 *	category - category
 *	domain_len - length of domain name
 *
 * OUTPUT
 * mp->msgfile - pathname to the message file is stored
 *
 * RETURN
 * mp->msgfile is returned
 */
char *
mk_msgfile(struct msg_pack *mp)
{
	const char *q;
	char	*p;
	const char	*catstr;
	uint32_t	cblen, loclen, catlen, totallen;

#ifdef GETTEXT_DEBUG
	gprintf(0, "*************** mk_msgfile(0x%p)\n", (void *)mp);
	printmp(mp, 1);
#endif

	p = mp->msgfile;
	q = mp->binding;
	while ((*p = *q++) != '\0')
		p++;
	cblen = (uint32_t)(p - mp->msgfile);
	if (*(p - 1) != '/') {
		/*
		 * if the last character of binding
		 * isn't a '/', adding '/'.
		 */
		if (cblen + 1 >= MAXPATHLEN) {
			/* MAXPATHLEN includes a null termination */
			return (NULL);
		}
		*p++ = '/';
		cblen++;
	}

	loclen = strlen(mp->locale);
	catstr = category_name[mp->category];
	catlen = (uint32_t)category_name_len[mp->category];
	/*
	 * totallen is the length of the msgfile
	 * pathname excluding a null termination.
	 */

	totallen = cblen + loclen + 1 + catlen + 1 +
	    mp->domain_len + MSGFILESUFFIXLEN;
	if (totallen >= MAXPATHLEN)
		return (NULL);

	q = mp->locale;
	while ((*p++ = *q++) != '\0')
		;
	*(p - 1) = '/';
	while ((*p++ = *catstr++) != '\0')
		;
	*(p - 1) = '/';
	q = mp->domain;
	while ((*p = *q++) != '\0')
		p++;
	q = MSGFILESUFFIX;
	while ((*p++ = *q++) != '\0')
		;

#ifdef GETTEXT_DEBUG
	gprintf(0, "*************** Exiting mk_msgfile\n");
	gprintf(0, "mp->msgfile: \"%s\"\n", mp->msgfile);
#endif

	return (mp->msgfile);
}

/*
 * check_cache
 *
 * INPUT
 * mp - may use the following members:
 *	msgfile - pathname to the message catalog file
 *	hash_domain - hash id of this domain
 *
 * RETURN
 * non-NULL
 *	pointer to the Msg_node object of the current message catalog
 *	found in the cache
 *
 * NULL
 *	this message catalog does not exist in the cache
 */
Msg_node *
check_cache(struct msg_pack *mp)
{
	Msg_node	*cur_msg, *mnp;
	Gettext_t	*gt = global_gt;

#ifdef GETTEXT_DEBUG
	gprintf(0, "*************** check_cache(0x%p)\n", mp);
	printmp(mp, 1);
#endif

	cur_msg = gt->c_m_node;		/* current Msg_node */
	if (cur_msg &&
	    cur_msg->hashid == mp->hash_domain &&
	    strcmp(cur_msg->path, mp->msgfile) == 0) {
		/*
		 * msgfile is the same as the previous message file
		 */
#ifdef GETTEXT_DEBUG
		gprintf(0, "*** cache found\n");
		gprintf(0, "************* exiting check_cache\n");
		printmnp(cur_msg, 1);
#endif
		return (cur_msg);
	}
	mnp = gt->m_node;
	while (mnp) {
#ifdef GETTEXT_DEBUG
		gprintf(0, "========== descending the list\n");
		gprintf(0, "  hashid: %d, hash_domain: %d\n",
		    mnp->hashid, mp->hash_domain);
		printmnp(mnp, 1);
#endif
		if (mnp->hashid == mp->hash_domain &&
		    strcmp(mnp->path, mp->msgfile) == 0) {
#ifdef GETTEXT_DEBUG
			gprintf(0, "*** cache found\n");
			gprintf(0, "******* exiting check_cache\n");
			printmnp(mnp, 1);
#endif
			gt->c_m_node = mnp;
			return (mnp);
		}
		mnp = mnp->next;
	}

#ifdef GETTEXT_DEBUG
	gprintf(0, "*** cache not found\n");
	gprintf(0, "******* exiting check_cache\n");
#endif
	return (NULL);
}

char *
get_codeset(const char *domain)
{
	char	*codeset;

#ifdef GETTEXT_DEBUG
	gprintf(0, "*************** get_codeset(\"%s\")\n",
	    domain ? domain : "(null)");
#endif

	codeset = _real_bindtextdomain_u(domain, NULL, TP_CODESET);
	if (codeset == NULL) {
		/* no codeset is bound to this domain */
		codeset = nl_langinfo(CODESET);
	}
#ifdef GETTEXT_DEBUG
	gprintf(0, "*************** existing get_codeset(\"%s\")\n",
	    domain ? domain : "(null)");
	gprintf(0, "                = \"%s\"\n", codeset);
#endif

	return (codeset);
}

/*
 * get_hashid (hashpjw)
 *
 * Calculates the hash value from the specified string.
 * Actual hashid will be mod(hash value, PRIME_NUMBER).
 *
 * Ref: Compilers - Principles, Techniques, and Tools
 * Aho, Sethi, and Ullman
 */
uint32_t
get_hashid(const char *str, uint32_t *len)
{
	const unsigned char	*p = (unsigned char *)str;
	uint32_t	h = 0;
	uint32_t	g;

	for (; *p; p++) {
		h = (h << 4) + *p;
		g = h & 0xf0000000;
		if (g) {
			h = h ^ (g >> 24);
			h = h ^ g;
		}
	}

	if (len)
		*len = (uint32_t)(p - (unsigned char *)str);
	return (h);
}

uint32_t
doswap32(uint32_t n)
{
	uint32_t	r;

	r = (n << 24) | ((n & 0xff00) << 8) |
	    ((n >> 8) & 0xff00) | (n >> 24);
	return (r);
}

#ifdef GETTEXT_DEBUG
static uint32_t
search_msg(Msg_g_node *p, const char *id, uint32_t hash_val,
    struct gnu_msg_ent *m)
{
	char	*base = (char *)p->msg_file_info;
	uint32_t	hash_size, num_of_str, i, idx, inc;
	char	*ms;

	num_of_str = p->num_of_str;
	hash_size = p->hash_size;
	idx = hash_val % hash_size;
	inc = 1 + (hash_val % (hash_size - 2));

	while ((i = p->hash_table[idx]) != 0) {
		ms = (i <= num_of_str) ?
		    base + SWAP(p, m[i-1].offset) :
		    p->mchunk + p->d_msg[MSGID][i-num_of_str-1].offset;
		if (strcmp(id, ms) == 0) {
			/* found */
			return (i);
		}
		idx = (idx + inc) % hash_size;
	}
	/* not found */
	return (0);
}

void
print_rev1_info(Msg_g_node *p)
{
	char	*base = (char *)p->msg_file_info;
	struct gnu_msg_info	*header = p->msg_file_info;
	struct gnu_msg_ent	*m;
	uint32_t	hv, hidx;
	char	*ms;
	enum gnu_msgidstr	v;
	int	x;

#ifdef	GETTEXT_DEBUG_DYMMSG
	gprintf(0, "******** dynamic msgid/msgstr\n");
	for (v = MSGID; v <= MSGSTR; v++) {
		for (x = 0; x < p->num_of_d_str; x++) {
			gprintf(0, "len: %u\n", p->d_msg[v][x].len);
			gprintf(0, "str: \"%s\"\n",
			    p->mchunk + p->d_msg[v][x].offset);
		}
	}
#endif
#ifdef	GETTEXT_DEBUG_HASHTBL
	gprintf(0, "******** dynamic hash table\n");
	for (x = 0; x < p->hash_size; x++) {
		gprintf(0, "%d: %u\n", x, p->hash_table[x]);
	}
#endif
#ifdef	GETTEXT_DEBUG_CHECK_STMSGID
	gprintf(0, "******** sanity check of static msgid\n");
	m = (struct gnu_msg_ent *)(uintptr_t)
	    (base + SWAP(p, header->off_msgid_tbl));
	for (x = 0; x < p->num_of_str; x++) {
		ms = base + SWAP(p, m[x].offset);
		gprintf(0, "\"%s\"\n", ms);
		hv = get_hashid(ms, NULL);
		hidx = search_msg(p, ms, hv, m);
		if (hidx == 0) {
			gprintf(0,
			    "failed to find this msg in the hash table\n");
		} else {
			if (hidx != x + 1) {
				gprintf(0, "hash table mismatch\n");
			}
		}
	}
#endif
#ifdef	GETTEXT_DEBUG_CHECK_DYMMSGID
	gprintf(0, "******* sanity check of dynamic msgid\n");
	m = (struct gnu_msg_ent *)(uintptr_t)
	    (base + SWAP(p, header->off_msgid_tbl));
	for (x = 0; x < p->num_of_d_str; x++) {
		ms = p->mchunk + p->d_msg[MSGID][x].offset;
		gprintf(0, "\"%s\"\n", ms);
		hv = get_hashid(ms, NULL);
		hidx = search_msg(p, ms, hv, m);
		if (hidx == 0) {
			gprintf(0,
			    "failed to find this msg in the hash table\n");
		} else {
			if (hidx != x + p->num_of_str + 1) {
				gprintf(0, "hash table mismatch\n");
			}
		}
	}
#endif
}

void
gprintf(int level, const char *format, ...)
{
	va_list	ap;

	va_start(ap, format);

	while (level-- > 0) {
		(void) fputs("   ", stdout);
	}
	(void) vprintf(format, ap);
	va_end(ap);

	(void) fflush(stdout);
}

void
printlist(void)
{
	struct domain_binding	*ppp;
	Gettext_t	*gt = global_gt;

	gprintf(0, "=== Printing default list and regural list\n");
	gprintf(0, "   Default domain=<%s>, binding=<%s>\n",
	    DEFAULT_DOMAIN, defaultbind);

	ppp = FIRSTBIND(gt);
	while (ppp) {
		gprintf(0, "   domain=<%s>, binding=<%s>, codeset=<%s>\n",
		    ppp->domain ? ppp->domain : "(null)",
		    ppp->binding ? ppp->binding : "(null)",
		    ppp->codeset ? ppp->codeset : "(null)");
		ppp = ppp->next;
	}
	(void) fflush(stdout);
}

void
printmp(struct msg_pack *mp, int level)
{
	gprintf(level, "=== mp ===\n");
	gprintf(level, "   msgid1: \"%s\"\n",
	    mp->msgid1 ? mp->msgid1 : "(null)");
	gprintf(level, "   msgid2: \"%s\"\n",
	    mp->msgid2 ? mp->msgid2 : "(null)");
	gprintf(level, "   msgfile: \"%s\"\n",
	    mp->msgfile ? mp->msgfile : "(null)");
	gprintf(level, "   domain: \"%s\"\n",
	    mp->domain ? mp->domain : "(null)");
	gprintf(level, "   binding: \"%s\"\n",
	    mp->binding ? mp->binding : "(null)");
	gprintf(level, "   locale: \"%s\"\n",
	    mp->locale ? mp->locale : "(null)");
	gprintf(level, "   language: \"%s\"\n",
	    mp->language ? mp->language : "(null)");
	gprintf(level, "   addr: 0x%p\n", mp->addr);
	gprintf(level, "   fsz: %d\n", mp->fsz);
	gprintf(level, "   hash_domain: %d\n", mp->hash_domain);
	gprintf(level, "   domain_len: %d\n", mp->domain_len);
	gprintf(level, "   n: %d\n", mp->n);
	gprintf(level, "   category: \"%s\"\n",
	    category_name[mp->category]);
	gprintf(level, "   plural: %d\n", mp->plural);
	gprintf(level, "   nlsp: %d\n", mp->nlsp);
	gprintf(level, "   trusted: %d\n", mp->trusted);
	gprintf(level, "   status: %d\n", mp->status);
}

void
printsunmsg(Msg_s_node *smnp, int level)
{
	gprintf(level, "=== sunmsg ===\n");
	gprintf(level, "   msg_file_info: 0x%p\n",
	    (void *)smnp->msg_file_info);
	gprintf(level, "      msg_mid: %d\n",
	    smnp->msg_file_info->msg_mid);
	gprintf(level, "      msg_count: %d\n",
	    smnp->msg_file_info->msg_count);
	gprintf(level, "      str_count_msgid: %d\n",
	    smnp->msg_file_info->str_count_msgid);
	gprintf(level, "      str_count_msgstr: %d\n",
	    smnp->msg_file_info->str_count_msgstr);
	gprintf(level, "      msg_struct_size: %d\n",
	    smnp->msg_file_info->msg_struct_size);
	gprintf(level, "   msg_list: 0x%p\n",
	    (void *)smnp->msg_list);
	gprintf(level, "   msg_ids: 0x%p\n",
	    (void *)smnp->msg_ids);
	gprintf(level, "   msg_strs: 0x%p\n",
	    (void *)smnp->msg_strs);
}

void
printgnumsg(Msg_g_node *gmnp, int level)
{
	gprintf(level, "=== gnumsg ===\n");
	gprintf(level, "   msg_file_info: 0x%p\n", gmnp->msg_file_info);
	gprintf(level, "      magic: 0x%x\n",
	    gmnp->msg_file_info->magic);
	gprintf(level, "      revision: %d\n",
	    SWAP(gmnp, gmnp->msg_file_info->revision));
	gprintf(level, "      num_of_str: %d\n",
	    SWAP(gmnp, gmnp->msg_file_info->num_of_str));
	gprintf(level, "      off_msgid_tbl: %d\n",
	    SWAP(gmnp, gmnp->msg_file_info->off_msgid_tbl));
	gprintf(level, "      off_msgstr_tbl: %d\n",
	    SWAP(gmnp, gmnp->msg_file_info->off_msgstr_tbl));
	gprintf(level, "      sz_hashtbl: %d\n",
	    SWAP(gmnp, gmnp->msg_file_info->sz_hashtbl));
	gprintf(level, "      off_hashtbl: %d\n",
	    SWAP(gmnp, gmnp->msg_file_info->off_hashtbl));
	if (gmnp->flag & ST_REV1) {
		struct gnu_msg_rev1_info	*a =
		    (struct gnu_msg_rev1_info *)(uintptr_t)
		    ((char *)gmnp->msg_file_info +
		    sizeof (struct gnu_msg_info));
		gprintf(level, "      num_of_dynamic_macro: %d\n",
		    SWAP(gmnp, a->num_of_dynamic_macro));
		gprintf(level, "      off_dynamic_macro: %d\n",
		    SWAP(gmnp, a->off_dynamic_macro));
		gprintf(level, "      num_of_dynamic_str: %d\n",
		    SWAP(gmnp, a->num_of_dynamic_str));
		gprintf(level, "      off_dynamic_msgid_tbl: %d\n",
		    SWAP(gmnp, a->off_dynamic_msgid_tbl));
		gprintf(level, "      off_dynamic_msgstr_tbl: %d\n",
		    SWAP(gmnp, a->off_dynamic_msgstr_tbl));
	}
	gprintf(level, "   fsize: %lu\n", gmnp->fsize);
	gprintf(level, "   flag: %08x\n", gmnp->flag);
	gprintf(level, "   num_of_str: %u\n", gmnp->num_of_str);
	gprintf(level, "   num_of_d_str: %u\n", gmnp->num_of_d_str);
	gprintf(level, "   hash_size: %u\n", gmnp->hash_size);
	gprintf(level, "   hash_table: 0x%p\n", (void *)gmnp->hash_table);
	gprintf(level, "   d_msgid: 0x%p\n", (void *)gmnp->d_msg[MSGID]);
	gprintf(level, "   d_msgstr: 0x%p\n", (void *)gmnp->d_msg[MSGSTR]);
	gprintf(level, "   mchunk: 0x%p\n", (void *)gmnp->mchunk);

	gprintf(level, "   src_encoding: \"%s\"\n",
	    gmnp->src_encoding ? gmnp->src_encoding : "(null)");
	gprintf(level, "   dst_encoding: \"%s\"\n",
	    gmnp->dst_encoding ? gmnp->dst_encoding : "(null)");
	gprintf(level, "   nplurals: %d\n",
	    gmnp->nplurals);
	gprintf(level, "   plural: 0x%p\n",
	    (void *)gmnp->plural);
	if (gmnp->plural)
		printexpr(gmnp->plural, level+1);
	gprintf(level, "   fd: 0x%p\n", (void *)gmnp->fd);
	gprintf(level, "   conv_msgstr: 0x%p\n",
	    (void *)gmnp->conv_msgstr);
}

void
printexpr(struct expr *e, int level)
{
	static const char	*op_name[] = {
	    "NULL", "INIT", "EXP",
	    "NUM", "VAR", "?", ":", "||",
	    "&&", "==", "!=", ">", "<",
	    ">=", "<=", "+", "-", "*", "/",
	    "%", "!", "(", ")", "ERR"
	};
	switch (GETOPNUM(e->op)) {
	case 0:
		switch (GETTYPE(e->op)) {
		case T_NUM:
			gprintf(level, "NUM(%d)\n", e->num);
			break;
		case T_VAR:
			gprintf(level, "VAR(n)\n");
			break;
		}
		break;
	case 1:
		gprintf(level, "OP: !\n");
		printexpr(e->nodes[0], level+1);
		break;
	case 2:
		gprintf(level, "OP: %s\n", op_name[GETTYPE(e->op)]);
		printexpr(e->nodes[0], level+1);
		printexpr(e->nodes[1], level+1);
		break;
	case 3:
		gprintf(level, "OP: ?\n");

		printexpr(e->nodes[0], level+1);
		printexpr(e->nodes[1], level+1);
		printexpr(e->nodes[2], level+1);
		break;
	}
}


void
printmnp(Msg_node *mnp, int level)
{
	gprintf(level, "=== mnp ===\n");

	gprintf(level, "   hashid: %d\n", mnp->hashid);
	gprintf(level, "   type: \"%s\"\n",
	    mnp->type == T_ILL_MO ? "T_ILL_MO" :
	    mnp->type == T_SUN_MO ? "T_SUN_MO" :
	    mnp->type == T_GNU_MO ? "T_GNU_MO" :
	    "UNKNOWN TYPE");
	gprintf(level, "   path: \"%s\"\n",
	    mnp->path ? mnp->path : "(null)");
	gprintf(level, "   msg_file_trusted: %d\n",
	    mnp->trusted);
	if (mnp->type == T_SUN_MO)
		printsunmsg(mnp->msg.sunmsg, level+1);
	else if (mnp->type == T_GNU_MO)
		printgnumsg(mnp->msg.gnumsg, level+1);
	gprintf(level, "   next: 0x%p\n", (void *)mnp->next);
}

void
printnls(Nls_node *n, int level)
{
	gprintf(level, "=== nls ===\n");
	gprintf(level, "   domain: \"%s\"\n", n->domain ? n->domain : "NULL");
	gprintf(level, "   locale: \"%s\"\n", n->locale ? n->locale : "NULL");
	gprintf(level, "   nlspath: \"%s\"\n", n->nlspath ? n->nlspath :
	    "NULL");
	gprintf(level, "   next: 0x%p\n", n->next);
}

void
printdbind(Dbinding *d, int level)
{
	gprintf(level, "=== dbind ===\n");
	gprintf(level, "   domain: \"%s\"\n", d->domain ? d->domain : "NULL");
	gprintf(level, "   binding: \"%s\"\n", d->binding ? d->binding :
	    "NULL");
	gprintf(level, "   codeset: \"%s\"\n", d->codeset ? d->codeset :
	    "NULL");
	gprintf(level, "   next: 0x%p\n", d->next);
}

void
printgt(Gettext_t *gt, int level)
{
	gprintf(level, "=== gt ===\n");
	gprintf(level, "   cur_domain: \"%s\"\n", gt->cur_domain);
	if (gt->dbind) {
		printdbind(gt->dbind, level+1);
	} else {
		gprintf(level, "   dbind: NULL\n");
	}
	if (gt->m_node) {
		printmnp(gt->m_node, level + 1);
	} else {
		gprintf(level, "   m_node: NULL\n");
	}
	if (gt->n_node) {
		printnls(gt->n_node, level + 1);
	} else {
		gprintf(level, "   n_node: NULL\n");
	}
	if (gt->c_m_node) {
		printmnp(gt->c_m_node, level + 1);
	} else {
		gprintf(level, "   c_m_node: NULL\n");
	}
	if (gt->c_n_node) {
		printnls(gt->c_n_node, level + 1);
	} else {
		gprintf(level, "   c_n_node: NULL\n");
	}
}

#endif