Blame pqos/common.h

Packit Service 8a4b7a
/*
Packit Service 8a4b7a
 * BSD LICENSE
Packit Service 8a4b7a
 *
Packit Service 8a4b7a
 * Copyright(c) 2019-2020 Intel Corporation. All rights reserved.
Packit Service 8a4b7a
 * All rights reserved.
Packit Service 8a4b7a
 *
Packit Service 8a4b7a
 * Redistribution and use in source and binary forms, with or without
Packit Service 8a4b7a
 * modification, are permitted provided that the following conditions
Packit Service 8a4b7a
 * are met:
Packit Service 8a4b7a
 *
Packit Service 8a4b7a
 *   * Redistributions of source code must retain the above copyright
Packit Service 8a4b7a
 *     notice, this list of conditions and the following disclaimer.
Packit Service 8a4b7a
 *   * Redistributions in binary form must reproduce the above copyright
Packit Service 8a4b7a
 *     notice, this list of conditions and the following disclaimer in
Packit Service 8a4b7a
 *     the documentation and/or other materials provided with the
Packit Service 8a4b7a
 *     distribution.
Packit Service 8a4b7a
 *   * Neither the name of Intel Corporation nor the names of its
Packit Service 8a4b7a
 *     contributors may be used to endorse or promote products derived
Packit Service 8a4b7a
 *     from this software without specific prior written permission.
Packit Service 8a4b7a
 *
Packit Service 8a4b7a
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit Service 8a4b7a
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit Service 8a4b7a
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit Service 8a4b7a
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit Service 8a4b7a
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit Service 8a4b7a
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit Service 8a4b7a
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit Service 8a4b7a
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit Service 8a4b7a
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit Service 8a4b7a
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit Service 8a4b7a
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O
Packit Service 8a4b7a
 *
Packit Service 8a4b7a
 */
Packit Service 8a4b7a
Packit Service 8a4b7a
/**
Packit Service 8a4b7a
 * @brief Internal header file for common functions
Packit Service 8a4b7a
 */
Packit Service 8a4b7a
Packit Service 8a4b7a
#ifndef __PQOS_COMMON_H__
Packit Service 8a4b7a
#define __PQOS_COMMON_H__
Packit Service 8a4b7a
Packit Service 8a4b7a
#ifdef __cplusplus
Packit Service 8a4b7a
extern "C" {
Packit Service 8a4b7a
#endif
Packit Service 8a4b7a
Packit Service 8a4b7a
#include <stdio.h>
Packit Service 8a4b7a
Packit Service 8a4b7a
/**
Packit Service 8a4b7a
 * @brief Wrapper around fopen() that additionally checks if a given path
Packit Service 8a4b7a
 * contains any symbolic links and fails if it does.
Packit Service 8a4b7a
 *
Packit Service 8a4b7a
 * @param [in] name a path to a file
Packit Service 8a4b7a
 * @param [in] mode a file access mode
Packit Service 8a4b7a
 *
Packit Service 8a4b7a
 * @return Pointer to a file
Packit Service 8a4b7a
 * @retval A valid pointer to a file or NULL on error (e.g. when the path
Packit Service 8a4b7a
 * contains any symbolic links).
Packit Service 8a4b7a
 */
Packit Service 8a4b7a
FILE * pqos_fopen(const char *name, const char *mode);
Packit Service 8a4b7a
Packit Service 8a4b7a
/**
Packit Service 8a4b7a
 * @brief Wrapper around open() that additionally checks if a given path
Packit Service 8a4b7a
 * contains any symbolic links and fails if it does.
Packit Service 8a4b7a
 *
Packit Service 8a4b7a
 * @param [in] pathname a path to a file
Packit Service 8a4b7a
 * @param [in] flags file access flags
Packit Service 8a4b7a
 * @param [in] mode file mode bits
Packit Service 8a4b7a
 *
Packit Service 8a4b7a
 * @return A file descriptor
Packit Service 8a4b7a
 * @retval A valid file descriptor or -1 on error (e.g. when the path
Packit Service 8a4b7a
 * contains any symbolic links).
Packit Service 8a4b7a
 */
Packit Service 8a4b7a
int pqos_open(const char *pathname, int flags, mode_t mode);
Packit Service 8a4b7a
Packit Service 8a4b7a
#ifdef __cplusplus
Packit Service 8a4b7a
}
Packit Service 8a4b7a
#endif
Packit Service 8a4b7a
Packit Service 8a4b7a
#endif /* __PQOS_COMMON_H__ */