Ejemplo n.º 1
0
static void
print_addrs (void)
{
    size_t i;
    int err;

    printf("%d servers:\n", (int)sl.nservers);
    for (i = 0; i < sl.nservers; i++) {
        struct server_entry *entry = &sl.servers[i];
        char hostbuf[NI_MAXHOST], srvbuf[NI_MAXSERV];

        if (entry->hostname != NULL) {
            printf("%2d: host %s\t%s\tport %d\n", (int)i, entry->hostname,
                   ttypename(entry->transport), ntohs(entry->port));
            continue;
        }
        err = getnameinfo((struct sockaddr *)&entry->addr, entry->addrlen,
                          hostbuf, sizeof(hostbuf), srvbuf, sizeof(srvbuf),
                          NI_NUMERICHOST | NI_NUMERICSERV);
        if (err) {
            printf("%2d: getnameinfo returns error %d=%s\n", (int)i, err,
                   gai_strerror(err));
        } else {
            printf("%2d: address %s\t%s\tport %s\n", (int)i, hostbuf,
                   ttypename(entry->transport), srvbuf);
        }
    }
}
Ejemplo n.º 2
0
Archivo: ltm.c Proyecto: bcrist/lua
/*
** Return the name of the type of an object. For tables and userdata
** with metatable, use their '__name' metafield, if present.
*/
const char *luaT_objtypename (lua_State *L, const TValue *o) {
  Table *mt;
  if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) ||
      (ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) {
    const TValue *name = luaH_getshortstr(mt, luaS_new(L, "__name"));
    if (ttisstring(name))  /* is '__name' a string? */
      return getstr(tsvalue(name));  /* use it as type name */
  }
  return ttypename(ttnov(o));  /* else use standard type name */
}
Ejemplo n.º 3
0
LUA_API const char *lua_typename (lua_State *L, int t) {
  UNUSED(L);
  return ttypename(t);
}
Ejemplo n.º 4
0
LUA_API const char *lua_typename (lua_State *L, int t) {
  UNUSED(L);
  api_check(LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag");
  return ttypename(t);
}