Changeset 21535 for trunk/tools/regedit/regapi.c
- Timestamp:
- Dec 23, 2010, 6:54:11 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/tools/regedit/regapi.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/regedit/regapi.c
r21534 r21535 475 475 memset(buf, 0, bufLen); 476 476 477 #ifndef ODININST 477 478 /* 478 479 * warn the user if we are here with a string longer than 2 bytes that does … … 482 483 printf("regapi: WARNING converting CSV hex stream with no comma, " 483 484 "input data seems invalid.\n"); 485 #endif 484 486 485 487 while (strPos < strLen) … … 681 683 682 684 hRes = setValue(argv); 685 #ifndef ODININST 683 686 if ( hRes == ERROR_SUCCESS ) 684 687 printf( … … 700 703 argv[0], 701 704 argv[1]); 705 #endif 702 706 } 703 707 … … 814 818 815 819 820 #ifndef ODININST 816 821 if ( hRes == ERROR_SUCCESS ) 817 822 printf( … … 825 830 keyValue, 826 831 currentKeyName); 832 #endif 827 833 828 834 /* … … 878 884 closeKey(); /* Close the previous key before */ 879 885 880 if ( openKey(stdInput) != ERROR_SUCCESS ) 886 if ( openKey(stdInput) != ERROR_SUCCESS ) { 887 #ifndef ODININST 881 888 printf ("regapi: doSetValue failed to open key %s\n", stdInput); 889 #endif 890 } 882 891 } 883 892 else if( ( bTheKeyIsOpen ) && … … 918 927 closeKey(); /* Close the previous key before */ 919 928 920 if ( openKey(stdInput) != ERROR_SUCCESS ) 929 if ( openKey(stdInput) != ERROR_SUCCESS ) { 930 #ifndef ODININST 921 931 printf ("regapi: doSetValue failed to open key %s\n", stdInput); 932 #endif 933 } 922 934 } 923 935 else if( ( bTheKeyIsOpen ) && … … 978 990 if (lpfnDLLRegProc) 979 991 retVal = lpfnDLLRegProc(); 992 #ifndef ODININST 980 993 else 981 994 printf("regapi: Couldn't find DllRegisterServer proc in '%s'.\n", stdInput); … … 983 996 if (retVal != S_OK) 984 997 printf("regapi: DLLRegisterServer error 0x%x in '%s'.\n", retVal, stdInput); 998 #endif 985 999 986 1000 FreeLibrary(theLib); 987 1001 } 1002 #ifndef ODININST 988 1003 else 989 1004 { 990 1005 printf("regapi: Could not load DLL '%s'.\n", stdInput); 991 1006 } 1007 #endif 992 1008 } 993 1009 … … 1011 1027 if (lpfnDLLRegProc) 1012 1028 retVal = lpfnDLLRegProc(); 1029 #ifndef ODININST 1013 1030 else 1014 1031 printf("regapi: Couldn't find DllUnregisterServer proc in '%s'.\n", stdInput); … … 1016 1033 if (retVal != S_OK) 1017 1034 printf("regapi: DLLUnregisterServer error 0x%x in '%s'.\n", retVal, stdInput); 1035 #endif 1018 1036 1019 1037 FreeLibrary(theLib); 1020 1038 } 1039 #ifndef ODININST 1021 1040 else 1022 1041 { 1023 1042 printf("regapi: Could not load DLL '%s'.\n", stdInput); 1024 1043 } 1025 } 1044 #endif 1045 } 1046 1047 #ifndef ODININST 1026 1048 1027 1049 /****************************************************************************** … … 1144 1166 return SUCCESS; 1145 1167 } 1168 1169 #else /* !ODININST */ 1170 1171 /****************************************************************************** 1172 * Treats the given data string as an embedded text file and executes the 1173 * setValue command on it. The function expects '\n' as line separators. 1174 */ 1175 int ProcessEmbeddedFile(const char *data, BOOL force) 1176 { 1177 LPSTR curLine = NULL; /* line read from data */ 1178 ULONG curSize = STDIN_MAX_LEN; 1179 const char *curData = data; 1180 INT cmdIndex; 1181 1182 bForce = force; 1183 1184 curLine = HeapAlloc(GetProcessHeap(), 0, STDIN_MAX_LEN); 1185 if (curLine == NULL) 1186 return NOT_ENOUGH_MEMORY; 1187 1188 cmdIndex = getCommand("setValue"); 1189 1190 while (TRUE) 1191 { 1192 /* 1193 * read a line 1194 */ 1195 const char *eol; 1196 int len, lastLen = 0; 1197 1198 while (TRUE) 1199 { 1200 1201 eol = strchr(curData, '\n'); 1202 if (!eol) 1203 eol = curData + strlen(curData); 1204 if (!*eol) 1205 break; // EOF 1206 1207 len = eol - curData + 1; 1208 if (lastLen + len > curSize) { 1209 curSize = lastLen + len; 1210 curLine = HeapReAlloc(GetProcessHeap(), 0, curLine, curSize); 1211 if (curLine == NULL) 1212 return NOT_ENOUGH_MEMORY; 1213 } 1214 1215 memcpy(curLine + lastLen, curData, len - 1); 1216 curLine[lastLen+len-1] = '\0'; 1217 lastLen += len; 1218 curData += len; 1219 1220 if (curLine[lastLen-2] == '\\') { 1221 // concatenate with the next string 1222 curLine[lastLen-2] == '\0'; 1223 lastLen -= 2; 1224 } else { 1225 break; 1226 } 1227 } 1228 1229 /* 1230 * Make some handy generic stuff here... 1231 */ 1232 if (curLine[0] == '#') 1233 continue; 1234 1235 /* 1236 * We process every lines even the NULL (last) line, to indicate the 1237 * end of the processing to the specific process. 1238 */ 1239 if (!*eol) { /* EOF? */ 1240 commandAPIs[cmdIndex](NULL); 1241 break; 1242 } else { 1243 commandAPIs[cmdIndex](curLine); 1244 } 1245 } 1246 1247 HeapFree(GetProcessHeap(), 0, curLine); 1248 1249 return SUCCESS; 1250 } 1251 1252 #endif /* !ODININST */
Note:
See TracChangeset
for help on using the changeset viewer.
