/usr/include/cdio/util.h is in libcdio-dev 1.0.0-2ubuntu2.
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 | /*
Copyright (C) 2004, 2005, 2006, 2008, 2010, 2012, 2014
Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CDIO_UTIL_H_
#define CDIO_UTIL_H_
/*!
\file util.h
\brief Miscellaneous utility functions.
Warning: this will probably get removed/replaced by using glib.h
*/
#include <stdlib.h>
#include <cdio/types.h>
#if !defined CDIO_INLINE
#if defined(__cplusplus) || defined(inline)
#define CDIO_INLINE inline
#elif defined(__GNUC__)
#define CDIO_INLINE __inline__
#elif defined(_MSC_VER)
#define CDIO_INLINE __inline
#else
#define CDIO_INLINE
#endif
#endif /* CDIO_INLINE */
#undef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#undef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#undef IN
#define IN(x, low, high) ((x) >= (low) && (x) <= (high))
#undef CLAMP
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
static CDIO_INLINE uint32_t
_cdio_len2blocks (uint32_t i_len, uint16_t i_blocksize)
{
uint32_t i_blocks;
i_blocks = i_len / (uint32_t) i_blocksize;
if (i_len % i_blocksize)
i_blocks++;
return i_blocks;
}
/*! free() and NULL out p_obj it is not already null. */
#define CDIO_FREE_IF_NOT_NULL(p_obj) \
if (NULL != p_obj) { free(p_obj); p_obj=NULL; };
/* round up to next block boundary */
static CDIO_INLINE unsigned
_cdio_ceil2block (unsigned offset, uint16_t i_blocksize)
{
return _cdio_len2blocks (offset, i_blocksize) * i_blocksize;
}
static CDIO_INLINE unsigned int
_cdio_ofs_add (unsigned offset, unsigned length, uint16_t i_blocksize)
{
if (i_blocksize - (offset % i_blocksize) < length)
offset = _cdio_ceil2block (offset, i_blocksize);
offset += length;
return offset;
}
static CDIO_INLINE const char *
_cdio_bool_str (bool b)
{
return b ? "yes" : "no";
}
#ifdef __cplusplus
extern "C" {
#endif
void *
_cdio_memdup (const void *mem, size_t count);
char *
_cdio_strdup_upper (const char str[]);
/*! Duplicate path and make it platform compliant. Typically needed for
MinGW/MSYS where a "/c/..." path must be translated to "c:/..." for
use with fopen(), etc. Returned string must be freed by the caller
using cdio_free(). */
char *
_cdio_strdup_fixpath (const char path[]);
void
_cdio_strfreev(char **strv);
size_t
_cdio_strlenv(char **str_array);
char **
_cdio_strsplit(const char str[], char delim);
uint8_t cdio_to_bcd8(uint8_t n);
uint8_t cdio_from_bcd8(uint8_t p);
/*! cdio_realpath() same as POSIX.1-2001 realpath if that's
around. If not we do poor-man's simulation of that behavior. */
char *cdio_realpath (const char *psz_src, char *psz_dst);
#ifdef WANT_FOLLOW_SYMLINK_COMPATIBILITY
# define cdio_follow_symlink cdio_realpath
#endif
#ifdef __cplusplus
}
#endif
#endif /* CDIO_UTIL_H_ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/
|