Fossil SCM
Moved string_xform.c code into encode.c, since that code serves a similar purpose.
Commit
97db3c0433d1e8e1b13c0c02feff76a797a0d0cf
Parent
6f05b4292a3443f…
1 file changed
-100
D
src/string_xform.c
-100
| --- a/src/string_xform.c | ||
| +++ b/src/string_xform.c | ||
| @@ -1,100 +0,0 @@ | ||
| 1 | -/* | |
| 2 | -** Copyright (c) 2007 D. Richard Hipp | |
| 3 | -** Copyright (c) 2008 Stephan Beal | |
| 4 | -** | |
| 5 | -** This program is free software; you can redistribute it and/or | |
| 6 | -** modify it under the terms of the GNU General Public | |
| 7 | -** License as published by the Free Software Foundation; either | |
| 8 | -** version 2 of the License, or (at your option) any later version. | |
| 9 | -** | |
| 10 | -** This program is distributed in the hope that it will be useful, | |
| 11 | -** but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | -** General Public License for more details. | |
| 14 | -** | |
| 15 | -** You should have received a copy of the GNU General Public | |
| 16 | -** License along with this library; if not, write to the | |
| 17 | -** Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 18 | -** Boston, MA 02111-1307, USA. | |
| 19 | -** | |
| 20 | -** Author contact information: | |
| 21 | -** [email protected] | |
| 22 | -** http://www.hwaci.com/drh/ | |
| 23 | -** | |
| 24 | -******************************************************************************* | |
| 25 | -** | |
| 26 | -** Implementation of the several string formatting routines. | |
| 27 | -*/ | |
| 28 | -#include <assert.h> | |
| 29 | -#include "config.h" | |
| 30 | -#include "string_xform.h" | |
| 31 | - | |
| 32 | -#if INTERFACE | |
| 33 | -/** | |
| 34 | -string_unary_xform_f is a typedef for funcs with the following policy: | |
| 35 | - | |
| 36 | -They accept a const string which they then transform into some other | |
| 37 | -form. They return a transformed copy, which the caller is responsible | |
| 38 | -for freeing. | |
| 39 | - | |
| 40 | -The intention of this is to provide a way for a generic query routine | |
| 41 | -to format specific column data (e.g. transform an object ID into a | |
| 42 | -link to that object). | |
| 43 | -*/ | |
| 44 | -typedef char * (*string_unary_xform_f)( char const * ); | |
| 45 | - | |
| 46 | -#endif // INTERFACE | |
| 47 | - | |
| 48 | -#if 0 | |
| 49 | -/** A no-op transformer which can be used as a placeholder. | |
| 50 | - | |
| 51 | -Conforms to the string_unary_xform_f typedef's policies. | |
| 52 | -*/ | |
| 53 | -char * strxform_copy( char const * uuid ) | |
| 54 | -{ | |
| 55 | - int len = strlen(uuid) + 1; | |
| 56 | - char * ret = (char *) malloc( len ); | |
| 57 | - ret[len] = '\0'; | |
| 58 | - strncpy( ret, uuid, len-1 ); | |
| 59 | - return ret; | |
| 60 | -} | |
| 61 | -#endif | |
| 62 | - | |
| 63 | -/** | |
| 64 | -Returns a hyperlink to uuid. | |
| 65 | - | |
| 66 | -Conforms to the string_unary_xform_f typedef's policies. | |
| 67 | -*/ | |
| 68 | -char * strxform_link_to_uuid( char const * uuid ) | |
| 69 | -{ | |
| 70 | - const int offset = 10; | |
| 71 | - char shortname[offset+1]; | |
| 72 | - shortname[offset] = '\0'; | |
| 73 | - memcpy( shortname, uuid, offset ); | |
| 74 | - return mprintf("<tt><a href='%s/vinfo/%s'><span style='font-size:1.5em'>" | |
| 75 | - "%s</span>%s</a></tt>", | |
| 76 | - g.zBaseURL, uuid, shortname, uuid+offset ); | |
| 77 | -} | |
| 78 | - | |
| 79 | -/** Returns a hyperlink to the given tag. | |
| 80 | - | |
| 81 | -Conforms to the string_unary_xform_f typedef's policies. | |
| 82 | -*/ | |
| 83 | -char * strxform_link_to_tagid( char const * tagid ) | |
| 84 | -{ | |
| 85 | - return mprintf( "<a href='%s/tagview?tagid=%s'>%s</a>", | |
| 86 | - g.zBaseURL, tagid, tagid ); | |
| 87 | -} | |
| 88 | - | |
| 89 | -/** Returns a hyperlink to the named tag. | |
| 90 | - | |
| 91 | -Conforms to the string_unary_xform_f typedef's policies. | |
| 92 | -*/ | |
| 93 | -char * strxform_link_to_tagname( char const * tagid ) | |
| 94 | -{ | |
| 95 | - return mprintf( "<a href='%s/tagview/%s'>%s</a>", | |
| 96 | - g.zBaseURL, tagid, tagid ); | |
| 97 | -} | |
| 98 | - | |
| 99 | - | |
| 100 | - |
| --- a/src/string_xform.c | |
| +++ b/src/string_xform.c | |
| @@ -1,100 +0,0 @@ | |
| 1 | /* |
| 2 | ** Copyright (c) 2007 D. Richard Hipp |
| 3 | ** Copyright (c) 2008 Stephan Beal |
| 4 | ** |
| 5 | ** This program is free software; you can redistribute it and/or |
| 6 | ** modify it under the terms of the GNU General Public |
| 7 | ** License as published by the Free Software Foundation; either |
| 8 | ** version 2 of the License, or (at your option) any later version. |
| 9 | ** |
| 10 | ** This program is distributed in the hope that it will be useful, |
| 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | ** General Public License for more details. |
| 14 | ** |
| 15 | ** You should have received a copy of the GNU General Public |
| 16 | ** License along with this library; if not, write to the |
| 17 | ** Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 18 | ** Boston, MA 02111-1307, USA. |
| 19 | ** |
| 20 | ** Author contact information: |
| 21 | ** [email protected] |
| 22 | ** http://www.hwaci.com/drh/ |
| 23 | ** |
| 24 | ******************************************************************************* |
| 25 | ** |
| 26 | ** Implementation of the several string formatting routines. |
| 27 | */ |
| 28 | #include <assert.h> |
| 29 | #include "config.h" |
| 30 | #include "string_xform.h" |
| 31 | |
| 32 | #if INTERFACE |
| 33 | /** |
| 34 | string_unary_xform_f is a typedef for funcs with the following policy: |
| 35 | |
| 36 | They accept a const string which they then transform into some other |
| 37 | form. They return a transformed copy, which the caller is responsible |
| 38 | for freeing. |
| 39 | |
| 40 | The intention of this is to provide a way for a generic query routine |
| 41 | to format specific column data (e.g. transform an object ID into a |
| 42 | link to that object). |
| 43 | */ |
| 44 | typedef char * (*string_unary_xform_f)( char const * ); |
| 45 | |
| 46 | #endif // INTERFACE |
| 47 | |
| 48 | #if 0 |
| 49 | /** A no-op transformer which can be used as a placeholder. |
| 50 | |
| 51 | Conforms to the string_unary_xform_f typedef's policies. |
| 52 | */ |
| 53 | char * strxform_copy( char const * uuid ) |
| 54 | { |
| 55 | int len = strlen(uuid) + 1; |
| 56 | char * ret = (char *) malloc( len ); |
| 57 | ret[len] = '\0'; |
| 58 | strncpy( ret, uuid, len-1 ); |
| 59 | return ret; |
| 60 | } |
| 61 | #endif |
| 62 | |
| 63 | /** |
| 64 | Returns a hyperlink to uuid. |
| 65 | |
| 66 | Conforms to the string_unary_xform_f typedef's policies. |
| 67 | */ |
| 68 | char * strxform_link_to_uuid( char const * uuid ) |
| 69 | { |
| 70 | const int offset = 10; |
| 71 | char shortname[offset+1]; |
| 72 | shortname[offset] = '\0'; |
| 73 | memcpy( shortname, uuid, offset ); |
| 74 | return mprintf("<tt><a href='%s/vinfo/%s'><span style='font-size:1.5em'>" |
| 75 | "%s</span>%s</a></tt>", |
| 76 | g.zBaseURL, uuid, shortname, uuid+offset ); |
| 77 | } |
| 78 | |
| 79 | /** Returns a hyperlink to the given tag. |
| 80 | |
| 81 | Conforms to the string_unary_xform_f typedef's policies. |
| 82 | */ |
| 83 | char * strxform_link_to_tagid( char const * tagid ) |
| 84 | { |
| 85 | return mprintf( "<a href='%s/tagview?tagid=%s'>%s</a>", |
| 86 | g.zBaseURL, tagid, tagid ); |
| 87 | } |
| 88 | |
| 89 | /** Returns a hyperlink to the named tag. |
| 90 | |
| 91 | Conforms to the string_unary_xform_f typedef's policies. |
| 92 | */ |
| 93 | char * strxform_link_to_tagname( char const * tagid ) |
| 94 | { |
| 95 | return mprintf( "<a href='%s/tagview/%s'>%s</a>", |
| 96 | g.zBaseURL, tagid, tagid ); |
| 97 | } |
| 98 | |
| 99 | |
| 100 |
| --- a/src/string_xform.c | |
| +++ b/src/string_xform.c | |
| @@ -1,100 +0,0 @@ | |