Skip to content

mingw64 #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,32 @@ AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([memmove memset regcomp select socket stpcpy strcasecmp strncasecmp strchr strdup strndup strrchr strstr strtol])

# Check for operating system
AC_MSG_CHECKING([whether to enable WIN32 build settings])
case ${host_os} in
*mingw*|*msys*|*cygwin*)
win32=true
AC_MSG_RESULT([yes])
AC_DEFINE(WIN32_LEAN_AND_MEAN, 1, [Define to limit the scope of windows.h])
AC_DEFINE(__USE_MINGW_ANSI_STDIO, 1, [Define to use C99 printf/snprintf in MinGW])
;;
*)
win32=false
AC_MSG_RESULT([no])
;;
esac
AM_CONDITIONAL(WIN32, test "x$win32" = "xtrue")

# Check for pcre presence if regex.h is absent
AC_CHECK_HEADER(regex.h, [ac_have_regex_h="yes"], [ac_have_regex_h="no"])
if test "x$ac_have_regex_h" = "xno"; then
PKG_CHECK_MODULES(libpcreposix, libpcreposix, [], [AC_MSG_ERROR([Neither regex.h nor pcre headers were found])])
else
AC_DEFINE(HAVE_REGEX_H, 1, [regex.h is present])
fi

AC_CHECK_FUNCS([memmove memset regcomp select socket strcasecmp strncasecmp strchr strdup strndup strrchr strstr strtol strcasestr getline])

SAVE_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $libimobiledevice_CFLAGS"
Expand Down
4 changes: 4 additions & 0 deletions examples/dl_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
// An example device_listener client
//

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
4 changes: 4 additions & 0 deletions examples/wi_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
// A minimal webinspector client
//

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <errno.h>
#include <signal.h>
#include <stdbool.h>
Expand Down
4 changes: 4 additions & 0 deletions examples/ws_echo1.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
// A minimal websocket "echo" server
//

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
4 changes: 4 additions & 0 deletions examples/ws_echo2.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
// A select-based websocket "echo" server
//

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
Expand Down
4 changes: 4 additions & 0 deletions examples/ws_echo_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
// A minimal websocket "echo" server
//

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#define _GNU_SOURCE
#include <stdbool.h>
#include <stdio.h>
Expand Down
128 changes: 128 additions & 0 deletions include/getline.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/* getline.c -- Replacement for GNU C library function getline

Copyright (C) 1993 Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

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. */

/* Written by Jan Brittenson, [email protected]. */

#ifndef __GETLINE_H
#define __GETLINE_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <sys/types.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>

#ifndef HAVE_GETLINE
/* Always add at least this many bytes when extending the buffer. */
#define GETLINE_MIN_CHUNK 256

static inline int getstr(char **lineptr, size_t *n, FILE *stream,
char terminator, int offset) {
int nchars_avail; /* Allocated but unused chars in *LINEPTR. */
char *read_pos; /* Where we're reading into *LINEPTR. */
int ret;

if (!lineptr || !n || !stream)
{
errno = EINVAL;
return -1;
}

if (!*lineptr)
{
*n = GETLINE_MIN_CHUNK;
*lineptr = malloc (*n);
if (!*lineptr)
{
errno = ENOMEM;
return -1;
}
}

nchars_avail = *n - offset;
read_pos = *lineptr + offset;

for (;;)
{
int save_errno;
register int c = getc (stream);

save_errno = errno;

/* We always want at least one char left in the buffer, since we
always (unless we get an error while reading the first char)
NUL-terminate the line buffer. */

assert((*lineptr + *n) == (read_pos + nchars_avail));
if (nchars_avail < 2)
{
if (*n > GETLINE_MIN_CHUNK)
*n *= 2;
else
*n += GETLINE_MIN_CHUNK;

nchars_avail = *n + *lineptr - read_pos;
*lineptr = realloc (*lineptr, *n);
if (!*lineptr)
{
errno = ENOMEM;
return -1;
}
read_pos = *n - nchars_avail + *lineptr;
assert((*lineptr + *n) == (read_pos + nchars_avail));
}

if (ferror (stream))
{
/* Might like to return partial line, but there is no
place for us to store errno. And we don't want to just
lose errno. */
errno = save_errno;
return -1;
}

if (c == EOF)
{
/* Return partial line, if any. */
if (read_pos == *lineptr)
return -1;
else
break;
}

*read_pos++ = c;
nchars_avail--;

if (c == terminator)
/* Return the line. */
break;
}

/* Done - NUL terminate and return the number of chars read. */
*read_pos = '\0';

ret = read_pos - (*lineptr + offset);
return ret;
}

static inline int getline(char **lineptr, size_t *n, FILE *stream)
{
return getstr(lineptr, n, stream, '\n', 0);
}
#endif

#endif
68 changes: 68 additions & 0 deletions include/strcasestr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/

#ifndef __STRCASESTR_H
#define __STRCASESTR_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <ctype.h>
#include <string.h>

#ifndef HAVE_STRCASESTR
static inline char* strcasestr(const char *s, const char *find)
{
char c, sc;
size_t len;

if ((c = *find++) != 0) {
c = tolower((unsigned char)c);
len = strlen(find);
do {
do {
if ((sc = *s++) == 0)
return (NULL);
} while ((char)tolower((unsigned char)sc) != c);
} while (strncasecmp(s, find, len) != 0);
s--;
}
return ((char *)s);
}
#endif

#endif
48 changes: 48 additions & 0 deletions include/strndup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Implement the strndup function.
Copyright (C) 2005 Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <[email protected]>.

This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

Libiberty 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
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
Boston, MA 02110-1301, USA. */

#ifndef __STRNDUP_H
#define __STRNDUP_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <string.h>

#ifndef HAVE_STRNDUP
static inline char* strndup(const char *s, size_t n)
{
char *result;
size_t len = strlen (s);

if (n < len)
len = n;

result = (char *) malloc (len + 1);
if (!result)
return 0;

result[len] = '\0';
return (char *) memcpy (result, s, len);
}
#endif

#endif
File renamed without changes.
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/ios-webkit-debug-proxy

AM_CFLAGS = $(GLOBAL_CFLAGS) $(libimobiledevice_CFLAGS) $(libplist_CFLAGS)
AM_LDFLAGS = $(libimobiledevice_LIBS) $(libplist_LIBS)
AM_CFLAGS = $(GLOBAL_CFLAGS) $(libimobiledevice_CFLAGS) $(libplist_CFLAGS) $(libpcreposix_CFLAGS)
AM_LDFLAGS = $(libimobiledevice_LIBS) $(libplist_LIBS) $(libpcreposix_LIBS)

lib_LTLIBRARIES = libios_webkit_debug_proxy.la
libios_webkit_debug_proxy_la_LIBADD =
Expand Down
4 changes: 4 additions & 0 deletions src/base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@

#if defined(POLARSSL_BASE64_C)

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

//#include "polarssl/base64.h"
#include "base64.h"
#include "stdio.h"
Expand Down
4 changes: 4 additions & 0 deletions src/char_buffer.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Google BSD license https://developers.google.com/google-bsd-license
// Copyright 2012 Google Inc. [email protected]

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
Loading