Browse Source

ncd/extra/NCDBProcessOpts: add NCDBProcessOpts_Init2() which also returns the presence of keep_stdout and keep_stderr options

ambrop7 13 years ago
parent
commit
705196709c
2 changed files with 15 additions and 0 deletions
  1. 13 0
      ncd/extra/NCDBProcessOpts.c
  2. 2 0
      ncd/extra/NCDBProcessOpts.h

+ 13 - 0
ncd/extra/NCDBProcessOpts.c

@@ -36,6 +36,12 @@
 #include "NCDBProcessOpts.h"
 
 int NCDBProcessOpts_Init (NCDBProcessOpts *o, NCDValRef opts_arg, NCDBProcessOpts_func_unknown func_unknown, void *func_unknown_user, NCDModuleInst *i, int blog_channel)
+{
+    return NCDBProcessOpts_Init2(o, opts_arg, func_unknown, func_unknown_user, i, blog_channel, NULL, NULL);
+}
+
+int NCDBProcessOpts_Init2 (NCDBProcessOpts *o, NCDValRef opts_arg, NCDBProcessOpts_func_unknown func_unknown, void *func_unknown_user, NCDModuleInst *i, int blog_channel,
+                           int *out_keep_stdout, int *out_keep_stderr)
 {
     if (!NCDVal_IsInvalid(opts_arg) && !NCDVal_IsMap(opts_arg)) {
         NCDModuleInst_Backend_Log(i, blog_channel, BLOG_ERROR, "options must be a map");
@@ -94,6 +100,13 @@ int NCDBProcessOpts_Init (NCDBProcessOpts *o, NCDValRef opts_arg, NCDBProcessOpt
     }
     o->fds[o->nfds] = -1;
     
+    if (out_keep_stdout) {
+        *out_keep_stdout = keep_stdout;
+    }
+    if (out_keep_stderr) {
+        *out_keep_stderr = keep_stderr;
+    }
+    
     return 1;
     
 fail1:

+ 2 - 0
ncd/extra/NCDBProcessOpts.h

@@ -45,6 +45,8 @@ typedef struct {
 typedef int (*NCDBProcessOpts_func_unknown) (void *user, NCDValRef key, NCDValRef val);
 
 int NCDBProcessOpts_Init (NCDBProcessOpts *o, NCDValRef opts_arg, NCDBProcessOpts_func_unknown func_unknown, void *func_unknown_user, NCDModuleInst *i, int blog_channel) WARN_UNUSED;
+int NCDBProcessOpts_Init2 (NCDBProcessOpts *o, NCDValRef opts_arg, NCDBProcessOpts_func_unknown func_unknown, void *func_unknown_user, NCDModuleInst *i, int blog_channel,
+                           int *out_keep_stdout, int *out_keep_stderr) WARN_UNUSED;
 void NCDBProcessOpts_InitOld (NCDBProcessOpts *o, int keep_stdout, int keep_stderr, int do_setsid);
 void NCDBProcessOpts_Free (NCDBProcessOpts *o);
 struct BProcess_params NCDBProcessOpts_GetParams (NCDBProcessOpts *o);