1226031Sstas/*
2226031Sstas * Copyright (c) 2009 Kungliga Tekniska H�gskolan
3226031Sstas * (Royal Institute of Technology, Stockholm, Sweden).
4226031Sstas * All rights reserved.
5226031Sstas *
6226031Sstas * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
7226031Sstas *
8226031Sstas * Redistribution and use in source and binary forms, with or without
9226031Sstas * modification, are permitted provided that the following conditions
10226031Sstas * are met:
11226031Sstas *
12226031Sstas * 1. Redistributions of source code must retain the above copyright
13226031Sstas *    notice, this list of conditions and the following disclaimer.
14226031Sstas *
15226031Sstas * 2. Redistributions in binary form must reproduce the above copyright
16226031Sstas *    notice, this list of conditions and the following disclaimer in the
17226031Sstas *    documentation and/or other materials provided with the distribution.
18226031Sstas *
19226031Sstas * 3. Neither the name of the Institute nor the names of its contributors
20226031Sstas *    may be used to endorse or promote products derived from this software
21226031Sstas *    without specific prior written permission.
22226031Sstas *
23226031Sstas * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24226031Sstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25226031Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26226031Sstas * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27226031Sstas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28226031Sstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29226031Sstas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30226031Sstas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31226031Sstas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32226031Sstas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33226031Sstas * SUCH DAMAGE.
34226031Sstas */
35226031Sstas
36226031Sstas#include <asn1-common.h>
37226031Sstas
38226031Sstastypedef struct heim_ipc *heim_ipc;
39226031Sstastypedef struct heim_sipc *heim_sipc;
40226031Sstastypedef struct heim_icred *heim_icred;
41226031Sstastypedef struct heim_isemaphore *heim_isemaphore;
42226031Sstastypedef struct heim_octet_string heim_idata;
43226031Sstastypedef struct heim_sipc_call *heim_sipc_call;
44226031Sstas
45226031Sstas/* common */
46226031Sstas
47226031Sstasvoid
48226031Sstasheim_ipc_free_cred(heim_icred);
49226031Sstas
50226031Sstasuid_t
51226031Sstasheim_ipc_cred_get_uid(heim_icred);
52226031Sstas
53226031Sstasgid_t
54226031Sstasheim_ipc_cred_get_gid(heim_icred);
55226031Sstas
56226031Sstaspid_t
57226031Sstasheim_ipc_cred_get_pid(heim_icred);
58226031Sstas
59226031Sstaspid_t
60226031Sstasheim_ipc_cred_get_session(heim_icred);
61226031Sstas
62226031Sstasvoid
63226031Sstasheim_ipc_main(void);
64226031Sstas
65226031Sstasheim_isemaphore
66226031Sstasheim_ipc_semaphore_create(long);
67226031Sstas
68226031Sstaslong
69226031Sstasheim_ipc_semaphore_wait(heim_isemaphore, time_t);
70226031Sstas
71226031Sstaslong
72226031Sstasheim_ipc_semaphore_signal(heim_isemaphore);
73226031Sstas
74226031Sstasvoid
75226031Sstasheim_ipc_semaphore_release(heim_isemaphore);
76226031Sstas
77226031Sstas#define HEIM_IPC_WAIT_FOREVER ((time_t)-1)
78226031Sstas
79226031Sstasvoid
80226031Sstasheim_ipc_free_data(heim_idata *);
81226031Sstas
82226031Sstas/* client */
83226031Sstas
84226031Sstasint
85226031Sstasheim_ipc_init_context(const char *, heim_ipc *);
86226031Sstas
87226031Sstasvoid
88226031Sstasheim_ipc_free_context(heim_ipc);
89226031Sstas
90226031Sstasint
91226031Sstasheim_ipc_call(heim_ipc, const heim_idata *, heim_idata *, heim_icred *);
92226031Sstas
93226031Sstasint
94226031Sstasheim_ipc_async(heim_ipc, const heim_idata *, void *, void (*func)(void *, int, heim_idata *, heim_icred));
95226031Sstas
96226031Sstas/* server */
97226031Sstas
98226031Sstas#define HEIM_SIPC_TYPE_IPC		1
99226031Sstas#define HEIM_SIPC_TYPE_UINT32		2
100226031Sstas#define HEIM_SIPC_TYPE_HTTP		4
101226031Sstas
102226031Sstastypedef void
103226031Sstas(*heim_ipc_complete)(heim_sipc_call, int, heim_idata *);
104226031Sstas
105226031Sstastypedef void
106226031Sstas(*heim_ipc_callback)(void *, const heim_idata *,
107226031Sstas		     const heim_icred, heim_ipc_complete, heim_sipc_call);
108226031Sstas
109226031Sstas
110226031Sstasint
111226031Sstasheim_sipc_launchd_mach_init(const char *, heim_ipc_callback,
112226031Sstas			    void *, heim_sipc *);
113226031Sstas
114226031Sstasint
115226031Sstasheim_sipc_stream_listener(int, int, heim_ipc_callback,
116226031Sstas			  void *, heim_sipc *);
117226031Sstas
118226031Sstasint
119226031Sstasheim_sipc_service_unix(const char *, heim_ipc_callback,
120226031Sstas		       void *, heim_sipc *);
121226031Sstas
122226031Sstas
123226031Sstasvoid
124226031Sstasheim_sipc_timeout(time_t);
125226031Sstas
126226031Sstasvoid
127226031Sstasheim_sipc_set_timeout_handler(void (*)(void));
128226031Sstas
129226031Sstasvoid
130226031Sstasheim_sipc_free_context(heim_sipc);
131