Changeset 21531 for trunk/tools
- Timestamp:
- Dec 23, 2010, 4:02:20 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/regedit/regapi.c
r7933 r21531 10 10 #include <stdio.h> 11 11 #include <stdlib.h> 12 #include <ctype.h> 13 12 14 #include <windows.h> 13 15 #include <winreg.h> … … 28 30 29 31 if(ret) { 30 31 32 32 *ret = (char)0; 33 ret++; 34 (*string) = ret; 33 35 ret1 = strchr(ret, *token); 34 36 if(ret1) *ret1 = 0; … … 36 38 return ret; 37 39 } 40 41 typedef HRESULT (* __stdcall lpfnDLLRegProc)(void); 38 42 #endif 39 43 … … 41 45 * Defines and consts 42 46 */ 43 #define IDENTICAL 0 47 #define IDENTICAL 0 44 48 #define COMMAND_COUNT 7 45 49 46 #define KEY_MAX_LEN 1024 50 #define KEY_MAX_LEN 1024 47 51 #define STDIN_MAX_LEN 2048 48 52 … … 65 69 66 70 /* Delimiters used to parse the "value"="data" pair for setValue*/ 67 #define SET_VALUE_MAX_ARGS 2 71 #define SET_VALUE_MAX_ARGS 2 68 72 /* Delimiters used to parse the "value" to query queryValue*/ 69 #define QUERY_VALUE_MAX_ARGS 1 73 #define QUERY_VALUE_MAX_ARGS 1 70 74 71 75 static const char *setValueDelim[SET_VALUE_MAX_ARGS] = {"=", ""}; … … 73 77 74 78 75 /* 76 * Forward declaration 79 /* 80 * Forward declaration 77 81 */ 78 82 typedef void (*commandAPI)(LPSTR lpsLine); … … 90 94 */ 91 95 static const char* commandNames[COMMAND_COUNT] = { 92 "setValue", 93 "deleteValue", 96 "setValue", 97 "deleteValue", 94 98 "createKey", 95 99 "deleteKey", … … 103 107 */ 104 108 static const commandAPI commandAPIs[COMMAND_COUNT] = { 105 doSetValue, 106 doDeleteValue, 109 doSetValue, 110 doDeleteValue, 107 111 doCreateKey, 108 112 doDeleteKey, … … 112 116 }; 113 117 114 /* 115 * This array controls the registry saving needs at the end of the process 118 /* 119 * This array controls the registry saving needs at the end of the process 116 120 */ 117 121 static const BOOL commandSaveRegistry[COMMAND_COUNT] = { … … 125 129 }; 126 130 127 /* 131 /* 128 132 * Generic prototypes 129 133 */ … … 138 142 static LPSTR convertHexToDWORDStr( BYTE *buf, ULONG len); 139 143 static HRESULT openKey(LPSTR stdInput); 140 static void closeKey( );141 142 /* 144 static void closeKey(void); 145 146 /* 143 147 * api setValue prototypes 144 148 */ … … 146 150 static HRESULT setValue(LPSTR *argv); 147 151 148 /* 152 /* 149 153 * api queryValue prototypes 150 154 */ … … 217 221 218 222 /****************************************************************************** 219 * This function returns the HKEY associated with the data type encoded in the 220 * value. It modifies the input parameter (key value) in order to skip this 223 * This function returns the HKEY associated with the data type encoded in the 224 * value. It modifies the input parameter (key value) in order to skip this 221 225 * "now useless" data type information. 222 226 * … … 268 272 269 273 /****************************************************************************** 270 * Extracts from a [HKEY\some\key\path] type of line the key name (what starts 274 * Extracts from a [HKEY\some\key\path] type of line the key name (what starts 271 275 * after the first '\' and end before the ']' 272 276 */ 273 LPSTR getRegKeyName(LPSTR lpLine) 277 LPSTR getRegKeyName(LPSTR lpLine) 274 278 { 275 279 LPSTR keyNameBeg = NULL; … … 286 290 keyNameEnd = strstr(lpLineCopy, "]"); /* The key name end by ']' */ 287 291 *keyNameEnd = '\0'; /* Isolate the key name */ 288 292 289 293 currentKeyName = HeapAlloc(GetProcessHeap(), 0, strlen(keyNameBeg)+1); 290 294 if (currentKeyName != NULL) 291 295 strcpy(currentKeyName, keyNameBeg); 292 296 293 297 return currentKeyName; 294 298 } 295 299 296 300 /****************************************************************************** 297 * Extracts from a [HKEY/some/key/path] type of line the key class (what 301 * Extracts from a [HKEY/some/key/path] type of line the key class (what 298 302 * starts after the '[' and ends before the first '\' 299 303 */ 300 static HKEY getRegClass(LPSTR lpClass) 304 static HKEY getRegClass(LPSTR lpClass) 301 305 { 302 306 LPSTR classNameEnd; … … 304 308 305 309 char lpClassCopy[KEY_MAX_LEN]; 306 310 307 311 if (lpClass == NULL) 308 312 return (HKEY)ERROR_INVALID_PARAMETER; … … 313 317 *classNameEnd = '\0'; /* Isolate the class name */ 314 318 classNameBeg = &lpClassCopy[1]; /* Skip the '[' */ 315 319 316 320 if (strcmp( classNameBeg, "HKEY_LOCAL_MACHINE") == IDENTICAL ) 317 321 return HKEY_LOCAL_MACHINE; … … 355 359 356 360 /****************************************************************************** 357 * Returns an allocated buffer with a cleaned copy (removed the surrounding 361 * Returns an allocated buffer with a cleaned copy (removed the surrounding 358 362 * dbl quotes) of the passed value. 359 363 */ … … 369 373 * Get rid of surrounding quotes 370 374 */ 371 len = strlen(arg); 375 len = strlen(arg); 372 376 373 377 if( arg[len-1] == '\"' ) arg[len-1] = '\0'; … … 387 391 INT count; 388 392 for (count=0; count < COMMAND_COUNT; count++) 389 if ( strcmp(commandName, commandNames[count]) == IDENTICAL) 393 if ( strcmp(commandName, commandNames[count]) == IDENTICAL) 390 394 return count; 391 395 … … 409 413 410 414 /****************************************************************************** 411 * Converts a hex buffer into a hex comma separated values 415 * Converts a hex buffer into a hex comma separated values 412 416 */ 413 417 static char* convertHexToHexCSV(BYTE *buf, ULONG bufLen) … … 432 436 strcat(str, res); 433 437 strcat(str, ","); 434 } 438 } 435 439 436 440 /* Get rid of the last comma */ … … 491 495 strPos+=3; 492 496 byteCount++; 493 } 497 } 494 498 495 499 return byteCount; … … 498 502 499 503 /****************************************************************************** 500 * Sets the value in argv[0] to the data in argv[1] for the currently 504 * Sets the value in argv[0] to the data in argv[1] for the currently 501 505 * opened key. 502 506 */ … … 519 523 lpsCurrentValue=HeapAlloc(GetProcessHeap(), 0,KEY_MAX_LEN); 520 524 /* 521 * Default registry values are encoded in the input stream as '@' but as 525 * Default registry values are encoded in the input stream as '@' but as 522 526 * blank in the wine registry. 523 527 */ … … 530 534 memset(lpsCurrentValue, 0, KEY_MAX_LEN); 531 535 hRes = RegQueryValueExA( 532 currentKeyHandle, 533 keyValue, 534 NULL, 535 &dwType, 536 (LPBYTE)lpsCurrentValue, 536 currentKeyHandle, 537 keyValue, 538 NULL, 539 &dwType, 540 (LPBYTE)lpsCurrentValue, 537 541 &dwSize); 538 542 … … 544 548 545 549 if( ( strlen(lpsCurrentValue) == 0 ) || /* The value is not existing */ 546 ( bForce )) /* -force option */ 547 { 550 ( bForce )) /* -force option */ 551 { 548 552 LPBYTE lpbData; 549 553 BYTE convert[KEY_MAX_LEN]; … … 553 557 { 554 558 dwLen = strlen(keyData); 555 if (dwLen>0 && keyData[dwLen-1]=='"') 559 lpbData = keyData; 560 if (dwLen>0) 556 561 { 557 dwLen--; 558 keyData[dwLen]='\0'; 562 if (keyData[dwLen-1]=='"') 563 { 564 dwLen--; 565 keyData[dwLen]='\0'; 566 } 567 if (keyData[0]=='"') 568 { 569 dwLen--; 570 lpbData++; 571 } 559 572 } 560 lpbData = keyData; 561 } 573 } 562 574 else if (dwParseType == REG_DWORD) /* Convert the dword types */ 563 575 { … … 572 584 573 585 hRes = RegSetValueEx( 574 currentKeyHandle, 586 currentKeyHandle, 575 587 keyValue, 576 588 0, /* Reserved */ … … 606 618 static HRESULT openKey( LPSTR stdInput) 607 619 { 608 DWORD dwDisp; 620 DWORD dwDisp; 609 621 HRESULT hRes; 610 622 611 623 /* Sanity checks */ 612 if (stdInput == NULL) 624 if (stdInput == NULL) 613 625 return ERROR_INVALID_PARAMETER; 614 626 … … 622 634 if (currentKeyName == NULL) 623 635 return ERROR_INVALID_PARAMETER; 624 625 hRes = RegCreateKeyEx( 636 637 hRes = RegCreateKeyEx( 626 638 currentKeyClass, /* Class */ 627 639 currentKeyName, /* Sub Key */ … … 642 654 } 643 655 /****************************************************************************** 644 * This function is a wrapper for the setValue function. It prepares the 656 * This function is a wrapper for the setValue function. It prepares the 645 657 * land and clean the area once completed. 646 658 */ … … 660 672 argv[counter]=NULL; 661 673 662 while( (token = getToken(&cmdline, setValueDelim[argCounter])) != NULL ) 674 while( (token = getToken(&cmdline, setValueDelim[argCounter])) != NULL ) 663 675 { 664 676 argv[argCounter++] = token; … … 669 681 670 682 hRes = setValue(argv); 671 if ( hRes == ERROR_SUCCESS ) 683 if ( hRes == ERROR_SUCCESS ) 672 684 printf( 673 "regapi: Value \"%s\" has been set to \"%s\" in key [%s]\n", 674 argv[0], 685 "regapi: Value \"%s\" has been set to \"%s\" in key [%s]\n", 686 argv[0], 675 687 argv[1], 676 688 currentKeyName); 677 689 678 else if ( hRes == KEY_VALUE_ALREADY_SET ) 690 else if ( hRes == KEY_VALUE_ALREADY_SET ) 679 691 printf( 680 "regapi: Value \"%s\" already set to \"%s\" in key [%s]\n", 681 argv[0], 682 argv[1], 692 "regapi: Value \"%s\" already set to \"%s\" in key [%s]\n", 693 argv[0], 694 argv[1], 683 695 currentKeyName); 684 696 … … 686 698 printf("regapi: ERROR Key %s not created. Value: %s, Data: %s\n", 687 699 currentKeyName, 688 argv[0], 700 argv[0], 689 701 argv[1]); 690 702 } 691 703 692 704 /****************************************************************************** 693 * This function is a wrapper for the queryValue function. It prepares the 705 * This function is a wrapper for the queryValue function. It prepares the 694 706 * land and clean the area once completed. 695 707 */ … … 710 722 argv[counter]=NULL; 711 723 712 while( (token = getToken(&cmdline, queryValueDelim[argCounter])) != NULL ) 724 while( (token = getToken(&cmdline, queryValueDelim[argCounter])) != NULL ) 713 725 { 714 726 argv[argCounter++] = getArg(token); … … 722 734 return; /* SHOULD NOT HAPPEN */ 723 735 else 724 keyValue = argv[0]; 725 726 if( (keyValue[0] == '@') && (strlen(keyValue) == 1) ) 736 keyValue = argv[0]; 737 738 if( (keyValue[0] == '@') && (strlen(keyValue) == 1) ) 727 739 { 728 740 LONG lLen = KEY_MAX_LEN; 729 741 CHAR* lpsData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN); 730 /* 742 /* 731 743 * We need to query the key default value 732 744 */ 733 745 hRes = RegQueryValue( 734 currentKeyHandle, 735 currentKeyName, 746 currentKeyHandle, 747 currentKeyName, 736 748 (LPBYTE)lpsData, 737 749 &lLen); … … 749 761 } 750 762 } 751 else 763 else 752 764 { 753 765 DWORD dwLen = KEY_MAX_LEN; 754 766 BYTE* lpbData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN); 755 767 DWORD dwType; 756 /* 768 /* 757 769 * We need to query a specific value for the key 758 770 */ 759 771 hRes = RegQueryValueEx( 760 currentKeyHandle, 761 keyValue, 762 0, 763 &dwType, 764 (LPBYTE)lpbData, 772 currentKeyHandle, 773 keyValue, 774 0, 775 &dwType, 776 (LPBYTE)lpbData, 765 777 &dwLen); 766 778 … … 772 784 if (hRes == ERROR_SUCCESS) 773 785 { 774 /* 786 /* 775 787 * Convert the returned data to a displayable format 776 788 */ … … 795 807 break; 796 808 } 797 } 809 } 798 810 } 799 811 800 812 HeapFree(GetProcessHeap(), 0, lpbData); 801 813 } 802 803 804 if ( hRes == ERROR_SUCCESS ) 814 815 816 if ( hRes == ERROR_SUCCESS ) 805 817 printf( 806 "regapi: Value \"%s\" = \"%s\" in key [%s]\n", 807 keyValue, 818 "regapi: Value \"%s\" = \"%s\" in key [%s]\n", 819 keyValue, 808 820 lpsRes, 809 821 currentKeyName); … … 811 823 else 812 824 printf("regapi: ERROR Value \"%s\" not found. for key \"%s\"\n", 813 keyValue, 825 keyValue, 814 826 currentKeyName); 815 827 816 828 /* 817 829 * Do some cleanup … … 829 841 * Close the currently opened key. 830 842 */ 831 static void closeKey( )832 { 833 RegCloseKey(currentKeyHandle); 843 static void closeKey(void) 844 { 845 RegCloseKey(currentKeyHandle); 834 846 835 847 HeapFree(GetProcessHeap(), 0, currentKeyName); /* Allocated by getKeyName */ … … 843 855 844 856 /****************************************************************************** 845 * This funtion is the main entry point to the setValue type of action. It 846 * receives the currently read line and dispatch the work depending on the 857 * This funtion is the main entry point to the setValue type of action. It 858 * receives the currently read line and dispatch the work depending on the 847 859 * context. 848 860 */ 849 861 static void doSetValue(LPSTR stdInput) 850 862 { 851 /* 852 * We encoutered the end of the file, make sure we 863 /* 864 * We encoutered the end of the file, make sure we 853 865 * close the opened key and exit 854 */ 855 if (stdInput == NULL) 856 { 857 if (bTheKeyIsOpen != FALSE) 858 closeKey(); 866 */ 867 if (stdInput == NULL) 868 { 869 if (bTheKeyIsOpen != FALSE) 870 closeKey(); 859 871 860 872 return; 861 873 } 862 874 863 875 if ( stdInput[0] == '[') /* We are reading a new key */ 864 876 { 865 if ( bTheKeyIsOpen != FALSE ) 877 if ( bTheKeyIsOpen != FALSE ) 866 878 closeKey(); /* Close the previous key before */ 867 879 … … 869 881 printf ("regapi: doSetValue failed to open key %s\n", stdInput); 870 882 } 871 else if( ( bTheKeyIsOpen ) && 883 else if( ( bTheKeyIsOpen ) && 884 (( stdInput[0] == '@') || /* reading a default @=data pair */ 885 ( stdInput[0] == '\"') || 886 ( isalpha(stdInput[0])))) /* reading a new value=data pair */ 887 { 888 processSetValue(stdInput); 889 } 890 else /* since we are assuming that the */ 891 { /* file format is valid we must */ 892 if ( bTheKeyIsOpen ) /* be reading a blank line which */ 893 closeKey(); /* indicate end of this key processing */ 894 } 895 } 896 897 /****************************************************************************** 898 * This funtion is the main entry point to the queryValue type of action. It 899 * receives the currently read line and dispatch the work depending on the 900 * context. 901 */ 902 static void doQueryValue(LPSTR stdInput) { 903 /* 904 * We encoutered the end of the file, make sure we 905 * close the opened key and exit 906 */ 907 if (stdInput == NULL) 908 { 909 if (bTheKeyIsOpen != FALSE) 910 closeKey(); 911 912 return; 913 } 914 915 if ( stdInput[0] == '[') /* We are reading a new key */ 916 { 917 if ( bTheKeyIsOpen != FALSE ) 918 closeKey(); /* Close the previous key before */ 919 920 if ( openKey(stdInput) != ERROR_SUCCESS ) 921 printf ("regapi: doSetValue failed to open key %s\n", stdInput); 922 } 923 else if( ( bTheKeyIsOpen ) && 872 924 (( stdInput[0] == '@') || /* reading a default @=data pair */ 873 925 ( stdInput[0] == '\"'))) /* reading a new value=data pair */ 874 926 { 875 process SetValue(stdInput);927 processQueryValue(stdInput); 876 928 } 877 929 else /* since we are assuming that the */ 878 { /* file format is valid we must */ 930 { /* file format is valid we must */ 879 931 if ( bTheKeyIsOpen ) /* be reading a blank line which */ 880 closeKey(); /* indicate end of this key processing */ 881 } 882 } 883 884 /****************************************************************************** 885 * This funtion is the main entry point to the queryValue type of action. It886 * receives the currently read line and dispatch the work depending on the 932 closeKey(); /* indicate end of this key processing */ 933 } 934 } 935 936 /****************************************************************************** 937 * This funtion is the main entry point to the deletetValue type of action. It 938 * receives the currently read line and dispatch the work depending on the 887 939 * context. 888 940 */ 889 static void doQueryValue(LPSTR stdInput) { 890 /* 891 * We encoutered the end of the file, make sure we 892 * close the opened key and exit 893 */ 894 if (stdInput == NULL) 895 { 896 if (bTheKeyIsOpen != FALSE) 897 closeKey(); 898 899 return; 900 } 901 902 if ( stdInput[0] == '[') /* We are reading a new key */ 903 { 904 if ( bTheKeyIsOpen != FALSE ) 905 closeKey(); /* Close the previous key before */ 906 907 if ( openKey(stdInput) != ERROR_SUCCESS ) 908 printf ("regapi: doSetValue failed to open key %s\n", stdInput); 909 } 910 else if( ( bTheKeyIsOpen ) && 911 (( stdInput[0] == '@') || /* reading a default @=data pair */ 912 ( stdInput[0] == '\"'))) /* reading a new value=data pair */ 913 { 914 processQueryValue(stdInput); 915 } 916 else /* since we are assuming that the */ 917 { /* file format is valid we must */ 918 if ( bTheKeyIsOpen ) /* be reading a blank line which */ 919 closeKey(); /* indicate end of this key processing */ 920 } 921 } 922 923 /****************************************************************************** 924 * This funtion is the main entry point to the deletetValue type of action. It 925 * receives the currently read line and dispatch the work depending on the 941 static void doDeleteValue(LPSTR line) { 942 printf ("regapi: deleteValue not yet implemented\n"); 943 } 944 /****************************************************************************** 945 * This funtion is the main entry point to the deleteKey type of action. It 946 * receives the currently read line and dispatch the work depending on the 926 947 * context. 927 948 */ 928 static void doDelete Value(LPSTR line) {929 printf ("regapi: delete Valuenot yet implemented\n");930 } 931 /****************************************************************************** 932 * This funtion is the main entry point to the deleteKey type of action. It933 * receives the currently read line and dispatch the work depending on the 949 static void doDeleteKey(LPSTR line) { 950 printf ("regapi: deleteKey not yet implemented\n"); 951 } 952 /****************************************************************************** 953 * This funtion is the main entry point to the createKey type of action. It 954 * receives the currently read line and dispatch the work depending on the 934 955 * context. 935 956 */ 936 static void doDeleteKey(LPSTR line) { 937 printf ("regapi: deleteKey not yet implemented\n"); 938 } 939 /****************************************************************************** 940 * This funtion is the main entry point to the createKey type of action. It 941 * receives the currently read line and dispatch the work depending on the 942 * context. 943 */ 944 static void doCreateKey(LPSTR line) { 957 static void doCreateKey(LPSTR line) { 945 958 printf ("regapi: createKey not yet implemented\n"); 946 959 } 947 960 948 961 /****************************************************************************** 949 * This funtion is the main entry point to the registerDLL action. It 962 * This funtion is the main entry point to the registerDLL action. It 950 963 * receives the currently read line, then loads and registers the requested DLLs 951 964 */ 952 static void doRegisterDLL(LPSTR stdInput) { 965 static void doRegisterDLL(LPSTR stdInput) { 953 966 HMODULE theLib = 0; 954 967 UINT retVal = 0; 955 968 956 969 /* Check for valid input */ 957 if (stdInput == NULL) 970 if (stdInput == NULL) 958 971 return; 959 972 … … 964 977 FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllRegisterServer"); 965 978 if (lpfnDLLRegProc) 966 retVal = (*lpfnDLLRegProc)();979 retVal = lpfnDLLRegProc(); 967 980 else 968 981 printf("regapi: Couldn't find DllRegisterServer proc in '%s'.\n", stdInput); 969 982 970 983 if (retVal != S_OK) 971 printf("regapi: DLLRegisterServer error 0x%x in '%s'.\n", retVal, stdInput); 984 printf("regapi: DLLRegisterServer error 0x%x in '%s'.\n", retVal, stdInput); 972 985 973 986 FreeLibrary(theLib); … … 975 988 else 976 989 { 977 printf("regapi: Could not load DLL '%s'.\n", stdInput); 978 } 979 } 980 981 /****************************************************************************** 982 * This funtion is the main entry point to the unregisterDLL action. It 990 printf("regapi: Could not load DLL '%s'.\n", stdInput); 991 } 992 } 993 994 /****************************************************************************** 995 * This funtion is the main entry point to the unregisterDLL action. It 983 996 * receives the currently read line, then loads and unregisters the requested DLLs 984 997 */ 985 static void doUnregisterDLL(LPSTR stdInput) { 998 static void doUnregisterDLL(LPSTR stdInput) { 986 999 HMODULE theLib = 0; 987 1000 UINT retVal = 0; 988 1001 989 1002 /* Check for valid input */ 990 if (stdInput == NULL) 1003 if (stdInput == NULL) 991 1004 return; 992 1005 … … 997 1010 FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllUnregisterServer"); 998 1011 if (lpfnDLLRegProc) 999 retVal = (*lpfnDLLRegProc)();1012 retVal = lpfnDLLRegProc(); 1000 1013 else 1001 1014 printf("regapi: Couldn't find DllUnregisterServer proc in '%s'.\n", stdInput); 1002 1015 1003 1016 if (retVal != S_OK) 1004 printf("regapi: DLLUnregisterServer error 0x%x in '%s'.\n", retVal, stdInput); 1017 printf("regapi: DLLUnregisterServer error 0x%x in '%s'.\n", retVal, stdInput); 1005 1018 1006 1019 FreeLibrary(theLib); … … 1008 1021 else 1009 1022 { 1010 printf("regapi: Could not load DLL '%s'.\n", stdInput); 1023 printf("regapi: Could not load DLL '%s'.\n", stdInput); 1011 1024 } 1012 1025 } … … 1025 1038 ULONG currentSize = STDIN_MAX_LEN; 1026 1039 1027 stdInput = HeapAlloc(GetProcessHeap(), 0, STDIN_MAX_LEN); 1040 stdInput = HeapAlloc(GetProcessHeap(), 0, STDIN_MAX_LEN); 1028 1041 nextLine = HeapAlloc(GetProcessHeap(), 0, STDIN_MAX_LEN); 1029 1042 … … 1033 1046 /* 1034 1047 * get the command, should be the first arg (modify cmdLine) 1035 */ 1048 */ 1036 1049 #ifdef __WIN32OS2__ 1037 1050 token = "setValue"; 1038 1051 #else 1039 token = getToken(&cmdline, " "); 1052 token = getToken(&cmdline, " "); 1040 1053 #endif 1041 if (token != NULL) 1054 if (token != NULL) 1042 1055 { 1043 1056 cmdIndex = getCommand(token); … … 1048 1061 return COMMAND_NOT_SUPPORTED; 1049 1062 } 1050 } 1063 } 1051 1064 else 1052 1065 { … … 1057 1070 } 1058 1071 1059 /* 1060 * check to see wether we force the action 1072 /* 1073 * check to see wether we force the action 1061 1074 * (meaning differs depending on the command performed) 1062 1075 */ … … 1069 1082 while ( TRUE ) 1070 1083 { 1071 /* 1084 /* 1072 1085 * read a line 1073 1086 */ 1074 1087 ULONG curSize=STDIN_MAX_LEN; 1075 1088 char* s=NULL; 1076 1089 1077 1090 while((NULL!=(stdInput=fgets(stdInput,curSize,stdin))) && (NULL==(s=strchr(stdInput,'\n'))) ){ 1078 1091 fseek(stdin,-curSize,SEEK_CUR+1); 1079 1092 stdInput=HeapReAlloc(GetProcessHeap(), 0,stdInput,curSize+=STDIN_MAX_LEN); 1080 1093 } 1081 /* 1082 * Make some handy generic stuff here... 1094 /* 1095 * Make some handy generic stuff here... 1083 1096 */ 1084 1097 if ( stdInput != NULL ) … … 1108 1121 } 1109 1122 1110 /* 1111 * We process every lines even the NULL (last) line, to indicate the 1123 /* 1124 * We process every lines even the NULL (last) line, to indicate the 1112 1125 * end of the processing to the specific process. 1113 1126 */ 1114 commandAPIs[cmdIndex](stdInput); 1127 commandAPIs[cmdIndex](stdInput); 1115 1128 1116 1129 if (stdInput == NULL) /* EOF encountered */ … … 1118 1131 } 1119 1132 1120 #if 0 1121 /* 1122 * Save the registry only if it was modified 1133 #if 0 1134 /* 1135 * Save the registry only if it was modified 1123 1136 */ 1124 1137 if ( commandSaveRegistry[cmdIndex] != FALSE )
Note:
See TracChangeset
for help on using the changeset viewer.