| 1 |
PHP Bindings for Genders |
| 2 |
|
| 3 |
INSTALLATION |
| 4 |
|
| 5 |
-> mkdir <php root>/php/include/php/ext/genders |
| 6 |
-> cp config.m4 genders.c php_genders.h <php root>/php/include/php/ext/genders |
| 7 |
-> cd <php root>/php/include/php/ext/genders |
| 8 |
-> phpize |
| 9 |
-> ./configure --with-genders=<path to genders> --with-php-config=<path to file "php-config"> |
| 10 |
|
| 11 |
example: ./configure --with-genders=/usr/local/genders --with-php-config=/usr/local/php/bin/php-config |
| 12 |
|
| 13 |
-> make |
| 14 |
-> make install |
| 15 |
|
| 16 |
USAGE |
| 17 |
|
| 18 |
Four functions from the genders library are implemented. They are genders_getnumattrs(), |
| 19 |
genders_getattr(), genders_getattr_all(), and genders_getnodes(), and all work similarly |
| 20 |
as their libgenders(3) counterparts: |
| 21 |
|
| 22 |
genders_getnumattrs() takes a genders file name (string) as an input, and returns the |
| 23 |
number of attributes listed in the genders file. |
| 24 |
|
| 25 |
genders_getattr() takes a genders file name (string), node name (string), and return type |
| 26 |
(boolean) as inputs, and returns an array of attributes or values. If the return type is |
| 27 |
0, attributes are returned. Otherwise, values are returned. |
| 28 |
|
| 29 |
genders_getnodes() takes a genders file name (string), attribute name (string), and value |
| 30 |
name (string) as inputs, and returns an array of nodes. If the input value string is NULL, |
| 31 |
then values are not considered when determining the node list. |
| 32 |
|
| 33 |
genders_getattr_all() takes a genders file name (string) as an input, and returns an array |
| 34 |
of attributes. |
| 35 |
|
| 36 |
In any of the above functions, if the file name string is set to NULL, libgenders will |
| 37 |
look in default locations for the genders file. |
| 38 |
|
| 39 |
EXAMPLES |
| 40 |
|
| 41 |
<?php |
| 42 |
$num = genders_getnumattrs("/etc/genders"); |
| 43 |
printf("Num: %d<P>\n", $num); |
| 44 |
$attrs = genders_getattr(NULL, "node1", 0); |
| 45 |
$vals = genders_getattr(NULL, "node1", 1); |
| 46 |
$k = sizeof($attrs); |
| 47 |
for($i=0;$i<$k;$i++) |
| 48 |
{ |
| 49 |
printf("%s -> %s<br>", $attrs[$i], $vals[$i]); |
| 50 |
} |
| 51 |
printf("<P>\n"); |
| 52 |
$nodes = genders_getnodes(NULL,"compute",NULL); |
| 53 |
$k = sizeof($nodes); |
| 54 |
for($i=0;$i<$k;$i++) |
| 55 |
{ |
| 56 |
printf("%s<br>", $nodes[$i]); |
| 57 |
} |
| 58 |
|
| 59 |
printf("<P>\n"); |
| 60 |
$attrs=genders_getattr_all("/etc/genders"); |
| 61 |
$k = sizeof($attrs); |
| 62 |
for($i=0;$i<$k;$i++) |
| 63 |
{ |
| 64 |
printf("%s<br>", $attrs[$i]); |
| 65 |
} |
| 66 |
?> |