Index: ChangeLog
===================================================================
--- ChangeLog	(revision 4998)
+++ ChangeLog	(revision 5010)
@@ -1,4 +1,5 @@
 v. 0.4beta7 - ?
 	* Updated roar_panic() (Closes: #132)
+	* Updated roar_reset() (Closes: #131)
 
 v. 0.4beta6 - Mon May 23 2011 19:49 CEST
Index: include/libroar/config.h
===================================================================
--- include/libroar/config.h	(revision 4779)
+++ include/libroar/config.h	(revision 5010)
@@ -109,4 +109,6 @@
 struct roar_libroar_config * roar_libroar_get_config(void);
 
+int    roar_libroar_reset_config(void);
+
 int    roar_libroar_config_parse(char * txt, char * delm);
 
Index: include/libroar/libroar.h
===================================================================
--- include/libroar/libroar.h	(revision 4998)
+++ include/libroar/libroar.h	(revision 5010)
@@ -201,5 +201,25 @@
 
 // call this function after we fork/exec()ed or similar.
-int roar_reset(int forked);
+enum roar_reset {
+ ROAR_RESET_UNKNOWN     = -1,
+#define ROAR_RESET_UNKNOWN ROAR_RESET_UNKNOWN
+ ROAR_RESET_NONE        =  0,
+#define ROAR_RESET_NONE ROAR_RESET_NONE
+ ROAR_RESET_ON_FORK     =  1,
+#define ROAR_RESET_ON_FORK ROAR_RESET_ON_FORK
+ ROAR_RESET_ON_EXIT     =  2,
+#define ROAR_RESET_ON_EXIT ROAR_RESET_ON_EXIT
+ ROAR_RESET_ON_PRE_EXEC =  3,
+#define ROAR_RESET_ON_PRE_EXEC ROAR_RESET_ON_PRE_EXEC
+ ROAR_RESET_MEMORY      =  0x81,
+#define ROAR_RESET_MEMORY ROAR_RESET_MEMORY
+ ROAR_RESET_CONFIG      =  0x82,
+#define ROAR_RESET_CONFIG ROAR_RESET_CONFIG
+ ROAR_RESET_RANDOMPOOL  =  0x84,
+#define ROAR_RESET_RANDOMPOOL ROAR_RESET_RANDOMPOOL
+ ROAR_RESET_EOL         = -2
+#define ROAR_RESET_EOL ROAR_RESET_EOL
+};
+int roar_reset(enum roar_reset what);
 
 // fatal probelms:
Index: include/libroar/memmgr.h
===================================================================
--- include/libroar/memmgr.h	(revision 5003)
+++ include/libroar/memmgr.h	(revision 5010)
@@ -48,4 +48,6 @@
 // those functions are currently not implemeted:
 
+int     roar_mm_reset(void);
+
 ssize_t roar_mm_sizeof(void * buf);
 
@@ -61,4 +63,5 @@
 
 #else
+#define roar_mm_reset()             (0)
 #define roar_mm_sizeof(ptr)         ((ssize_t)-1)
 #define roar_mm_calloc(nmemb, size) calloc((nmemb), (size))
Index: include/libroar/roarfeatures.h
===================================================================
--- include/libroar/roarfeatures.h	(revision 4998)
+++ include/libroar/roarfeatures.h	(revision 5010)
@@ -47,4 +47,5 @@
 #define ROAR_FT_FUNC_SIMPLE_CONNECT2
 #define ROAR_FT_FUNC_PANIC
+#define ROAR_FT_FUNC_RESET
 #define ROAR_FT_FEATURE_VS
 #define ROAR_FT_FEATURE_VS_FILE
Index: libroar/config.c
===================================================================
--- libroar/config.c	(revision 5006)
+++ libroar/config.c	(revision 5010)
@@ -84,4 +84,15 @@
 
  return config;
+}
+
+int    roar_libroar_reset_config(void) {
+ struct roar_libroar_config * config = roar_libroar_get_config_ptr();
+
+ if ( config->codecs.codec != NULL ) {
+  roar_mm_free(config->codecs.codec);
+  config->codecs.num = 0;
+ }
+
+ return 0;
 }
 
Index: libroar/libroar.c
===================================================================
--- libroar/libroar.c	(revision 4998)
+++ libroar/libroar.c	(revision 5010)
@@ -146,16 +146,58 @@
 }
 
-int roar_reset(int forked) {
+int roar_reset(enum roar_reset what) {
  char c;
  int i;
+ enum roar_reset subsets = ROAR_RESET_NONE;
 
  roar_err_set(ROAR_ERROR_NONE);
 
- for (i = 0; i < 16; i++) {
-  roar_random_gen_nonce(&c, 1);
-  roar_random_uint16();
-  roar_random_uint32();
- }
-
+ switch (what) {
+  case ROAR_RESET_NONE:
+    return 0;
+   break;
+  case ROAR_RESET_UNKNOWN:
+  case ROAR_RESET_EOL:
+    roar_err_set(ROAR_ERROR_INVAL);
+    return -1;
+   break;
+  case ROAR_RESET_ON_FORK:
+    subsets |= ROAR_RESET_MEMORY|ROAR_RESET_RANDOMPOOL;
+   break;
+  case ROAR_RESET_ON_EXIT:
+  case ROAR_RESET_ON_PRE_EXEC:
+    subsets |= ROAR_RESET_MEMORY|ROAR_RESET_CONFIG;
+   break;
+  default:
+    if ( what & 0x80 ) {
+     subsets |= what;
+    } else {
+     roar_err_set(ROAR_ERROR_INVAL);
+     return -1;
+    }
+   break;
+ }
+
+ // strip 0x80 so we can easly test on the other bit per subsystem.
+ what |= 0x80;
+ what -= 0x80;
+
+ if ( what & ROAR_RESET_MEMORY ) {
+  roar_mm_reset();
+ }
+
+ if ( what & ROAR_RESET_CONFIG ) {
+  roar_libroar_reset_config();
+ }
+
+ if ( what & ROAR_RESET_RANDOMPOOL ) {
+  for (i = 0; i < 16; i++) {
+   roar_random_gen_nonce(&c, 1);
+   roar_random_uint16();
+   roar_random_uint32();
+  }
+ }
+
+ roar_err_set(ROAR_ERROR_NONE);
  return 0;
 }
Index: libroar/memmgr.c
===================================================================
--- libroar/memmgr.c	(revision 5002)
+++ libroar/memmgr.c	(revision 5010)
@@ -50,4 +50,11 @@
 
 #ifdef ROAR_USE_MEMMGR
+
+int     roar_mm_reset(void) {
+ // currently this does nothing.
+ // we need to free pools and such here later.
+ return 0;
+}
+
 ssize_t roar_mm_sizeof(void * buf) {
  if ( buf == NULL ) {
