Writing C Modules with Inline::C
The C code is placed after the __DATA__ symbol. Below __DATA__, __C__ marks 
the start of the C code:
__DATA__
__C__
#include 
char * file_type (char *filename) {
  return gnome_mime_type(filename);
}
I'll discuss the actual C code in the next section.
A First Inlined Function
Just as in the first XS example in the last chapter, I'll start with the gnome_mime_type()
function. This function takes a filename as an argument and returns a string con 
taining the MIME type of the filename. It has the following signature:
const char * gnome_mime_type(const gchar *filename);
One way to wrap this function is shown in Listing 10 2, with the function 
file_type():
char * file_type (char *filename) {
  return gnome_mime_type(filename);
}
With this function in place, test.pl can be written:
use Test::More  no_plan ;
BEGIN { use_ok( Gnome::MIME ); }
# test some simple mime file_type recognitions
is(Gnome::MIME::file_type("foo.gif"),   image/gif ,  "recognizes .gif");
is(Gnome::MIME::file_type("foo.jpg"),   image/jpeg , "recognizes .jpg");
is(Gnome::MIME::file_type("foo.html"),  text/html ,  "recognizes .html");
24
243
3






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