File: gtmlink.c

package info (click to toggle)
fis-gtm 7.1-006-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 32,908 kB
  • sloc: ansic: 344,906; asm: 5,184; csh: 4,859; sh: 2,000; awk: 294; makefile: 73; sed: 13
file content (65 lines) | stat: -rw-r--r-- 1,714 bytes parent folder | download | duplicates (5)
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
/****************************************************************
 *								*
 * Copyright (c) 2013-2017 Fidelity National Information	*
 * Services, Inc. and/or its subsidiaries. All rights reserved.	*
 *								*
 *	This source code contains the intellectual property	*
 *	of its copyright holder(s), and is made available	*
 *	under a license.  If you do not know the terms of	*
 *	the license, please stop and do not read further.	*
 *								*
 ****************************************************************/

#include "mdef.h"

#include "gtm_caseconv.h"
#include "gtm_string.h"
#include "gtmlink.h"

LITDEF mstr relink_allowed_mstr[] = {
	{0, LEN_AND_LIT("NORECURSIVE")},
	{0, LEN_AND_LIT("RECURSIVE")},		/* if env var $gtm_link = "RECURSIVE", then recursive relink is enabled */
	{0, LEN_AND_LIT("")}
};

#define MAX_KEYWORD_LEN	16

void init_relink_allowed(mstr *keyword)
{
	mstr	trans;
	char	buf[MAX_KEYWORD_LEN];
	int	i;
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	DEBUG_ONLY(check_max_keyword_len());
	if ((keyword->len >= MAX_KEYWORD_LEN) || (0 == keyword->len))
	{	/* unrecognized keyword - use default */
		TREF(relink_allowed) = LINK_NORECURSIVE;
		return;
	}
	lower_to_upper((unsigned char *)&buf[0], (unsigned char *)keyword->addr, keyword->len);
	trans.len = keyword->len;
	trans.addr = &buf[0];
	for (i = 0; i < LINK_MAXTYPE; i++)
	{
		if (MSTR_EQ(&trans, &relink_allowed_mstr[i]))
		{
			TREF(relink_allowed) = i;
			return;
		}
	}
	/* unrecognized keyword - use default */
	TREF(relink_allowed) = LINK_NORECURSIVE;
	return;
}

#ifdef DEBUG
void check_max_keyword_len(void)
{
	int	i;

	for (i = 0; i < LINK_MAXTYPE; i++)
		assert(MAX_KEYWORD_LEN > relink_allowed_mstr[i].len);
}
#endif