home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: alt.hackers
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!spool.mu.edu!umn.edu!lynx!carina.unm.edu!schaker
- From: schaker@carina.unm.edu (The Big Bwana)
- Subject: Ling-ling
- Message-ID: <kvrnjcl@lynx.unm.edu>
- Date: Tue, 08 Sep 92 17:12:59 GMT
- Organization: University of New Mexico, Albuquerque
- Keywords: comsat(8)
- Approved: foo@bar
- Lines: 86
-
-
- This is just an obhack with little or no verberhea. This way, I get credit
- and can post some verbage later. (It does work that way, right? ;^)
-
- I'll let the real hackers out there figure this out. The non-hackers
- might be SOL. I do not apologize for the inelegance. It's a hack,
- and I was under the gun for time. I didn't bother to clean it up.
- I suspect the socket stuff will work on all systems, but I can't be
- sure.
-
- BTW, Ling-ling is my chow that barks at lots of things. She'll even
- bark for no reason at all.
-
- stef
-
-
-
- #include <stdio.h>
- #include <strings.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <netdb.h>
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- int s, cc, len, offset;
- char *hostname, hn[50], user[50], message[100];
- struct hostent *hent;
- struct sockaddr_in saddr;
-
- if (argc < 2)
- Usage(argv[0]);
- if ((len = strlen(argv[1])) == 0)
- Usage(argv[0]);
- if (argc < 3)
- offset = 0;
- else
- offset = atoi(argv[2]);
-
- strcpy(user, argv[1]);
- if ((hostname = index(argv[1], '@')) != NULL)
- user[hostname - argv[1]] = '\0';
- if (hostname == NULL) {
- gethostname(hn, 50);
- hostname = hn;
- } else
- hostname++;
- if ((hent = gethostbyname(hostname)) == NULL) {
- fprintf(stderr, "could not find hostname \"%s\"\n", hostname);
- exit(1);
- }
- saddr.sin_family = hent->h_addrtype;
- saddr.sin_port = htons(512);
- bcopy(hent->h_addr, &saddr.sin_addr, sizeof(struct in_addr));
-
- if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
- perror("socket");
- exit (1);
- }
-
- sprintf(message, "%s@%d", user, offset);
- len = strlen(message);
-
- if ((cc=sendto(s, message, len, 0, (struct sockaddr *) &saddr,
- sizeof(struct sockaddr))) < 0) {
- perror("sendto");
- exit(1);
- }
- close(s);
- exit(0);
- }
-
- Usage(name)
- char *name;
- {
- fprintf(stderr, "Usage: %s user@host [offset]\n", name);
- exit(1);
- }
- --
- _---_ Stefan Chakerian
- / o o \ schaker@triton.unm.edu, schaker@unmb.bitnet
- | \___/ |
- \_____/ Don't anthropomorphize computers. They don't like it.
-