Skip to content

Commit

Permalink
2009-08-24 Marek Habersack <mhabersack@novell.com>
Browse files Browse the repository at this point in the history
	* configure.in: no longer checks for glib

2009-08-24  Marek Habersack  <mhabersack@novell.com>

	* Makefile.am (mod_mono_la_CFLAGS): glib is no longer used

	* glib_compat.c, glib_compat.h: added. Compatibility glib
	functions/macros used in mono-io-portability.c

svn path=/trunk/mod_mono/; revision=140495
  • Loading branch information
grendello committed Aug 24, 2009
1 parent f88a85f commit d102a58
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 8 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,3 +1,7 @@
2009-08-24 Marek Habersack <mhabersack@novell.com>

* configure.in: no longer checks for glib

2009-08-22 Marek Habersack <mhabersack@novell.com>

* mod_mono.conf.in: added X-Powered-By header. Fixes bug #400825
Expand Down
4 changes: 0 additions & 4 deletions configure.in
Expand Up @@ -44,10 +44,6 @@ AC_HEADER_STDC
AC_FUNC_SELECT_ARGTYPES
AC_CHECK_FUNCS([memset mkdir unsetenv putenv setenv setrlimit select strcasecmp strerror strrchr dup2])

GLIB_REQUIRED_VERSION=1.3.11

PKG_CHECK_MODULES(GLIB_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)

#
# --enable-debug
#
Expand Down
7 changes: 7 additions & 0 deletions src/ChangeLog
@@ -1,3 +1,10 @@
2009-08-24 Marek Habersack <mhabersack@novell.com>

* Makefile.am (mod_mono_la_CFLAGS): glib is no longer used

* glib_compat.c, glib_compat.h: added. Compatibility glib
functions/macros used in mono-io-portability.c

2009-03-16 Marek Habersack <mhabersack@novell.com>

* mod_mono.c (ensure_dashboard_initialized): do the XXGLOBAL
Expand Down
6 changes: 3 additions & 3 deletions src/Makefile.am
@@ -1,10 +1,10 @@
CLEANFILES = .libs/libmod_mono.so .libs/libmod_mono_old.so *~

lib_LTLIBRARIES = mod_mono.la
mod_mono_la_SOURCES = mod_mono.c mod_mono.h mono-io-portability.c mono-io-portability.h
mod_mono_la_LDFLAGS = -module $(GLIB_DEPENDENCIES_LIBS)
mod_mono_la_SOURCES = mod_mono.c mod_mono.h mono-io-portability.c mono-io-portability.h glib_compat.h glib_compat.c
mod_mono_la_LDFLAGS = -module
#/usr/sbin/apxs -c -I../include -I. -D HAVE_CONFIG_H mod_mono.c
mod_mono_la_CFLAGS = -Wall -DDFLT_MONO_CONFIG_DIR=\"$(DFLT_MONO_CONFIG_DIR)\" $(GLIB_DEPENDENCIES_CFLAGS)
mod_mono_la_CFLAGS = -Wall -DDFLT_MONO_CONFIG_DIR=\"$(DFLT_MONO_CONFIG_DIR)\"

install: $(lib_LTLIBRARIES)
$(mkinstalldirs) "$(DESTDIR)$(APXS_LIBEXECDIR)"
Expand Down
188 changes: 188 additions & 0 deletions src/glib_compat.c
@@ -0,0 +1,188 @@
#ifdef HAVE_CONFIG_H
#include "mod_mono_config.h"
#endif

#include <ctype.h>

#include "glib_compat.h"

#define ASCII_TOLOWER(_ch_) (isascii ((int)(_ch_)) && isalpha ((int)(_ch_))) ? tolower ((_ch_)) : (_ch_)

static void add_to_vector (gchar ***vector, int size, gchar *token)
{
*vector = *vector == NULL ?
(gchar **) malloc (2 * sizeof (*vector)) :
(gchar **) realloc (*vector, (size + 1) * sizeof (*vector));

(*vector)[size - 1] = token;
}

static gchar **make_empty_vector ()
{
gchar **vector = (gchar**)malloc (2 * sizeof (vector));
vector [0] = NULL;

return vector;
}

gchar **g_strsplit (const gchar *string, const gchar *delimiter, int max_tokens)
{
gchar **vector = NULL;
int delimiter_len = strlen (delimiter);
int size = 1;
const gchar *c;
gchar *token;

if (!string || !*string)
return make_empty_vector ();

if (!delimiter || !*delimiter) {
add_to_vector (&vector, size, strdup (string));
return vector;
}

if (strncmp (string, delimiter, delimiter_len) == 0) {
add_to_vector (&vector, size, strdup (""));
size++;
string += delimiter_len;
} else
vector = NULL;

while (*string && !(max_tokens > 0 && size >= max_tokens)) {
c = string;

if (*string == *delimiter && strncmp (string, delimiter, delimiter_len) == 0) {
token = strdup ("");
string += delimiter_len;
} else {
while (*string && (*string != *delimiter || strncmp (string, delimiter, delimiter_len) != 0))
string++;

if (*string) {
size_t toklen = (size_t)(string - c);
token = strndup (c, toklen);

if (strcmp (string, delimiter) != 0)
string += delimiter_len;
} else
token = strdup (c);
}

add_to_vector (&vector, size, token);
size++;
}

if (*string) {
add_to_vector (&vector, size, strdup (string));
size++;
}

if (!vector)
return make_empty_vector ();
else if (size > 0)
vector [size - 1] = NULL;

return vector;
}

gint g_ascii_strcasecmp (const gchar *s1, const gchar *s2)
{
gchar ch1, ch2;

if (s1 == s2)
return 0;

do {
ch1 = ASCII_TOLOWER (*s1);
ch2 = ASCII_TOLOWER (*s2);

if (ch1 == 0)
break;

s1++;
s2++;
} while (ch1 == ch2);

return (ch1 > ch2 ? 1 : ch1 < ch2 ? -1 : 0);
}

gchar* g_strdelimit (gchar *string, const gchar *delimiters, gchar new_delimiter)
{
gchar *ptr;

if (!string)
return NULL;

if (delimiters == NULL)
delimiters = G_STR_DELIMITERS;

for (ptr = string; *ptr; ptr++) {
if (strchr (delimiters, *ptr))
*ptr = new_delimiter;
}

return string;
}

gchar* g_strdup (const gchar *str)
{
if (!str)
return NULL;

return (gchar*) strdup (str);
}

void g_free (gpointer mem)
{
if (!mem)
return;

free (mem);
}

gboolean g_ascii_isalpha (gchar c)
{
return (isascii ((int)c) && isalpha ((int)c));
}

void g_strfreev (gchar **str_array)
{
gchar **orig = str_array;
if (str_array == NULL)
return;
while (*str_array != NULL){
g_free (*str_array);
str_array++;
}
g_free (orig);
}

gchar *g_strjoinv (const gchar *separator, gchar **str_array)
{
char *res;
size_t slen, len, i;

if (separator != NULL)
slen = strlen (separator);
else
slen = 0;

len = 0;
for (i = 0; str_array [i] != NULL; i++){
len += strlen (str_array [i]);
len += slen;
}
if (len == 0)
return g_strdup ("");
if (slen > 0 && len > 0)
len -= slen;
len++;
res = (char*)malloc (len);
strcpy (res, str_array [0]);
for (i = 1; str_array [i] != NULL; i++){
if (separator != NULL)
strcat (res, separator);
strcat (res, str_array [i]);
}
return res;
}
48 changes: 48 additions & 0 deletions src/glib_compat.h
@@ -0,0 +1,48 @@
#ifndef GLIB_COMPAT_H_
#define GLIB_COMPAT_H_

#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>

typedef char gboolean;
typedef char gchar;
typedef int gint;
typedef void* gpointer;

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

#ifndef G_STR_DELIMITERS
#define G_STR_DELIMITERS "_-|> <."
#endif

#ifndef g_memmove
#define g_memmove memmove
#endif

#ifndef g_new0
#define g_new0(struct_type, n_structs) ((struct_type*)calloc (sizeof (struct_type), n_structs))
#endif

#ifndef g_assert
#define g_assert(expr)
#endif

gchar **g_strsplit (const gchar *string, const gchar *delimiter, int max_tokens);
gint g_ascii_strcasecmp (const gchar *s1, const gchar *s2);
gchar* g_strdup (const gchar *str);
void g_free (gpointer mem);
gchar* g_strdelimit (gchar *string, const gchar *delimiters, gchar new_delimiter);
gboolean g_ascii_isalpha (gchar c);
void g_strfreev (gchar **str_array);
gchar *g_strjoinv (const gchar *separator, gchar **str_array);

#endif /* !GLIB_COMPAT_H_ */
2 changes: 1 addition & 1 deletion src/mono-io-portability.h
@@ -1,8 +1,8 @@
#ifndef __MONO_IO_PORTABILITY_H
#define __MONO_IO_PORTABILITY_H

#include <glib.h>
#include "mod_mono.h"
#include "glib_compat.h"

enum {
PORTABILITY_NONE = 0x00,
Expand Down

0 comments on commit d102a58

Please sign in to comment.