title: Getting the file-mode from the FILE struct?
body: <p>I have a piece of C code, a function to be specific, which operates on a <code>FILE*</code>.</p>
  
  <p>Depending on which mode the <code>FILE*</code> was opened with there are certain things I can and cannot do.</p>
  
  <p>Is there any way I can obtain the mode the <code>FILE*</code> was opened with?</p>
  
  <p>That <code>FILE*</code> is all the info I can rely on, because it is created somewhere else in the program and the actual file-name is long lost before it reaches my function, and this I cannot influence.</p>
  
  <p>I would prefer a portable solution.</p>
  
  <p>Edit: I'm not interested in file-restrictions specifying which users can do what with the file. That is mostly irrelevant as it is dealt with upon file-opening. For this bit of code I only care about the  open-mode.</p>