Merge branch 'master' of git://github.com/renaudallard/fiche into renaudallard-master

This commit is contained in:
solusipse
2015-09-23 19:09:41 +02:00
6 changed files with 4014 additions and 3 deletions

View File

@@ -1,2 +1,2 @@
language: c language: c
script: make script: ./configure && make

View File

@@ -5,6 +5,7 @@
# ----------------------------------- # -----------------------------------
CFLAGS+=-pthread -O2 CFLAGS+=-pthread -O2
CFLAGS+=@LIBS@
all: fiche all: fiche

2
config.h.in Normal file
View File

@@ -0,0 +1,2 @@
#undef HAVE_ARC4RANDOM

3987
configure vendored Executable file

File diff suppressed because it is too large Load Diff

20
configure.in Normal file
View File

@@ -0,0 +1,20 @@
AC_INIT([fiche], [0.99])
AC_CONFIG_SRCDIR([fiche.c])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC
# Function arc4random() is in BSD standard C or GNU systems -lbsd
AC_SEARCH_LIBS([arc4random], [bsd], [HAVE_ARC4RANDOM="yes"])
# Checks for library functions.
AC_CHECK_FUNCS([bzero arc4random])
AC_SUBST(HAVE_ARC4RANDOM)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@@ -29,6 +29,7 @@ $ cat fiche.c | nc localhost 9999
*/ */
#include <sys/param.h> #include <sys/param.h>
#include "config.h"
#include "fiche.h" #include "fiche.h"
int main(int argc, char **argv) int main(int argc, char **argv)
@@ -297,7 +298,7 @@ void generate_url(char *buffer, char *slug, size_t slug_length, struct client_da
for (i = 0; i <= SLUG_SIZE - 1; i++) for (i = 0; i <= SLUG_SIZE - 1; i++)
{ {
#if defined(BSD) #if defined(HAVE_ARC4RANDOM)
int symbol_id = arc4random() % strlen(symbols); int symbol_id = arc4random() % strlen(symbols);
#else #else
int symbol_id = rand_r(&time_seed) % strlen(symbols); int symbol_id = rand_r(&time_seed) % strlen(symbols);
@@ -307,7 +308,7 @@ void generate_url(char *buffer, char *slug, size_t slug_length, struct client_da
while (create_directory(slug) == -1) while (create_directory(slug) == -1)
{ {
#if defined(BSD) #if defined(HAVE_ARC4RANDOM)
int symbol_id = arc4random() % strlen(symbols); int symbol_id = arc4random() % strlen(symbols);
#else #else
int symbol_id = rand_r(&time_seed) % strlen(symbols); int symbol_id = rand_r(&time_seed) % strlen(symbols);