This file is indexed.

/usr/include/x86_64-linux-gnu/qcc/Util.h is in liballjoyn-common-dev-1604 16.04a-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#ifndef _QCC_UTIL_H
#define _QCC_UTIL_H
/**
 * @file
 *
 * This file provides some useful utility macros and wrappers around system APIs
 */

/******************************************************************************
 * Copyright AllSeen Alliance. All rights reserved.
 *
 *    Permission to use, copy, modify, and/or distribute this software for any
 *    purpose with or without fee is hereby granted, provided that the above
 *    copyright notice and this permission notice appear in all copies.
 *
 *    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 *    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 *    MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 *    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 *    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 *    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 *    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 ******************************************************************************/

#include <qcc/platform.h>
#include <qcc/String.h>
#include <qcc/Environ.h>
#include <list>
#include <Status.h>


/*
 * Platform util.h will define QCC_TARGET_ENDIAN to one of these.  This will
 * allow for compile time determination of the target system's endianness.
 */
#define QCC_LITTLE_ENDIAN 1234
#define QCC_BIG_ENDIAN    4321


/*
 * Include platform-specific utility macros
 */
#if defined(QCC_OS_GROUP_POSIX)
#include <qcc/posix/util.h>
#elif defined(QCC_OS_GROUP_WINDOWS)
#include <qcc/windows/util.h>
#else
#error No OS GROUP defined.
#endif


/**
 * Returns the size of a statically allocated array
 */
#define ArraySize(a)  (sizeof(a) / sizeof(a[0]))


/**
 * Number of pad bytes needed to align to a specified byte boundary.
 *
 * @param p  The pointer to align
 * @param b  The byte boundary to align it on (b must be a power of 2)
 */
#define PadBytes(p, b) (((b) - reinterpret_cast<size_t>(p)) & ((b) - 1))

/**
 * Return a pointer aligned (up) to a specified byte boundary
 *
 * @param p  The pointer to align
 * @pram b   The byte boundary to align it on (b must be a power of 2)
 */
#define AlignPtr(p, b) ((p) + PadBytes(p, b))

/**
 * Return the number of array elements needed to store a number of bytes
 *
 * @param bytes  Required number of bytes in the array
 * @param type   Type of the array elements
 */
#define RequiredArrayLength(bytes, type) (((bytes) + sizeof(type) - 1) / sizeof(type))

/**
 * Return the number of bytes required to store a number of bits
 * (rounds up to the next byte).
 *
 * @param bits Number of bits
 */
#define BitlenToBytelen(bits) (((bits) + 7) / 8)

namespace qcc {
/**
 * The enum defining the high level operating system on the device.
 */
typedef enum _OSType {

    /*Invalid*/
    NONE = 0,

    /*Android*/
    ANDROID_OS,

    /*Windows*/
    WINDOWS_OS,

    /*Darwin*/
    DARWIN_OS,

    /*Linux*/
    LINUX_OS,

} OSType;

/**
 * @brief Get the OS type.
 */
OSType GetSystemOSType(void);

/**
 * Return an 8 bit random number.
 *
 * @return An 8 bit random number
 */
uint8_t Rand8();

/**
 * Return a 16 bit random number.
 *
 * @return A 16 bit random number
 */
uint16_t Rand16();

/**
 * Return a cryptographically strong 32 bit random number
 *
 * @return A 32 bit random number
 */
uint32_t Rand32();

/**
 * Return a cryptographically strong 64 bit random number
 *
 * @return A 64 bit random number
 */
uint64_t Rand64();

/**
 * Clear memory even with compiler optimizations
 */
void ClearMemory(void* s, size_t n);

/**
 * Return the Process ID as an unsigned 32 bit integer.
 *
 * @return The 32 bit Process ID
 */
uint32_t GetPid();

/**
 * Return the User ID as an unsigned 32 bit integer.
 *
 * @return The 32 bit User ID
 */
uint32_t GetUid();

/**
 * Return the Group ID as an unsigned 32 bit integer.
 *
 * @return The 32 bit User ID
 */
uint32_t GetGid();

/**
 * Return the User ID of the named user as an unsigned 32 bit integer.
 *
 * @param name  Username to lookup.
 */
uint32_t GetUsersUid(const char* name);

/**
 * Return the Group ID of the named user as an unsigned 32 bit integer.
 *
 * @param name  Username to lookup.
 */
uint32_t GetUsersGid(const char* name);

/**
 * Return the home directory of the calling user
 */
qcc::String GetHomeDir();

/**
 * Return a string with random, filename safe characters.
 *
 * @param prefix    [optional] resulting string will start with this.
 * @param len       [optional] number of charaters to generate.
 *
 * @return  The string with random characters.
 */
qcc::String RandomString(const char* prefix = NULL, size_t len = 10);


/**
 * Container type for directory listing results.
 */
typedef std::list<qcc::String> DirListing;

/**
 * Get a list of files and subdirectories in the specified path.
 *
 * @param path      The path from which the listing will be gathered.
 * @param listing   [OUT] Collection of filenames in path.
 *
 * @return  ER_OK if directory listing was gathered without problems.
 */
QStatus GetDirListing(const char* path, DirListing& listing);


/**
 * Container type for arguments to a program to be executed.
 */
typedef std::list<qcc::String> ExecArgs;

/**
 * Execute the specified program in a separate process with the specified
 * arguments.
 *
 * @param exec  Program to be executed.
 * @param args  Arguments to be passed to the program.
 * @param envs  Environment variables defining the envrionment the program will run in.
 *
 * @return  ER_OK if program was launched successfully.
 */
QStatus Exec(const char* exec, const ExecArgs& args, const qcc::Environ& envs);

/**
 * Execute the specified program in a separate process with the specified
 * arguments as a different user.
 *
 * @param user  user ID of the user to run as.
 * @param exec  Program to be executed.
 * @param args  Arguments to be passed to the program.
 * @param envs  Environment variables defining the envrionment the program will run in.
 *
 * @return  ER_OK if program was launched successfully.
 */
QStatus ExecAs(const char* user, const char* exec, const ExecArgs& args, const qcc::Environ& envs);


/**
 * Computes crc on a buffer using caller's running CRC as a base.
 *
 * @param buffer      Pointer to data bytes.
 * @param bufLen      Number of bytes in buffer.
 * @param runningCrc  [IN/OUT] Initial CRC16 value on input, final CRC16 value on output.
 */
void CRC16_Compute(const uint8_t* buffer, size_t bufLen, uint16_t*runningCrc);

/**
 * Resolves a hostname to its packed address representation.
 *
 * @param hostname  hostname to resolve.
 * @param addr      Buffer to receive the packed address.
 * @param addrSize  Size of the buffer specified in addr.
 * @param addrLen   The number of bytes copied into the addr buffer.
 * @param timeoutMs The timeout for hostname resolution.
 *
 * @return  ER_OK if conversion was successful.
 */
QStatus ResolveHostName(qcc::String hostname, uint8_t addr[], size_t addrSize, size_t& addrLen, uint32_t timeoutMs);

}
#endif