Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!samsung!munnari.oz.au!basser!usage!sdipl!andrews From: andrews@sdipl.oz (Andrew Schonberger) Newsgroups: comp.sys.apollo Subject: Re: DM editor as a process (Source Code included) Keywords: Summary: generate non-zero return code when aborted Message-ID: <176@sdipl.oz> Date: 28 Nov 89 00:30:03 GMT References: <5431@ncar.ucar.edu> <109@crk56.bnr.com> Reply-To: andrews@sdipl.sdi.oz.au (Andrew Schonberger) Organization: Software Developments Int'l Lines: 82 In article <109@crk56.bnr.com> janick@crk56.bnr.ca writes: >Here is a small C program (I called it dmvi) that will pop-up an edit pad >and wait for it to be close before exiting. > >I use it with rn (I am writing this with it) and its perfect. >I am running SR10 so I don't know if it'll work under SR9. I wrote a similar program, and it is really nice to set the VISUAL variable and then use it from rn or mail. The only difference from 'dmvi' is the use of return code. When editing a new letter, my mailer (mailx) is testing the return code from the editor. If the editor ended abnormally, the mailer does not replace the old message. This is usefull, since I can change my mind while editing, and after pressing the ABORT key I still have the original version. As another small difference, my editor returns abnormally if it could not open the file. Also, I took some extra care to have the pad closed when the program ends. On the other hand, there are no options recognized. I append the source for this editor. I'm using the same variable names as in the 'dmvi' posted before, so people can compose their own flavour. Andrew Schonberger -these are only my private opinions- Software Developments Int'l ACSNET: andrews@sdipl.sdi.oz 845 Pacific Hwy, NSW 2067 UUNET:..!uunet!munnari!sdipl.sdi.oz.au!andrews Australia +61-(2)-411-7200 INTERNET: andrews@sdipl.sdi.oz.au or munnari!sdipl.sdi.oz.au!andrews@uunet.uu.net ---------------------- cut here ---------------------------------- /* Apollo file editor (Andrew Schonberger) Does not use the parent's window. Thus it is more general than "xdmc cv filename". Use this program as: cred filename */ #include #include #include #include #include #include pad_$window_desc_t window; ios_$id_t stream_id; status_$t status; int main (int argc, char *argv[], char *envp[]) { if (argc!=2) { fprintf(stderr, "usage: cred filename\n"); exit(2); }; pad_$create_window ( argv[1] , strlen (argv[1]) , pad_$edit , 1 , window , &stream_id , &status ); if (status_$ok != status.all) { fprintf (stderr, "could not open: %s\n" , argv[1]) ; exit(1); } pad_$set_auto_close (stream_id, 1, true, &status); pad_$edit_wait (stream_id, &status); if (status_$ok != status.all) { fprintf (stderr, "editing aborted on %s\n", argv[1]); ios_$close (stream_id, &status); exit(2); } ios_$close (stream_id, &status); exit(0); }