Chapter 9
To start with, I'll define the back end XSUBs in a separate package using the 
PACKAGE command on the MODULE line:
MODULE = Gnome::MIME   PACKAGE = Gnome::MIME::Backend   PREFIX = gnome_mime_
After this line every XSUB defined will have its Perl interface defined in the 
Gnome::MIME::Backend package. An XS file can contain any number of such 
lines and PACKAGEs, although only one MODULE may be used.
Then each of the functions is wrapped in the plain style shown earlier:
const char *
gnome_mime_type(filename)
  char * filename
const char *
gnome_mime_type_or_default(filename, default)
  char * filename
  char * default
const char *
gnome_mime_type_of_file(filename)
  char * filename
const char *
gnome_mime_type_of_file_or_default(filename, default)
  char * filename
  char * default
The Perl code to implement the named parameter interface is then added to 
MIME.pm:
use Carp qw(croak);
sub file_type {
  croak("Usage: Gnome::MIME::file_type(k => v, ...)") if @_ % 2;
  my %args = @_;
  # check for bad parameter names
  my %allowed = map { $_, 1 } qw(filename default_type read_file);
  for (keys %args) {
    croak("Unknown key found in Gnome::MIME::file_type parameter list: $_")
      unless exists $allowed{$_};
  }
224






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