Пример #1
0
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;
  }
}
Пример #2
0
Файл: exif.c Проект: 0ion9/feh
/* Show the given MakerNote tag if it exists */
void exif_get_mnote_tag(ExifData *d, unsigned int tag, char* buffer, unsigned int maxsize)
{
  ExifMnoteData *mn = NULL; 
  int i, num;
  char buf[1024];

  if ( (d!=NULL) && (buffer!=NULL) && (maxsize > 0) )
  {
    mn = exif_data_get_mnote_data(d);
  }
  else
  {
    return;
  }
    
  if ( mn != NULL ) 
  {
    num = exif_mnote_data_count(mn);

    /* Loop through all MakerNote tags, searching for the desired one */
    for (i=0; i < num; ++i) 
    {
      D(("%d/%d %d 0x%2x %s; %s\n", i, num, exif_mnote_data_get_id(mn, i), 
        exif_mnote_data_get_id(mn, i),
        exif_mnote_data_get_name(mn,i), 
        exif_mnote_data_get_title(mn, i) ));
      
      if (exif_mnote_data_get_id(mn, i) == tag) 
      {
        if (exif_mnote_data_get_value(mn, i, buf, sizeof(buf))) 
        {
          /* Don't bother printing it if it's entirely blank */
          exif_trim_spaces(buf);
          if (*buf != '\0')
          {
             D(("%s\n", buf));
             snprintf(buffer, (size_t)maxsize, "%s: %s\n", exif_mnote_data_get_title(mn, i), buf);
          }
        }
      }
    }
  }
}