File: Metaphone.xs

package info (click to toggle)
libtext-metaphone-perl 20160805-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid, stretch
  • size: 124 kB
  • ctags: 25
  • sloc: ansic: 269; perl: 91; makefile: 3
file content (30 lines) | stat: -rw-r--r-- 677 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "metaphone.h"

MODULE = Text::Metaphone        PACKAGE = Text::Metaphone

PROTOTYPES: ENABLE

SV *
Metaphone(word, ...)
        char* word
        PROTOTYPE: $;$
        PREINIT:
            size_t max_length = 0;
        INIT:
            char *phoned_word;
        CODE:
            if( items > 1 ) {
                max_length = SvIV(ST(1));
            }

            phoned_word = metaphone(word, max_length);
            RETVAL = newSVpv(phoned_word, 0);
/* Use the real free() to free memory allocated by the real calloc() */
#undef free
            free(phoned_word);
        OUTPUT:
            RETVAL