Esempio n. 1
0
/**
 * Print a meta data entry.
 *
 * @param cls closure (unused)
 * @param plugin_name name of the plugin that generated the meta data
 * @param type type of the keyword
 * @param format format of data
 * @param data_mime_type mime type of data
 * @param data value of the meta data
 * @param data_size number of bytes in data
 * @return always 0 (to continue iterating)
 */
static int
item_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type,
              enum EXTRACTOR_MetaFormat format, const char *data_mime_type,
              const char *data, size_t data_size)
{
  if (type == EXTRACTOR_METATYPE_GNUNET_FULL_DATA)
  {
    printf (_("\t<original file embedded in %u bytes of meta data>\n"),
            (unsigned int) data_size);
    return 0;
  }
  if ((format != EXTRACTOR_METAFORMAT_UTF8) &&
      (format != EXTRACTOR_METAFORMAT_C_STRING))
    return 0;
  if (type == EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME)
    return 0;
  printf ("\t%20s: %s\n",
          dgettext (LIBEXTRACTOR_GETTEXT_DOMAIN,
                    EXTRACTOR_metatype_to_string (type)), data);
  return 0;
}
Esempio n. 2
0
/**
 * Type of a function that libextractor calls for each
 * meta data item found.
 *
 * @param cls closure (user-defined, unused)
 * @param plugin_name name of the plugin that produced this value;
 *        special values can be used (i.e. '&lt;zlib&gt;' for zlib being
 *        used in the main libextractor library and yielding
 *        meta data).
 * @param type libextractor-type describing the meta data
 * @param format basic format information about data
 * @param data_mime_type mime-type of data (not of the original file);
 *        can be NULL (if mime-type is not known)
 * @param data actual meta-data found
 * @param data_size number of bytes in data
 * @return 0 to continue extracting, 1 to abort
 */
static int
item_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type,
              enum EXTRACTOR_MetaFormat format, const char *data_mime_type,
              const char *data, size_t data_size)
{
  if ((format != EXTRACTOR_METAFORMAT_UTF8) &&
      (format != EXTRACTOR_METAFORMAT_C_STRING))
    return 0;
  if (type == EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME)
    return 0;
#if HAVE_LIBEXTRACTOR
  printf ("\t%20s: %s\n",
          dgettext (LIBEXTRACTOR_GETTEXT_DOMAIN,
                    EXTRACTOR_metatype_to_string (type)), data);
#else
  printf ("\t%20d: %s\n",
          type,
          data);
#endif
  return 0;
}
Esempio n. 3
0
static int process_keyword (void *cls, const char *plugin_name, 
                     enum EXTRACTOR_MetaType type, 
                     enum EXTRACTOR_MetaFormat format, 
                     const char *data_mime_type, 
                     const char *data, size_t data_len) {
    
    zval *keywords, **subarray;
    const char *ktype = EXTRACTOR_metatype_to_string(type);
    const char *kval  = estrndup(data, data_len);
    
    ALLOC_INIT_ZVAL(keywords);
    array_init(keywords);

    if (zend_hash_find(Z_ARRVAL_P((zval*) cls), ktype, strlen(ktype) + 1, (void**) &subarray) == SUCCESS) {
        add_next_index_string(*subarray, kval, 1);
        return 0;
    }
    
    add_next_index_string(keywords, kval, 1);
    add_assoc_zval(cls, ktype, keywords);

    return 0;
}
static int extractor_callback_metainfo(void *priv,
                                       const char *plugin_name,
                                       enum EXTRACTOR_MetaType type,
                                       enum EXTRACTOR_MetaFormat format,
                                       const char *data_mime_type,
                                       const char *data,
                                       size_t data_len)
{
  struct CallbackData *cd = (struct CallbackData *)priv;

  if (format == EXTRACTOR_METAFORMAT_UTF8 &&
      type   != EXTRACTOR_METATYPE_THUMBNAIL &&
      cd   && !cd->seen_types[type] &&
      data && data[0]) {

    const char *key = EXTRACTOR_metatype_to_string(type);
    if (key) {
      cd->Append(key, data);
      cd->seen_types[type] = 1;
    }
  }

  return 0;
}