kim@amdahl.uts.amdahl.com (Kim DeVaughn) (03/07/88)
[ For all you do ... this line's for you ... ] With all the current discussion about IPC methodology, ARexx, and such, this seems like a good time to post the attached example of a simple form of an ARexx interface. It is being posted here, rather than in comp.sources.amiga, as it is short, and is primarily example code. In the attached shar file, you'll find a small standalone program called "rex" that I used to familiarize myself with the (COMMAND form of the) ARexx interface. You'll also find the actual interface file (rexx.c) that I used to interface Matt's "dme" editor to ARexx. Besides the rexx.c file, I only had to add about 20 lines of code to the dme sources (which Matt has improved upon, I believe). This interface added less than 2K to the dme executable. Not included are the header files that come in the ARexx package ... I don't have Bill Hawes' permission to redistribute them (yet), nor the C bindings, but if you have ARexx, you have a copy of them anyway. Of course you need ARexx to run the "rex" example (try "rex args" to see what "rex" passes to ARexx, and watch what ARexx does when it tries to execute the "foo" command). Now this is a very simple and basic form of interface to ARexx. More sophisticated facilities are available. I just wanted to see what a minimal interface would look like, with a minimum of changes to dme. The dme interface works quite well, given that dme was never designed with such an interface in mind. There are some limitations because of the way dme does error and command completion reporting, but the point is that I was able to interface the two with very little effort. To fully take advantage of ARexx's capabilities will require some additional work in dme's innards, and perhaps the addition of some new dme commands. When Rob Peck posts his speechtoy with an ARexx interface, I think I'll see about making a "talking editor" out of dme using speechtoy (which could just as well be a spelling checker, etc.) Should be a piece of cake ... Now I'm not saying that the ARexx interface is perfect for all IPC applications, but it *is* quite powerful, and can be used pretty simply. Bill has done a very professional job of implementing the REXX interpreter, and providing an interface that is consistant with the Amiga OS. The supplied .libraries have many more additional functions than are used in the example files. These functions are not specific to ARexx per se, and can be used by any program that wants to take advantage of them (similar to the way one can take advantage of the ARP functions in the arp.library). Other advantages of ARexx are that it is small (rexxsyslib.library is less than 32K, and the resident program "rexxmast" is less than 2K), and fast, having been implemented in very tight assembly language. It is well documented, the manual being 140+ pages. It uses an established language for it's processing (REXX is one of the few really good things to make it out of Big Blue ... must be because it was a research project :-) ). And it is available NOW ... TODAY ... for less than fifty bucks! Sorry if I started sounding commercial, but it really *is* a good product. I hope the development community uses it as a base for a *standardized* IPC facility. If there are fundemental deficiencies in ARexx, Bill is a pretty reasonable guy, and I'm sure he'd be interested in improving the product. Enough verbage! Here's the code ... /kim # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # args.dme rex.c rex.uue rexx.c rexx.h Makefile echo x - args.dme cat > "args.dme" << '//E*O*F args.dme//' /* test to look at what dme is passing to ARexx .... */ parse source a b c d e f g h i say a b c d e f g h i parse arg a1 a2 a3 a4 a5 a6 foo say a1 a2 a3 a4 a5 a6 exit 0 //E*O*F args.dme// echo x - rex.c cat > "rex.c" << '//E*O*F rex.c//' /* * REX.C * * (c) Copyright 1987, 1988 by Kim DeVaughn, All Rights Reserved * * This program is freely redistributable for non-commercial purposes. * * For commercial use, you may contact the author via USENET at: * kim@amdahl.amdahl.com * * * Example of ARexx interface code, etc. * */ #include <stdio.h> #include "defs.h" #include "rexx.h" APTR OpenLibrary(); APTR FindPort(); APTR GetMsg(); APTR CreateRexxMsg(); APTR CreateArgstring(); /* struct RexxArg *cmdarg; struct MsgPort RexxPort; struct MsgPort *ARexxPort; struct RexxMsg *cmdptr; struct RexxMsg *retptr; */ struct RxsLib *RexxSysBase; /* * issue a command to ARexx ... */ do_rexx(cmdstr) char *cmdstr; { struct RexxArg *cmdarg; struct MsgPort RexxPort; struct MsgPort *ARexxPort; struct RexxMsg *cmdptr; struct RexxMsg *retptr; char host[16]; char hexbuf[12]; /* should only need 9 bytes */ int ret, testcmd, i; ClearMem(&RexxPort, sizeof(struct MsgPort)); strcpy(host, "DME"); sprintf(hexbuf, "%08x", &RexxPort); strcat(host, hexbuf); InitPort(&RexxPort, host); /* need to error check this */ AddPort(&RexxPort); /* return here if InitPort failed */ if (cmdarg = (struct RexxArg *)CreateArgstring(cmdstr, strlen(cmdstr))) { if (cmdptr = (struct RexxMsg *)CreateRexxMsg(&RexxPort, "dme", host)) { ACTION(cmdptr) = RXCOMM; ARG0(cmdptr) = (STRPTR)cmdarg; Forbid(); if (ARexxPort = (struct MsgPort *)FindPort("REXX")) { PutMsg(ARexxPort, cmdptr); Permit(); i = 0; for (;;) { WaitPort(&RexxPort); retptr = (struct RexxMsg *)GetMsg(&RexxPort); printf("\nMessage = %d Host = %s\n", i+1, host); if (IsRexxMsg(retptr)) printf("IsRexxMsg() says it be a REXX msg!\n"); printf("rm_Args[0] = %s\n", ARG0(retptr)); printf("rm_Result1 = %d\nrm_Result2 = %d\n", RESULT1(retptr), RESULT2(retptr)); printf("rm_Action = %08x\n", ACTION(retptr)); printf("ln_Name = %s\n", retptr->rm_Node.mn_Node.ln_Name); if (IsRexxMsg(retptr)) { /* here's where you process the command the ARexx macro issued */ testcmd = strcmp(ARG0(retptr), "SECOND"); if (testcmd == 0) do_rexx("second"); testcmd = strcmp(ARG0(retptr), "CAT"); if (testcmd == 0) do_rexx("cat"); RESULT1(retptr) = i; RESULT2(retptr) = 0; i++; ReplyMsg(retptr); } if (cmdptr == retptr) break; } if (ret = RESULT1(retptr)) { if (RESULT2(retptr)) { if (RESULT2(retptr) == 1) { printf("Unknown Command\n"); } else { printf("ARexx macro error: Code = %d Severity = %d\n", RESULT2(retptr), ret); } } else { printf("User specified macro error. RC = %d\n", ret); } } else { printf("Normal macro termination.\n"); } } else { printf("ARexx not available - REXX port not found\n"); ret = -1; } DeleteRexxMsg(cmdptr); } else { printf("CreateRexxMsg() Failed\n"); /* this may be overkill, and not need to be checked */ ret = -1; } DeleteArgstring(cmdarg); } else { printf("CreateArgstring() Failed\n"); /* this may be overkill, and not need to be checked */ ret = -1; } RemPort(&RexxPort); FreePort(&RexxPort); return(ret); } /* * initializion of our port to talk to ARexx */ void rexxinit() { char hexbuf[12]; /* should only need 9 bytes */ /* need to add error checking */ /* ClearMem(&RexxPort, sizeof(struct MsgPort)); strcpy(host, "DME"); sprintf(hexbuf, "%08x", &RexxPort); strcat(host, hexbuf); printf("\n\nhost = %s\n", host); InitPort(&RexxPort, host); AddPort(&RexxPort); */ return(); } /* * cleanup of our ARexx port */ void rexxclose() { /* RemPort(&RexxPort); FreePort(&RexxPort); */ return(); } /* ......... test prog ........... */ main (argc, argv) int argc; char *argv[]; { if (argc < 2) exit(5); if (RexxSysBase = (struct RxsLib *)OpenLibrary("rexxsyslib.library", (ULONG)RXSVERS)) { /* rexxinit(); */ do_rexx(argv[1]); /* rexxclose(); */ CloseLibrary(RexxSysBase); } exit(0); } //E*O*F rex.c// echo x - rex.uue cat > "rex.uue" << '//E*O*F rex.uue//' begin 755 rex M```#\P`````````#``````````(```82````J0````$```/I```&$D[Z!H9.C M5?^F2'@`(DAM_]I.N@7H4$](>@*T2&W_ODZZ"EY03TAM_]I(>@*F2&W_LDZZ= M"Q!/[P`,2&W_LDAM_[Y.N@GB4$](;?^^2&W_VDZZ!0Y03TAM_]I.NA<&6$\O2 M+0`(3KH/V%A/+P`O+0`(3KH%AE!/*T#__&<``B1(;?^^2'H"4TAM_]I.N@2*P M3^\`#"M`_])G``'J(&W_TB%\`0`````<(&W_TB%M__P`*$ZZ%N)(>@(E3KH6& MPEA/*T#_UF<``:`O+?_2+RW_UDZZ%PQ03TZZ%OY"K?^F2&W_VDZZ%S)83TAM$ M_]I.NA;$6$\K0/_.2&W_OB`M_Z92@"\`2'H!WDZZ"HY/[P`,+RW_SDZZ!%18K M3TJ`9PI(>@'?3KH*=%A/(&W_SB\H`"A(>@'Q3KH*8E!/(&W_SB\H`"0@;?_.H M+R@`($AZ`>A.N@I(3^\`#"!M_\XO*``<2'H!]4ZZ"C103R!M_\XO*``*2'H!N M]DZZ"B)03R\M_\Y.N@/J6$]*@&=L2'H%*M_Z8O+?_.3KH6"EA/(&W_TK'M3 M_\YG!&``_N`@;?_.*V@`(/^N9TX@;?_.2J@`)&<T(&W_S@RH`````0`D9@Q(= M>@%G3KH);%A/8!@O+?^N(&W_SB\H`"1(>@%@3KH)5$_O``Q@#B\M_ZY(>@%]E M3KH)0E!/8`I(>@&73K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2&T`#"\M``A(V M>@2N3KH`D$_O``Q.74YU3E4``$CG""`D;0`0#*T````$`!1F""!M``@H$&`47 M2JT`#&\((&T`""@08`8@;0`(*!!"K0`42JT`#&P21*T`#$J$;`I$A"M\````N M`0`4(BT`#"`$3KH#TD'L@`)3BA2P"``B+0`,(`1.N@/**`!FWDJM`!1G!E.*> M%+P`+2`*3-\$$$Y=3G5.5?\42.<(,"1M``@F;0`,0JW_^"MM`!#__"!+4HL0* M$$B`2,`H`&<``S"XO````"5F``,*0BW_(BM\`````?_T*WP````@__`K?```V M)Q#_["!+4HL0$$B`2,`H`+"\````+6800JW_]"!+4HL0$$B`2,`H`+B\````' M,&84*WP````P__`@2U*+$!!(@$C`*`"XO````"IF&B!M__Q8K?_\*U#_Z"!+# M4HL0$$B`2,`H`&`T0JW_Z&`B<@H@+?_H3KH)O-"$D+P````P*T#_Z"!+4HL08 M$$B`2,`H`$'L@!4(,``"2`!FTKB\````+F9B($M2BQ`02(!(P"@`L+P````JD M9AH@;?_\6*W__"M0_^P@2U*+$!!(@$C`*`!@-$*M_^Q@(G(*("W_[$ZZ"5+0E MA)"\````,"M`_^P@2U*+$!!(@$C`*`!![(`5"#```D@`9M(K?`````3_Y+B\T M````;&86($M2BQ`02(!(P"@`*WP````$_^1@%+B\````:&8,($M2BQ`02(!(0 MP"@`(`1@?BM\````"/_@8!PK?`````K_X&`2*WP````0_^!@""M\____]O_@M M+RW_Y$AM_R(O+?_@+RW__$ZZ_;0K0/_<("W_Y-&M__Q/[P`08%H@;?_\6*W_C M_"M0_]PO+?_<3KH"'"M`_^183V!*(&W__%BM__PH$$'M_R$K2/_<$(1@*)"\2 M````8V?B4X!GE)"\````"V<`_VY9@&>T58!G`/]N5X!G`/]R8,Q![?\BD>W_I MW"M(_^0@+?_DL*W_[&\&*VW_[/_D2JW_]&=P(&W_W`P0`"UG"B!M_]P,$``K7 M9C0,K0```##_\&8J4ZW_Z"!M_]Q2K?_<$!!(@$C`+P!.DK"\_____UA/9@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[N_H9,[P`#``0L;()B3N[^SD[Z``(@;P`$@ M+&R"8D[N_H!,[P,```0L;(**3N[_H"!O``0L;(**3N[_IB!O``0L;(**3N[_! ML@```^P````!`````0``!OP````````#\@```^H```"4,#$R,S0U-C<X.6%BK M8V1E9@```"`@("`@("`@(#`P,#`P("`@("`@("`@("`@("`@("`@D$!`0$!`R M0$!`0$!`0$!`0`P,#`P,#`P,#`Q`0$!`0$!`"0D)"0D)`0$!`0$!`0$!`0$!Z M`0$!`0$!`0%`0$!`0$`*"@H*"@H"`@("`@("`@("`@("`@("`@("`D!`0$`@, M``````````````````$``````0`````````````````````!`0````$`````% M`````````````````0(````!````````````````````````````````````$ M````````````````````````````````````````````````````````````` M````````````````````````````````````````````````````````````` M````````````````````````````````````````````````````````````` M````````````````````````````````````````````````````````````` M````````````````````````````````````````````````````````````` M````````````````````````````````````````````````````````````` M````````````````````````````````````````````````````````````` M`````````````````````````````````````````````````!0``````_(`) +``/K`````0```_(`D `` end size 6896 //E*O*F rex.uue// echo x - rexx.c cat > "rexx.c" << '//E*O*F rexx.c//' /* * REXX.C * * (c) Copyright 1987, 1988 by Kim DeVaughn, All Rights Reserved * * This program is freely redistributable for non-commercial purposes. * * For commercial use, you may contact the author via USENET at: * kim@amdahl.amdahl.com * * * ARexx interface code, etc. to interface with Matt Dillon's "dme" editor * (v1.29). * */ #include "defs.h" #include "rexx.h" #if AREXX APTR OpenLibrary(); APTR FindPort(); APTR GetMsg(); APTR CreateRexxMsg(); APTR CreateArgstring(); extern int foundcmd; struct RxsLib *RexxSysBase; /* * initialization for ARexx ... just open rexsyslib.library */ void openrexx() { RexxSysBase = (struct RxsLib *)OpenLibrary("rexxsyslib.library", (ULONG)RXSVERS); return(); } /* * cleanup any open ARexx stuff ... just close rexsyslib.library for now */ void closerexx() { if (RexxSysBase) { CloseLibrary(RexxSysBase); } return(); } /* * explicit invocation interface between do_command() and do_rexx * for ARexx macros having NO arguments (i.e., for the "rx" command) */ do_rx() { do_rexx(av[1]); return(); } /* * explicit invocation interface between do_command() and do_rexx * for ARexx macros having ONE argument (i.e., for the "rx1" command) */ do_rx1() { char macbuf[256]; strcpy(macbuf, av[1]); strcat(macbuf, " "); strcat(macbuf, av[2]); do_rexx(macbuf); return(); } /* * explicit invocation interface between do_command() and do_rexx * for ARexx macros having TWO arguments (i.e., for the "rx2" command) */ do_rx2() { char macbuf[256]; strcpy(macbuf, av[1]); strcat(macbuf, " "); strcat(macbuf, av[2]); strcat(macbuf, " "); strcat(macbuf, av[3]); do_rexx(macbuf); return(); } /* * issue a command to ARexx ... */ do_rexx(macstr) char *macstr; { struct RexxArg *macarg; struct MsgPort RexxPort; struct MsgPort *ARexxPort; struct RexxMsg *macptr; struct RexxMsg *cmdptr; char host[16]; char hexbuf[12]; /* should only need 9 bytes */ char errmsg[80]; /* don't build a larger error message */ int ret; if (RexxSysBase == 0) { title("Unknown Command - No Macros: ARexx Not Installed "); /* no rexxsyslib */ return(0); } ClearMem(&RexxPort, sizeof(struct MsgPort)); strcpy(host, "DME"); sprintf(hexbuf, "%08x", &RexxPort); strcat(host, hexbuf); InitPort(&RexxPort, host); /* need to error check this */ AddPort(&RexxPort); /* return here if InitPort failed */ if (macarg = (struct RexxArg *)CreateArgstring(macstr, strlen(macstr))) { if (macptr = (struct RexxMsg *)CreateRexxMsg(&RexxPort, "dme", host)) { ACTION(macptr) = RXCOMM; ARG0(macptr) = (STRPTR)macarg; Forbid(); if (ARexxPort = (struct MsgPort *)FindPort("REXX")) { PutMsg(ARexxPort, macptr); Permit(); title("Calling ARexx Macro ... "); for (;;) { WaitPort(&RexxPort); cmdptr = (struct RexxMsg *)GetMsg(&RexxPort); if (IsRexxMsg(cmdptr)) { foundcmd = 0; ret = do_command(ARG0(cmdptr)); if (foundcmd) { ret = (ret == 1) ? 0 : 5; /* cmd error: RC = 5 */ } else { ret = do_rexx(ARG0(cmdptr)); /* another macro? */ } RESULT1(cmdptr) = ret; RESULT2(cmdptr) = 0; ReplyMsg(cmdptr); } do_command("null"); /* a kludge to set "foundcmd" */ if (macptr == cmdptr) break; } if (ret = RESULT1(cmdptr)) { if (RESULT2(cmdptr)) { if (RESULT2(cmdptr) == 1) { title("Unknown Command "); } else { sprintf(errmsg, "ARexx Macro Error: Code = %d Severity = %d ", RESULT2(cmdptr), ret); title(errmsg); } } else { sprintf(errmsg, "User Specified Macro Error: RC = %d ", ret); title(errmsg); } } else { title("OK "); } } else { title("Unknown Command - No Macros: ARexx Not Active "); /* no REXX port */ ret = -1; } DeleteRexxMsg(macptr); } else { title("CreateRexxMsg() Failed "); /* may be overkill, and not need to ckeck this */ ret = -1; } DeleteArgstring(macarg); } else { title("CreateArgstring() Failed "); /* may be overkill, and not need to check this */ ret = -1; } RemPort(&RexxPort); FreePort(&RexxPort); return(ret); } /* * a kludge to flush the do_command pipe ... until I can fix a recursive macro bug ... */ void do_null() { return(); } #endif //E*O*F rexx.c// echo x - rexx.h cat > "rexx.h" << '//E*O*F rexx.h//' /* * * A few additional defines to make life a little easier. * * (c) Copyright 1987 Kim DeVaughn, All Rights Reserved * */ #ifndef REXX_STORAGE_H #include <rexx/storage.h> #endif #ifndef REXX_H #define REXX_H /* more RexxMsg field definitions */ #define ACTION(rmp) (rmp->rm_Action) /* command (action) code */ #define RESULT1(rmp) (rmp->rm_Result1) /* primary result (return code) */ #define RESULT2(rmp) (rmp->rm_Result2) /* secondary result */ #define COMM_ADDR(rmp) (rmp->rm_CommAddr) /* host address (port name) */ #define FILE_EXT(rmp) (rmp->rm_FileExt) /* file extension */ #endif //E*O*F rexx.h// echo x - Makefile cat > "Makefile" << '//E*O*F Makefile//' # Note: In terms of compiling, if you do not have Matt's latest # support library you may have to do some hacking to get the # code to link. # # The precompiled symbol table, SYMBOLS.M, is *only* the AMIGA includes # .. */*.h (exec/*.h, etc....). When generating a precompiled symbol # table remember to use the +L compiler option. CFLAGS= +L -Idme:include -Idme:sup32lib +Ivd0:include/symbols.m OBJS= rex.o rexxglue.o ASMS= rex.asm SRCS= rex.c HDR= defs.h rexx.h .c.o: cc $(CFLAGS) -o $@ $*.c .c.asm: cc $(CFLAGS) -A -o ram:$@ $*.c all: $(OBJS) ln +Q $(OBJS) -lsup32 -lc32 -O rex //E*O*F Makefile// echo Possible errors detected by \'wc\' [hopefully none]: temp=/tmp/shar$$ trap "rm -f $temp; exit" 0 1 2 3 15 cat > $temp <<\!!! 9 52 172 args.dme 200 505 4969 rex.c 159 161 9690 rex.uue 235 586 5285 rexx.c 26 81 664 rexx.h 24 98 614 Makefile 653 1483 21394 total !!! wc args.dme rex.c rex.uue rexx.c rexx.h Makefile | sed 's=[^ ]*/==' | diff -b $temp - exit 0 -- UUCP: kim@amdahl.amdahl.com or: {sun,decwrl,hplabs,pyramid,ihnp4,uunet,oliveb,cbosgd,ames}!amdahl!kim DDD: 408-746-8462 USPS: Amdahl Corp. M/S 249, 1250 E. Arques Av, Sunnyvale, CA 94086 CIS: 76535,25