-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdl_help.c
119 lines (101 loc) · 3.25 KB
/
dl_help.c
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
/*
* HypView - (c) - 2006 Philipp Donze
* 2006 - Philipp Donze & Odd Skancke
*
* A replacement hypertext viewer
*
* This file is part of HypView.
*
* HypView is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* HypView is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HypView; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string.h>
#ifdef __GNUC__
#include <osbind.h>
#else
#include <tos.h>
#endif
#include <gem.h>
#include "diallib.h"
#include "include/av.h"
#if USE_STGUIDE == YES
char *help_file=STGUIDE_FILE;
void STGuideHelp(void);
void STGuideHelp(void)
{
char *help_article;
help_article=GetTopic();
if(help_article)
{
char *path, fname[DL_NAMEMAX];
short helpviewer_id, msg[8]={VA_START,0,0,0,0,0,0,0};
/* Look for environment variable which points to the help viewer */
shel_envrn(&path,"HELPVIEWER=");
if(path) /* variable found? */
{
char *ptr;
ptr=strrchr(path,'\\'); /* find start of file name */
if(!ptr++) /* No file name found? */
ptr=path; /* Treat path as file name */
strcpy(fname,ptr); /* copy file name in temp. mem */
ptr=strrchr(fname,'.'); /* find start of extension (like ".APP") */
if(ptr) /* extension exists? ... */
*ptr=0; /* ... cut away */
}
else
strcpy(fname,"ST-GUIDE"); /* no variable? -> default app is ST-Guide */
/* Look for the help viewer application in memory */
helpviewer_id=appl_find(fname);
if(helpviewer_id<0) /* not found? */
{
char command[DL_PATHMAX];
/* Build command line with apostrophes and length byte */
strcpy(command+1,help_file);
strcat(command+1,"'");
strcat(command+1,help_article);
strcat(command+1,"'");
command[0]=(char)strlen(command+1);
if(path) /* if a path was given: try to start */
helpviewer_id=shel_write(SHW_EXEC,1,SHW_PARALLEL,path,command);
if(helpviewer_id<0) /* no viewer ? */
{
/* Alert user */
form_alert(1,tree_addr[DIAL_LIBRARY][DI_HELP_ERROR].ob_spec.free_string);
return;
}
}
else /* Viewer in memory: transfer path and chapter name */
{
char *command;
/* Allocate global accessible memory for transfer */
command=(char *)Mxalloc(strlen(help_file)+strlen(help_article)+1, MX_PREFTTRAM|MX_MPROT|MX_GLOBAL);
if (command == (void *)-32l)
command=(char *)Malloc(strlen(help_file)+strlen(help_article)+1);
if(!command)
{
/* Alert user: not enough memory */
form_alert(1,tree_addr[DIAL_LIBRARY][DI_MEMORY_ERROR].ob_spec.free_string);
return;
}
/* Build VA_START-command line */
strcpy(command,help_file);
strcat(command,help_article);
/* And send message */
msg[1]=ap_id;
*(char **)&msg[3]=command;
appl_write(helpviewer_id, 16, msg);
}
}
}
#endif