Skip to content

Commit

Permalink
Merge pull request #36 from Cruder/develop
Browse files Browse the repository at this point in the history
Release v0.2
  • Loading branch information
alex-lairan authored Dec 13, 2016
2 parents 7c2ed8f + 8e319a4 commit feb15f9
Show file tree
Hide file tree
Showing 33 changed files with 817,009 additions and 398 deletions.
File renamed without changes.
42 changes: 42 additions & 0 deletions lib/AccelLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
cmake_minimum_required(VERSION 3.0)

project(libAccelLib)

include_directories(include)

if(WIN32)
if(MSYS OR MINGW)
link_directories(lib/mingw)
elseif()
message(SEND_ERROR "AccelLib not already avaible for this environnement.")
#link_directories(lib/win32)
endif()
else() #unix system
link_directories(lib/unix)
endif()

#environnement cible
if(WIN32)
add_definitions(-DWIN32)
elseif(APPLE)
add_definitions(-DAPPLE)
elseif(UNIX AND NOT APPLE)
add_definitions(-DLINUX)
elseif(UNIX)
add_definitions(-DUNIX)
endif()

#compilateur utilisé
if(BORLAND)
add_definitions(-DBORLAND)
elseif(MSYS)
add_definitions(-DMSYS)
elseif(MINGW)
add_definitions(-DMINGW)
elseif(CYGWIN)
add_definitions(-DCYGWIN)
elseif(WATCOM)
add_definitions(-DWATCOM)
elseif(MSVC OR MSVC_IDE OR MSVC60 OR MSVC70 OR MSVC71 OR MSVC80 OR CMAKE_COMPILER_2005 OR MSVC90 OR MSVC10 OR "MSVC10 (Visual Studio 2010)")
add_definitions(-DMSVC)
endif()
31 changes: 31 additions & 0 deletions lib/AccelLib/include/AccelLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef ACCELLIB_H_INCLUDED
#define ACCELLIB_H_INCLUDED
/*
Cette librairie essaye d'être au maximum multi-plateforme (principalement Windows (MinGW) et Unix (GCC)).
*/
/*
Fichier raccourci incluant toutes les sous-parties.
*/

/** Permet de tester/détecter l'environnement de compilation */
//#include "AccelLib\testOS.h"

/** pseudo-librairie de logging légère */
//#include "AccelLib\_log.h"

/** Fonctionnalités relative au temps */
#include "AccelLib\time_.h"

/** Permet une utilisation avancée du terminal */
#include "AccelLib\terminal.h"

/** Gestion légère des versions */
#include "AccelLib\version.h"

/** Fonctionnalités relative aux chaines de caractère */
#include "AccelLib\strings.h"

/** Fonctionnalités relative aux fichiers */
#include "AccelLib\file.h"

#endif // ACCELLIB_H_INCLUDED
35 changes: 35 additions & 0 deletions lib/AccelLib/include/AccelLib/_log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef _LOG_H_INCLUDED
#define _LOG_H_INCLUDED

/** Fonction de log dans un fichier au nom générrer aléatoirement (mais unique) */
/* flog et non log car conflit avec math.h ... */

#ifdef NDEBUG
#define flog_init(b_aff_src) ((void)0)
#define flog(msg, ...) ((void)0)
#define flog_add(msg, ...) ((void)0)
#else
#include <stdarg.h>
#include <stdbool.h>
void flog_init(const bool aff_src, const char *file, const int line);
#define flog_init(b_aff_src) flog_init(b_aff_src, __FILE__, __LINE__)

#define FLOG_B 1
#ifndef FLOG_B
void flog(const char *file, const int line, const const char * format, ...);
#define flog(format, ...) flog(__FILE__, __LINE__, format, __VA_ARGS__)
void flog_add(const char *file, const int line, const const char * format, ...);
#define flog_add(format, ...) flog_add(__FILE__, __LINE__, format, __VA_ARGS__)
#else
void flog_b(bool newLine, const char *file, const int line, const const char * format, ...);
#define flog(format, ...) flog_b(true, __FILE__, __LINE__, format, __VA_ARGS__)
#define flog_add(format, ...) flog_b(false, __FILE__, __LINE__, format, __VA_ARGS__)
#endif // FLOG_B

/* au cas ou si l'utilisateur en a besoin */
bool flog_is_affSrc();
bool flog_is_init();
#endif // NDEBUG


#endif // _LOG_H_INCLUDED
9 changes: 9 additions & 0 deletions lib/AccelLib/include/AccelLib/file.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef FILE_H_INCLUDED
#define FILE_H_INCLUDED

#include <stdbool.h>
#include <sys/types.h>

bool getFileSize(const char *filepath, off_t *size);

#endif // FILE_H_INCLUDED
21 changes: 21 additions & 0 deletions lib/AccelLib/include/AccelLib/strings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef STRINGS_H_INCLUDED
#define STRINGS_H_INCLUDED

/**
* \brief Convertir une chaine de caractère en minuscule
* \param str chaine de caractère à convertir
*
* Utilise en interne la fonction tolower de ctype
*/
void str_tolower(char str[]);

/**
* \brief Convertir une chaine de caractère en majuscule
* \param str chaine de caractère à convertir
*
* Utilise en interne la fonction toupper de ctype
*/
void str_toupper(char str[]);


#endif // STRINGS_H_INCLUDED
63 changes: 63 additions & 0 deletions lib/AccelLib/include/AccelLib/terminal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#ifndef TERMINAL_H_INCLUDED
#define TERMINAL_H_INCLUDED

#include <stdarg.h> //va_args
#include "testOS.h"
#include <stdint.h>

void term_resize(const unsigned short int lng, const unsigned short int col);
//void term_posWin(const unsigned int x, const unsigned int y);
void term_posCursor(const unsigned int x, const unsigned int y);


/// Couleurs du terminal
typedef enum COLOR_TERMINAL
{
#ifdef _IS_WINDOWS
COLOR_BLACK=0x0, COLOR_RED=0x4, COLOR_GREEN=0x2, COLOR_YELLOW=0x6,
COLOR_BLUE=0x1, COLOR_MAGENTA=0x5, COLOR_CYAN=0x3, COLOR_WHITE=0xF,
COLOR_LIGHT_GRAY=0x7, COLOR_DARK_GRAY=0x8, COLOR_LIGHT_RED=0xC, COLOR_LIGHT_GREEN=0xA,
COLOR_LIGHT_YELLOW=0xE, COLOR_LIGHT_BLUE=0x9, COLOR_LIGHT_MAGENTA=0xD, COLOR_LIGHT_CYAN=0xB
#else
COLOR_BLACK=0, COLOR_RED=1, COLOR_GREEN=2, COLOR_YELLOW=3,
COLOR_BLUE=4, COLOR_MAGENTA=5, COLOR_CYAN=6, COLOR_WHITE=67,
COLOR_LIGHT_GRAY=7, COLOR_DARK_GRAY=60, COLOR_LIGHT_RED=61, COLOR_LIGHT_GREEN=62,
COLOR_LIGHT_YELLOW=63, COLOR_LIGHT_BLUE=64, COLOR_LIGHT_MAGENTA=65, COLOR_LIGHT_CYAN=66
#endif
} COLOR_TERMINAL;

/* compatibilité avec ancien nommage des couleurs de base */
#define BLACK COLOR_BLACK
#define RED COLOR_RED
#define GREEN COLOR_GREEN
#define YELLOW COLOR_YELLOW
#define BLUE COLOR_BLUE
#define MAGENTA COLOR_MAGENTA
#define CYAN COLOR_CYAN
#define WHITE COLOR_WHITE


/*!
* Fonction effaçant le terminal
*/
void clear_terminal();

/*!
* Printf en couleur. Les deux premiers paramètres sont les couleurs d'écriture et de fond (mettre une des valeurs parmi :
* BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN et WHITE).
* Les parmètres suivants sont comme le printf "normal" : chaîne de format puis toutes les valeurs à afficher
*/
int color_printf(COLOR_TERMINAL fg, COLOR_TERMINAL bg, const char * format, ...);
int color_puts(COLOR_TERMINAL fg, COLOR_TERMINAL bg, const char *chaine);


typedef struct Size {
uint16_t w, h;
} Size;

/*!
* Récupère la taille de la console (en nombre de caractères)
*/
Size term_size();

#endif // TERMINAL_H_INCLUDED
41 changes: 41 additions & 0 deletions lib/AccelLib/include/AccelLib/testOS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef TESTOS_H_INCLUDED
#define TESTOS_H_INCLUDED

/** Détecte & définit l'environnement cible de la compilation */
#if defined(_WIN32) || defined(_win32) || defined(WIN32) || defined(win32) || defined(__WIN32__) || defined(__win32__) //__WINRT__
#define _OS_WIN32 true
#elif defined(_WIN64) || defined(_win64) || defined(WIN64) || defined(win64) || defined(__WIN64__) || defined(__win64__)
#define _OS_WIN64 true
#elif defined(LINUX) || defined(linux) || defined(_LINUX) || defined(_linux) || defined(__LINUX) || defined(__linux)
#define _OS_LINUX true
#elif defined(__APPLE__) || defined(APPLE)
#define _OS_APPLE true
#elif defined(__UNIX__) || defined(UNIX) || defined(unix) || defined(_UNIX) || defined(_unix)
#define _OS_UNIX true
#endif // _WIN32

#if defined(_OS_WIN32) || defined(_OS_WIN64)
#define _IS_WINDOWS true
//#warning System Windows detected
#elif defined(_OS_UNIX) || defined(_OS_LINUX) || defined(_OS_APPLE)
#define _IS_UNIX true
#if !defined(_OS_LINUX) && !defined(_OS_APPLE)
#warning Unknow System Unix detected
#else
//#message System Unix detected
#endif
#else
#error System not recognize
#endif // defined


/** Détecte le compilateur utilisé */
#if defined(_MSC_VER) || defined(MSVC) // Microsoft compiler
#define _CMPL_MSVC true
#elifdef __GNUC__ // GNU compiler
#define _CMPL_GNUC true
#else
#warning Define your compiler
#endif // Compil

#endif // TESTOS_H_INCLUDED
7 changes: 7 additions & 0 deletions lib/AccelLib/include/AccelLib/time_.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef TIME_H_INCLUDED
#define TIME_H_INCLUDED

inline void msleep(const unsigned int ms);
inline void wait();

#endif // TIME_H_INCLUDED
130 changes: 130 additions & 0 deletions lib/AccelLib/include/AccelLib/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#ifndef VERSION_H_INCLUDED
#define VERSION_H_INCLUDED

#include <stdint.h>

/**
* \brief Information the version in use.
*
* Represents the library's version as three levels: major revision
* (increments with massive changes, additions, and enhancements),
* minor revision (increments with backwards-compatible changes to the
* major revision), and patchlevel (increments with fixes to the minor
* revision).
*/
typedef struct Version {
uint8_t major, minor, patch;
} Version;

/**
* \brief Information the version of AccelLib in use.
*
* Represents the library's version as three levels: major revision
* (increments with massive changes, additions, and enhancements),
* minor revision (increments with backwards-compatible changes to the
* major revision), and patchlevel (increments with fixes to the minor
* revision).
*
* \sa ACCELLIB_VERSION
* \sa AccelLib_GetVersion
*/
typedef Version AccelLib_version;

/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/
#define ACCELLIB_MAJOR_VERSION 0
#define ACCELLIB_MINOR_VERSION 0
#define ACCELLIB_PATCHLEVEL 2

#define ACCELLIB_REVISION "git-0022:000029879485EN"
#define ACCELLIB_REVISION_NUMBER 0022


/**
* \brief Macro to determine AccelLib version program was compiled against.
*
* This macro fills in a SDL_version structure with the version of the
* library you compiled against. This is determined by what header the
* compiler uses. Note that if you dynamically linked the library, you might
* have a slightly newer or older version at runtime. That version can be
* determined with AccelLib_GetVersion(), which, unlike ACCELLIB_VERSION(),
* is not a macro.
*
* \param x A pointer to a AccelLib_version struct to initialize.
*
* \sa AccelLib_version
* \sa AccelLib_GetVersion
*/
#define ACCELLIB_VERSION(x) \
{ \
(x)->major = ACCELLIB_MAJOR_VERSION; \
(x)->minor = ACCELLIB_MINOR_VERSION; \
(x)->patch = ACCELLIB_PATCHLEVEL; \
}


/**
* \brief Get the version of AccelLib that is linked against your program.
*
* If you are linking to AccelLib dynamically, then it is possible that the
* current version will be different than the version you compiled against.
* This function returns the current version, while ACCELLIB_VERSION() is a
* macro that tells you what version you compiled with.
*
* \code
* AccelLib_version compiled;
* AccelLib_version linked;
*
* ACCELLIB_VERSION(&compiled);
* AccelLib_GetVersion(&linked);
* printf("We compiled against AccelLib version %d.%d.%d ...\n",
* compiled.major, compiled.minor, compiled.patch);
* printf("But we linked against AccelLib version %d.%d.%d.\n",
* linked.major, linked.minor, linked.patch);
* \endcode
*
* \sa ACCELLIB_VERSION
*/
void AccelLib_GetVersion(AccelLib_version *ver);

/**
* \brief Get the code revision of AccelLib that is linked against your program.
*
* Returns an arbitrary string (a hash value) uniquely identifying the
* exact revision of the AccelLib library in use, and is only useful in comparing
* against other revisions. It is NOT an incrementing number.
*/
const char* AccelLib_GetRevision(/*void*/);

/**
* \brief Get the revision number of AccelLib that is linked against your program.
*
* Returns a number uniquely identifying the exact revision of the AccelLib
* library in use. It is an incrementing number based on commits to
* gtihub.org.
*/
int AccelLib_GetRevisionNumber(/*void*/);


/**
* This macro turns the version numbers into a numeric value:
* \verbatim
(1,2,3) -> (1203)
\endverbatim
*
* This assumes that there will never be more than 100 patchlevels.
*/
#define ACCELLIB_VERSIONNUM(X, Y, Z) ((X)*1000 + (Y)*100 + (Z))

/**
* This is the version number macro for the current AccelLib version.
*/
#define ACCELLIB_COMPILEDVERSION ACCELLIB_VERSIONNUM(LIB_MAJOR_VERSION, LIB_MINOR_VERSION, LIB_PATCHLEVEL)

/**
* This macro will evaluate to true if compiled with AccelLib at least X.Y.Z.
*/
#define ACCELLIB_VERSION_ATLEAST(X, Y, Z) (ACCELLIB_COMPILEDVERSION >= ACCELLIB_VERSIONNUM(X, Y, Z))


#endif // VERSION_H_INCLUDED
Binary file added lib/AccelLib/lib/mingw/libAccelLib.a
Binary file not shown.
Binary file added lib/AccelLib/lib/unix/libAccelLib.a
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

#target_include_directory(. PUBLIC)

add_subdirectory(md5)
add_subdirectory(AccelLib)

include_directories(*/include)
Loading

0 comments on commit feb15f9

Please sign in to comment.