2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 //%% (c) Copyright 1993, 1994 Hewlett-Packard Company
24 //%% (c) Copyright 1993, 1994 International Business Machines Corp.
25 //%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
26 //%% (c) Copyright 1993, 1994 Novell, Inc.
27 //%% $XConsortium: api_session_prop.C /main/4 1995/11/28 19:22:54 cde-sun $
32 * Copyright (c) 1990 by Sun Microsystems, Inc.
36 #include "api/c/tt_c.h"
37 #include "api/c/api_api.h"
38 #include "api/c/api_mp.h"
39 #include "api/c/api_handle.h"
40 #include "util/tt_audit.h"
44 tt_session_prop(const char *sessid, const char *propname, int i)
47 Tt_status status = audit.entry("Cri", TT_SESSION_PROP, sessid,
51 if (status != TT_OK) {
52 audit.exit((char *)error_pointer(status));
53 return (char *)error_pointer(status);
56 result = _tt_session_prop(sessid, propname, i);
64 tt_session_prop_add(const char *sessid, const char *propname, const char *value)
67 Tt_status status = audit.entry("CrnI", TT_SESSION_PROP_ADD, sessid,
69 (char *) 0 == value ? 0 : strlen(value));
71 if (status != TT_OK) {
76 status = _tt_session_prop_add(sessid, propname, value);
84 tt_session_prop_count(const char *sessid, const char *propname)
87 Tt_status status = audit.entry("Cr", TT_SESSION_PROP_COUNT,
91 if (status != TT_OK) {
92 audit.exit(error_int(status));
93 return error_int(status);
96 result = _tt_session_prop_count(sessid, propname);
104 tt_session_prop_set(const char *sessid, const char *propname,
108 Tt_status status = audit.entry("CrnI", TT_SESSION_PROP_SET, sessid,
110 (char *) 0 == value ? 0 : strlen(value));
112 if (status != TT_OK) {
117 status = _tt_session_prop_set(sessid, propname, value);
125 tt_session_bprop(const char *sessid, const char *propname, int i,
126 unsigned char **value, int *length)
129 Tt_status status = audit.entry("Cri", TT_SESSION_BPROP, sessid,
132 if (status != TT_OK) {
137 status = _tt_session_bprop(sessid, propname, i, value, length);
145 tt_session_bprop_add(const char *sessid, const char *propname,
146 const unsigned char *value, int length)
149 Tt_status status = audit.entry("CrnI", TT_SESSION_BPROP_ADD, sessid,
150 propname, value, length);
152 if (status != TT_OK) {
157 status = _tt_session_bprop_add(sessid, propname, value, length);
165 tt_session_bprop_set(const char *sessid, const char *propname,
166 const unsigned char *value, int length)
169 Tt_status status = audit.entry("CrnI", TT_SESSION_BPROP_ADD, sessid,
170 propname, value, length);
172 if (status != TT_OK) {
177 status = _tt_session_bprop_set(sessid, propname, value, length);
185 tt_session_propname(const char *sessid, int n)
188 Tt_status status = audit.entry("Ci", TT_SESSION_PROPNAME, sessid, n);
191 if (status != TT_OK) {
192 audit.exit((char *)error_pointer(status));
193 return (char *)error_pointer(status);
196 result = _tt_session_propname(sessid, n);
204 tt_session_propnames_count(const char *sessid)
207 Tt_status status = audit.entry("C", TT_SESSION_PROPNAMES_COUNT,
211 if (status != TT_OK) {
212 audit.exit(error_int(status));
213 return error_int(status);
216 result = _tt_session_propnames_count(sessid);
224 * return the character string value of the specified property on the session
227 _tt_session_prop(const char *sessid, const char *propname, int i)
233 rc = _tt_session_bprop(sessid,propname,i, &v, &junk);
237 return (char *)error_pointer(rc);
242 * Return the ith value of the specified property on the session
245 _tt_session_bprop(const char *sessid, const char *propname,
246 int i, unsigned char **value, int *length)
250 _Tt_c_session *d_session;
251 _Tt_c_procid *d_procid = _tt_c_mp->default_c_procid().c_pointer();
256 d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
257 if (!strcmp(sessid,(char *)(d_session->id()))) {
258 err = d_session->c_getprop(propname, i, val);
262 if (val.len() == 0) {
263 *value = (unsigned char *)tt_malloc(1);
268 *value = (unsigned char *)_tt_strdup(val, *length);
272 return TT_ERR_POINTER;
277 * Add the character string value to the property for the session
280 _tt_session_prop_add(const char *sessid, const char *propname,
283 return _tt_session_bprop_add(sessid, propname,
284 (unsigned char *)value,
285 (char *)0==value?0:strlen(value));
289 * Add the value to the property for the session
292 _tt_session_bprop_add(const char *sessid, const char *propname,
293 unsigned const char *value, int length)
295 _Tt_c_session *d_session;
296 _Tt_string val(value, length);
297 _Tt_c_procid *d_procid = _tt_c_mp->default_c_procid().c_pointer();
301 d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
302 if (!strcmp(sessid, (char *)(d_session->id()))) {
303 return d_session->c_addprop(propname, val);
305 return TT_ERR_POINTER;
310 * Return the number of values for the property on the session
313 _tt_session_prop_count(const char *sessid, const char *propname)
317 _Tt_c_session *d_session;
318 _Tt_c_procid *d_procid = _tt_c_mp->default_c_procid().c_pointer();
322 d_session = d_procid->default_session().c_pointer();
323 if (!strcmp(sessid,(char *)(d_session->id()))) {
324 err = d_session->c_propcount(propname, cnt);
326 return error_int(err);
331 return error_int(TT_ERR_POINTER);
337 * Replace all the values of the property of the session with the
338 * supplied character string value
341 _tt_session_prop_set(const char *sessid, const char *propname,
344 return _tt_session_bprop_set(sessid, propname,
345 (unsigned char *)value,
346 (char *) 0 == value ? 0 : strlen(value));
350 * Replace all of the values of the property of the session
353 _tt_session_bprop_set(const char *sessid, const char *propname,
354 unsigned const char *value, int length)
356 _Tt_string val(value, length);
357 _Tt_c_session *d_session;
358 _Tt_c_procid *d_procid = _tt_c_mp->default_c_procid().c_pointer();
362 d_session = d_procid->default_session().c_pointer();
363 if (!strcmp(sessid,(char *)(d_session->id()))) {
364 return(d_session->c_setprop(propname, val));
366 return TT_ERR_POINTER;
371 * Return the nth propname of the session
374 _tt_session_propname(const char *sessid, int n)
378 _Tt_c_session *d_session;
379 _Tt_c_procid *d_procid = _tt_c_mp->default_c_procid().c_pointer();
381 PTR_PCOMMIT(char_ptr);
383 d_session = d_procid->default_session().c_pointer();
384 if (!strcmp(sessid,(char *)(d_session->id()))) {
385 err = d_session->c_propname(n, prop);
387 return (char *)error_pointer(err);
389 return _tt_strdup(prop);
391 return (char *)error_pointer(TT_ERR_POINTER);
396 * Return the number of properties on the session
399 _tt_session_propnames_count(const char *sessid)
403 _Tt_c_session *d_session;
404 _Tt_c_procid *d_procid = _tt_c_mp->default_c_procid().c_pointer();
408 d_session = d_procid->default_session().c_pointer();
409 if (!strcmp(sessid,(char *)(d_session->id()))) {
410 err = d_session->c_propnames_count(cnt);
412 return error_int(err);
417 return error_int(TT_ERR_POINTER);