Ejemplo n.º 1
0
int push_protection(lua_State *L, apr_fileperms_t perm)
{
  char str[9], *p = str;

#define UNPARSE(KIND, CHAR, MAGIC) \
    *p++ = (perm & APR_FPROT_ ## KIND ## READ) ? 'r' : '-'; \
    *p++ = (perm & APR_FPROT_ ## KIND ## WRITE) ? 'w' : '-'; \
    if ((perm & APR_FPROT_ ## KIND ## EXECUTE) && \
        (perm & APR_FPROT_ ## KIND ## MAGIC)) \
      *p++ = CHAR; \
    else if (perm & APR_FPROT_ ## KIND ## MAGIC) \
      *p++ = (CHAR - 32); \
    else if (perm & APR_FPROT_ ## KIND ## EXECUTE) \
      *p++ = 'x'; \
    else \
      *p++ = '-'

  UNPARSE(U, 's', SETID);
  UNPARSE(G, 's', SETID);
  UNPARSE(W, 't', STICKY);

#undef UNPARSE

  lua_pushlstring(L, str, sizeof str);
  return 1;
}
Ejemplo n.º 2
0
void uuid_unparse(uuid_t uu, char *out)
{
    struct uuid_s *uuid = (struct uuid_s *) uu;

    UNPARSE(uuid->time_low, out);
    *out++ = '-';
    UNPARSE(uuid->time_mid, out);
    *out++ = '-';
    UNPARSE(uuid->time_hi_and_version, out);
    *out++ = '-';
    UNPARSE(uuid->clock_seq_hi_and_reserved, out);
    UNPARSE(uuid->clock_seq_low, out);
    *out++ = '-';
    UNPARSE(uuid->node, out);
    *out = '\0';
}