Initial commit of files
This commit is contained in:
40
src/libutil/CMakeLists.txt
Normal file
40
src/libutil/CMakeLists.txt
Normal file
@ -0,0 +1,40 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
set(NAME util)
|
||||
set(TARGET lib${NAME})
|
||||
project(Cnomicon-${TARGET})
|
||||
set(CMAKE_INSTALL_PREFIX ..)
|
||||
set(LIBRARY ${TARGET})
|
||||
|
||||
# list of header files
|
||||
set(LIBH
|
||||
utillib.h
|
||||
)
|
||||
|
||||
# list of source files
|
||||
set(LIBSRC
|
||||
hex_print.c
|
||||
)
|
||||
|
||||
# includes
|
||||
include_directories(../include)
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../lib)
|
||||
|
||||
# this is the "object library" target: compiles the sources only once
|
||||
add_library(${LIBRARY} OBJECT ${LIBSRC})
|
||||
|
||||
# shared libraries need PIC
|
||||
set_property(TARGET ${LIBRARY} PROPERTY POSITION_INDEPENDENT_CODE 1)
|
||||
|
||||
# shared and static libraries built from the same object files
|
||||
add_library(${LIBRARY}-shared SHARED $<TARGET_OBJECTS:${LIBRARY}>)
|
||||
add_library(${LIBRARY}-static STATIC $<TARGET_OBJECTS:${LIBRARY}>)
|
||||
|
||||
# output file names
|
||||
set_target_properties(${LIBRARY}-shared PROPERTIES OUTPUT_NAME ${NAME})
|
||||
set_target_properties(${LIBRARY}-static PROPERTIES OUTPUT_NAME ${NAME})
|
||||
|
||||
# installations
|
||||
install (FILES ${LIBH} DESTINATION include)
|
||||
#install (FILES lib${NAME}.a lib${NAME}.so DESTINATION lib)
|
||||
11
src/libutil/hex_print.c
Normal file
11
src/libutil/hex_print.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include "utillib.h"
|
||||
|
||||
void hex_print(FILE *pHexOut, const u_char *packet, int length) {
|
||||
if (!pHexOut)
|
||||
return;
|
||||
|
||||
while (length--) {
|
||||
fprintf(pHexOut, "%02X", *packet++);
|
||||
}
|
||||
fprintf(pHexOut, "\n");
|
||||
}
|
||||
55
src/libutil/utillib.h
Normal file
55
src/libutil/utillib.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (C) 2008
|
||||
* ProbeStar Telematics, LLC
|
||||
* All Rights Reserved. Proprietary and Confidential.
|
||||
*============================================================================
|
||||
* Multiplatform Embedded Data Types and Conversion
|
||||
* Checksum and CRC Routines
|
||||
*****************************************************************************/
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef _UTILLIB_H_
|
||||
#define _UTILLIB_H_
|
||||
|
||||
/*****************************************************************************
|
||||
* includes
|
||||
*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*****************************************************************************
|
||||
* defines
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* macros
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* structs & typedefs
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* global constants
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* global variables
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* C function prototypes
|
||||
*****************************************************************************/
|
||||
/* export C functions to C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void hex_print(FILE *pHexFile, const u_char *packet, int length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user