aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Teirney <david@teirney.net>2012-06-24 09:40:30 +1200
committerDavid Teirney <david@teirney.net>2012-06-30 17:02:16 +1200
commit01b3f30b8338c4e2cdabb2fca2f03fce5325bcca (patch)
tree1bd03aadd251dabdc31f05cb31f7acf517a21832 /lib
parentd399ac796ef28a7e7e788382adbc16ad766d58ac (diff)
[libcmyth] Pull across upstream changes to handle compiling with the Microsoft Compiler.
Includes some cosmetic rearrangement of the includes for some files to make the directory diff with upstream easier.
Diffstat (limited to 'lib')
-rw-r--r--lib/cmyth/libcmyth/cmyth_local.h58
-rw-r--r--lib/cmyth/libcmyth/cmyth_msc.h79
-rw-r--r--lib/cmyth/libcmyth/connection.c13
-rw-r--r--lib/cmyth/libcmyth/file.c4
-rw-r--r--lib/cmyth/libcmyth/freespace.c6
-rw-r--r--lib/cmyth/libcmyth/keyframe.c3
-rw-r--r--lib/cmyth/libcmyth/livetv.c18
-rw-r--r--lib/cmyth/libcmyth/mythtv_mysql.c22
-rw-r--r--lib/cmyth/libcmyth/posmap.c4
-rw-r--r--lib/cmyth/libcmyth/proginfo.c4
-rw-r--r--lib/cmyth/libcmyth/proglist.c4
-rw-r--r--lib/cmyth/libcmyth/rec_num.c5
-rw-r--r--lib/cmyth/libcmyth/recorder.c20
-rw-r--r--lib/cmyth/libcmyth/ringbuf.c6
-rw-r--r--lib/cmyth/libcmyth/socket.c8
-rw-r--r--lib/cmyth/libcmyth/timestamp.c8
16 files changed, 104 insertions, 158 deletions
diff --git a/lib/cmyth/libcmyth/cmyth_local.h b/lib/cmyth/libcmyth/cmyth_local.h
index ef5f7c68aa..93fda9efd7 100644
--- a/lib/cmyth/libcmyth/cmyth_local.h
+++ b/lib/cmyth/libcmyth/cmyth_local.h
@@ -25,56 +25,36 @@
#ifndef __CMYTH_LOCAL_H
#define __CMYTH_LOCAL_H
-#ifdef _MSC_VER
#include <stdio.h>
-#include <malloc.h>
-#else
-#include <unistd.h>
+#include <stdlib.h>
+#if !defined(_MSC_VER)
+#include <sys/time.h>
#endif
#include <refmem/refmem.h>
#include <cmyth/cmyth.h>
#include <time.h>
-#include <mysql/mysql.h>
#include <stdint.h>
+#include <mysql/mysql.h>
-#ifdef _MSC_VER
-#pragma warning(disable:4267)
-#define pthread_mutex_lock(a)
-#define pthread_mutex_unlock(a)
-#define PTHREAD_MUTEX_INITIALIZER NULL;
-typedef void* pthread_mutex_t;
-extern pthread_mutex_t mutex;
-#define mutex __cmyth_mutex
-#define SHUT_RDWR SD_BOTH
-typedef SOCKET cmyth_socket_t;
-typedef int socklen_t;
-#define snprintf _snprintf
-#define sleep(a) Sleep(a*1000)
-#define usleep(a) Sleep(a/1000)
-static inline struct tm* localtime_r (const time_t *clock, struct tm *result) {
- struct tm* data;
- if (!clock || !result) return NULL;
- data = localtime(clock);
- if (!data) return NULL;
- memcpy(result,data,sizeof(*result));
- return result;
-}
-static inline __int64 atoll(const char* s)
-{
- __int64 value;
- if(sscanf(s,"%I64d", &value))
- return value;
- else
- return 0;
-}
-
+#if defined(_MSC_VER)
+#include "cmyth_msc.h"
#else
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/select.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <arpa/inet.h>
#include <pthread.h>
+
+typedef int cmyth_socket_t;
+#define closesocket(fd) close(fd)
+#endif /* _MSC_VER */
+
#define mutex __cmyth_mutex
extern pthread_mutex_t mutex;
-#define closesocket(fd) close(fd)
-typedef int cmyth_socket_t;
-#endif
+
/*
* Some useful constants
*/
diff --git a/lib/cmyth/libcmyth/cmyth_msc.h b/lib/cmyth/libcmyth/cmyth_msc.h
new file mode 100644
index 0000000000..78e0c92f98
--- /dev/null
+++ b/lib/cmyth/libcmyth/cmyth_msc.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2012, Jon Gettler
+ * http://www.mvpmc.org/
+ *
+ * This library 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; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/**
+ * \file cmyth_msc.h
+ * Contain most of the Microsoft related differences in a single file.
+ */
+
+#ifndef __CMYTH_MSC_H
+#define __CMYTH_MSC_H
+
+#if !defined(_MSC_VER)
+#error This file may only be included on windows builds!
+#endif /* !_MSC_VER */
+
+#include <malloc.h>
+#include <winsock2.h>
+#include <Ws2tcpip.h>
+
+#pragma warning(disable:4267)
+#pragma warning(disable:4996)
+
+#define pthread_mutex_lock(a)
+#define pthread_mutex_unlock(a)
+#define PTHREAD_MUTEX_INITIALIZER NULL;
+typedef void *pthread_mutex_t;
+
+#undef ECANCELED
+#undef ETIMEDOUT
+
+#define ECANCELED -1
+#define ETIMEDOUT -1
+#define SHUT_RDWR SD_BOTH
+
+typedef SOCKET cmyth_socket_t;
+typedef int socklen_t;
+
+#define snprintf _snprintf
+#define sleep(a) Sleep(a*1000)
+#define usleep(a) Sleep(a/1000)
+
+static inline struct tm *localtime_r(const time_t * clock, struct tm *result)
+{
+ struct tm *data;
+ if (!clock || !result)
+ return NULL;
+ data = localtime(clock);
+ if (!data)
+ return NULL;
+ memcpy(result, data, sizeof(*result));
+ return result;
+}
+
+static inline __int64 atoll(const char *s)
+{
+ __int64 value;
+ if (sscanf(s, "%I64d", &value))
+ return value;
+ else
+ return 0;
+}
+
+#endif /* __CMYTH_MSC_H */
diff --git a/lib/cmyth/libcmyth/connection.c b/lib/cmyth/libcmyth/connection.c
index 85eddaee9b..8ac72ccdb3 100644
--- a/lib/cmyth/libcmyth/connection.c
+++ b/lib/cmyth/libcmyth/connection.c
@@ -23,21 +23,8 @@
* interacting with those connections.
*/
-#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
#include <stdio.h>
-#ifdef _MSC_VER
-#include <winsock2.h>
-#include <Ws2tcpip.h>
-#else
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#endif
#include <errno.h>
#include <string.h>
#include <signal.h>
diff --git a/lib/cmyth/libcmyth/file.c b/lib/cmyth/libcmyth/file.c
index 516da03d59..401e3e7d2b 100644
--- a/lib/cmyth/libcmyth/file.c
+++ b/lib/cmyth/libcmyth/file.c
@@ -21,9 +21,7 @@
#include <stdlib.h>
#include <errno.h>
#include <inttypes.h>
-#ifndef _MSC_VER
-#include <sys/socket.h>
-#endif
+#include <sys/types.h>
#include <cmyth_local.h>
/*
diff --git a/lib/cmyth/libcmyth/freespace.c b/lib/cmyth/libcmyth/freespace.c
index ca8e3c3b39..6b291aca71 100644
--- a/lib/cmyth/libcmyth/freespace.c
+++ b/lib/cmyth/libcmyth/freespace.c
@@ -20,13 +20,7 @@
/*
* freespace.c - functions to manage freespace structures.
*/
-#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <errno.h>
#include <cmyth_local.h>
/*
diff --git a/lib/cmyth/libcmyth/keyframe.c b/lib/cmyth/libcmyth/keyframe.c
index 7117683ed7..4f6f912313 100644
--- a/lib/cmyth/libcmyth/keyframe.c
+++ b/lib/cmyth/libcmyth/keyframe.c
@@ -23,9 +23,6 @@
*/
#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
#include <string.h>
#include <stdio.h>
#include <cmyth_local.h>
diff --git a/lib/cmyth/libcmyth/livetv.c b/lib/cmyth/libcmyth/livetv.c
index 31ecb2a4fc..9f5ccd77de 100644
--- a/lib/cmyth/libcmyth/livetv.c
+++ b/lib/cmyth/libcmyth/livetv.c
@@ -24,29 +24,13 @@
* This allows the watcher to do things like pause, rewind
* and so forth on live-tv.
*/
-#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#include <sys/socket.h>
-#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
+#include <sys/types.h>
#include <cmyth_local.h>
-#ifdef _MSC_VER
-static void nullprint(a, ...) { return; }
-#define PRINTF nullprint
-#define TRC nullprint
-#elif 0
-#define PRINTF(x...) PRINTF(x)
-#define TRC(fmt, args...) PRINTF(fmt, ## args)
-#else
-#define PRINTF(x...)
-#define TRC(fmt, args...)
-#endif
-
#define LAST 0x7FFFFFFF
static int cmyth_livetv_chain_has_url(cmyth_recorder_t rec, char * url);
diff --git a/lib/cmyth/libcmyth/mythtv_mysql.c b/lib/cmyth/libcmyth/mythtv_mysql.c
index ab69b4f0ac..3179fad112 100644
--- a/lib/cmyth/libcmyth/mythtv_mysql.c
+++ b/lib/cmyth/libcmyth/mythtv_mysql.c
@@ -17,36 +17,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
-#ifdef _MSC_VER
-#include <time.h>
-#else
-#include <sys/time.h>
-#endif
#include <mysql/mysql.h>
#include <cmyth_local.h>
#include <safe_string.h>
-#ifdef _MSC_VER
-static void nullprint(a, ...) { return; }
-#define PRINTF nullprint
-#define TRC nullprint
-#elif 0
-#define PRINTF(x...) PRINTF(x)
-#define TRC(fmt, args...) PRINTF(fmt, ## args)
-#else
-#define PRINTF(x...)
-#define TRC(fmt, args...)
-#endif
-
-
void
cmyth_database_close(cmyth_database_t db)
{
diff --git a/lib/cmyth/libcmyth/posmap.c b/lib/cmyth/libcmyth/posmap.c
index e6929e78c8..c5043ec0e2 100644
--- a/lib/cmyth/libcmyth/posmap.c
+++ b/lib/cmyth/libcmyth/posmap.c
@@ -25,11 +25,7 @@
* be markers inserted by commercial detection. A position
* map collects these in one place.
*/
-#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
#include <stdio.h>
#include <cmyth_local.h>
diff --git a/lib/cmyth/libcmyth/proginfo.c b/lib/cmyth/libcmyth/proginfo.c
index 2e6daaa694..48e4b95ad4 100644
--- a/lib/cmyth/libcmyth/proginfo.c
+++ b/lib/cmyth/libcmyth/proginfo.c
@@ -26,11 +26,7 @@
* also retrieve and manipulate recordings and program
* material based on program information.
*/
-#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
diff --git a/lib/cmyth/libcmyth/proglist.c b/lib/cmyth/libcmyth/proglist.c
index f6d12e27db..b0a4820702 100644
--- a/lib/cmyth/libcmyth/proglist.c
+++ b/lib/cmyth/libcmyth/proglist.c
@@ -23,11 +23,7 @@
* and cmyth_proglist_t and between long long and
* cmyth_proglist_t.
*/
-#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
diff --git a/lib/cmyth/libcmyth/rec_num.c b/lib/cmyth/libcmyth/rec_num.c
index b78a64e4b0..a5ae2b3e40 100644
--- a/lib/cmyth/libcmyth/rec_num.c
+++ b/lib/cmyth/libcmyth/rec_num.c
@@ -21,14 +21,9 @@
* rec_num.c - functions to manage recorder number structures. Mostly
* just allocating, freeing, and filling them out.
*/
-#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
#include <stdio.h>
#include <string.h>
-#include <errno.h>
#include <cmyth_local.h>
/*
diff --git a/lib/cmyth/libcmyth/recorder.c b/lib/cmyth/libcmyth/recorder.c
index 02a436b36d..207a241ba0 100644
--- a/lib/cmyth/libcmyth/recorder.c
+++ b/lib/cmyth/libcmyth/recorder.c
@@ -26,33 +26,13 @@
* owns the tuner and channel information (i.e. program
* guide data).
*/
-#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
-#ifdef _MSC_VER
#include <time.h>
-#else
-#include <sys/time.h>
-#endif
#include <cmyth_local.h>
-#ifdef _MSC_VER
-static void nullprint(a, ...) { return; }
-#define PRINTF nullprint
-#define TRC nullprint
-#elif 0
-#define PRINTF(x...) PRINTF(x)
-#define TRC(fmt, args...) PRINTF(fmt, ## args)
-#else
-#define PRINTF(x...)
-#define TRC(fmt, args...)
-#endif
-
/*
* cmyth_recorder_destroy(cmyth_recorder_t rec)
*
diff --git a/lib/cmyth/libcmyth/ringbuf.c b/lib/cmyth/libcmyth/ringbuf.c
index 960f000b0e..49519f0cdf 100644
--- a/lib/cmyth/libcmyth/ringbuf.c
+++ b/lib/cmyth/libcmyth/ringbuf.c
@@ -24,15 +24,11 @@
* This allows the watcher to do things like pause, rewind
* and so forth on live-tv.
*/
-#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#include <sys/socket.h>
-#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
+#include <sys/types.h>
#include <cmyth_local.h>
/*
diff --git a/lib/cmyth/libcmyth/socket.c b/lib/cmyth/libcmyth/socket.c
index 28be4d7d8b..4e7ca681c4 100644
--- a/lib/cmyth/libcmyth/socket.c
+++ b/lib/cmyth/libcmyth/socket.c
@@ -21,16 +21,12 @@
* socket.c - functions to handle low level socket interactions with a
* MythTV frontend.
*/
-#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#include <sys/socket.h>
-#endif
#include <stdio.h>
-#include <string.h>
#include <ctype.h>
+#include <string.h>
#include <errno.h>
+#include <sys/types.h>
#include <cmyth_local.h>
#define __UNSIGNED "0123456789"
diff --git a/lib/cmyth/libcmyth/timestamp.c b/lib/cmyth/libcmyth/timestamp.c
index 02d1b84678..e19e37a27f 100644
--- a/lib/cmyth/libcmyth/timestamp.c
+++ b/lib/cmyth/libcmyth/timestamp.c
@@ -23,18 +23,12 @@
* and cmyth_timestamp_t and between time_t and
* cmyth_timestamp_t.
*/
-#include <sys/types.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
-#include <ctype.h>
#include <stdio.h>
+#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <cmyth_local.h>
-#include <time.h>
-
/*
* cmyth_timestamp_create(void)