Changeset 21535 for trunk/tools
- Timestamp:
- Dec 23, 2010, 6:54:11 AM (15 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/install/makefile
r21458 r21535 29 29 # 30 30 OBJS = \ 31 $(OBJDIR)\odininst.obj 32 31 $(OBJDIR)\odininst.obj \ 32 $(OBJDIR)\regapi.obj \ 33 $(OBJDIR)\tz.obj 33 34 34 35 # -
trunk/tools/install/odininst.cpp
r10169 r21535 1088 1088 } 1089 1089 //****************************************************************************** 1090 //[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation] 1091 //"Bias"=dword:ffffffc4 1092 //"StandardName"="Romance Standard Time" 1093 //"StandardBias"=dword:00000000 1094 //"StandardStart"=hex:00,00,0a,00,05,00,03,00,00,00,00,00,00,00,00,00 1095 // typedef struct _SYSTEMTIME { 1096 // WORD wYear; 1097 // WORD wMonth; 1098 // WORD wDayOfWeek; 1099 // WORD wDay; 1100 // WORD wHour; 1101 // WORD wMinute; 1102 // WORD wSecond; 1103 // WORD wMilliseconds; 1104 //} SYSTEMTIME, *PSYSTEMTIME; 1105 //"DaylightName"="Romance Daylight Time" 1106 //"DaylightBias"=dword:ffffffc4 1107 //"DaylightStart"=hex:00,00,03,00,05,00,02,00,00,00,00,00,00,00,00,00 1108 //"ActiveTimeBias"=dword:ffffffc4 1109 //****************************************************************************** 1090 //****************************************************************************** 1091 extern "C" const char *TimeZones; 1092 extern "C" int ProcessEmbeddedFile(const char *data, BOOL force); 1110 1093 void SetupTimeZoneInfo() 1111 1094 { 1112 HKEY hkey; 1113 DWORD val = 0; 1114 char szTimeZoneStd[4]; 1115 char szTimeZoneDay[4]; 1116 int sign = FALSE; 1117 int bias; 1118 char *pszTZ = NULL; 1119 SYSTEMTIME stime = {0}; 1120 SYSTEMTIME dtime = {0}; 1121 1122 if (RegCreateKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", &hkey) != ERROR_SUCCESS) 1123 { 1124 dprintf(("SetupTimeZoneInfo: Unable to create key")); 1125 return; 1126 } 1127 //Little bit difficult to map the 3 letter timezone to a name 1128 //(duplicate values for different regions) 1129 //So we just copy that timezone string and hope the apps don't really 1130 //on hardcoded timezone names. 1131 1132 //parse TZ environment variable 1133 pszTZ = getenv("TZ"); 1134 if(pszTZ == NULL) { 1135 //default is Central European Time 1136 pszTZ = "CET-1CDT"; 1137 } 1138 strncpy(szTimeZoneStd, pszTZ, 3); 1139 szTimeZoneStd[3] = 0; 1140 if(pszTZ[3] == '-') { 1141 sign = TRUE; 1142 pszTZ += 4; 1143 } 1144 else pszTZ += 3; 1145 1146 if(isdigit(*pszTZ)) { 1147 bias = (int)(*pszTZ - '0') * 60; 1148 pszTZ++; 1149 if(isdigit(*pszTZ)) {//double digit hour difference 1150 bias *= 10; 1151 bias += (int)(*pszTZ - '0') * 60; 1152 pszTZ++; 1153 } 1154 } 1155 else bias = 0; 1156 1157 if(sign) bias = -bias; 1158 1159 if(isalpha(*pszTZ)) {//daylight timezone name follows 1160 strncpy(szTimeZoneDay, pszTZ, 3); 1161 szTimeZoneDay[3] = 0; 1162 } 1163 else szTimeZoneDay[0] = 0; 1164 1165 RegSetValueEx(hkey, "Bias",0,REG_DWORD, (LPBYTE)&bias, sizeof(bias)); 1166 RegSetValueEx(hkey, "ActiveTimeBias",0,REG_DWORD, (LPBYTE)&bias, sizeof(bias)); 1167 1168 RegSetValueEx(hkey, "StandardName", 0, REG_SZ, (LPBYTE)szTimeZoneStd, strlen(szTimeZoneStd)); 1169 RegSetValueEx(hkey, "StandardBias",0,REG_DWORD, (LPBYTE)&bias, sizeof(bias)); 1170 RegSetValueEx(hkey, "StandardStart",0,REG_BINARY, (LPBYTE)&stime, sizeof(stime)); 1171 RegSetValueEx(hkey, "DaylightName", 0, REG_SZ, (LPBYTE)szTimeZoneDay, strlen(szTimeZoneDay)); 1172 RegSetValueEx(hkey, "DaylightBias",0,REG_DWORD, (LPBYTE)&bias, sizeof(bias)); 1173 RegSetValueEx(hkey, "DaylightStart",0,REG_BINARY, (LPBYTE)&dtime, sizeof(dtime)); 1174 RegCloseKey(hkey); 1175 1176 TIME_ZONE_INFORMATION tzinfo; 1177 1178 tzinfo.Bias = bias; 1179 lstrcpynAtoW(tzinfo.StandardName, szTimeZoneStd, sizeof(tzinfo.StandardName)/sizeof(WCHAR)); 1180 tzinfo.StandardDate = stime; 1181 tzinfo.StandardBias = bias; 1182 lstrcpynAtoW(tzinfo.DaylightName, szTimeZoneDay, sizeof(tzinfo.StandardName)/sizeof(WCHAR)); 1183 tzinfo.DaylightDate = dtime; 1184 tzinfo.DaylightBias = bias; 1185 1186 SetTimeZoneInformation(&tzinfo); 1095 ProcessEmbeddedFile(TimeZones, TRUE); 1187 1096 } 1188 1097 //****************************************************************************** -
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.