Fix win32 build
authorJelmer Vernooij <jelmer@samba.org>
Mon, 13 Dec 2004 17:36:08 +0000 (18:36 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 13 Dec 2004 17:36:08 +0000 (18:36 +0100)
ptb.c
ptb.h
ptb2ly.c
ptb2xml.c
win32/ptb.def [new file with mode: 0644]

diff --git a/ptb.c b/ptb.c
index a9c553d50c05ddd3e6f62f120c0549e4af9e8892..86208735c7da03fe2a9ab6f5a743e8bfbbe6b60f 100644 (file)
--- a/ptb.c
+++ b/ptb.c
  */
 
 #include <stdio.h>
+#ifndef _WIN32
 #include <unistd.h>
+#else
+#include <io.h>
+typedef int ssize_t;
+#endif
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <string.h>
+#define PTB_CORE
 #include "ptb.h"
-#include <glib.h>
 
 int assert_is_fatal = 0;
 
 #define ptb_assert(ptb, expr) \
        if (!(expr)) { ptb_debug("---------------------------------------------"); \
-               ptb_debug("file: %s, line: %d (%s): assertion failed: %s. Current position: 0x%lx", __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr, ptb->curpos); \
+               ptb_debug("file: %s, line: %d (%s): assertion failed: %s. Current position: 0x%lx", __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, #expr, ptb->curpos); \
                if(assert_is_fatal) abort(); \
        }
 
@@ -46,12 +51,10 @@ extern struct ptb_section_handler ptb_section_handlers[];
 
 void ptb_debug(const char *fmt, ...);
 
-#define read DONT_USE_READ
-
 int debugging = 0;
 
-ssize_t ptb_read(struct ptbf *f, void *data, size_t length){
-#undef read
+ssize_t ptb_read(struct ptbf *f, void *data, size_t length)
+{
        ssize_t ret = read(f->fd, data, length);
 #define read DONT_USE_READ
 
@@ -82,7 +85,7 @@ ssize_t ptb_read_unknown(struct ptbf *f, size_t length) {
        char unknown[255];
        ssize_t ret;
        off_t oldpos = f->curpos;
-       int i;
+       size_t i;
 
        ret = ptb_read(f, unknown, length);
        if(debugging) {
diff --git a/ptb.h b/ptb.h
index 4b7b55f2a1d7828d5a0ad62adf5b056f4c30e600..18269812fc91ab534b9527d9d14f06306171a546 100644 (file)
--- a/ptb.h
+++ b/ptb.h
 #include <glib.h>
 #include <stdlib.h>
 
+#define PTB_VERSION "0.4"
+
+#if defined(_WIN32) && !defined(PTB_CORE)
+#pragma comment(lib,"ptb.lib")
+#endif
+
 typedef guint8 ptb_chord;
 typedef guint8 ptb_tone;
 typedef guint8 ptb_note;
@@ -53,6 +59,7 @@ struct ptb_hdr {
                                        guint16 year;
                                } bootleg;
                                struct {
+                                       char empty;
                                } unreleased;
                        } release_info;
                        guint8 is_original_author_unknown;
@@ -328,4 +335,4 @@ const char *ptb_get_tone_full(ptb_tone);
 
 void ptb_get_position_difference(struct ptb_section *, int start, int end, int *bars, int *length);
 
-#endif /* __PTB_H__ */
+#endif /* __PTB_H__ */
\ No newline at end of file
index ebdfc5ea0dd9a5a0350c453d44400fc509b5588d..6c231b0c8decad0b15dfd5c3a497eb034d03c763 100644 (file)
--- a/ptb2ly.c
+++ b/ptb2ly.c
@@ -22,7 +22,7 @@
 #include <string.h>
 #include "ptb.h"
 
-#define LILYPOND_VERSION "2.4"
+#define LILYPOND_VERSION "0.4"
 
 const char *num_to_string(int num, char *data)
 {
@@ -44,7 +44,7 @@ const char *num_to_string(int num, char *data)
 const char *get_staff_name(int sec_num, int staff_num)
 {
        static char name[30], num[2][30];
-       snprintf(name, sizeof(name), "staff%sx%s", num_to_string(sec_num, num[0]), num_to_string(staff_num, num[1]));
+       g_snprintf(name, sizeof(name), "staff%sx%s", num_to_string(sec_num, num[0]), num_to_string(staff_num, num[1]));
        return name;
 }
 
@@ -167,11 +167,11 @@ void ly_write_chordtext(FILE *out, struct ptb_section *section, struct ptb_chord
                ly_write_chordtext_helper(out, name, length);
 }
 
-static float previous = 0.0;
+static double previous = 0.0;
 
 void ly_write_position(FILE *out, struct ptb_position *pos)
 {
-       float this = 0.0;
+       double this = 0.0;
        char print_length = 0;
        GList *gl = pos->linedatas;
        int l = g_list_length(pos->linedatas);
index db71f669fc67af012cfecfe76eb5dbe50f39d2ad..677e10e46d5b1a660c075fecca73eac6fee1ff92 100644 (file)
--- a/ptb2xml.c
+++ b/ptb2xml.c
@@ -20,7 +20,7 @@
 #include <errno.h>
 #include <string.h>
 #include <popt.h>
-#include <sys/time.h>
+//#include <sys/time.h>
 #include <time.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
diff --git a/win32/ptb.def b/win32/ptb.def
new file mode 100644 (file)
index 0000000..9fb6f8d
--- /dev/null
@@ -0,0 +1,7 @@
+EXPORTS\r
+       ptb_read_file\r
+       ptb_set_debug\r
+       ptb_set_asserts_fatal\r
+       ptb_get_tone\r
+       ptb_get_tone_full\r
+       ptb_get_position_difference\r