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: tttar_utils.h /main/3 1995/10/20 17:01:53 rswiston $ */
29 * tttar_utils.h - Utilities for the ToolTalk archive tool.
31 * Copyright (c) 1990 by Sun Microsystems, Inc.
34 #ifndef _LSTAR_UTILS_H
35 #define _LSTAR_UTILS_H
37 #include <api/c/tt_c.h>
38 #include <util/tt_string.h>
45 extern Tt_status err_noted; // Used by note_err() macro.
46 extern char *ptr_returned; // Used by note_ptr_err() macro.
47 extern void *voidptr_returned; // Used by note_voidptr_err() macro.
48 extern Tt_message msg_returned; // Used by note_msg_err() macro.
49 extern int int_returned; // Used by note_int_err() macro.
50 extern char our_process_name[];
57 * STRING_EQUAL() - Check 2 strings for equality.
59 #define STRING_EQUAL(s1,s2) ( strcmp( s1, s2 ) == 0 )
62 * NULL_OR_EMPTY() - Is this string ptr NULL or empty?
64 #define NULL_OR_EMPTY(p) (( (char *)p == NULL ) || ( *(char *)p == '\0' ))
67 * IS_TT_ERR() - Is this Tt_status neither TT_OK nor a TT_WARN?
69 #define IS_TT_ERR(err) ( err > TT_WRN_LAST )
72 * stringify() - Turn a macro argument into a string.
73 * gross Reiserism, use # in ANSI C
76 #define stringify(s) #s
78 /* gross Reiserism, use # in ANSI C */
79 #define stringify(s) "s"
83 * note_err() - Note any error corresponding to this Tt_status
84 * expression, returning the error code
86 #define note_err(expression) \
87 ( ( TT_OK == ( err_noted = expression)) \
89 : note_error( err_noted, stringify(expression), \
94 * note_ptr_err() - Assign the (char *) expression to ptr_returned,
95 * noting any error on stderr if error isn't TT_OK, and
96 * return the error code
98 #define note_ptr_err(expression) \
101 tt_pointer_error(ptr_returned = expression))) \
103 : note_error( err_noted, stringify(expression), \
104 __FILE__, __LINE__ ))
107 * note_int_err() - Assign the (int) expression to int_returned,
108 * noting any error on stderr if error isn't TT_OK, and
109 * return the error code
111 #define note_int_err(expression) \
114 tt_int_error(int_returned = expression))) \
116 : note_error( err_noted, stringify(expression), \
117 __FILE__, __LINE__ ))
120 * note_msg_err() - Assign the expression to msg_returned,
121 * noting any error on stderr if error isn't TT_OK, and
122 * return the error code
124 #define note_msg_err(expression) \
127 tt_pointer_error(msg_returned = expression))) \
129 : note_error( err_noted, stringify(expression), \
130 __FILE__, __LINE__ ))
133 * note_voidptr_err() - Assign the expression to voidptr_returned,
134 * noting any error on stderr if error isn't TT_OK, and
135 * return the error code
137 #define note_voidptr_err(expression) \
140 tt_pointer_error(voidptr_returned = expression))) \
142 : note_error( err_noted, stringify(expression), \
143 __FILE__, __LINE__ ))
146 * Procedure declarations
149 Tt_status note_error( Tt_status error, char *expression,
150 char *file, int line );
151 void my_tt_free( caddr_t p );
152 void my_tt_release( int mark );
153 bool_t in_list( _Tt_string s, _Tt_string_list_ptr list );
155 #endif /* _LSTAR_UTILS_H */