sxscrmbl.c

Go to the documentation of this file.
00001 /******************************************************************************
00002  *                                S Y N T A X
00003  *-----------------------------------------------------------------------------
00004  *   Copyright (C) 1972-2008 INRIA (Institut National de Recherche en
00005  *   Informatique et Automatique)
00006  *-----------------------------------------------------------------------------
00007  *   URL: http://syntax.gforge.inria.fr
00008  *-----------------------------------------------------------------------------
00009  *   The source code of SYNTAX is distributed with two different licenses,
00010  *   depending on the files:
00011  *   - The recursive content of src/ and incl/ and the non-recursive content
00012  *     of SYNTAX's root directory are distributed under the CeCILL-C license
00013  *   - The recursive content of all other repertories is distributed under
00014  *     the CeCILL license
00015  *   All code produced by SYNTAX must be considered as being under the
00016  *   CeCILL-C license. Information about the CeCILL and CeCILL-C licenses
00017  *   can be found at, e.g., http://www.cecill.fr
00018  *****************************************************************************/
00019 
00020 
00021 /* Procedure commune a str_mngr et word_mngr. */
00022 
00023 
00024 
00025 #include        "sxversion.h"
00026 #include        "sxcommon.h"
00027 #include    "sxscrmbl.h"
00028 
00029 char WHAT_SXSCRMBL[] = "@(#)SYNTAX - $Id: sxscrmbl.c 1429 2008-07-03 14:28:41Z rlacroix $" WHAT_DEBUG;
00030 
00031 #ifndef SXBITS_PER_LONG
00032 #define SXBITS_PER_LONG 32
00033 #endif
00034 
00035 
00036 #if SXBITS_PER_LONG==64
00037 SXUINT
00038 sxscrmbl (char *string, SXUINT length)
00039 {
00040     SXUINT  scramble;
00041     char        *last;
00042 
00043     switch (scramble = length) {
00044     case 0:
00045     return 0;
00046 
00047     default:
00048     last = string + length - 1;
00049     scramble += (SXUINT) *last-- << 48;
00050     scramble += (SXUINT) *last-- << 56;
00051     scramble += (SXUINT) *last-- << 52;
00052     scramble += (SXUINT) *last-- << 36;
00053     scramble += (SXUINT) *last << 44;
00054 
00055     last = string + length/2 + 1;
00056     scramble += (SXUINT) *last-- << 60;
00057     scramble += (SXUINT) *last-- << 40;
00058     scramble += (SXUINT) *last-- << 32;
00059     scramble += (SXUINT) *last-- << 16;
00060     scramble += (SXUINT) *last << 24;
00061 
00062     goto k5;
00063 
00064     case 15:
00065     scramble += (SXUINT) *string++ << 48;
00066 
00067     case 14:
00068     scramble += (SXUINT) *string++ << 56;
00069 
00070     case 13:
00071     scramble += (SXUINT) *string++ << 52;
00072 
00073     case 12:
00074     scramble += (SXUINT) *string++ << 36;
00075 
00076     case 11:
00077     scramble += (SXUINT) *string++ << 44;
00078 
00079     case 10:
00080     scramble += (SXUINT) *string++ << 60;
00081 
00082     case 9:
00083     scramble += (SXUINT) *string++ << 40;
00084 
00085     case 8:
00086     scramble += (SXUINT) *string++ << 32;
00087 
00088     case 7:
00089     scramble += (SXUINT) *string++ << 16;
00090 
00091     case 6:
00092     scramble += (SXUINT) *string++ << 24;
00093 
00094     case 5:
00095     k5:
00096     scramble += (SXUINT) *string++ << 20;
00097 
00098     case 4:
00099     scramble += (SXUINT) *string++ << 4;
00100 
00101     case 3:
00102     scramble += (SXUINT) *string++ << 12;
00103 
00104     case 2:
00105     scramble += (SXUINT) *string++ << 28;
00106 
00107     case 1:
00108     return (scramble + ((SXUINT) *string << 8));
00109     }
00110 }
00111 #else
00112 SXUINT
00113 sxscrmbl (char *string, SXUINT length)
00114 {
00115     SXUINT  scramble;
00116     char        *last;
00117 
00118     switch (scramble = length) {
00119     case 0:
00120     return 0;
00121 
00122     default:
00123     last = string + length - 1;
00124     scramble += (SXUINT) *last-- << 16;
00125     scramble += (SXUINT) *last << 24;
00126 
00127     last = string + length/2;
00128     scramble += (SXUINT) *last-- << 20;
00129     scramble += (SXUINT) *last << 4;
00130     goto k3;
00131 
00132     case 7:
00133     scramble += (SXUINT) *string++ << 16;
00134 
00135     case 6:
00136     scramble += (SXUINT) *string++ << 24;
00137 
00138     case 5:
00139     scramble += (SXUINT) *string++ << 20;
00140 
00141     case 4:
00142     scramble += (SXUINT) *string++ << 4;
00143 
00144     case 3:
00145     k3:
00146     scramble += (SXUINT) *string++ << 12;
00147 
00148     case 2:
00149     scramble += (SXUINT) *string++ << 28;
00150 
00151     case 1:
00152     return (scramble + ((SXUINT) *string << 8));
00153     }
00154 }
00155 #endif
00156 

Generated on Wed Apr 21 16:39:34 2010 for syntax-6.0b7 by  doxygen 1.6.1