Annotation of driverkit/tests/smsg.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
        !             7:  * Reserved.  This file contains Original Code and/or Modifications of
        !             8:  * Original Code as defined in and that are subject to the Apple Public
        !             9:  * Source License Version 1.1 (the "License").  You may not use this file
        !            10:  * except in compliance with the License.  Please obtain a copy of the
        !            11:  * License at http://www.apple.com/publicsource and read it before using
        !            12:  * this file.
        !            13:  * 
        !            14:  * The Original Code and all software distributed under the License are
        !            15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT.  Please see the
        !            19:  * License for the specific language governing rights and limitations
        !            20:  * under the License.
        !            21:  * 
        !            22:  * @APPLE_LICENSE_HEADER_END@
        !            23:  */
        !            24: /*     @(#)lfs.c       2.0     26/06/90        (c) 1990 NeXT   */
        !            25: 
        !            26: /* 
        !            27:  * smsg.c -- Send simple message to arbitrary server.
        !            28:  *
        !            29:  * HISTORY
        !            30:  * 23-Jun-91   Doug Mitchell at NeXT
        !            31:  *     Clones from lfs.c.
        !            32:  */
        !            33: 
        !            34: #import <sys/types.h>
        !            35: #import <mach/mach.h>
        !            36: #import <mach/mach_error.h>
        !            37: #import <ansi/stdlib.h>
        !            38: #import <bsd/libc.h>
        !            39: #import <mach/port.h>
        !            40: #import <servers/netname.h>
        !            41: 
        !            42: extern void usage(char **argv);
        !            43: 
        !            44: int main(int argc, char **argv)
        !            45: {
        !            46:        kern_return_t krtn;
        !            47:        int arg;
        !            48:        char *hostname = "";
        !            49:        port_t fs_port, local_port;
        !            50:        msg_header_t msg;
        !            51:        
        !            52:        if(argc < 3) 
        !            53:                usage(argv);
        !            54:        for(arg=3; arg<argc; arg++) {
        !            55:                switch(argv[arg][0]) {
        !            56:                    case 'h':
        !            57:                        hostname = &argv[arg][2];
        !            58:                        break;
        !            59:                    default:
        !            60:                        usage(argv);
        !            61:                }
        !            62:        }
        !            63:        krtn = port_allocate(task_self(), &local_port);
        !            64:        if(krtn) {
        !            65:                mach_error("port_allocate", krtn);
        !            66:                exit(1);
        !            67:        }
        !            68:        krtn = netname_look_up(name_server_port, hostname, argv[1], &fs_port);
        !            69:        if(krtn) {
        !            70:                mach_error("netname_look_up", krtn);
        !            71:                exit(1);
        !            72:        }
        !            73:        
        !            74:        /*
        !            75:         * Cook up a basic message.
        !            76:         */
        !            77:        msg.msg_id = atoi(argv[2]);
        !            78:        msg.msg_size = sizeof(msg_header_t);
        !            79:        msg.msg_local_port = local_port;
        !            80:        msg.msg_remote_port = fs_port;
        !            81:        krtn = msg_rpc(&msg,
        !            82:                MSG_OPTION_NONE,        
        !            83:                msg.msg_size,           
        !            84:                0,                      /* send_timeout */
        !            85:                0);                     /* rcv_timeout */
        !            86:        if(krtn) {
        !            87:                mach_error("msg_rpc", krtn);
        !            88:                exit(1);
        !            89:        }
        !            90:        printf("...OK\n");
        !            91:        exit(0);
        !            92: }
        !            93: 
        !            94: void usage(char **argv)
        !            95: {
        !            96:        printf("usage: %s server_name msg_id [h=hostname]\n", argv[0]);
        !            97:        exit(1);
        !            98: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.