Attachment 'print_wrappers.c'

Download

   1 #include <stdio.h>
   2 #include <stdlib.h>
   3 #include <stdarg.h>
   4 #include <stdarg.h>
   5 #include <string.h>
   6 
   7 #if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
   8 #include <dynmex.h>
   9 #endif
  10 
  11 int constant_seed;
  12 
  13 int
  14 swz_printf(char *msg, ...)
  15 {
  16   int ret;
  17   va_list ap;
  18   va_start(ap, msg);
  19 
  20 #if defined(MATLAB_MEX_FILE)
  21   ret = mexPrintf(msg, ap);
  22 #elif defined(OCTAVE_MEX_FILE)
  23   mexPrintf(msg, ap);
  24   ret = 1;
  25 #else
  26   ret = vprintf(msg, ap);
  27 #endif
  28 
  29   va_end(ap);
  30   return ret;
  31 }
  32 
  33 int
  34 swz_fprintf_stdout(char *msg, ...)
  35 {
  36   int ret;
  37   va_list ap;
  38   va_start(ap, msg);
  39 
  40 #if defined(MATLAB_MEX_FILE)
  41   ret = mexPrintf(msg, ap);
  42   mexEvalString("pause(.001);");
  43   //  mexEvalString("drawnow;");
  44 #elif defined(OCTAVE_MEX_FILE)
  45   mexPrintf(msg, ap);
  46   ret = 1;
  47 #else
  48   ret = vprintf(msg, ap);
  49 #endif
  50 
  51   va_end(ap);
  52   return ret;
  53 }
  54 
  55 void
  56 swz_fprintf_err(char *str, ...)
  57 {
  58   char *whole_str=(char*)NULL;
  59   char *msg_truncated = ".....MSG TRUNCATED\n";
  60   int num_args = 0;
  61   va_list ap;
  62 
  63   va_start(ap, str);
  64 
  65 #if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
  66   mexPrintf(str, ap);
  67   /*  mexEvalString("drawnow;");*/
  68 #else
  69   vfprintf(stderr, str, ap);
  70 #endif
  71 
  72   va_end(ap);
  73 }
  74 
  75 void
  76 swz_exit(int status)
  77 {
  78 #if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
  79   mexErrMsgTxt("Error in mexfile.\n");
  80 #else
  81   exit(status);
  82 #endif
  83 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2010-05-31 12:11:02, 0.5 KB) [[attachment:change_ending.sh]]
  • [get | view] (2010-05-31 12:04:52, 1.3 KB) [[attachment:print_wrappers.c]]
  • [get | view] (2010-05-31 12:08:53, 0.5 KB) [[attachment:remove_trailing_whitespace.sh]]
  • [get | view] (2010-05-31 12:12:34, 2.0 KB) [[attachment:rep_comm.sh]]
  • [get | view] (2010-05-31 12:13:03, 0.6 KB) [[attachment:replace_comments.sh]]
  • [get | view] (2010-05-31 12:13:43, 0.5 KB) [[attachment:replace_tabs_w_spaces.sh]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.