Open Core Interface - MLPI
MLPI-MotionLogicProgrammingInterface(mlpiCore)  1.26.2
mlpiGlobalHelper.h
Go to the documentation of this file.
1 #ifndef __MLPIGLOBALHELPER_H__
2 #define __MLPIGLOBALHELPER_H__
3 
4 // -----------------------------------------------------------------------
5 // MLPI - <mlpiGlobalHelper.h>
6 // -----------------------------------------------------------------------
7 // Copyright (c) 2013 Bosch Rexroth. All rights reserved.
8 // Redistribution and use in source and binary forms of this MLPI software
9 // (SW) provided to you, with or without modification, are permitted
10 // without prior approval provided that the following conditions are met:
11 //
12 // 1. Redistributions of source code of SW must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // 2. Redistributions in binary form of SW must reproduce the above copyright
16 // notice, this list of conditions and the following disclaimer in the
17 // documentation and/or other materials provided with the distribution.
18 //
19 // 3. User recognizes and acknowledges that it acquires no right,
20 // title or interest in or to any of the names or trademarks used in
21 // connection with the SW ("names") by virtue of this License and waives
22 // any right to or interest in the names. User recognizes and acknowledges
23 // that names of companies or names or products of companies displayed
24 // in the documentation of SW to indicate the interoperability of products
25 // with the SW are the names of their respective owners. The use of such
26 // names in the documentation of SW does not imply any sponsorship,
27 // approval, or endorsement by such companies of this product.
28 //
29 // 4. Modified code versions, i.e. any addition to or deletion from
30 // the substance or structure of the original code of the SW running
31 // the MLPI must be plainly marked as such and must not be misrepresented
32 // as being original SW.
33 //
34 // 5. The SW may only be used in connection with a Bosch Rexroth product.
35 //
36 // THIS INFORMATION IS PROVIDED BY BOSCH REXROTH CORPORATION "AS IS"
37 // AND WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING
38 // (BUT NOTLIMITED TO) ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
39 // FITNESS FOR ANY PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WHILE THE
40 // INFORMATION PROVIDED IS BELIEVED TO BE ACCURATE, IT MAY INCLUDE
41 // ERRORS OR INACCURACIES.
42 // SUBJECT TO COMPULSORY STATUTORY PROVISIONS OF THE GERMAN LAW AS
43 // THE APPLICABLE LAW FOR THIS LICENSE BOSCH REXROTH CORPORATION WILL
44 // NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING FROM THE USE OF
45 // THE SOFTWARE DISTRIBUTED HEREUNDER, INCLUDING BUT NOT LIMITED TO
46 // DIRECT, INDIRECT, INCIDENTAL, PUNITIVE, AND CONSEQUENTIAL DAMAGES.
47 // -----------------------------------------------------------------------
48 //
58 //
59 // -----------------------------------------------------------------------
60 
61 
62 
76 
77 
78 
79 // -----------------------------------------------------------------------
80 // GLOBAL INCLUDES
81 // -----------------------------------------------------------------------
82 #include <ctype.h>
83 
84 #include "mlpiGlobal.h"
85 #include "wchar16.h"
86 
87 // -----------------------------------------------------------------------
88 // GLOBAL TYPEDEFS
89 // -----------------------------------------------------------------------
90 
91 // -----------------------------------------------------------------------
92 // GLOBAL CONSTANTS
93 // -----------------------------------------------------------------------
94 
95 // -----------------------------------------------------------------------
96 // GLOBAL MACROS
97 // -----------------------------------------------------------------------
98 
99 // -----------------------------------------------------------------------
100 // GLOBAL EXPORTS
101 // -----------------------------------------------------------------------
102 
107 inline void utilHexdump(const void *data, size_t size)
108 {
109  unsigned char *ptr = (unsigned char*) data;
110  size_t i, j;
111  for (i=0; i<size; i+=16) {
112  printf("%06x: ", i);
113  for (j=0; j<16; j++) {
114  if (i+j < size)
115  printf("%02x ", (unsigned char) ptr[i+j]);
116  else
117  printf(" ");
118  }
119  printf(" ");
120  for (j=0; j<16; j++) {
121  if (i+j < size)
122  printf("%u", isprint((unsigned char) ptr[i+j]) ? (unsigned char) ptr[i+j] : '.');
123  }
124  printf("\n");
125  }
126 }
127 
132 inline size_t utilSizeOfMlpiType(MlpiType type)
133 {
134  switch (type)
135  {
136  default:
137  case MLPI_TYPE_INVALID: return 0;
138  case MLPI_TYPE_CHAR: return sizeof(CHAR);
139  case MLPI_TYPE_UCHAR: return sizeof(UCHAR);
140  case MLPI_TYPE_SHORT: return sizeof(SHORT);
141  case MLPI_TYPE_USHORT: return sizeof(USHORT);
142  case MLPI_TYPE_LONG: return sizeof(LONG);
143  case MLPI_TYPE_ULONG: return sizeof(ULONG);
144  case MLPI_TYPE_LLONG: return sizeof(LLONG);
145  case MLPI_TYPE_ULLONG: return sizeof(ULLONG);
146  case MLPI_TYPE_FLOAT: return sizeof(FLOAT);
147  case MLPI_TYPE_DOUBLE: return sizeof(DOUBLE);
148  case MLPI_TYPE_BOOL8: return sizeof(BOOL8);
149  case MLPI_TYPE_CHAR_ARRAY: return sizeof(CHAR);
150  case MLPI_TYPE_UCHAR_ARRAY: return sizeof(UCHAR);
151  case MLPI_TYPE_SHORT_ARRAY: return sizeof(SHORT);
152  case MLPI_TYPE_USHORT_ARRAY: return sizeof(USHORT);
153  case MLPI_TYPE_LONG_ARRAY: return sizeof(LONG);
154  case MLPI_TYPE_ULONG_ARRAY: return sizeof(ULONG);
155  case MLPI_TYPE_LLONG_ARRAY: return sizeof(LLONG);
156  case MLPI_TYPE_ULLONG_ARRAY: return sizeof(ULLONG);
157  case MLPI_TYPE_FLOAT_ARRAY: return sizeof(FLOAT);
158  case MLPI_TYPE_DOUBLE_ARRAY: return sizeof(DOUBLE);
159  case MLPI_TYPE_BOOL8_ARRAY: return sizeof(BOOL8);
160  case MLPI_TYPE_CHAR_UTF8: return sizeof(CHAR);
161  case MLPI_TYPE_CHAR_UTF16: return sizeof(WCHAR16);
162  }
163 }
164 
165 
166 #endif /* __MLPIGLOBALHELPER_H__ */
8 byte signed integer
Definition: mlpiGlobal.h:227
unsigned char UCHAR
1 byte unsigned integer
Definition: mlpiGlobal.h:160
string with 2 bytes per character
Definition: mlpiGlobal.h:247
invalid or not supported type
Definition: mlpiGlobal.h:219
4 byte signed integer array
Definition: mlpiGlobal.h:236
unsigned long long ULLONG
8 byte unsigned integer
Definition: mlpiGlobal.h:171
int LONG
4 byte signed integer
Definition: mlpiGlobal.h:164
2 byte signed integer
Definition: mlpiGlobal.h:223
char CHAR
1 byte signed integer
Definition: mlpiGlobal.h:159
signed char BOOL8
1 byte boolean
Definition: mlpiGlobal.h:158
unsigned short USHORT
2 byte unsigned integer
Definition: mlpiGlobal.h:162
4 byte floating point
Definition: mlpiGlobal.h:229
2 byte unsigned integer array
Definition: mlpiGlobal.h:235
size_t utilSizeOfMlpiType(MlpiType type)
Function to determine the size of a MLPI data type.
1 byte boolean array
Definition: mlpiGlobal.h:244
1 byte boolean
Definition: mlpiGlobal.h:243
1 byte signed integer array
Definition: mlpiGlobal.h:232
short SHORT
2 byte signed integer
Definition: mlpiGlobal.h:161
8 byte unsigned integer
Definition: mlpiGlobal.h:228
string with 1 byte per character
Definition: mlpiGlobal.h:246
wchar_t WCHAR16
UTF16 string.
Definition: mlpiGlobal.h:193
unsigned int ULONG
4 byte unsigned integer
Definition: mlpiGlobal.h:165
8 byte signed integer array
Definition: mlpiGlobal.h:238
4 byte floating point array
Definition: mlpiGlobal.h:240
8 byte floating point array
Definition: mlpiGlobal.h:241
1 byte unsigned integer
Definition: mlpiGlobal.h:222
4 byte unsigned integer array
Definition: mlpiGlobal.h:237
8 byte floating point
Definition: mlpiGlobal.h:230
1 byte signed integer
Definition: mlpiGlobal.h:221
MlpiType
This enumeration defines the basic types of as used by the MLPI.
Definition: mlpiGlobal.h:217
2 byte unsigned integer
Definition: mlpiGlobal.h:224
2 byte signed integer array
Definition: mlpiGlobal.h:234
4 byte unsigned integer
Definition: mlpiGlobal.h:226
long long LLONG
8 byte signed integer
Definition: mlpiGlobal.h:170
float FLOAT
4 byte floating point
Definition: mlpiGlobal.h:172
double DOUBLE
8 byte floating point
Definition: mlpiGlobal.h:177
8 byte unsigned integer array
Definition: mlpiGlobal.h:239
void utilHexdump(const void *data, size_t size)
1 byte unsigned integer array
Definition: mlpiGlobal.h:233
4 byte signed integer
Definition: mlpiGlobal.h:225