summaryrefslogtreecommitdiff
path: root/vkflex.c
blob: d8d86d322206932de1b266eca22b14c8d12c0e1b (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "vkext_flex.h"
#include <stdio.h>
 
#define PHP_MY_EXTENSION_VERSION "1.0"
#define PHP_MY_EXTENSION_EXTNAME "vkflex"
 
extern zend_module_entry vkflex_module_entry;
#define phpext_my_extension_ptr &vkflex_entry
 
// declaration of a custom my_function()
PHP_FUNCTION(vkflex);
 
// list of custom PHP functions provided by this extension
// set {NULL, NULL, NULL} as the last record to mark the end of list
static zend_function_entry my_functions[] = {
    PHP_FE(vkflex, NULL)
    {NULL, NULL, NULL}
};
 
// the following code creates an entry for the module and registers it with Zend.
zend_module_entry vkflex_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
    STANDARD_MODULE_HEADER,
#endif
    PHP_MY_EXTENSION_EXTNAME,
    my_functions,
    NULL, // name of the MINIT function or NULL if not applicable
    NULL, // name of the MSHUTDOWN function or NULL if not applicable
    NULL, // name of the RINIT function or NULL if not applicable
    NULL, // name of the RSHUTDOWN function or NULL if not applicable
    NULL, // name of the MINFO function or NULL if not applicable
#if ZEND_MODULE_API_NO >= 20010901
    PHP_MY_EXTENSION_VERSION,
#endif
    STANDARD_MODULE_PROPERTIES
};
 
ZEND_GET_MODULE(vkflex)
 
// implementation of a custom my_function()
PHP_FUNCTION(vkflex)
{
    char *name, *case_;
    long name_len, case_len;
    //long name_len, case_len;
    long sex, lang, type;
    
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sslll", 
            &name, &name_len, &case_, &case_len, &sex, &lang, &type) == FAILURE) {
        RETURN_NULL();
    }
    
    char *result = do_flex(name, name_len, case_, case_len,
        (int)sex, (type == 0 ? "names" : "surnames"), (int)lang);

    RETURN_STRING(result);
    efree(result);
}