File: ttcn3_help

package info (click to toggle)
eclipse-titan 8.2.0-1
  • links: PTS
  • area: main
  • in suites: bookworm, sid
  • size: 103,544 kB
  • sloc: cpp: 271,008; ansic: 33,683; yacc: 23,419; makefile: 15,483; lex: 9,204; java: 4,848; perl: 4,555; sh: 2,242; xml: 1,378; javascript: 85; awk: 48; php: 32; python: 13
file content (118 lines) | stat: -rw-r--r-- 3,687 bytes parent folder | download
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
#! /bin/sh
#
#! /bin/sh -x
###############################################################################
# Copyright (c) 2000-2021 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
###############################################################################

###############################################################################
#  Shell script: ttcn3_help
#  Part of     : TITAN
#  Purpose     : opening help pages
#  Content     :
#  The followings can be configured
#  browser: the application which opens the help page
#           (netscape by default)
#  browser_options: command line options for the browser
#  help_format: extension of the help files
#  help_root: root of the help files
#
#  Return value: 1 on error
#                0 on success
###############################################################################

# check the number of arguments
if test "`expr $# != 1`" = "1"
then echo "Error: exactly one argument is expected"; exit 1;
fi

# check for necessary environment variables
if test "${TTCN3_DIR}" = "" 
then echo "Error: TTCN3_DIR environment variable is not set"; exit 1;
fi

# file extension for help files
help_format=".html";
# path of the help pages
help_root="${TTCN3_DIR}/help";

# check for browser
if test "${TTCN3_BROWSER}" = "" 
then browser="netscape"; browser_options="-no-about-splash ";
else browser="${TTCN3_BROWSER}"; browser_options=" ";
fi

# check for already running browsers
# Netscape
if test "`echo ${browser} | grep netscape`" != ""
then {
  username=`whoami`
  # avoid listing grep command as well
  pslist=`/bin/ps -u ${username} -f`
  if test "`echo ${pslist} | grep netscape`" != ""
  then browser_options="-remote openURL(file:"; endtag=")"
  else browser_options="-no-about-splash "; endtag=""
  fi
}
# Mozilla
elif test "`echo ${browser} | grep mozilla`" != ""
then {
  username=`whoami`
  # avoid listing grep command as well
  pslist=`/bin/ps -u ${username}`
  if test "`echo ${pslist} | grep mozilla`" != ""
  then browser_options="-remote openURL(file:"; endtag=")"
  else browser_options="file:"; endtag=""
  fi
}
# Opera
elif test "`echo ${browser} | grep opera`" != ""
then {
  username=`whoami`
  # avoid listing grep command as well
  pslist=`/bin/ps -u ${username} -f`
  if test "`echo ${pslist} | grep opera`" != ""
  then browser_options="-remote openURL(file:"; endtag=")"
  else endtag=""
  fi
}
# Lynx should be executed in a new terminal
elif test "`echo ${browser} | grep lynx`" != ""
then {
  browser="xterm -e ${browser}"
  endtag=""
}
else endtag=""
fi

#echo "browser=$browser"
#echo "options=$browser_options"
#echo "endtag =$endtag"

# the file tree looks like
# $TTCN3_DIR/help/titan_main.html
# $TTCN3_DIR/help/titan_index.html
# $TTCN3_DIR/help/info/<keyword>.html

##### check if it is a document name #####
if test -f ${help_root}/$1
then exec ${browser} ${browser_options}${help_root}/$1${endtag}
elif test -f ${help_root}/info/$1
then exec ${browser} ${browser_options}${help_root}/info/$1${endtag}

##### check if it is the keyword 'main' #####
elif test $1 = "main"
then exec ${browser} ${browser_options}${help_root}/titan_main${help_format}${endtag}

##### check if it is a keyword #####
elif test -f ${help_root}/info/$1${help_format}
then exec ${browser} ${browser_options}${help_root}/info/$1${help_format}${endtag}

# otherwise open the index file
else exec ${browser} ${browser_options}${help_root}/titan_index${help_format}${endtag}
fi