/*1* Copyright (c) 2009 Kungliga Tekniska H�gskolan2* (Royal Institute of Technology, Stockholm, Sweden).3* All rights reserved.4*5* Portions Copyright (c) 2009 Apple Inc. All rights reserved.6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10*11* 1. Redistributions of source code must retain the above copyright12* notice, this list of conditions and the following disclaimer.13*14* 2. Redistributions in binary form must reproduce the above copyright15* notice, this list of conditions and the following disclaimer in the16* documentation and/or other materials provided with the distribution.17*18* 3. Neither the name of the Institute nor the names of its contributors19* may be used to endorse or promote products derived from this software20* without specific prior written permission.21*22* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND23* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE24* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE25* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE26* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL27* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS28* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)29* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT30* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF32* SUCH DAMAGE.33*/3435#include <stdio.h>36#include <stdlib.h>37#include <krb5-types.h>38#include <heim-ipc.h>39#include <getarg.h>40#include <roken.h>4142static int help_flag;43static int version_flag;4445static struct getargs args[] = {46{ "help", 'h', arg_flag, &help_flag },47{ "version", 'v', arg_flag, &version_flag }48};4950static int num_args = sizeof(args) / sizeof(args[0]);5152static void53usage(int ret)54{55arg_printusage (args, num_args, NULL, "");56exit (ret);57}5859static void60test_service(void *ctx, const heim_idata *req,61const heim_icred cred,62heim_ipc_complete complete,63heim_sipc_call cctx)64{65heim_idata rep;66printf("got request\n");67rep.length = 0;68rep.data = NULL;69(*complete)(cctx, 0, &rep);70}717273int74main(int argc, char **argv)75{76heim_sipc u;77int optidx = 0;7879setprogname(argv[0]);8081if (getarg(args, num_args, argc, argv, &optidx))82usage(1);8384if (help_flag)85usage(0);8687if (version_flag) {88print_version(NULL);89exit(0);90}9192#if __APPLE__93{94heim_sipc mach;95heim_sipc_launchd_mach_init("org.h5l.test-ipc",96test_service, NULL, &mach);97}98#endif99heim_sipc_service_unix("org.h5l.test-ipc",100test_service, NULL, &u);101heim_ipc_main();102103return 0;104}105106107