title: wrapper printf function that filters according to user preferences
body: <p>My program writes to a log and to stdout. Every message, however, has a certain priority and the user specifies in Preferences which priorities go to which stream (log or stdout). </p>
  
  <pre><code>unsigned short PRIO_HIGH = 0x0001;
  unsigned short PRIO_NORMAL = 0x0002;
  unsigned short PRIO_LOW = 0x0004;
  </code></pre>
  
  <p>The preferences is handled by some flags:</p>
  
  <pre><code>unsigned short PRIO_LOG = (PRIO_HIGH | PRIO_NORMAL);
  unsigned short PRIO_STD = (PRIO_HIGH);
  </code></pre>
  
  <p>The <code>write_log</code> function should work with the same parameters as the printf function, with the added parameter of <code>unsigned short priority</code>.</p>
  
  <pre><code>write_log((PRIO_NORMAL|PRIO_LOW), "HELLO %s, take %d", "World", 1);
  </code></pre>
  
  <p>(Even if <code>PRIO_NORMAL|PRIO_LOW</code> makes little sense...)</p>
  
  <p>Checking the flags is easy: <code>if(priority &amp; PRIO_LOG)</code> (Returns >1 if any flag is set in both arguments)</p>
  
  <p>I cannot however find out how I would go about passing the string literal <em>and</em> the format arguments to the printf function. Can anyone help or give me a pointer (possible to an alternative method that achieves the same effect)? It would be much appreciated.</p>