Index: /libmpc/trunk/common/tags.c
===================================================================
--- /libmpc/trunk/common/tags.c	(revision 413)
+++ /libmpc/trunk/common/tags.c	(revision 414)
@@ -28,4 +28,8 @@
 #ifdef _WIN32
 # include <windows.h>
+#endif
+
+#ifdef _MSC_VER
+# define strncasecmp	strnicmp
 #endif
 
Index: /libmpc/trunk/mpcchap/CMakeLists.txt
===================================================================
--- /libmpc/trunk/mpcchap/CMakeLists.txt	(revision 413)
+++ /libmpc/trunk/mpcchap/CMakeLists.txt	(revision 414)
@@ -1,8 +1,8 @@
-FIND_PATH(CUEFILE_INCLUDE_DIR src/lib/cuefile.h
-	${libmpc_SOURCE_DIR}/../cuetools-1.3.1
+FIND_PATH(CUEFILE_INCLUDE_DIR lib/cuefile.h
+	${libmpc_SOURCE_DIR}/../cuetools-1.3.1/src
 )
 
 FIND_LIBRARY(CUEFILE_LIBRARY NAMES cuefile_static PATHS
-	${CUEFILE_INCLUDE_DIR}/src/lib
+	${CUEFILE_INCLUDE_DIR}/lib
 )
 
Index: /libmpc/trunk/mpcchap/dictionary.c
===================================================================
--- /libmpc/trunk/mpcchap/dictionary.c	(revision 413)
+++ /libmpc/trunk/mpcchap/dictionary.c	(revision 414)
@@ -21,9 +21,4 @@
  ---------------------------------------------------------------------------*/
 #include "dictionary.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
 
 /** Maximum value size for integers and doubles. */
Index: /libmpc/trunk/mpcchap/dictionary.h
===================================================================
--- /libmpc/trunk/mpcchap/dictionary.h	(revision 413)
+++ /libmpc/trunk/mpcchap/dictionary.h	(revision 414)
@@ -31,5 +31,8 @@
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
+
+#ifndef _MSC_VER
+# include <unistd.h>
+#endif
 
 /*---------------------------------------------------------------------------
Index: /libmpc/trunk/mpcchap/mpcchap.c
===================================================================
--- /libmpc/trunk/mpcchap/mpcchap.c	(revision 413)
+++ /libmpc/trunk/mpcchap/mpcchap.c	(revision 414)
@@ -38,5 +38,8 @@
 
 #ifdef _MSC_VER
-#define atoll _atoi64
+# include <io.h>
+# define atoll		_atoi64
+# define ftruncate	chsize
+# define strcasecmp stricmp
 #endif
 
@@ -66,5 +69,7 @@
 	struct stat stbuf;
 	FILE * in_file;
-	int chap_pos, end_pos, chap_size, i;
+	int chap_pos, end_pos, chap_size, i, nchap;
+	char * tmp_buff;
+	dictionary * dict;
 
 	chap_pos = (demux->chap_pos >> 3) + si->header_position;
@@ -73,5 +78,5 @@
 
 	stat(mpc_file, &stbuf);
-	char * tmp_buff = malloc(stbuf.st_size - chap_pos - chap_size);
+	tmp_buff = malloc(stbuf.st_size - chap_pos - chap_size);
 	in_file = fopen( mpc_file, "r+b" );
 	fseek(in_file, chap_pos + chap_size, SEEK_SET);
@@ -79,11 +84,11 @@
 	fseek(in_file, chap_pos, SEEK_SET);
 
-	dictionary * dict = iniparser_load(chap_file);
-
-	int nchap = iniparser_getnsec(dict);
+	dict = iniparser_load(chap_file);
+
+	nchap = iniparser_getnsec(dict);
 	for (i = 0; i < nchap; i++) {
-		int j, nitem, ntags = 0, tag_len = 0;
+		int j, nitem, ntags = 0, tag_len = 0, offset_size;
 		mpc_uint16_t gain = 0, peak = 0;
-		char * chap_sec = iniparser_getsecname(dict, i);
+		char * chap_sec = iniparser_getsecname(dict, i), block_header[12] = "CT", sample_offset[10];
 		mpc_int64_t chap_pos = atoll(chap_sec);
 
@@ -112,7 +117,6 @@
 		}
 		if (ntags > 0) tag_len += 24 + ntags * 9;
-		char block_header[12] = "CT";
-		char sample_offset[10];
-		int offset_size = encodeSize(chap_pos, sample_offset, MPC_FALSE);
+		
+		offset_size = encodeSize(chap_pos, sample_offset, MPC_FALSE);
 		tag_len = encodeSize(tag_len + 4 + offset_size + 2, block_header + 2, MPC_TRUE);
 		fwrite(block_header, 1, tag_len + 2, in_file);
@@ -143,4 +147,5 @@
 	FILE * in_file;
 	int chap_pos, end_pos, chap_size, i;
+	char * tmp_buff;
 
 	if (0 == (cd = cf_parse(chap_file, &format))) {
@@ -154,5 +159,5 @@
 
 	stat(mpc_file, &stbuf);
-	char * tmp_buff = malloc(stbuf.st_size - chap_pos - chap_size);
+	tmp_buff = malloc(stbuf.st_size - chap_pos - chap_size);
 	in_file = fopen( mpc_file, "r+b" );
 	fseek(in_file, chap_pos + chap_size, SEEK_SET);
@@ -162,7 +167,9 @@
 	nchap = cd_get_ntrack(cd);
 	for (i = 1; i <= nchap; i++) {
-		int j, nitem = 0, tag_len = 0, key_len, item_len;
+		char track_buf[16], block_header[12] = "CT", sample_offset[10];
+		int j, nitem = 0, tag_len = 0, key_len, item_len, offset_size;
 		Track * track;
 		Cdtext *cdtext;
+		mpc_int64_t chap_pos;
 
 		track = cd_get_track (cd, i);
@@ -170,5 +177,5 @@
 
 		// position du chapitre
-		mpc_int64_t chap_pos = (mpc_int64_t) si->sample_freq * track_get_start (track) / 75;
+		chap_pos = (mpc_int64_t) si->sample_freq * track_get_start (track) / 75;
 
 		if (chap_pos > si->samples - si->beg_silence)
@@ -178,5 +185,4 @@
 		Init_Tags();
 
-		char track_buf[16];
 		sprintf(track_buf, "%i/%i", i, nchap);
 		key_len = 5;
@@ -199,7 +205,5 @@
 
 		tag_len += 24 + nitem * 9;
-		char block_header[12] = "CT";
-		char sample_offset[10];
-		int offset_size = encodeSize(chap_pos, sample_offset, MPC_FALSE);
+		offset_size = encodeSize(chap_pos, sample_offset, MPC_FALSE);
 		tag_len = encodeSize(tag_len + 4 + offset_size + 2, block_header + 2, MPC_TRUE);
 		fwrite(block_header, 1, tag_len + 2, in_file);
@@ -262,4 +266,5 @@
 	mpc_status err;
 	FILE * test_file;
+	int chap_nb;
 
 	if (argc != 3)
@@ -281,5 +286,5 @@
 	}
 
-	int chap_nb = mpc_demux_chap_nb(demux);
+	chap_nb = mpc_demux_chap_nb(demux);
 
 	test_file = fopen(chap_file, "rb" );
