Writing C Modules with XS
Listing 9 8. XSUB for Gnome::MIME::type_data() with Multiple Value Return
void
type_data(type)
  const gchar * type
PREINIT:
  GList *keys, *iter;
  HV *hv;
  SV *value;
  char *key;         
PPCODE:
  // initialize hash
  hv = newHV();
  // get GList of keys for this type
  keys = gnome_mime_get_keys(type);
  // iterate through keys
  for (iter = keys; iter; iter = iter >next) {
    // get the key from the iterator
    key = iter >data;
    // create a new SV and load it with the value for this key
    value = newSVpv(gnome_mime_get_value(type, key), 0);
   
    // store the key/value pair in
    hv_store(hv, key, strlen(key), value, 0);
  }
  // free keys GList
  g_list_free(keys);
  // test context with GIMME_V
  if (GIMME_V == G_ARRAY) {
    // list context   return a list of key/value pairs
    IV count = hv_iterinit(hv);
    IV i;
    I32 len;
    // loop over key/value pairs
    for (i = 1; i <= count; i++) {
      value = hv_iternextsv(hv, &key, &len);
22
229
9






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

web hosting perl

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved