Changeset 23
- Timestamp:
- Apr 19, 2010, 3:43:17 PM (15 years ago)
- Location:
- branches/1.0/src
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/src/makefile.kmk
r22 r23 26 26 uni_main_SOURCES = \ 27 27 uni.def \ 28 uni.c 28 uni.c \ 29 utils.c 29 30 30 31 # english source -
branches/1.0/src/uni.c
r20 r23 58 58 #include <stdlib.h> 59 59 #include <process.h> 60 #include "UNI.h" 61 62 /* replace one string by another */ 63 BOOL searchReplace(const UCHAR *search, const UCHAR *replace, const UCHAR *string, UCHAR *replaced) 64 { 65 /* create init some variables */ 66 UCHAR *searchStart; 67 int len = 0; 68 69 /* do we find the searched string at all */ 70 searchStart = strstr(string, search); 71 if (searchStart == NULL) 72 { 73 strncpy(replaced, string, strlen(replaced)); 74 return FALSE; 75 } 76 77 /* copy first part */ 78 len = searchStart - string; 79 strncpy(replaced, string, len); 80 81 /* add the replaced string */ 82 strcat(replaced, replace); 83 84 /* add the last part */ 85 len += strlen(search); 86 strcat(replaced, string+len); 87 88 return TRUE; 89 } 90 91 /* Password encryption/decryption routines from ndpsmb.c */ 92 93 static unsigned char fromhex (char c) 94 { 95 if ('0' <= c && c <= '9') 96 { 97 return c - '0'; 98 } 99 100 if ('A' <= c && c <= 'F') 101 { 102 return c - 'A' + 0xA; 103 } 104 105 if ('a' <= c && c <= 'f') 106 { 107 return c - 'a' + 0xA; 108 } 109 110 return 0; 111 } 112 113 static char tohex (unsigned char b) 114 { 115 b &= 0xF; 116 117 if (b <= 9) 118 { 119 return b + '0'; 120 } 121 122 return 'A' + (b - 0xA); 123 } 124 125 static void decryptPassword (const char *pszCrypt, char *pszPlain) 126 { 127 /* A simple "decryption", character from the hex value. */ 128 const char *s = pszCrypt; 129 char *d = pszPlain; 130 131 while (*s) 132 { 133 *d++ = (char)((fromhex (*s++) << 4) + fromhex (*s++)); 134 } 135 136 *d++ = 0; 137 } 138 139 static void encryptPassword (const char *pszPlain, char *pszCrypt) 140 { 141 /* A simple "encryption" encode each character as hex value. */ 142 const char *s = pszPlain; 143 char *d = pszCrypt; 144 145 while (*s) 146 { 147 *d++ = tohex ((*s) >> 4); 148 *d++ = tohex (*s); 149 s++; 150 } 151 152 *d++ = 0; 153 } 60 #include "uni.h" 61 #include "utils.h" 154 62 155 63 // … … 998 906 UCHAR arg[256]; 999 907 UCHAR j_parms[256] ; 1000 UCHAR*f_parms;908 char *f_parms; 1001 909 UCHAR j_id[3]; 1002 910 UCHAR parameters[256]; … … 1082 990 1083 991 1084 f_parms = malloc((strlen(parameters) - strlen("%file%") + strlen(filename)) * sizeof( UCHAR));992 f_parms = malloc((strlen(parameters) - strlen("%file%") + strlen(filename)) * sizeof(char)); 1085 993 1086 994 searchReplace("%file%", filename, parameters, f_parms);
Note:
See TracChangeset
for help on using the changeset viewer.