static int M_index (lua_State *L) { /** mnotedata[n] */ if (lua_isnumber(L, 2)) { ExifMnoteData *md = checkmnote_data(L); lua_Number n = lua_tonumber(L, 2); if (n < 1 || exif_mnote_data_count(md) < n) { lua_pushnil(L); } else { unsigned int n_ = (unsigned int)(n-1); lua_createtable(L, 0, 5); lua_pushnumber(L, exif_mnote_data_get_id(md, n_)); lua_setfield(L, -2, "tagid"); lua_pushstring(L, exif_mnote_data_get_name(md, n_)); lua_setfield(L, -2, "tag"); lua_pushstring(L, exif_mnote_data_get_title(md, n_)); lua_setfield(L, -2, "title"); lua_pushstring(L, exif_mnote_data_get_description(md, n_)); lua_setfield(L, -2, "description"); { char buffer[1024]; lua_pushstring(L, exif_mnote_data_get_value(md, n_, buffer, sizeof(buffer)/sizeof(char))); lua_setfield(L, -2, "value"); } } return 1; } else { lua_getmetatable(L, 1); lua_pushvalue(L, 2); lua_gettable(L, -2); return 1; } }
static int test_exif_data (ExifData *d) { unsigned int i, c; char v[1024], *p; ExifMnoteData *md; fprintf (stdout, "Byte order: %s\n", exif_byte_order_get_name (exif_data_get_byte_order (d))); fprintf (stdout, "Parsing maker note...\n"); md = exif_data_get_mnote_data (d); if (!md) { fprintf (stderr, "Could not parse maker note!\n"); exif_data_unref (d); return 1; } fprintf (stdout, "Increasing ref-count...\n"); exif_mnote_data_ref (md); fprintf (stdout, "Decreasing ref-count...\n"); exif_mnote_data_unref (md); fprintf (stdout, "Counting entries...\n"); c = exif_mnote_data_count (md); fprintf (stdout, "Found %i entries.\n", c); for (i = 0; i < c; i++) { fprintf (stdout, "Dumping entry number %i...\n", i); fprintf (stdout, " Name: '%s'\n", exif_mnote_data_get_name (md, i)); fprintf (stdout, " Title: '%s'\n", exif_mnote_data_get_title (md, i)); fprintf (stdout, " Description: '%s'\n", exif_mnote_data_get_description (md, i)); p = exif_mnote_data_get_value (md, i, v, sizeof (v)); if (p) { fprintf (stdout, " Value: '%s'\n", v); } } return 0; }