1 /*
2 
3 Copyright 1993, 1998  The Open Group
4 
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
10 
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
24 
25 */
26 
27 /*
28  * Author: Ralph Mor, X Consortium
29  */
30 
31 #ifdef HAVE_CONFIG_H
32 #include <config.h>
33 #endif
34 #include <X11/SM/SMlib.h>
35 #include "SMlibint.h"
36 #include <stdio.h>
37 
38 /*
39  * Free property
40  */
41 
42 void
SmFreeProperty(SmProp * prop)43 SmFreeProperty(SmProp *prop)
44 {
45     if (prop)
46     {
47 	int i;
48 
49 	if (prop->name)
50 	    free (prop->name);
51 	if (prop->type)
52 	    free (prop->type);
53 	if (prop->vals)
54 	{
55 	    for (i = 0; i < prop->num_vals; i++)
56 		if (prop->vals[i].value)
57 		    free (prop->vals[i].value);
58 	    free (prop->vals);
59 	}
60 
61 	free (prop);
62     }
63 }
64 
65 
66 /*
67  * Free reason messages
68  */
69 
70 void
SmFreeReasons(int count,char ** reasonMsgs)71 SmFreeReasons(int count, char **reasonMsgs)
72 {
73     if (reasonMsgs)
74     {
75 	int i;
76 
77 	for (i = 0; i < count; i++)
78 	    free (reasonMsgs[i]);
79 
80 	free (reasonMsgs);
81     }
82 }
83 
84 
85 
86 /*
87  * Smc informational functions
88  */
89 
90 int
SmcProtocolVersion(SmcConn smcConn)91 SmcProtocolVersion(SmcConn smcConn)
92 {
93     return (smcConn->proto_major_version);
94 }
95 
96 
97 int
SmcProtocolRevision(SmcConn smcConn)98 SmcProtocolRevision(SmcConn smcConn)
99 {
100     return (smcConn->proto_minor_version);
101 }
102 
103 
104 char *
SmcVendor(SmcConn smcConn)105 SmcVendor(SmcConn smcConn)
106 {
107     return strdup(smcConn->vendor);
108 }
109 
110 
111 char *
SmcRelease(SmcConn smcConn)112 SmcRelease(SmcConn smcConn)
113 {
114     return strdup(smcConn->release);
115 }
116 
117 
118 char *
SmcClientID(SmcConn smcConn)119 SmcClientID(SmcConn smcConn)
120 {
121     return strdup(smcConn->client_id);
122 }
123 
124 
125 IceConn
SmcGetIceConnection(SmcConn smcConn)126 SmcGetIceConnection(SmcConn smcConn)
127 {
128     return (smcConn->iceConn);
129 }
130 
131 
132 
133 /*
134  * Sms informational functions
135  */
136 
137 int
SmsProtocolVersion(SmsConn smsConn)138 SmsProtocolVersion(SmsConn smsConn)
139 {
140     return (smsConn->proto_major_version);
141 }
142 
143 
144 int
SmsProtocolRevision(SmsConn smsConn)145 SmsProtocolRevision(SmsConn smsConn)
146 {
147     return (smsConn->proto_minor_version);
148 }
149 
150 
151 char *
SmsClientID(SmsConn smsConn)152 SmsClientID(SmsConn smsConn)
153 {
154     return strdup(smsConn->client_id);
155 }
156 
157 
158 IceConn
SmsGetIceConnection(SmsConn smsConn)159 SmsGetIceConnection(SmsConn smsConn)
160 {
161     return (smsConn->iceConn);
162 }
163