openblt

a hobby OS from the late 90s
git clone http://frotz.net/git/openblt.git
Log | Files | Refs | LICENSE

tell.c (975B)


      1 /* Copyright 1999, Sidney Cammeresi. All rights reserved.
      2 ** Distributed under the terms of the OpenBLT License
      3 */
      4 
      5 #include <stdio.h>
      6 #include <stdlib.h>
      7 #include <string.h>
      8 #include <blt/syscall.h>
      9 #include <blt/namer.h>
     10 
     11 int main (int argc, char **argv)
     12 {
     13 	char *text;
     14 	int i, loc_port, rem_port;
     15 	msg_hdr_t mh;
     16 
     17 	if (argc < 3)
     18 	{
     19 		printf ("tell: syntax: tell [server] [message]\n");
     20 		return 0;
     21 	}
     22 	text = malloc (256);
     23 	strlcpy (text, argv[1], 256);
     24 	strlcat (text, ":tell", 256);
     25 
     26 	rem_port = namer_find (text, 0);
     27 	if (rem_port < 1)
     28 	{
     29 		printf ("tell: no such server or server not using tell\n");
     30 		return 0;
     31 	}
     32 	loc_port = port_create (rem_port,"port");
     33 	strlcpy (text, argv[2], 256);
     34 	for (i = 3; i < argc; i++)
     35 	{
     36 		strlcat (text, " ", 256);
     37 		strlcat (text, argv[i], 256);
     38 	}
     39 
     40 	mh.src = loc_port;
     41 	mh.dst = rem_port;
     42 	mh.data = text;
     43 	mh.size = strlen (text) + 1;
     44 	old_port_send (&mh);
     45 	mh.src = rem_port;
     46 	mh.dst = loc_port;
     47 	old_port_recv (&mh);
     48 	return 0;
     49 }
     50