title: Convert errno to exit codes
body: <p>I'm working on lib which uses a lot of file system functions.</p>
  <p>What I want is that my function returns various of <strong>error codes</strong> (not just -1 as error) depending on <strong>errno</strong> in case file system function fails.</p>
  <p>Although I could use <strong>errno values</strong> directly but I want to create some abstraction layer between my functions <strong>error codes</strong> and <strong>system errno</strong> (e.g. my error values begins on -1000 and are negative whereas errno values are positive).</p>
  <p>My question what is the best way to implement it.</p>
  <p>For now I see two possible solution:</p>
  <ol>
  <li>use an enum with error codes and <strong>switch case</strong> function to translate, e.g.:</li>
  </ol>
  <pre><code>    typedef enum {
      MY_ERROR_EPERM  = -1104,  /* Operation not permitted                  */
      MY_ERROR_ENOENT = -1105,  /* No such file or directory                */
  //  ...
      } MyReturnCodes_t;
  int ErrnoToErrCode(unsigned int sysErrno) {
          int error = ENOSYS;
          switch(sysErrno) {
          case EPERM: error = MY_ERROR_EPERM; break;
          case ENOENT: error = MY_ERROR_ENOENT; break;
  //      ...
          }
          return error;
  }
  </code></pre>
  <ol start="2">
  <li>use translation directly in <strong>enum</strong>:</li>
  </ol>
  <pre><code>#define ERR_OFFSET -1000
  typedef enum {
      MY_ERROR_EPERM  = ERR_OFFSET - EPERM,   /* Operation not permitted   */
      MY_ERROR_ENOENT = ERR_OFFSET - ENOENT,  /* No such file or directory */
      MY_ERROR_ESRCH  = ERR_OFFSET - ESRCH,   /* No such process           */
   //  ...
  } MyReturnCodes_t;
  </code></pre>
  <p>Which way is more constant?</p>
  <p>One more point: This library should be used both on <strong>QNX</strong> and <strong>Linux OS</strong>, what is the proper way to align errno codes (which different in some cases)?</p>