home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / vbcc / machines / amiga68k / vbrowse / vsend.c < prev   
Encoding:
C/C++ Source or Header  |  1997-12-30  |  1.8 KB  |  70 lines

  1. /*  Sendet stdin als Messages an vbrowse    */
  2. /*  written in 1995 by Volker Barthelmann   */
  3.  
  4. #include <clib/exec_protos.h>
  5. #include <clib/alib_protos.h>
  6. #include <clib/dos_protos.h>
  7. #include <exec/libraries.h>
  8.  
  9. #include <stdlib.h>
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <ctype.h>
  13.  
  14. #include "vbrowse.h"
  15.  
  16. struct MsgPort *myport,*browseport;
  17.  
  18. #define BUFSIZE 256
  19. char buf[BUFSIZE];
  20.  
  21. struct mymsg msg;
  22.  
  23. struct Library *DOSBase;
  24.  
  25. void closethings(void)
  26. {
  27.     if(myport) DeletePort(myport);
  28.     if(DOSBase) CloseLibrary(DOSBase);
  29.     exit(EXIT_SUCCESS);
  30. }
  31. int main(void)
  32. {
  33.     int len;long result=1;
  34.     if(!(DOSBase=OpenLibrary("dos.library",0))) closethings();
  35.     Forbid();
  36.     if(!(browseport=FindPort(PORTNAME)))
  37.         {Permit();Write(Output(),"vbrowse not running\n",20);closethings();}
  38.     Permit();
  39.     if(!(myport=CreatePort(0,0)))
  40.         {Write(Output(),"Could get no port\n",18);closethings();}
  41.     while(result){
  42.         char *p,c;
  43.         p=buf;len=0;
  44.         do{
  45.             *p=0;
  46.             result=Read(Input(),p,1);
  47.             c=*p;len++;
  48.             if(c=='\n'||c=='\r'||c=='\f') *p=0;
  49.         }while(result>0&&*p++);
  50. /*        if((len=strlen(buf))==0) continue;*/
  51. /*        if(isspace(buf[len-1])) buf[len-1]=0; else buf[len]=0;*/
  52. /*        printf("ms: read %s\n",buf);*/
  53.         msg.m.mn_Node.ln_Type=NT_MESSAGE;
  54.         msg.m.mn_ReplyPort=myport;
  55.         msg.m.mn_Length=sizeof(char *);
  56.         msg.text=buf;
  57.         Forbid();
  58.         if(!(browseport=FindPort(PORTNAME)))
  59.             {Permit();Write(Output(),"vbrowse not running\n",20);closethings();}
  60.         PutMsg(browseport,&msg.m);
  61.         Permit();
  62. /*        puts("ms: Message sent");*/
  63.         WaitPort(myport); /*    auf Reply warten    */
  64.         while(GetMsg(myport));
  65. /*        puts("ms: Got Reply");*/
  66.     }
  67.     closethings();
  68. }
  69.  
  70.