Beispiel #1
0
void amf_decode_msg(lua_State *L, amf_cursor *c)
{
    uint16_t ver, hc, bc;

    lua_createtable(L, 3, 0);

    amf_cursor_read_u16(c, &ver);
    amf_cursor_checkerr(c);
    lua_pushinteger(L, ver);
    lua_rawseti(L, -2, 1);


    /* headers */
    amf_cursor_read_u16(c, &hc);
    if (hc > 0) lua_createtable(L, hc, 0);
    unsigned int i;
    for (i = 0; i < hc; i++) {
        decode_hdr(L, c);
        amf_cursor_checkerr(c);
        lua_rawseti(L, -2, i+1);
    }
    lua_rawseti(L, -2, 2);

    /* bodies */
    amf_cursor_read_u16(c, &bc);
    if (bc > 0) lua_createtable(L, bc, 0);
    unsigned int j;
    for (j = 0; j < hc; j++) {
        decode_body(L, c);
        amf_cursor_checkerr(c);
        lua_rawseti(L, -2, j+1);
    }
    lua_rawseti(L, -2, 3);
}
Beispiel #2
0
static enum MLkind prim_ml_kind(mlval val)
/* WARNING:
 *
 * This function is critically dependent upon tags.h.  Changes
 * to that file could seriously affect the operation of this
 * function.
 *
 */
{
   switch (PRIMARY(val)) {

      case HEADER   :   return( decode_hdr((unsigned)val) );

      case POINTER  :   return( decode_hdr(GETHEADER(val)) );

      case INTEGER0 :   /* FALLTHROUGH */
      case INTEGER1 :   return( Int_MLK        );

      case REFPTR   :   /* FALLTHROUGH */
      case PAIRPTR  :   return( Tuple_MLK      );

      default :         return( Invalid_MLK    );
   };
}