dvnixload/src/common.h

82 lines
2.0 KiB
C

/*
* common.h -- common definitions and macros
*
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef COMMON_H
#define COMMON_H 1
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
/* Define this to remove temporary files generated by this program. */
/* #define REMOVE_TEMP_FILES 1 */
#define DEFAULT_UART_PORT "/dev/ttyS0"
#define MAX_FILENAME_LENGTH 512
#define MAX_CMD_LENGTH 1024
#define MAX_ENV_VAR_LENGTH 128
#define CR 0x0D /* ASCII code for CARRIAGE RETURN */
#define LF 0x0A /* ASCII code for LINE FEED */
/* Returns TRUE if the strings 'a' and 'b' are equal. */
#define STREQ(a, b) (strcmp((a), (b)) == 0)
/* Returns TRUE if the first 'c' characters of strings 'a' and 'b' are equal. */
#define STREQ_LEN(a, b, c) (strncmp((a), (b), (c)) == 0)
enum DEBUG_LOG_LEVELS {
LEVEL_ERR = 0,
LEVEL_WARN,
LEVEL_INFO,
LEVEL_DEBUG1,
LEVEL_DEBUG2,
LEVEL_DEBUG3,
};
#define LAST_DEBUG_LEVEL LEVEL_DEBUG3
int
decode_debug_option(char *arg);
void
log_debug1(const char *format, ...);
void
log_debug2(const char *format, ...);
void
log_debug3(const char *format, ...);
void
log_info(const char *format, ...);
void
log_warn(const char *format, ...);
void
log_fail(const char *format, ...);
int
hv_strncpy(char *dest, const char *src, ssize_t n);
#endif /* COMMON_H */