From 99359f145206e7405e8a9ada17bfee16541fb6d3 Mon Sep 17 00:00:00 2001 From: silvioprog Date: Sat, 20 Jan 2018 19:25:28 -0300 Subject: [PATCH 01/10] [*] apply many improvements from this brach: https://github.com/silvioprog/orcania/tree/cmake ; it replaces the old pure make to the platform CMake building; some fixes in the sources to compile on mingw-w64 32/64; add GCC/CLang's -Wextra flag; allow to control the library version from building system; allow to get library info from pkg-config tool in all supported platforms; export all Orcania API functions to be used by other programming languages; allow to include the Orcania header in C++ projects; and more other improvements. --- .gitignore | 765 +++++++++++++++++++++++++- CMakeLists.txt | 181 ++++++ Makefile | 38 -- cmake-modules/CMakeUninstall.cmake.in | 21 + cmake-modules/CTestCustom.cmake.in | 2 + cmake-modules/FindCheck.cmake | 60 ++ cmake-modules/FindJansson.cmake | 53 ++ cmake-modules/FindSubunit.cmake | 46 ++ {src => include}/orcania.h | 104 ++-- liborcania.pc.in | 11 + src/Makefile | 82 --- src/base64.c | 2 +- src/memory.c | 4 +- src/orcania.c | 53 +- test/Makefile | 59 -- test/jansson_test.c | 8 +- test/memory_test.c | 17 +- test/split_test.c | 7 +- test/str_test.c | 10 +- 19 files changed, 1260 insertions(+), 263 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile create mode 100644 cmake-modules/CMakeUninstall.cmake.in create mode 100644 cmake-modules/CTestCustom.cmake.in create mode 100644 cmake-modules/FindCheck.cmake create mode 100644 cmake-modules/FindJansson.cmake create mode 100644 cmake-modules/FindSubunit.cmake rename {src => include}/orcania.h (61%) create mode 100644 liborcania.pc.in delete mode 100644 src/Makefile delete mode 100644 test/Makefile diff --git a/.gitignore b/.gitignore index 5f3153a..9b69c3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,763 @@ +build +cmake-build-debug +cmake-build-release + +# Created by .ignore support plugin (hsz.mobi) +### CMake template +CMakeCache.txt +CMakeFiles +CMakeScripts +Makefile +cmake_install.cmake +install_manifest.txt +CTestTestfile.cmake +### Autotools template +# http://www.gnu.org/software/automake + +Makefile.in +/ar-lib +/mdate-sh +/py-compile +/test-driver +/ylwrap +config.h +config.status + +# http://www.gnu.org/software/autoconf + +/autom4te.cache/* +/autom4te.cache +/autoscan.log +/autoscan-*.log +/aclocal.m4 +/compile +/config.guess +/config.h.in +/config.sub +/configure +/configure.scan +/depcomp +/install-sh +/missing +/stamp-h1 + +# https://www.gnu.org/software/libtool/ + +/ltmain.sh + +# http://www.gnu.org/software/texinfo + +/texinfo.tex +### TeX template +## Core latex/pdflatex auxiliary files: +*.aux +*.lof +*.log +*.lot +*.fls +*.out +*.toc +*.fmt +*.fot +*.cb +*.cb2 + +## Intermediate documents: +*.dvi +*-converted-to.* +# these rules might exclude image files for figures etc. +# *.ps +# *.eps +# *.pdf + +## Generated if empty string is given at "Please type another file name for output:" +.pdf + +## Bibliography auxiliary files (bibtex/biblatex/biber): +*.bbl +*.bcf +*.blg +*-blx.aux +*-blx.bib +*.brf +*.run.xml + +## Build tool auxiliary files: +*.fdb_latexmk +*.synctex +*.synctex(busy) +*.synctex.gz +*.synctex.gz(busy) +*.pdfsync + +## Auxiliary and intermediate files from other packages: +# algorithms +*.alg +*.loa + +# achemso +acs-*.bib + +# amsthm +*.thm + +# beamer +*.nav +*.snm +*.vrb + +# cprotect +*.cpt + +# fixme +*.lox + +# feynmf/feynmp +*.mf +*.mp +*.t[1-9] +*.t[1-9][0-9] +*.tfm +*.[1-9] +*.[1-9][0-9] + +#(r)(e)ledmac/(r)(e)ledpar +*.end +*.?end +*.[1-9][0-9][0-9] +*.[1-9]R +*.[1-9][0-9]R +*.[1-9][0-9][0-9]R +*.eledsec[1-9] +*.eledsec[1-9]R +*.eledsec[1-9][0-9] +*.eledsec[1-9][0-9]R +*.eledsec[1-9][0-9][0-9] +*.eledsec[1-9][0-9][0-9]R + +# glossaries +*.acn +*.acr +*.glg +*.glo +*.gls +*.glsdefs + +# gnuplottex +*-gnuplottex-* + +# gregoriotex +*.gaux +*.gtex + +# hyperref + +# knitr +*-concordance.tex +# TODO Comment the next line if you want to keep your tikz graphics files +*.tikz +*-tikzDictionary + +# listings +*.lol + +# makeidx +*.idx +*.ilg +*.ind +*.ist + +# minitoc +*.maf +*.mlf +*.mlt +*.mtc[0-9]* + +# minted +_minted* +*.pyg + +# morewrites +*.mw + +# mylatexformat + +# nomencl +*.nlo + +# sagetex +*.sagetex.sage +*.sagetex.py +*.sagetex.scmd + +# scrwfile +*.wrt + +# sympy +*.sout +*.sympy +sympy-plots-for-*.tex/ + +# pdfcomment +*.upa +*.upb + +# pythontex +*.pytxcode +pythontex-files-*/ + +# thmtools +*.loe + +# TikZ & PGF +*.dpth +*.md5 +*.auxlock + +# todonotes +*.tdo + +# easy-todo +*.lod + +# xindy +*.xdy + +# xypic precompiled matrices +*.xyc + +# endfloat +*.ttt +*.fff + +# Latexian +TSWLatexianTemp* + +## Editors: +# WinEdt +*.bak +*.sav + +# Texpad +.texpadtmp + +# Kile +*.backup + +# KBibTeX +*~[0-9]* + +# auto folder when using emacs and auctex +/auto/* +### C template +# Prerequisites +*.d + +# Object files *.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll *.so *.so.* -*.a -str_test -split_test -memory_test -jansson_test +*.dylib + +# Executables +*.exe +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +modules.order +Module.symvers +Mkfile.old +dkms.conf +### Windows template +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk +### macOS template +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk +### VisualStudio template +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates +*.vcxproj.filters + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +*_i.c +*_p.c +*_i.h +*.meta +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/ +### Delphi template +# Uncomment these types if you want even more clean repository. But be careful. +# It can make harm to an existing project source. Read explanations below. +# +# Resource files are binaries containing manifest, project icon and version info. +# They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files. +#*.res +# +# Type library file (binary). In old Delphi versions it should be stored. +# Since Delphi 2009 it is produced from .ridl file and can safely be ignored. +#*.tlb +# +# Diagram Portfolio file. Used by the diagram editor up to Delphi 7. +# Uncomment this if you are not using diagrams or use newer Delphi version. +#*.ddp +# +# Visual LiveBindings file. Added in Delphi XE2. +# Uncomment this if you are not using LiveBindings Designer. +#*.vlb +# +# Deployment Manager configuration file for your project. Added in Delphi XE2. +# Uncomment this if it is not mobile development and you do not use remote debug feature. +#*.deployproj +# +# C++ object files produced when C/C++ Output file generation is configured. +# Uncomment this if you are not using external objects (zlib library for example). +#*.obj +# + +# Delphi compiler-generated binaries (safe to delete) +*.bpl +*.bpi +*.dcp +*.apk +*.drc +*.dres +*.rsm +*.tds +*.dcu +*.ocx + +# Delphi autogenerated files (duplicated info) +*.cfg +*.hpp +*Resource.rc + +# Delphi local files (user-specific info) +*.local +*.identcache +*.projdata +*.tvsconfig +*.dsk + +# Delphi history and backups +__history/ +__recovery/ +*.~* + +# Castalia statistics file (since XE7 Castalia is distributed with Delphi) +*.stat +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/workspace.xml +.idea/tasks.xml + +# Sensitive or high-churn files: +.idea/dataSources/ +.idea/dataSources.ids +.idea/dataSources.xml +.idea/dataSources.local.xml +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# Gradle: +.idea/gradle.xml +.idea/libraries + +# Mongo Explorer plugin: +.idea/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties +### Lazarus template +# Lazarus compiler-generated binaries (safe to delete) +*.lrs +*.res +*.compiled +*.dbg +*.ppu +*.or + +# Lazarus autogenerated files (duplicated info) +*.rst +*.rsj +*.lrt + +# Lazarus local files (user-specific info) +*.lps + +# Lazarus backups and unit output folders. +# These can be changed by user in Lazarus/project options. +backup/ +lib/ + +# Application bundle for Mac OS +*.app/ +### Tags template +# Ignore tags created by etags, ctags, gtags (GNU global) and cscope +TAGS +.TAGS +!TAGS/ +tags +.tags +!tags/ +gtags.files +GTAGS +GRTAGS +GPATH +GSYMS +cscope.files +cscope.out +cscope.in.out +cscope.po.out diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..46620d7 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,181 @@ +cmake_minimum_required(VERSION 3.5) + +project(orcania C) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") + +# library info + +set(PROJECT_DESCRIPTION "Potluck with different functions for different purposes that can be shared among programs") +set(PROJECT_BUGREPORT_PATH "https://github.com/babelouest/orcania/issues") + +set(LIBRARY_VERSION_MAJOR "1") +set(LIBRARY_VERSION_MINOR "1") +set(LIBRARY_VERSION_PATCH "1") +set(LIBRARY_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}") +set(LIBRARY_SOVERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}") + +add_definitions(-DLIBRARY_VERSION=\"${LIBRARY_VERSION}\") + +# cmake modules + +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules) + +include(GNUInstallDirs) +include(CheckSymbolExists) + +# check if _GNU_SOURCE is available + +if (NOT _GNU_SOURCE) + check_symbol_exists(__GNU_LIBRARY__ "features.h" _GNU_SOURCE) + + if (NOT _GNU_SOURCE) + unset(_GNU_SOURCE CACHE) + check_symbol_exists(_GNU_SOURCE "features.h" _GNU_SOURCE) + endif () +endif () + +if (_GNU_SOURCE) + add_definitions(-D_GNU_SOURCE) +endif () + +# directories and source + +set(INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) +set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) + +include_directories(${INC_DIR}) + +set(LIB_SRC + ${INC_DIR}/orcania.h # allow many IDEs to find and edit it + ${SRC_DIR}/base64.c + ${SRC_DIR}/memory.c + ${SRC_DIR}/orcania.c) + +# static library + +add_library(orcania_static STATIC ${LIB_SRC}) +target_compile_definitions(orcania_static PUBLIC -DO_STATIC_LIBRARY) +set_target_properties(orcania_static PROPERTIES + OUTPUT_NAME orcania) + +# shared library + +option(WITH_JANSSON "Use jansson library" ON) + +if (WITH_JANSSON) + include(FindJansson) + find_package(Jansson) + set(WITH_JANSSON ${JANSSON_FOUND}) + if (WITH_JANSSON) + set(LIBS ${JANSSON_LIBRARIES}) + add_definitions(-DUSE_JANSSON=1) + endif () +endif () + +add_library(orcania SHARED ${LIB_SRC}) +set_target_properties(orcania PROPERTIES + COMPILE_OPTIONS -Wextra + PUBLIC_HEADER ${INC_DIR}/orcania.h + VERSION "${LIBRARY_VERSION}" + SOVERSION "${LIBRARY_SOVERSION}") +if (WIN32) + set_target_properties(orcania PROPERTIES SUFFIX "-${LIBRARY_VERSION_MAJOR}.dll") +endif () +target_link_libraries(orcania ${LIBS}) + +# tests + +option(BUILD_TESTING "Build the testing tree." OFF) # because we don not use include(CTest) + +if (BUILD_TESTING) + include(FindCheck) + find_package(Check) + if (CHECK_FOUND) + include(FindSubunit) + find_package(Subunit REQUIRED) + + enable_testing() + + set(CMAKE_CTEST_COMMAND ctest -V) + + set(TST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test) + set(LIBS orcania ${LIBS} ${CHECK_LIBRARIES} ${SUBUNIT_LIBRARIES}) + if (NOT WIN32) + find_package(Threads REQUIRED) + set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT}) + endif () + set(LIBS ${LIBS} m rt) + + set(TESTS + str_test + split_test + memory_test) + if (WITH_JANSSON) + set(TESTS ${TESTS} jansson_test) + endif () + + configure_file( + "${CMAKE_MODULE_PATH}/CTestCustom.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake" + @ONLY) + + foreach (t ${TESTS}) + add_executable(${t} EXCLUDE_FROM_ALL ${TST_DIR}/${t}.c) + target_include_directories(${t} PUBLIC ${TST_DIR}) + target_link_libraries(${t} PUBLIC ${LIBS}) + add_test(NAME ${t} + WORKING_DIRECTORY ${TST_DIR} + COMMAND ${t}) + endforeach () + endif () +endif () + +# install target + +configure_file(liborcania.pc.in liborcania.pc @ONLY) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liborcania.pc + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) + +install(TARGETS orcania orcania_static + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +# uninstall target + +if (NOT TARGET uninstall) + configure_file( + "${CMAKE_MODULE_PATH}/CMakeUninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +endif () + +# packaging + +set(CPACK_PACKAGE_VERSION_MAJOR ${LIBRARY_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${LIBRARY_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${LIBRARY_VERSION_PATCH}) + +set(PACKAGE_FILE_NAME + "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +set(PACKAGE_IGNORED_FILES + "${CMAKE_CURRENT_BINARY_DIR}/;/.git/;.gitignore;/.idea/;~$;${CPACK_SOURCE_IGNORE_FILES}") + +#set(CPACK_GENERATOR "TGZ;DEB;RPM") +#set(CPACK_DEBIAN_PACKAGE_MAINTAINER "silvioprog") # required +#set(CPACK_PACKAGE_FILE_NAME ${PACKAGE_FILE_NAME}) + +set(CPACK_SOURCE_GENERATOR "TGZ") +set(CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_FILE_NAME}) +set(CPACK_SOURCE_IGNORE_FILES ${PACKAGE_IGNORED_FILES}) + +include(CPack) + +add_custom_target(dist + COMMAND ${CMAKE_MAKE_PROGRAM} package_source) \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index d03d5bc..0000000 --- a/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# -# Orcania Framework -# -# Makefile used to build all programs -# -# Copyright 2017 Nicolas Mora -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the MIT License -# -# This library 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. -# - -LIBORCANIA_LOCATION=./src -TESTS_LOCATION=./test - -all: liborcania.so - -debug: - cd $(LIBORCANIA_LOCATION) && $(MAKE) debug - -clean: - cd $(LIBORCANIA_LOCATION) && $(MAKE) clean - cd $(TESTS_LOCATION) && $(MAKE) clean - -run_test: - cd $(TESTS_LOCATION) && $(MAKE) test - -install: - cd $(LIBORCANIA_LOCATION) && $(MAKE) install - -uninstall: - cd $(LIBORCANIA_LOCATION) && $(MAKE) uninstall - -liborcania.so: - cd $(LIBORCANIA_LOCATION) && $(MAKE) diff --git a/cmake-modules/CMakeUninstall.cmake.in b/cmake-modules/CMakeUninstall.cmake.in new file mode 100644 index 0000000..59b8655 --- /dev/null +++ b/cmake-modules/CMakeUninstall.cmake.in @@ -0,0 +1,21 @@ +if (NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") +endif (NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach (file ${files}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if (IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + exec_program( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if (NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif (NOT "${rm_retval}" STREQUAL 0) + else (IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif (IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") +endforeach (file) \ No newline at end of file diff --git a/cmake-modules/CTestCustom.cmake.in b/cmake-modules/CTestCustom.cmake.in new file mode 100644 index 0000000..959df11 --- /dev/null +++ b/cmake-modules/CTestCustom.cmake.in @@ -0,0 +1,2 @@ +string(REPLACE ";" " " TESTS "@TESTS@") +set(CTEST_CUSTOM_PRE_TEST "@CMAKE_MAKE_PROGRAM@ ${TESTS}") \ No newline at end of file diff --git a/cmake-modules/FindCheck.cmake b/cmake-modules/FindCheck.cmake new file mode 100644 index 0000000..90857d9 --- /dev/null +++ b/cmake-modules/FindCheck.cmake @@ -0,0 +1,60 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindCheck +# ----------- +# +# Find Check +# +# Find Check headers and libraries. +# +# :: +# +# CHECK_FOUND - True if Check found. +# CHECK_INCLUDE_DIRS - Where to find check.h. +# CHECK_LIBRARIES - List of libraries when using Check. +# CHECK_VERSION_STRING - The version of Check found. + +# Written by Silvio Clecio +# Sat Jan 20 23:33:47 -03 2018 + +find_package(PkgConfig QUIET) +pkg_check_modules(PC_CHECK QUIET check) + +find_path(CHECK_INCLUDE_DIR + NAMES check.h + HINTS ${PC_CHECK_INCLUDEDIR} ${PC_CHECK_INCLUDE_DIRS}) + +find_library(CHECK_LIBRARY + NAMES check libcheck + HINTS ${PC_CHECK_LIBDIR} ${PC_CHECK_LIBRARY_DIRS}) + +if (PC_CHECK_VERSION) + set(CHECK_VERSION_STRING ${PC_CHECK_VERSION}) +elseif (CHECK_INCLUDE_DIR AND EXISTS "${CHECK_INCLUDE_DIR}/check.h") + set(check_version_list MAJOR MINOR MICRO) + foreach (v ${check_version_list}) + set(regex_check_version "^#define CHECK_${v}_VERSION +\\(?([0-9]+)\\)?$") + file(STRINGS "${CHECK_INCLUDE_DIR}/check.h" check_version_${v} REGEX "${regex_check_version}") + string(REGEX REPLACE "${regex_check_version}" "\\1" check_version_${v} "${check_version_${v}}") + unset(regex_check_version) + endforeach () + set(CHECK_VERSION_STRING "${check_version_MAJOR}.${check_version_MINOR}.${check_version_MICRO}") + foreach (v check_version_list) + unset(check_version_${v}) + endforeach () + unset(check_version_list) +endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Check + REQUIRED_VARS CHECK_LIBRARY CHECK_INCLUDE_DIR + VERSION_VAR CHECK_VERSION_STRING) + +if (CHECK_FOUND) + set(CHECK_LIBRARIES ${CHECK_LIBRARY}) + set(CHECK_INCLUDE_DIRS ${CHECK_INCLUDE_DIR}) +endif () + +mark_as_advanced(CHECK_INCLUDE_DIR CHECK_LIBRARY) \ No newline at end of file diff --git a/cmake-modules/FindJansson.cmake b/cmake-modules/FindJansson.cmake new file mode 100644 index 0000000..81adcfa --- /dev/null +++ b/cmake-modules/FindJansson.cmake @@ -0,0 +1,53 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindJansson +# ----------- +# +# Find Jansson +# +# Find Jansson headers and libraries. +# +# :: +# +# JANSSON_FOUND - True if Jansson found. +# JANSSON_INCLUDE_DIRS - Where to find jansson.h. +# JANSSON_LIBRARIES - List of libraries when using Jansson. +# JANSSON_VERSION_STRING - The version of Jansson found. + +# Written by Silvio Clecio +# Sat Jan 20 12:32:26 -03 2018 + +find_package(PkgConfig QUIET) +pkg_check_modules(PC_JANSSON QUIET jansson) + +find_path(JANSSON_INCLUDE_DIR + NAMES jansson.h + HINTS ${PC_JANSSON_INCLUDEDIR} ${PC_JANSSON_INCLUDE_DIRS}) + +find_library(JANSSON_LIBRARY + NAMES jansson libjansson + HINTS ${PC_JANSSON_LIBDIR} ${PC_JANSSON_LIBRARY_DIRS}) + +if (PC_JANSSON_VERSION) + set(JANSSON_VERSION_STRING ${PC_JANSSON_VERSION}) +elseif (JANSSON_INCLUDE_DIR AND EXISTS "${JANSSON_INCLUDE_DIR}/jansson.h") + set(regex_jansson_version "^#define[ \t]+JANSSON_VERSION[ \t]+\"([^\"]+)\".*") + file(STRINGS "${JANSSON_INCLUDE_DIR}/jansson.h" jansson_version REGEX "${regex_jansson_version}") + string(REGEX REPLACE "${regex_jansson_version}" "\\1" JANSSON_VERSION_STRING "${jansson_version}") + unset(regex_jansson_version) + unset(jansson_version) +endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Jansson + REQUIRED_VARS JANSSON_LIBRARY JANSSON_INCLUDE_DIR + VERSION_VAR JANSSON_VERSION_STRING) + +if (JANSSON_FOUND) + set(JANSSON_LIBRARIES ${JANSSON_LIBRARY}) + set(JANSSON_INCLUDE_DIRS ${JANSSON_INCLUDE_DIR}) +endif () + +mark_as_advanced(JANSSON_INCLUDE_DIR JANSSON_LIBRARY) \ No newline at end of file diff --git a/cmake-modules/FindSubunit.cmake b/cmake-modules/FindSubunit.cmake new file mode 100644 index 0000000..ca21966 --- /dev/null +++ b/cmake-modules/FindSubunit.cmake @@ -0,0 +1,46 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindSubunit +# ----------- +# +# Find Subunit +# +# Find Subunit headers and libraries. +# +# :: +# +# SUBUNIT_FOUND - True if Subunit found. +# SUBUNIT_INCLUDE_DIRS - Where to find subunit/child.h. +# SUBUNIT_LIBRARIES - List of libraries when using Subunit. +# SUBUNIT_VERSION_STRING - The version of Subunit found. + +# Written by Silvio Clecio +# Fri Jan 19 22:27:51 -03 2018 + +find_package(PkgConfig QUIET) +pkg_check_modules(PC_SUBUNIT QUIET libsubunit) + +set(SUBUNIT_VERSION_STRING "${PC_SUBUNIT_VERSION}") + +find_path(SUBUNIT_INCLUDE_DIR + NAMES child.h + HINTS ${PC_SUBUNIT_INCLUDEDIR} ${PC_SUBUNIT_INCLUDE_DIRS} + PATH_SUFFIXES subunit) + +find_library(SUBUNIT_LIBRARY + NAMES subunit libsubunit + HINTS ${PC_SUBUNIT_LIBDIR} ${PC_SUBUNIT_LIBRARY_DIRS}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Subunit + REQUIRED_VARS SUBUNIT_LIBRARY SUBUNIT_INCLUDE_DIR + VERSION_VAR SUBUNIT_VERSION_STRING) + +if (SUBUNIT_FOUND) + set(SUBUNIT_LIBRARIES ${SUBUNIT_LIBRARY}) + set(SUBUNIT_INCLUDE_DIRS ${SUBUNIT_INCLUDE_DIR}) +endif () + +mark_as_advanced(SUBUNIT_INCLUDE_DIR SUBUNIT_LIBRARY) \ No newline at end of file diff --git a/src/orcania.h b/include/orcania.h similarity index 61% rename from src/orcania.h rename to include/orcania.h index 3506d18..7214cd9 100644 --- a/src/orcania.h +++ b/include/orcania.h @@ -10,11 +10,39 @@ #ifndef __ORCANIA_H__ #define __ORCANIA_H__ -#ifndef U_DISABLE_JANSSON +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef O_EXTERN +# ifdef O_SHARED_LIBRARY +# ifdef _WIN32 +# define O_EXTERN __declspec(dllexport) +# else +# define O_EXTERN extern +# endif +# else +# ifdef O_STATIC_LIBRARY +# define O_EXTERN +# else +# define O_EXTERN extern +# endif +# endif +#endif + +#ifndef ORCANIA_VERSION +#define ORCANIA_VERSION LIBRARY_VERSION +#endif + +#ifdef USE_JANSSON #include #endif -#define ORCANIA_VERSION 1.1.1 +/** + * Return the library version. + */ +O_EXTERN const char *o_version(); + /** * char * str_replace(const char * source, char * old, char * new) * replace all occurences of old by new in the string source @@ -22,93 +50,93 @@ * return NULL on error * returned value must be free'd after use */ -char * str_replace(const char * source, const char * str_old, const char * str_new); +O_EXTERN char * str_replace(const char * source, const char * str_old, const char * str_new); /** * o_strdup * a modified strdup function that don't crash when source is NULL, instead return NULL * Returned value must be free'd after use */ -char * o_strdup(const char * source); +O_EXTERN char * o_strdup(const char * source); /** * o_strndup * a modified strndup function that don't crash when source is NULL, instead return NULL * Returned value must be free'd after use */ -char * o_strndup(const char * source, size_t len); +O_EXTERN char * o_strndup(const char * source, size_t len); /** * o_strcmp * a modified strcmp function that don't crash when p1 is NULL or p2 us NULL */ -int o_strcmp(const char * p1, const char * p2); +O_EXTERN int o_strcmp(const char * p1, const char * p2); /** * o_strncmp * a modified strncmp function that don't crash when p1 is NULL or p2 us NULL */ -int o_strncmp(const char * p1, const char * p2, size_t n); +O_EXTERN int o_strncmp(const char * p1, const char * p2, size_t n); /** * o_strcpy * a modified strcpy function that don't crash when p1 is NULL or p2 us NULL */ -char * o_strcpy(char * p1, const char * p2); +O_EXTERN char * o_strcpy(char * p1, const char * p2); /** * o_strncpy * a modified strncpy function that don't crash when p1 is NULL or p2 us NULL */ -char * o_strncpy(char * p1, const char * p2, size_t n); +O_EXTERN char * o_strncpy(char * p1, const char * p2, size_t n); /** * o_strcasecmp * a modified strcasecmp function that don't crash when p1 is NULL or p2 us NULL */ -int o_strcasecmp(const char * p1, const char * p2); +O_EXTERN int o_strcasecmp(const char * p1, const char * p2); /** * o_strncasecmp * a modified strncasecmp function that don't crash when p1 is NULL or p2 us NULL */ -int o_strncasecmp(const char * p1, const char * p2, size_t n); +O_EXTERN int o_strncasecmp(const char * p1, const char * p2, size_t n); /** * o_strstr * a modified strstr function that don't crash when haystack is NULL or needle us NULL */ -char * o_strstr(const char * haystack, const char * needle); +O_EXTERN char * o_strstr(const char * haystack, const char * needle); /** * o_strnstr * a modified strnstr function that don't crash when haystack is NULL or needle us NULL */ -char * o_strnstr(const char * haystack, const char * needle, size_t len); +O_EXTERN char * o_strnstr(const char * haystack, const char * needle, size_t len); /** * o_strcasestr * a modified strcasestr function that don't crash when haystack is NULL or needle us NULL */ -char * o_strcasestr(const char * haystack, const char * needle); +O_EXTERN char * o_strcasestr(const char * haystack, const char * needle); /** * o_strchr * a modified strchr function that don't crash when haystack is NULL */ -char * o_strchr(const char * haystack, int c); +O_EXTERN char * o_strchr(const char * haystack, int c); /** * o_strrchr * a modified strrchr function that don't crash when haystack is NULL */ -char * o_strrchr(const char * haystack, int c); +O_EXTERN char * o_strrchr(const char * haystack, int c); /** * o_strlen * a modified version of strlen that don't crash when s is NULL */ -size_t o_strlen(const char * s); +O_EXTERN size_t o_strlen(const char * s); /** * char * msprintf(const char * message, ...) @@ -116,7 +144,7 @@ size_t o_strlen(const char * s); * because life is too short to use 3 lines instead of 1 * but don't forget to free the returned value after use! */ -char * msprintf(const char * message, ...); +O_EXTERN char * msprintf(const char * message, ...); /** * Split a string into an array of strings using separator string @@ -126,44 +154,44 @@ char * msprintf(const char * message, ...); * return_array must be free'd after use * you can use free_string_array to free return_array */ -int split_string(const char * string, const char * separator, char *** return_array); +O_EXTERN int split_string(const char * string, const char * separator, char *** return_array); /** * Clean an array of strings */ -void free_string_array(char ** array); +O_EXTERN void free_string_array(char ** array); /** * Check if an array of string has a specified value, case sensitive */ -int string_array_has_value(const char ** array, const char * needle); +O_EXTERN int string_array_has_value(const char ** array, const char * needle); /** * Check if an array of string has a specified value, case insensitive */ -int string_array_has_value_case(const char ** array, const char * needle); +O_EXTERN int string_array_has_value_case(const char ** array, const char * needle); /** * Check if an array of string has a specified value, case sensitive, limit to len characters */ -int string_array_has_value_n(const char ** array, const char * needle, size_t len); +O_EXTERN int string_array_has_value_n(const char ** array, const char * needle, size_t len); /** * Check if an array of string has a specified value, case insensitive, limit to len characters */ -int string_array_has_value_ncase(const char ** array, const char * needle, size_t len); +O_EXTERN int string_array_has_value_ncase(const char ** array, const char * needle, size_t len); /** * Check if an array of string has a specified trimmed value */ -int string_array_has_trimmed_value(const char ** array, const char * needle); +O_EXTERN int string_array_has_trimmed_value(const char ** array, const char * needle); /** * Remove string of beginning and ending whitespaces */ -char * trimwhitespace(char * str); +O_EXTERN char * trimwhitespace(char * str); -#ifndef U_DISABLE_JANSSON +#ifdef USE_JANSSON /** * json_t * json_search(json_t * haystack, json_t * needle) * jansson library addon @@ -173,12 +201,12 @@ char * trimwhitespace(char * str); * If needle is present in haystack, return the reference to the json_t * that is equal to needle * If needle is not found, return NULL */ -json_t * json_search(json_t * haystack, json_t * needle); +O_EXTERN json_t * json_search(json_t * haystack, json_t * needle); /** * Check if the result json object has a "result" element that is equal to value */ -int check_result_value(json_t * result, const int value); +O_EXTERN int check_result_value(json_t * result, int value); #endif /** @@ -193,11 +221,11 @@ typedef void *(*o_malloc_t)(size_t); typedef void *(*o_realloc_t)(void *, size_t); typedef void (*o_free_t)(void *); -void * o_malloc(size_t size); -void * o_realloc(void * ptr, size_t size); -void o_free(void * ptr); -void o_set_alloc_funcs(o_malloc_t malloc_fn, o_realloc_t realloc_fn, o_free_t free_fn); -void o_get_alloc_funcs(o_malloc_t * malloc_fn, o_realloc_t * realloc_fn, o_free_t * free_fn); +O_EXTERN void * o_malloc(size_t size); +O_EXTERN void * o_realloc(void * ptr, size_t size); +O_EXTERN void o_free(void * ptr); +O_EXTERN void o_set_alloc_funcs(o_malloc_t malloc_fn, o_realloc_t realloc_fn, o_free_t free_fn); +O_EXTERN void o_get_alloc_funcs(o_malloc_t * malloc_fn, o_realloc_t * realloc_fn, o_free_t * free_fn); /** * Base64 encode and decode functions @@ -213,7 +241,7 @@ void o_get_alloc_funcs(o_malloc_t * malloc_fn, o_realloc_t * realloc_fn, o_free_ * * The nul terminator is not included in out_len. */ -int o_base64_encode(const unsigned char * src, size_t len, unsigned char * out, size_t * out_len); +O_EXTERN int o_base64_encode(const unsigned char * src, size_t len, unsigned char * out, size_t * out_len); /** * o_base64_decode - Base64 decode @@ -225,6 +253,10 @@ int o_base64_encode(const unsigned char * src, size_t len, unsigned char * out, * * The nul terminator is not included in out_len. */ -int o_base64_decode(const unsigned char *src, size_t len, unsigned char * out, size_t * out_len); +O_EXTERN int o_base64_decode(const unsigned char *src, size_t len, unsigned char * out, size_t * out_len); + +#ifdef __cplusplus +} +#endif #endif diff --git a/liborcania.pc.in b/liborcania.pc.in new file mode 100644 index 0000000..4876c16 --- /dev/null +++ b/liborcania.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ +Description: @PROJECT_DESCRIPTION@ +URL: @PROJECT_BUGREPORT_PATH@ +Version: @PROJECT_VERSION@ +Libs: -L${libdir} -lorcania +Cflags: -I${includedir} \ No newline at end of file diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index 430a53d..0000000 --- a/src/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -# -# Ulfius Framework -# -# Makefile used to build the software -# -# Copyright 2014-2017 Nicolas Mora -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation; -# version 2.1 of the License. -# -# This library 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 library. If not, see . -# -PREFIX=/usr/local -CC=gcc -CFLAGS=-c -fPIC -Wall -D_REENTRANT $(ADDITIONALFLAGS) $(JANSSONFLAG) -OUTPUT=liborcania.so -VERSION=1.1.1 - -ifndef JANSSONFLAG -LJANSSON=-ljansson -endif - -LIBS=-lc $(LJANSSON) - -all: release - -liborcania.so: memory.o orcania.o base64.o - $(CC) -shared -Wl,-soname,$(OUTPUT) -o $(OUTPUT).$(VERSION) orcania.o memory.o base64.o $(LIBS) - ln -sf $(OUTPUT).$(VERSION) $(OUTPUT) - -liborcania.a: memory.o orcania.o base64.o - ar rcs liborcania.a memory.o orcania.o base64.o - -orcania.o: orcania.h orcania.c - $(CC) $(CFLAGS) orcania.c - -memory.o: orcania.h memory.c - $(CC) $(CFLAGS) memory.c - -base64.o: orcania.h base64.c - $(CC) $(CFLAGS) base64.c - -clean: - rm -f *.o *.so *.a $(OUTPUT) $(OUTPUT).* - -install: all - cp $(OUTPUT).$(VERSION) $(PREFIX)/lib - cp orcania.h $(PREFIX)/include - -ldconfig - -static-install: static - cp liborcania.a $(PREFIX)/lib - cp orcania.h $(PREFIX)/include - -uninstall: - rm -f $(PREFIX)/lib/$(OUTPUT) $(PREFIX)/lib/liborcania.a - rm -f $(PREFIX)/lib/$(OUTPUT).* - rm -f $(PREFIX)/include/orcania.h - -debug: ADDITIONALFLAGS=-DDEBUG -g -O0 - -debug: liborcania.so - -release: ADDITIONALFLAGS=-O3 - -release: liborcania.so - -static-debug: ADDITIONALFLAGS=-DDEBUG -g -O0 - -static-debug: liborcania.a - -static: ADDITIONALFLAGS=-O3 - -static: liborcania.a diff --git a/src/base64.c b/src/base64.c index 3e77df9..04f466f 100644 --- a/src/base64.c +++ b/src/base64.c @@ -7,7 +7,7 @@ */ #include -#include "orcania.h" +#include static const unsigned char base64_table[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; diff --git a/src/memory.c b/src/memory.c index d57f904..77bad7e 100644 --- a/src/memory.c +++ b/src/memory.c @@ -9,7 +9,7 @@ */ #include -#include "orcania.h" +#include /* memory function pointers */ static o_malloc_t do_malloc = malloc; @@ -44,7 +44,7 @@ void o_set_alloc_funcs(o_malloc_t malloc_fn, o_realloc_t realloc_fn, o_free_t fr do_malloc = malloc_fn; do_realloc = realloc_fn; do_free = free_fn; -#ifndef U_DISABLE_JANSSON +#ifdef USE_JANSSON json_set_alloc_funcs(malloc_fn, free_fn); #endif } diff --git a/src/orcania.c b/src/orcania.c index c7f4047..25d59b2 100644 --- a/src/orcania.c +++ b/src/orcania.c @@ -1,9 +1,11 @@ -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif #include #include #include #include -#include "orcania.h" +#include /** * @@ -14,6 +16,13 @@ * */ +/** + * Return the library version. + */ +const char *o_version() { + return ORCANIA_VERSION; +} + /** * char * str_replace(const char * source, char * str_old, char * str_new) * replace all occurences of str_old by str_new in the string source @@ -77,8 +86,8 @@ char * msprintf(const char * message, ...) { char * out = NULL; if (message != NULL) { va_start(argp, message); - va_copy(argp_cpy, argp); // We make a copy because in some architectures, vsnprintf can modify argp - out_len = vsnprintf(NULL, 0, message, argp); + va_copy(argp_cpy, argp); /* We make a copy because in some architectures, vsnprintf can modify argp */ + out_len = (size_t)vsnprintf(NULL, 0, message, argp); out = o_malloc(out_len+sizeof(char)); if (out == NULL) { return NULL; @@ -107,7 +116,7 @@ char * o_strdup(const char * source) { char * o_strndup(const char * source, size_t len) { char *new_str; - if (source == NULL || len < 0) { + if (source == NULL || (int)len < 0) { return NULL; } else { new_str = o_malloc(len + 1); @@ -130,7 +139,7 @@ int o_strcmp(const char * p1, const char * p2) { return 0; } else if (p1 != NULL && p2 == NULL) { return -1; - } else if (p1 == NULL && p2 != NULL) { + } else if (p1 == NULL) { return 1; } else { return strcmp(p1, p2); @@ -146,7 +155,7 @@ int o_strncmp(const char * p1, const char * p2, size_t n) { return 0; } else if (p1 != NULL && p2 == NULL) { return -1; - } else if (p1 == NULL && p2 != NULL) { + } else if (p1 == NULL) { return 1; } else { return strncmp(p1, p2, n); @@ -186,7 +195,7 @@ int o_strcasecmp(const char * p1, const char * p2) { return 0; } else if (p1 != NULL && p2 == NULL) { return -1; - } else if (p1 == NULL && p2 != NULL) { + } else if (p1 == NULL) { return 1; } else { return strcasecmp(p1, p2); @@ -202,7 +211,7 @@ int o_strncasecmp(const char * p1, const char * p2, size_t n) { return 0; } else if (p1 != NULL && p2 == NULL) { return -1; - } else if (p1 == NULL && p2 != NULL) { + } else if (p1 == NULL) { return 1; } else { return strncasecmp(p1, p2, n); @@ -245,7 +254,7 @@ char * o_strrchr(const char * haystack, int c) { } } -#if defined(__linux__) || defined(__GLIBC__) +#if defined(__linux__) || defined(__GLIBC__) || defined(_WIN32) static char *strnstr(const char *haystack, const char *needle, size_t len) { int i; size_t needle_len; @@ -264,6 +273,22 @@ static char *strnstr(const char *haystack, const char *needle, size_t len) { } #endif +#ifdef _WIN32 +static char *strcasestr(const char *haystack, const char *needle) { + size_t n; + if (haystack == NULL || needle == NULL) { + return NULL; + } + n = o_strlen(needle); + while (*haystack) { + if (!strnicmp(haystack++, needle, n)) { + return (char *)(haystack-sizeof(char)); + } + } + return NULL; +} +#endif + /** * o_strnstr * a modified strnstr function that don't crash when haystack is NULL or needle us NULL @@ -482,7 +507,7 @@ int string_array_has_trimmed_value(const char ** array, const char * needle) { return to_return; } -#ifndef U_DISABLE_JANSSON +#ifdef USE_JANSSON /** * json_t * json_search(json_t * haystack, json_t * needle) * jansson library addon @@ -501,12 +526,12 @@ json_t * json_search(json_t * haystack, json_t * needle) { if (haystack == needle) return haystack; - // If both haystack and needle are the same type, test them + /* If both haystack and needle are the same type, test them */ if (json_typeof(haystack) == json_typeof(needle) && !json_is_object(haystack)) if (json_equal(haystack, needle)) return haystack; - // If they are not equals, test json_search in haystack elements recursively if it's an array or an object + /* If they are not equals, test json_search in haystack elements recursively if it's an array or an object */ if (json_is_array(haystack)) { json_array_foreach(haystack, index, value1) { if (json_equal(value1, needle)) { @@ -547,7 +572,7 @@ json_t * json_search(json_t * haystack, json_t * needle) { /** * Check if the result json object has a "result" element that is equal to value */ -int check_result_value(json_t * result, const int value) { +int check_result_value(json_t * result, int value) { return (result != NULL && json_is_object(result) && json_object_get(result, "result") != NULL && diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index c904ca6..0000000 --- a/test/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -# -# Orcania library -# -# Makefile used to build the tests -# -# Copyright 2017 Nicolas Mora -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU GENERAL PUBLIC LICENSE -# License as published by the Free Software Foundation; -# version 3 of the License. -# -# 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 . -# - -CC=gcc -CFLAGS=-Wall -D_REENTRANT -DDEBUG -g -O0 -ORCANIA_LOCATION=../src -LIBS=-lc -lorcania -ljansson -lcheck -lpthread -lm -lrt -lsubunit -L$(ORCANIA_LOCATION) - -all: test - -clean: - rm -f *.o str_test split_test memory_test jansson_test valgrind.txt - -liborcania.so: - cd $(ORCANIA_LOCATION) && $(MAKE) debug - -str_test: str_test.c - $(CC) $(CFLAGS) str_test.c -o str_test $(LIBS) - -test_str_test: liborcania.so str_test - -LD_LIBRARY_PATH=$(ORCANIA_LOCATION):${LD_LIBRARY_PATH} ./str_test - -split_test: split_test.c - $(CC) $(CFLAGS) split_test.c -o split_test $(LIBS) - -test_split_test: liborcania.so split_test - -LD_LIBRARY_PATH=$(ORCANIA_LOCATION):${LD_LIBRARY_PATH} ./split_test - -memory_test: memory_test.c - $(CC) $(CFLAGS) memory_test.c -o memory_test $(LIBS) - -test_memory_test: liborcania.so memory_test - -LD_LIBRARY_PATH=$(ORCANIA_LOCATION):${LD_LIBRARY_PATH} ./memory_test - -jansson_test: jansson_test.c - $(CC) $(CFLAGS) jansson_test.c -o jansson_test $(LIBS) - -test_jansson_test: liborcania.so jansson_test - -LD_LIBRARY_PATH=$(ORCANIA_LOCATION):${LD_LIBRARY_PATH} ./jansson_test - -test: test_str_test test_split_test test_jansson_test diff --git a/test/jansson_test.c b/test/jansson_test.c index 6217e80..5195624 100644 --- a/test/jansson_test.c +++ b/test/jansson_test.c @@ -1,14 +1,10 @@ /* Public domain, no copyright. Use at your own risk. */ -#include #include -#include -#include -#include #include #include -#include "../src/orcania.h" +#include START_TEST(test_json_search) { @@ -52,7 +48,7 @@ static Suite *orcania_suite(void) return s; } -int main(int argc, char *argv[]) +int main() { int number_failed; Suite *s; diff --git a/test/memory_test.c b/test/memory_test.c index a176fdd..fba2568 100644 --- a/test/memory_test.c +++ b/test/memory_test.c @@ -2,20 +2,17 @@ #include #include -#include -#include -#include #include -#include "../src/orcania.h" +#include START_TEST(test_o_malloc) { void * var; - var = malloc(8); + var = o_malloc(8); ck_assert_ptr_ne(var, NULL); o_free(var); - var = malloc(-1); + var = o_malloc(0); ck_assert_ptr_eq(var, NULL); } END_TEST @@ -23,11 +20,11 @@ END_TEST START_TEST(test_o_realloc) { void * var, * new_var; - var = malloc(8); + var = o_malloc(8); ck_assert_ptr_ne(var, NULL); - var = realloc(var, 16); + var = o_realloc(var, 16); ck_assert_ptr_ne(var, NULL); - new_var = realloc(var, -1); + new_var = o_realloc(var, 0); ck_assert_ptr_eq(new_var, NULL); o_free(var); } @@ -48,7 +45,7 @@ static Suite *orcania_suite(void) return s; } -int main(int argc, char *argv[]) +int main() { int number_failed; Suite *s; diff --git a/test/split_test.c b/test/split_test.c index 82925a1..1108222 100644 --- a/test/split_test.c +++ b/test/split_test.c @@ -1,13 +1,10 @@ /* Public domain, no copyright. Use at your own risk. */ -#include #include #include -#include -#include #include -#include "../src/orcania.h" +#include START_TEST(test_split_string) { @@ -49,7 +46,7 @@ static Suite *orcania_suite(void) return s; } -int main(int argc, char *argv[]) +int main() { int number_failed; Suite *s; diff --git a/test/str_test.c b/test/str_test.c index 148bce0..ebb6b07 100644 --- a/test/str_test.c +++ b/test/str_test.c @@ -3,11 +3,9 @@ #include #include #include -#include -#include #include -#include "../src/orcania.h" +#include START_TEST(test_str_replace) { @@ -176,8 +174,10 @@ END_TEST START_TEST(test_msprintf) { char * target; + char tmp[100]; target = msprintf("target1 %s %d %p", "str1", 42, NULL); - ck_assert_str_eq(target, "target1 str1 42 (nil)"); + sprintf(tmp, "target1 str1 42 %p", NULL); + ck_assert_str_eq(target, tmp); o_free(target); ck_assert_ptr_eq(msprintf(NULL, "str1", 42, NULL), NULL); } @@ -258,7 +258,7 @@ static Suite *orcania_suite(void) return s; } -int main(int argc, char *argv[]) +int main() { int number_failed; Suite *s; From f4dfb2e179b7300240fb1cc0fd7c642514abaaf0 Mon Sep 17 00:00:00 2001 From: silvioprog Date: Sun, 21 Jan 2018 01:29:03 -0300 Subject: [PATCH 02/10] [src/b64] fix https://github.com/babelouest/orcania/pull/11#discussion_r162800457. --- src/base64.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/base64.c b/src/base64.c index 04f466f..9bea12b 100644 --- a/src/base64.c +++ b/src/base64.c @@ -7,7 +7,6 @@ */ #include -#include static const unsigned char base64_table[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; From 46448533d5a7e6546a5f4bdcc521278db691190e Mon Sep 17 00:00:00 2001 From: silvioprog Date: Sun, 21 Jan 2018 01:38:52 -0300 Subject: [PATCH 03/10] [*] merging ... --- cmake-modules/FindCheck.cmake | 3 +-- cmake-modules/FindJansson.cmake | 3 +-- cmake-modules/FindSubunit.cmake | 3 +-- src/orcania.c | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cmake-modules/FindCheck.cmake b/cmake-modules/FindCheck.cmake index 90857d9..92357d1 100644 --- a/cmake-modules/FindCheck.cmake +++ b/cmake-modules/FindCheck.cmake @@ -1,5 +1,4 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. +#TODO: FIXME! please attach a license here! #.rst: # FindCheck diff --git a/cmake-modules/FindJansson.cmake b/cmake-modules/FindJansson.cmake index 81adcfa..ca57ad8 100644 --- a/cmake-modules/FindJansson.cmake +++ b/cmake-modules/FindJansson.cmake @@ -1,5 +1,4 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. +#TODO: FIXME! please attach a license here! #.rst: # FindJansson diff --git a/cmake-modules/FindSubunit.cmake b/cmake-modules/FindSubunit.cmake index ca21966..e2ed2f9 100644 --- a/cmake-modules/FindSubunit.cmake +++ b/cmake-modules/FindSubunit.cmake @@ -1,5 +1,4 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. +#TODO: FIXME! please attach a license here! #.rst: # FindSubunit diff --git a/src/orcania.c b/src/orcania.c index 25d59b2..c973169 100644 --- a/src/orcania.c +++ b/src/orcania.c @@ -116,7 +116,7 @@ char * o_strdup(const char * source) { char * o_strndup(const char * source, size_t len) { char *new_str; - if (source == NULL || (int)len < 0) { + if (source == NULL) { return NULL; } else { new_str = o_malloc(len + 1); From 3a93367c66727b85053177875fa615ba6de1bbb7 Mon Sep 17 00:00:00 2001 From: silvioprog Date: Sun, 21 Jan 2018 01:45:10 -0300 Subject: [PATCH 04/10] [.gitignore] comment github's best practices regarding to ignore binaries, makefiles, temporary files etc allowing to revert deleted makefiles listed at https://github.com/babelouest/orcania/issues/10#issuecomment-359212689 . --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9b69c3c..2c189d4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ cmake-build-release CMakeCache.txt CMakeFiles CMakeScripts -Makefile +#Makefile cmake_install.cmake install_manifest.txt CTestTestfile.cmake From 3e31c78994b8635d516bf5d7ed6405b2d066718c Mon Sep 17 00:00:00 2001 From: silvioprog Date: Sun, 21 Jan 2018 02:01:09 -0300 Subject: [PATCH 05/10] [*] revert typo. --- src/memory.c | 2 +- src/orcania.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/memory.c b/src/memory.c index 77bad7e..3eead46 100644 --- a/src/memory.c +++ b/src/memory.c @@ -9,7 +9,7 @@ */ #include -#include +#include "orcania.h" /* memory function pointers */ static o_malloc_t do_malloc = malloc; diff --git a/src/orcania.c b/src/orcania.c index c973169..e7e4278 100644 --- a/src/orcania.c +++ b/src/orcania.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include "orcania.h" /** * From c16252dbe26e1d3534f4749d13f03741f0f61c32 Mon Sep 17 00:00:00 2001 From: silvioprog Date: Sun, 21 Jan 2018 02:07:39 -0300 Subject: [PATCH 06/10] [*] revert deleted static makefiles (but they need some updates). --- Makefile | 38 ++++++++++++++++++++++++ src/Makefile | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ test/Makefile | 59 ++++++++++++++++++++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 Makefile create mode 100644 src/Makefile create mode 100644 test/Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d03d5bc --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +# +# Orcania Framework +# +# Makefile used to build all programs +# +# Copyright 2017 Nicolas Mora +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the MIT License +# +# This library 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. +# + +LIBORCANIA_LOCATION=./src +TESTS_LOCATION=./test + +all: liborcania.so + +debug: + cd $(LIBORCANIA_LOCATION) && $(MAKE) debug + +clean: + cd $(LIBORCANIA_LOCATION) && $(MAKE) clean + cd $(TESTS_LOCATION) && $(MAKE) clean + +run_test: + cd $(TESTS_LOCATION) && $(MAKE) test + +install: + cd $(LIBORCANIA_LOCATION) && $(MAKE) install + +uninstall: + cd $(LIBORCANIA_LOCATION) && $(MAKE) uninstall + +liborcania.so: + cd $(LIBORCANIA_LOCATION) && $(MAKE) diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..430a53d --- /dev/null +++ b/src/Makefile @@ -0,0 +1,82 @@ +# +# Ulfius Framework +# +# Makefile used to build the software +# +# Copyright 2014-2017 Nicolas Mora +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library 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 library. If not, see . +# +PREFIX=/usr/local +CC=gcc +CFLAGS=-c -fPIC -Wall -D_REENTRANT $(ADDITIONALFLAGS) $(JANSSONFLAG) +OUTPUT=liborcania.so +VERSION=1.1.1 + +ifndef JANSSONFLAG +LJANSSON=-ljansson +endif + +LIBS=-lc $(LJANSSON) + +all: release + +liborcania.so: memory.o orcania.o base64.o + $(CC) -shared -Wl,-soname,$(OUTPUT) -o $(OUTPUT).$(VERSION) orcania.o memory.o base64.o $(LIBS) + ln -sf $(OUTPUT).$(VERSION) $(OUTPUT) + +liborcania.a: memory.o orcania.o base64.o + ar rcs liborcania.a memory.o orcania.o base64.o + +orcania.o: orcania.h orcania.c + $(CC) $(CFLAGS) orcania.c + +memory.o: orcania.h memory.c + $(CC) $(CFLAGS) memory.c + +base64.o: orcania.h base64.c + $(CC) $(CFLAGS) base64.c + +clean: + rm -f *.o *.so *.a $(OUTPUT) $(OUTPUT).* + +install: all + cp $(OUTPUT).$(VERSION) $(PREFIX)/lib + cp orcania.h $(PREFIX)/include + -ldconfig + +static-install: static + cp liborcania.a $(PREFIX)/lib + cp orcania.h $(PREFIX)/include + +uninstall: + rm -f $(PREFIX)/lib/$(OUTPUT) $(PREFIX)/lib/liborcania.a + rm -f $(PREFIX)/lib/$(OUTPUT).* + rm -f $(PREFIX)/include/orcania.h + +debug: ADDITIONALFLAGS=-DDEBUG -g -O0 + +debug: liborcania.so + +release: ADDITIONALFLAGS=-O3 + +release: liborcania.so + +static-debug: ADDITIONALFLAGS=-DDEBUG -g -O0 + +static-debug: liborcania.a + +static: ADDITIONALFLAGS=-O3 + +static: liborcania.a diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..c904ca6 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,59 @@ +# +# Orcania library +# +# Makefile used to build the tests +# +# Copyright 2017 Nicolas Mora +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU GENERAL PUBLIC LICENSE +# License as published by the Free Software Foundation; +# version 3 of the License. +# +# 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 . +# + +CC=gcc +CFLAGS=-Wall -D_REENTRANT -DDEBUG -g -O0 +ORCANIA_LOCATION=../src +LIBS=-lc -lorcania -ljansson -lcheck -lpthread -lm -lrt -lsubunit -L$(ORCANIA_LOCATION) + +all: test + +clean: + rm -f *.o str_test split_test memory_test jansson_test valgrind.txt + +liborcania.so: + cd $(ORCANIA_LOCATION) && $(MAKE) debug + +str_test: str_test.c + $(CC) $(CFLAGS) str_test.c -o str_test $(LIBS) + +test_str_test: liborcania.so str_test + -LD_LIBRARY_PATH=$(ORCANIA_LOCATION):${LD_LIBRARY_PATH} ./str_test + +split_test: split_test.c + $(CC) $(CFLAGS) split_test.c -o split_test $(LIBS) + +test_split_test: liborcania.so split_test + -LD_LIBRARY_PATH=$(ORCANIA_LOCATION):${LD_LIBRARY_PATH} ./split_test + +memory_test: memory_test.c + $(CC) $(CFLAGS) memory_test.c -o memory_test $(LIBS) + +test_memory_test: liborcania.so memory_test + -LD_LIBRARY_PATH=$(ORCANIA_LOCATION):${LD_LIBRARY_PATH} ./memory_test + +jansson_test: jansson_test.c + $(CC) $(CFLAGS) jansson_test.c -o jansson_test $(LIBS) + +test_jansson_test: liborcania.so jansson_test + -LD_LIBRARY_PATH=$(ORCANIA_LOCATION):${LD_LIBRARY_PATH} ./jansson_test + +test: test_str_test test_split_test test_jansson_test From 32e370787245179d1699eb2a5585331b614bfed0 Mon Sep 17 00:00:00 2001 From: silvioprog Date: Sun, 21 Jan 2018 02:23:28 -0300 Subject: [PATCH 07/10] [make] improving makefile to be more portable. --- src/Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Makefile b/src/Makefile index 430a53d..fb6cbf7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -20,7 +20,9 @@ # PREFIX=/usr/local CC=gcc -CFLAGS=-c -fPIC -Wall -D_REENTRANT $(ADDITIONALFLAGS) $(JANSSONFLAG) +INC_DIR=../include +CFLAGS=-I$(INC_DIR) -c -fPIC -Wall -D_REENTRANT $(ADDITIONALFLAGS) $(JANSSONFLAG) +DEPS=$(INC_DIR)/orcania.h OUTPUT=liborcania.so VERSION=1.1.1 @@ -39,13 +41,13 @@ liborcania.so: memory.o orcania.o base64.o liborcania.a: memory.o orcania.o base64.o ar rcs liborcania.a memory.o orcania.o base64.o -orcania.o: orcania.h orcania.c +orcania.o: $(DEPS) orcania.c $(CC) $(CFLAGS) orcania.c -memory.o: orcania.h memory.c +memory.o: $(DEPS) memory.c $(CC) $(CFLAGS) memory.c -base64.o: orcania.h base64.c +base64.o: $(DEPS) base64.c $(CC) $(CFLAGS) base64.c clean: @@ -53,12 +55,12 @@ clean: install: all cp $(OUTPUT).$(VERSION) $(PREFIX)/lib - cp orcania.h $(PREFIX)/include + cp $(DEPS) $(PREFIX)/include -ldconfig static-install: static cp liborcania.a $(PREFIX)/lib - cp orcania.h $(PREFIX)/include + cp $(DEPS) $(PREFIX)/include uninstall: rm -f $(PREFIX)/lib/$(OUTPUT) $(PREFIX)/lib/liborcania.a From 72621377cf197fef391cb944787f40d0c3b5f6d5 Mon Sep 17 00:00:00 2001 From: silvioprog Date: Sun, 21 Jan 2018 02:27:45 -0300 Subject: [PATCH 08/10] [make] fix building. --- src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index fb6cbf7..5b313e0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -21,10 +21,10 @@ PREFIX=/usr/local CC=gcc INC_DIR=../include -CFLAGS=-I$(INC_DIR) -c -fPIC -Wall -D_REENTRANT $(ADDITIONALFLAGS) $(JANSSONFLAG) +VERSION=1.1.1 +CFLAGS=-I$(INC_DIR) -c -fPIC -Wall -DLIBRARY_VERSION=\"$(VERSION)\" -D_REENTRANT $(ADDITIONALFLAGS) $(JANSSONFLAG) DEPS=$(INC_DIR)/orcania.h OUTPUT=liborcania.so -VERSION=1.1.1 ifndef JANSSONFLAG LJANSSON=-ljansson From b39e7532467be9ed1ad70a36ef0313e47649de53 Mon Sep 17 00:00:00 2001 From: silvioprog Date: Sun, 21 Jan 2018 02:49:54 -0300 Subject: [PATCH 09/10] [cmake/modules] attach license to the modules. --- cmake-modules/FindCheck.cmake | 20 +++++++++++++++++--- cmake-modules/FindJansson.cmake | 20 +++++++++++++++++--- cmake-modules/FindSubunit.cmake | 20 +++++++++++++++++--- 3 files changed, 51 insertions(+), 9 deletions(-) diff --git a/cmake-modules/FindCheck.cmake b/cmake-modules/FindCheck.cmake index 92357d1..4aad6bc 100644 --- a/cmake-modules/FindCheck.cmake +++ b/cmake-modules/FindCheck.cmake @@ -1,5 +1,3 @@ -#TODO: FIXME! please attach a license here! - #.rst: # FindCheck # ----------- @@ -15,7 +13,23 @@ # CHECK_LIBRARIES - List of libraries when using Check. # CHECK_VERSION_STRING - The version of Check found. -# Written by Silvio Clecio +#============================================================================= +# Copyright 2018 Silvio Clecio +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library 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 library. If not, see . +#============================================================================= + # Sat Jan 20 23:33:47 -03 2018 find_package(PkgConfig QUIET) diff --git a/cmake-modules/FindJansson.cmake b/cmake-modules/FindJansson.cmake index ca57ad8..10eea48 100644 --- a/cmake-modules/FindJansson.cmake +++ b/cmake-modules/FindJansson.cmake @@ -1,5 +1,3 @@ -#TODO: FIXME! please attach a license here! - #.rst: # FindJansson # ----------- @@ -15,7 +13,23 @@ # JANSSON_LIBRARIES - List of libraries when using Jansson. # JANSSON_VERSION_STRING - The version of Jansson found. -# Written by Silvio Clecio +#============================================================================= +# Copyright 2018 Silvio Clecio +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library 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 library. If not, see . +#============================================================================= + # Sat Jan 20 12:32:26 -03 2018 find_package(PkgConfig QUIET) diff --git a/cmake-modules/FindSubunit.cmake b/cmake-modules/FindSubunit.cmake index e2ed2f9..4ce3a24 100644 --- a/cmake-modules/FindSubunit.cmake +++ b/cmake-modules/FindSubunit.cmake @@ -1,5 +1,3 @@ -#TODO: FIXME! please attach a license here! - #.rst: # FindSubunit # ----------- @@ -15,7 +13,23 @@ # SUBUNIT_LIBRARIES - List of libraries when using Subunit. # SUBUNIT_VERSION_STRING - The version of Subunit found. -# Written by Silvio Clecio +#============================================================================= +# Copyright 2018 Silvio Clecio +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library 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 library. If not, see . +#============================================================================= + # Fri Jan 19 22:27:51 -03 2018 find_package(PkgConfig QUIET) From bfdee37a7af2882d8c54fc13f3425f3e2c771221 Mon Sep 17 00:00:00 2001 From: silvioprog Date: Sun, 21 Jan 2018 03:03:05 -0300 Subject: [PATCH 10/10] [cmake] attach project description/copyright. --- CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 46620d7..5c72fa0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,21 @@ +# +# Orcania Framework +# +# CMake file used to build all programs +# +# Copyright 2017 Nicolas Mora +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the MIT License +# +# This library 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. +# + +# Written by Silvio Clecio +# Fri Jan 19 20:01:43 -03 2018 + cmake_minimum_required(VERSION 3.5) project(orcania C)