Index: ChangeLog
===================================================================
--- ChangeLog	(revision 5207)
+++ ChangeLog	(revision 5210)
@@ -14,4 +14,5 @@
 	* Updated filters to support 8 and 32 bit mode as well (pr1)
 	* Re-wrote ALSA plugin (pr1)
+	* Updated ports to minimal, win32 and avr (pr2)
 
 v. 0.4rc0 - Mon Sep 05 2011 15:25 CEST
Index: configure
===================================================================
--- configure	(revision 5133)
+++ configure	(revision 5210)
@@ -670,4 +670,6 @@
 
 test_lib () {
+ _have_libs=false
+ _have_headers=false
  echo > $TF_C
 
@@ -694,7 +696,9 @@
    '-'*)
     LIBS="$LIBS $1"
+    _have_libs=true
    ;;
    *)
     LIBS="$LIBS -l$1"
+    _have_libs=true
    ;;
   esac
@@ -718,8 +722,16 @@
   else
    echo "#include <$_h>"  >> $TF_C
+   _have_headers=true
   fi
  done
 
  echo 'int main (void) { return 0; }' >> $TF_C
+
+ if [ "$_have_libs" = 'false' -a "$_have_headers" = 'false' ]
+ then
+  echo "no (nothing to test left)$_info"
+  echo "LIB($name) HAS NOTHING TO TEST" >&5
+  return 1
+ fi
 
  echo "LIB($name) IS TESTED USING TEST CODE:" >&5
Index: include/roaraudio/caps.h
===================================================================
--- include/roaraudio/caps.h	(revision 4708)
+++ include/roaraudio/caps.h	(revision 5210)
@@ -38,16 +38,16 @@
 
 // standard vendors:
-#define ROAR_STDV_ROARAUDIO      0
-#define ROAR_STDV_PROTO          1
-#define ROAR_STDV_RFC            2
+#define ROAR_STDV_ROARAUDIO      ((uint32_t)0)
+#define ROAR_STDV_PROTO          ((uint32_t)1)
+#define ROAR_STDV_RFC            ((uint32_t)2)
 
 // data macros for standards:
-#define ROAR_STD_MASK_VENDOR     0xFF000000
-#define ROAR_STD_MASK_STD        0x00FFFF00
-#define ROAR_STD_MASK_VERSION    0x000000FF
+#define ROAR_STD_MASK_VENDOR     ((uint32_t)0xFF000000)
+#define ROAR_STD_MASK_STD        ((uint32_t)0x00FFFF00)
+#define ROAR_STD_MASK_VERSION    ((uint32_t)0x000000FF)
 
-#define ROAR_STD_MAKE(vendor,standard,version) ((((vendor)   & 0x00FF) << 24) | \
-                                                (((standard) & 0xFFFF) <<  8) | \
-                                                 ((version)  & 0x00FF)        )
+#define ROAR_STD_MAKE(vendor,standard,version) ((((uint32_t)(vendor)   & 0x00FF) << 24) | \
+                                                (((uint32_t)(standard) & 0xFFFF) <<  8) | \
+                                                 ((uint32_t)(version)  & 0x00FF)        )
 
 #define ROAR_STD_MAKE_RFC(rfc) ROAR_STD_MAKE(ROAR_STDV_RFC, (rfc), 0)
Index: include/roaraudio/muconthacks.h
===================================================================
--- include/roaraudio/muconthacks.h	(revision 5015)
+++ include/roaraudio/muconthacks.h	(revision 5210)
@@ -47,4 +47,5 @@
 #define O_NONBLOCK     0x04
 #define O_CREAT        0x08
+#define O_TRUNC        0x10
 
 #define EAGAIN         11
Index: include/roaraudio/notify.h
===================================================================
--- include/roaraudio/notify.h	(revision 4841)
+++ include/roaraudio/notify.h	(revision 5210)
@@ -34,21 +34,21 @@
 #define ROAR_EVENT_NETFLAG_PROXYEVENT  0x00000002
 
-#define ROAR_NOTIFY_SPECIAL       0xffffffff
+#define ROAR_NOTIFY_SPECIAL       (uint32_t)0xffffffff
 
 // protocol cmds:
-#define ROAR_NOTIFY_OFFSET_CMD    0x00000000
-#define ROAR_NOTIFY_MASK_CMD      0x000000ff
+#define ROAR_NOTIFY_OFFSET_CMD    (uint32_t)0x00000000
+#define ROAR_NOTIFY_MASK_CMD      (uint32_t)0x000000ff
 
 // event groups (AKA meta events):
-#define ROAR_NOTIFY_OFFSET_EGRP    0x00010000
-#define ROAR_NOTIFY_MASK_EGRP      0x0000ffff
+#define ROAR_NOTIFY_OFFSET_EGRP   (uint32_t)0x00010000
+#define ROAR_NOTIFY_MASK_EGRP     (uint32_t)0x0000ffff
 
 // object event:
-#define ROAR_NOTIFY_OFFSET_OE    0x00020000
-#define ROAR_NOTIFY_MASK_OE      0x0000ffff
+#define ROAR_NOTIFY_OFFSET_OE     (uint32_t)0x00020000
+#define ROAR_NOTIFY_MASK_OE       (uint32_t)0x0000ffff
 
 // user defined events:
-#define ROAR_NOTIFY_OFFSET_USER   0x40000000
-#define ROAR_NOTIFY_MASK_USER     0x3fffffff
+#define ROAR_NOTIFY_OFFSET_USER   (uint32_t)0x40000000
+#define ROAR_NOTIFY_MASK_USER     (uint32_t)0x3fffffff
 
 #define ROAR_NOTIFY_X2EVENT(x,offset,mask) ((x) == -1 ? ROAR_NOTIFY_SPECIAL : (((x) & (mask))+(offset)))
Index: include/roaraudio/units.h
===================================================================
--- include/roaraudio/units.h	(revision 4708)
+++ include/roaraudio/units.h	(revision 5210)
@@ -35,7 +35,7 @@
 #define _ONE    1
 #define _KILO   1000
-#define _MEGA   (_KILO*_KILO)
-#define _GIGA   (_KILO*_MEGA)
-#define _TERA   (_KILO*_GIGA)
+#define _MEGA   ((int_least32_t)_KILO*(int_least32_t)_KILO)
+#define _GIGA   ((int_least32_t)_KILO*_MEGA)
+#define _TERA   ((int_least32_t)_KILO*_GIGA)
 
 
@@ -43,15 +43,22 @@
 #ifndef _SEC
 #if defined(_UNITS_T_BASE_MSEC)
-#define _SEC  1000
+#define _SEC_TYPE int_least32_t
+#define _SEC  (_SEC_TYPE)1000
 #elif defined(_UNITS_T_BASE_USEC)
-#define _SEC  1000000
+#define _SEC_TYPE int_least32_t
+#define _SEC  (_SEC_TYPE)1000000
 //#elif defined(_UNITS_T_BASE_SEC)
 #else
 #define _SEC  1
+#define _SEC_TYPE int
 #endif
 #endif
 
-#define _MIN  (60*_SEC)
-#define _HOUR (60*_MIN)
+#ifndef _SEC_TYPE
+#define _SEC_TYPE int_least32_t
+#endif
+
+#define _MIN  ((_SEC_TYPE)60*_SEC)
+#define _HOUR ((_SEC_TYPE)60*_MIN)
 
 #define _MSEC (_SEC*_MILI)
@@ -62,14 +69,21 @@
 #ifndef _METER
 #if defined(_UNITS_D_BASE_MMETER)
+#define _METER_TYPE int
 #define _METER 1000
 #elif defined(_UNITS_D_BASE_UMETER)
-#define _METER 1000000
+#define _METER_TYPE int_least32_t
+#define _METER (_METER_TYPE)1000000
 //#elif defined(_UNITS_D_BASE_METER)
 #else
+#define _METER_TYPE int
 #define _METER 1
 #endif
 #endif
 
-#define _AE    (149597870691LL     *_METER)
+#ifndef _METER_TYPE
+#define _METER_TYPE int_least32_t
+#endif
+
+#define _AE    ((int_least64_t)149597870691LL     *_METER)
 #define _LJ    (9460730472580800LL *_METER)
 #define _PC    (30856804413117847LL*_METER) /* TODO: FIXME: get a more corret value */
Index: libroar/socket.c
===================================================================
--- libroar/socket.c	(revision 5203)
+++ libroar/socket.c	(revision 5210)
@@ -168,5 +168,5 @@
 
 int roar_socket_set_tos(int fh) {
-#ifndef ROAR_TARGET_WIN32
+#if defined(ROAR_HAVE_BSDSOCKETS) && !defined(ROAR_TARGET_WIN32)
  int opt = IPTOS_LOWDELAY;
  int ret;
Index: libroardsp/alaw.c
===================================================================
--- libroardsp/alaw.c	(revision 4758)
+++ libroardsp/alaw.c	(revision 5210)
@@ -839,5 +839,5 @@
    bits = 1;
 
-  op = _roardsp_alaw2pcm16[(int)alaw] << 16;
+  op = (uint32_t)_roardsp_alaw2pcm16[(int)alaw] << 16;
 //  out[i] |= extra << (11 + bits);
   out[i]  = op;
Index: roard/caps.c
===================================================================
--- roard/caps.c	(revision 4708)
+++ roard/caps.c	(revision 5210)
@@ -71,7 +71,7 @@
   version = ROAR_STD_VERSION(cap);
   if ( version == 0 ) {
-   snpret = snprintf(ret+off, len-off, "%i-%i,", ROAR_STD_VENDOR(cap), ROAR_STD_STD(cap));
+   snpret = snprintf(ret+off, len-off, "%i-%i,", (int)ROAR_STD_VENDOR(cap), (int)ROAR_STD_STD(cap));
   } else {
-   snpret = snprintf(ret+off, len-off, "%i-%i-%i,", ROAR_STD_VENDOR(cap), ROAR_STD_STD(cap), version);
+   snpret = snprintf(ret+off, len-off, "%i-%i-%i,", (int)ROAR_STD_VENDOR(cap), (int)ROAR_STD_STD(cap), (int)version);
   }
   if ( snpret > 0 ) {
Index: roard/codecfilter.c
===================================================================
--- roard/codecfilter.c	(revision 4708)
+++ roard/codecfilter.c	(revision 5210)
@@ -269,5 +269,5 @@
     strcpy(delay, "dyn");
    } else {
-    snprintf(delay, 5, "%ims", d/1000);
+    snprintf(delay, 5, "%ims", (int)(d/(uint_least32_t)1000));
    }
   }
Index: roard/codecfilter_au.c
===================================================================
--- roard/codecfilter_au.c	(revision 4708)
+++ roard/codecfilter_au.c	(revision 5210)
@@ -93,5 +93,5 @@
    header[1] -= ROAR_AU_MIN_HEADER_LEN;
 
-   if ( header[1] > 32*1024 ) // do not allow more than 32KiB header...
+   if ( header[1] > (uint32_t)32768U ) // do not allow more than 32KiB header...
     return -1;
 
Index: roard/hwmixer.c
===================================================================
--- roard/hwmixer.c	(revision 4852)
+++ roard/hwmixer.c	(revision 5210)
@@ -238,4 +238,5 @@
  int ret;
  int error = 0;
+ char * strtok_store;
 //int hwmixer_open(int basestream, char * drv, char * dev, int fh, char * basename, char * subnames) {
 
@@ -248,5 +249,5 @@
   k = NULL;
  } else {
-  k = strtok(opts, ",");
+  k = roar_mm_strtok_r(opts, ",", &strtok_store);
  }
 
@@ -281,5 +282,5 @@
   }
 
-  k = strtok(NULL, ",");
+  k = roar_mm_strtok_r(NULL, ",", &strtok_store);
  }
 
Index: roard/include/light.h
===================================================================
--- roard/include/light.h	(revision 5194)
+++ roard/include/light.h	(revision 5210)
@@ -43,5 +43,5 @@
 } g_light_mixer;
 
-int light_init  (unsigned int channels);
+int light_init  (uint32_t channels);
 int light_free  (void);
 
Index: roard/light.c
===================================================================
--- roard/light.c	(revision 5194)
+++ roard/light.c	(revision 5210)
@@ -33,5 +33,5 @@
 // //
 
-int light_init  (unsigned int channels) {
+int light_init  (uint32_t channels) {
  struct roar_stream_server * ss;
  int i;
@@ -39,5 +39,5 @@
  g_light_state.channels = 0;
 
- if ( channels == 0 || channels > (512*512) ) /* unrealstic values */
+ if ( channels == 0 || channels > ((uint32_t)512UL*(uint32_t)512UL) ) /* unrealstic values */
   return -1;
 
Index: roard/midi.c
===================================================================
--- roard/midi.c	(revision 5208)
+++ roard/midi.c	(revision 5210)
@@ -282,5 +282,5 @@
     switch (mes->kk) {
      case MIDI_CCE_MAIN_VOL:
-       if ( (516 * mes->vv) > 65100 ) { // max volume
+       if ( (516U * (unsigned int)mes->vv) > 65100 ) { // max volume
         ss->mixer.mixer[mes->channel] = 65535;
        } else {
@@ -611,5 +611,5 @@
       switch (mes->kk) {
        case MIDI_CCE_MAIN_VOL:
-         if ( 516 * mes->vv > 65100 ) { // max volume
+         if ( 516U * (unsigned int)mes->vv > 65100 ) { // max volume
           ss->mixer.mixer[mes->channel] = 65535;
          } else {
Index: roard/output.c
===================================================================
--- roard/output.c	(revision 5192)
+++ roard/output.c	(revision 5210)
@@ -189,4 +189,5 @@
  uint16_t tu16;
  float q = -32e6;
+ char * strtok_store;
 
  ROAR_INFO("add_output(drv='%s', dev='%s', opts='%s', prim=%i, count=%i): trying to add output driver", ROAR_DBG_INFO_INFO, drv, dev, opts, prim, count);
@@ -244,5 +245,5 @@
   k = NULL;
  } else {
-  k = strtok(opts, ",");
+  k = roar_mm_strtok_r(opts, ",", &strtok_store);
  }
 
@@ -375,5 +376,5 @@
   }
 
-  k = strtok(NULL, ",");
+  k = roar_mm_strtok_r(NULL, ",", &strtok_store);
  }
 
Index: roard/roard.c
===================================================================
--- roard/roard.c	(revision 5194)
+++ roard/roard.c	(revision 5210)
@@ -119,5 +119,5 @@
  } else if ( ROAR_NOTIFY_IS_CMD(ev) ) {
   if ( command_get_name(ROAR_NOTIFY_EVENT2CMD(ev), &ttname) == -1 ) {
-   snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_CMD2EVENT(%i) */", ROAR_NOTIFY_EVENT2CMD(ev));
+   snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_CMD2EVENT(%lu) */", (long unsigned int)ROAR_NOTIFY_EVENT2CMD(ev));
   } else {
    snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_CMD2EVENT(ROAR_CMD_%s) */", ttname);
@@ -127,5 +127,5 @@
   }
  } else if ( ROAR_NOTIFY_IS_EGRP(ev) ) {
-  snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_EGRP2EVENT(%i) */", ROAR_NOTIFY_EVENT2EGRP(ev));
+  snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_EGRP2EVENT(%lu) */", (long unsigned int)ROAR_NOTIFY_EVENT2EGRP(ev));
  } else if ( ROAR_NOTIFY_IS_OE(ev) ) {
   switch (ev) {
@@ -155,9 +155,9 @@
    // OE Default:
    default:
-     snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_OE2EVENT(%i) */", ROAR_NOTIFY_EVENT2OE(ev));
+     snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_OE2EVENT(%lu) */", (long unsigned int)ROAR_NOTIFY_EVENT2OE(ev));
     break;
   }
  } else if ( ROAR_NOTIFY_IS_USER(ev) ) {
-  snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_USER2EVENT(%i) */", ROAR_NOTIFY_EVENT2USER(ev));
+  snprintf(estr, sizeof(estr)-1, "/* ROAR_NOTIFY_USER2EVENT(%lu) */", (long unsigned int)ROAR_NOTIFY_EVENT2USER(ev));
  }
 
@@ -959,4 +959,5 @@
 #endif
 
+#ifdef ROAR_HAVE_MAIN_ARGS
 static void list_aiprofiles (void) {
  struct roar_audio_info info;
@@ -990,4 +991,5 @@
  }
 }
+#endif
 
 int update_stream_flags (char * str) {
@@ -1365,4 +1367,5 @@
  char * k;
  enum output_format print_format = FORMAT_NATIVE;
+ const struct rolestack * rolestack;
 #endif
 #if defined(ROAR_SUPPORT_LISTEN) && defined(ROAR_HAVE_GETUID)
@@ -1371,5 +1374,4 @@
  struct roar_audio_info sa, max_sa;
  struct roard_config config;
- const struct rolestack * rolestack;
 #if defined(ROAR_HAVE_FORK) || defined(ROAR_TARGET_WIN32)
  int    daemon       = 0;
@@ -1412,5 +1414,5 @@
  enum roard_client_acclev af_acclev    = ACCLEV_ALL;
 #ifndef ROAR_WITHOUT_DCOMP_LIGHT
- int    light_channels = LIGHT_CHANNELS_DEFAULT;
+ uint32_t light_channels = LIGHT_CHANNELS_DEFAULT;
 #endif
 #ifdef ROAR_DEFAULT_SOCKGRP
@@ -2606,6 +2608,8 @@
  ROAR_INFO("Shuting down complete", ROAR_DBG_INFO_INFO);
 
+#ifdef ROAR_HAVE_SYSTEM
  if ( g_config->scripts.post_shutdown != NULL )
   system(g_config->scripts.post_shutdown);
+#endif
 
  ROAR_INFO("Exiting, no error", ROAR_DBG_INFO_INFO);
@@ -2698,6 +2702,8 @@
  ROAR_INFO("Shuting down complete", ROAR_DBG_INFO_INFO);
 
+#ifdef ROAR_HAVE_SYSTEM
  if ( g_config->scripts.post_shutdown != NULL )
   system(g_config->scripts.post_shutdown);
+#endif
 
  ROAR_INFO("Exiting, no error", ROAR_DBG_INFO_INFO);
Index: roard/sources.c
===================================================================
--- roard/sources.c	(revision 5194)
+++ roard/sources.c	(revision 5210)
@@ -140,4 +140,5 @@
  int f_sync = 0, f_mmap = 0;
  int codec;
+ char * strtok_store;
 
  if ( source == NULL )
@@ -166,5 +167,5 @@
  s->pos_rel_id = -1;
 
- k = strtok(options, ",");
+ k = roar_mm_strtok_r(options, ",", &strtok_store);
  while (k != NULL) {
   if ( (v = strstr(k, "=")) != NULL ) {
@@ -214,5 +215,5 @@
   }
 
-  k = strtok(NULL, ",");
+  k = roar_mm_strtok_r(NULL, ",", &strtok_store);
  }
 
