home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) 1992 by Clarance Howatt, Gary Ritchie, Andrew Penn
- * You may modify and (hopefully) improve this code if you keep the
- * original copyright messages, don't sell it, and share your improvements
- * with with the World.
- *
- * NAME
- * displaymsg -- unix utility
- *
- * DESCRIPTION
- * Display a message in a panel. There must be someone logged in,
- * and they must have Broadcast.daemon running for this to work.
- *
- * COMMENTS/PROBLEMS
- * This program and the associated daemon represent a potential
- * security hole. Use at your own risk.
- *
- * AUTHOR/DATE CREATED
- * Gary Ritchie/December 22, 1992
- *
- * REVISIONS
- *
- */
-
- #import <appkit/appkit.h>
- #import <shared.h>
- #import <pwd.h>
- #import <BroadcastSpeaker.h>
-
- int main(int argc, char *argv[])
- {
- port_t thePort;
- id theSpeaker;
- int result;
- struct passwd *password;
- char *host;
-
- if (argc != 2 && argc != 3) {
- NXLogError("usage: %s \"message string\" [host]\n", argv[0]);
- exit(1);
- }
-
- if (argc == 3)
- host = argv[2];
- else
- host = NULL;
- thePort = NXPortFromName(BROADCASTPORT, host);
- if (!thePort) {
- NXLogError("Unable to connect to Broadcast daemon.\n");
- exit(2);
- }
-
- password = getpwuid(getuid());
-
- theSpeaker = [[BroadcastSpeaker alloc] init];
- [theSpeaker setSendPort:thePort];
- result = [theSpeaker broadcast:argv[1] from:password->pw_name];
- if (result) {
- NXLogError("Broadcast failed.\n");
- }
- [theSpeaker free];
- port_deallocate(task_self(), thePort);
-
- return 0;
- }
-