]> granicus.if.org Git - php/commitdiff
ported rot13() from php3
authorHartmut Holzgraefe <hholzgra@php.net>
Thu, 6 Dec 2001 19:02:27 +0000 (19:02 +0000)
committerHartmut Holzgraefe <hholzgra@php.net>
Thu, 6 Dec 2001 19:02:27 +0000 (19:02 +0000)
ext/standard/basic_functions.c
ext/standard/basic_functions.h
ext/standard/string.c

index e31138f88d146e6a5878e6ba441a629d60dc87f5..c7ffbd7a21b67ee7efde3fa8c76d9232036058e6 100644 (file)
@@ -803,6 +803,7 @@ function_entry basic_functions[] = {
        PHP_FALIAS(ftok  , warn_not_available,      NULL)
 #endif 
 
+       PHP_FE(rot13, NULL)
        {NULL, NULL, NULL}
 };
 
index 27d9cf472cf36f9df94c44f1c0e61862653ff109..a5d41d1389d82439490628f412f484c27f2570d5 100644 (file)
@@ -116,6 +116,8 @@ PHP_FUNCTION(move_uploaded_file);
 /* From the INI parser */
 PHP_FUNCTION(parse_ini_file);
 
+PHP_FUNCTION(rot13);
+
 #ifdef PHP_WIN32
 typedef unsigned int php_stat_len;
 #else
index f1070e7e43b32732e79167dcf44dfff5aac77c8b..56fff3bcec180e3550988da1eb7b0db5084261a1 100644 (file)
@@ -398,6 +398,8 @@ PHP_MINIT_FUNCTION(nl_langinfo)
 }
 /* }}} */
 
+/* {{{ proto string nl_langinfo(int item)
+   Query language and locale information */
 PHP_FUNCTION(nl_langinfo)
 {
        zval **item;
@@ -3861,6 +3863,30 @@ PHP_FUNCTION(sscanf)
 }
 /* }}} */
 
+/* {{{ proto string rot13(string str)
+   Perform the rot13 transform on a string */
+PHP_FUNCTION(rot13)
+{
+       char *str;
+       int str_len;
+    static char xfrom[] = "abcdefghijklmnopqrstuvwxyz"
+        "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+    static char xto[] = "nopqrstuvwxyzabcdefghijklm"
+        "NOPQRSTUVWXYZABCDEFGHIJKLM";
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
+                                                         &str, &str_len) == FAILURE) {
+               return;
+       }
+
+    php_strtr(str, str_len, xfrom, xto, 52);
+       RETURN_STRINGL(str, str_len, 1);
+}
+/* }}} */
+
+
+
+
 /*
  * Local variables:
  * tab-width: 4