home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d7xx
/
d739
/
hyper.lha
/
Hyper
/
help.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-26
|
5KB
|
162 lines
/****************** help.c *********************
* *
* HYPER *
* *
* *
* © by Koessi *
* *
* Thursday, 03 Sep 1992 *
* *
* *
* this is an help showing the usage of *
* "hyper" from inside another program *
* *
* Compile with DICE: *
* dcc help.c -ohelp -rr -2.0 *
* *
*************************************************/
#include <exec/types.h>
#include <exec/execbase.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <dos/dostags.h>
#include <rexx/storage.h>
/* Prototypes */
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
#include <clib/alib_protos.h>
#include <clib/rexxsyslib_protos.h>
#define MSG struct Message
#define RMSG struct RexxMsg
#define MSGP struct MsgPort
#define SIZE 32
extern void SendRxMsg(char *);
extern void _main(int, char *);
extern int main(int, char **);
/*
int
main(int argc, char **argv)
{
return(FALSE);
}
*/
/*************************************************
* *
* *
* FUNCTION: _main *
* *
* *
* INPUT: short len *
* char *arg *
* *
* OUTPUT: int *
* *
* NOTE: no cmdline parsing ! *
* *
*************************************************/
char portname[] = "HYPER_RXPORT";
char command[] = "SYS:Utilities/hyper -b";
void
_main(int arglen, char *argptr)
{
if (!FindPort(portname))
{
SystemTags(command,
SYS_Asynch, TRUE,
SYS_Output, NULL,
SYS_Input, NULL,
TAG_DONE);
Delay(10);
}
char *arg = argptr;
while (*argptr && *argptr != '\n')
++argptr;
*argptr = '\0';
SendRxMsg(arg);
}
/*************************************************
* *
* *
* FUNCTION: SendRxMsg *
* *
* *
* INPUT: char *msgtxt *
* *
* OUTPUT: void *
* *
* NOTE: if e.g. input string is *
* formatted like this: *
* "IconAuthor/GADGETS" *
* this will cause 'hyper' to *
* search for a file called *
* a) "IconAuthor" in the *
* current directory *
* b) "HYPER:IconAuthor" *
* c) "HYPER:IconAuthor.hyper" *
* d) "HYPER:IconAuthor.guide" *
* *
* If that file is found, *
* hyper will show the page *
* "GADGETS" if a node named *
* like that is found in the *
* database *
* *
*************************************************/
void
SendRxMsg(char *msgtxt)
{
MSGP *reply_port;
MSGP *rx_port;
void *rx_msg; /* casted to parts of a RexxMsg struct */
if (reply_port = CreateMsgPort())
{
if (rx_msg = AllocVec(sizeof(RMSG), MEMF_PUBLIC|MEMF_CLEAR))
{
((struct Node *)rx_msg)->ln_Type = NT_MESSAGE;
((MSG *)rx_msg)->mn_ReplyPort = reply_port;
((MSG *)rx_msg)->mn_Length = sizeof(RMSG);
((RMSG *)rx_msg)->rm_Args[0] = msgtxt;
Forbid();
if (rx_port = (MSGP *)FindPort(portname))
{
PutMsg(rx_port, (MSG *)rx_msg);
Permit();
WaitPort(reply_port);
ReplyMsg(GetMsg(reply_port));
}
else
Permit();
FreeVec(rx_msg);
}
DeleteMsgPort(reply_port);
}
}