Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/misc/rot13.c # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / misc / rot13.c` 115 lines ยท 2770 bytes Raw Blame History 1 /* 2 ** 2013-05-15 3 ** 4 ** The author disclaims copyright to this source code. In place of 5 ** a legal notice, here is a blessing: 6 ** 7 ** May you do good and not evil. 8 ** May you find forgiveness for yourself and forgive others. 9 ** May you share freely, never taking more than you give. 10 ** 11 ****************************************************************************** 12 ** 13 ** This SQLite extension implements a rot13() function and a rot13 14 ** collating sequence. 15 */ 16 #include "sqlite3ext.h" 17 SQLITE_EXTENSION_INIT1 18 #include 19 #include 20 21 /* 22 ** Perform rot13 encoding on a single ASCII character. 23 */ 24 static unsigned char rot13(unsigned char c){ 25 if( c>='a' && c<='z' ){ 26 c += 13; 27 if( c>'z' ) c -= 26; 28 }else if( c>='A' && c<='Z' ){ 29 c += 13; 30 if( c>'Z' ) c -= 26; 31 } 32 return c; 33 } 34 35 /* 36 ** Implementation of the rot13() function. 37 ** 38 ** Rotate ASCII alphabetic characters by 13 character positions. 39 ** Non-ASCII characters are unchanged. rot13(rot13(X)) should always 40 ** equal X. 41 */ 42 static void rot13func( 43 sqlite3_context *context, 44 int argc, 45 sqlite3_value **argv 46 ){ 47 const unsigned char *zIn; 48 int nIn; 49 unsigned char *zOut; 50 unsigned char *zToFree = 0; 51 int i; 52 unsigned char zTemp[100]; 53 assert( argc==1 ); 54 if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; 55 zIn = (const unsigned char*)sqlite3_value_text(argv[0]); 56 nIn = sqlite3_value_bytes(argv[0]); 57 if( nIn