Utilities.hpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 /******************************************************************************/
39 
40 #ifndef Included_Utilities
41 #define Included_Utilities
42 
43 #include <rexx.h>
44 #include <sys/types.h>
45 #include <stdarg.h>
46 
47 #ifdef __REXX64__
48 #define CONCURRENCY_TRACE "%16.16x %16.16x %16.16x %5.5hu%c "
49 #else
50 #define CONCURRENCY_TRACE "%8.8x %8.8x %8.8x %5.5hu%c "
51 #endif
52 
53 #define CONCURRENCY_BUFFER_SIZE 100 // Must be enough to support CONCURRENCY_TRACE
54 
55 
56 class Utilities
57 {
58 public:
59  static int strCaselessCompare(const char *opt1, const char *opt2);
60  static int memicmp(const void *opt1, const void *opt2, size_t len);
61  static void strupper(char *str);
62  static void strlower(char *str);
63  static const char *strnchr(const char *, sizeB_t n, char ch);
64  static const char *locateCharacter(const char *s, const char *set, sizeB_t l);
65  static int vsnprintf(char *buffer, size_t count, const char *format, va_list args);
66  static int snprintf(char *buffer, size_t count, const char *format, ...);
67  static wholenumber_t currentThreadId(); // Could be in SysThread.hpp, but for the moment, it's here...
68  static void traceConcurrency(bool);
69  static bool traceConcurrency();
70  static void traceParsing(bool);
71  static bool traceParsing();
72 };
73 
74 #endif
75 
static const char * strnchr(const char *, sizeB_t n, char ch)
Definition: Utilities.cpp:172
static void strupper(char *str)
Definition: Utilities.cpp:132
static wholenumber_t currentThreadId()
static bool traceConcurrency()
static void strlower(char *str)
Definition: Utilities.cpp:151
static bool traceParsing()
static int strCaselessCompare(const char *opt1, const char *opt2)
Definition: Utilities.cpp:82
static const char * locateCharacter(const char *s, const char *set, sizeB_t l)
Definition: Utilities.cpp:52
static int memicmp(const void *opt1, const void *opt2, size_t len)
Definition: Utilities.cpp:107
static int vsnprintf(char *buffer, size_t count, const char *format, va_list args)
static int snprintf(char *buffer, size_t count, const char *format,...)
ssize_t wholenumber_t
Definition: rexx.h:230
stringsizeB_t sizeB_t
Definition: rexx.h:248