Ignore:
Timestamp:
Dec 23, 2010, 6:54:11 AM (15 years ago)
Author:
dmik
Message:

Deduce Windows Time Zone information from the TZ environment variable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/regedit/regapi.c

    r21534 r21535  
    475475  memset(buf, 0, bufLen);
    476476
     477#ifndef ODININST
    477478  /*
    478479   * warn the user if we are here with a string longer than 2 bytes that does
     
    482483    printf("regapi: WARNING converting CSV hex stream with no comma, "
    483484           "input data seems invalid.\n");
     485#endif
    484486
    485487  while (strPos < strLen)
     
    681683
    682684  hRes = setValue(argv);
     685#ifndef ODININST
    683686  if ( hRes == ERROR_SUCCESS )
    684687    printf(
     
    700703      argv[0],
    701704      argv[1]);
     705#endif
    702706}
    703707
     
    814818
    815819
     820#ifndef ODININST
    816821  if ( hRes == ERROR_SUCCESS )
    817822    printf(
     
    825830      keyValue,
    826831      currentKeyName);
     832#endif
    827833
    828834  /*
     
    878884      closeKey();                    /* Close the previous key before */
    879885
    880     if ( openKey(stdInput) != ERROR_SUCCESS )
     886    if ( openKey(stdInput) != ERROR_SUCCESS ) {
     887#ifndef ODININST
    881888      printf ("regapi: doSetValue failed to open key %s\n", stdInput);
     889#endif
     890    }
    882891  }
    883892  else if( ( bTheKeyIsOpen ) &&
     
    918927      closeKey();                    /* Close the previous key before */
    919928
    920     if ( openKey(stdInput) != ERROR_SUCCESS )
     929    if ( openKey(stdInput) != ERROR_SUCCESS ) {
     930#ifndef ODININST
    921931      printf ("regapi: doSetValue failed to open key %s\n", stdInput);
     932#endif
     933    }
    922934  }
    923935  else if( ( bTheKeyIsOpen ) &&
     
    978990    if (lpfnDLLRegProc)
    979991      retVal = lpfnDLLRegProc();
     992#ifndef ODININST
    980993    else
    981994      printf("regapi: Couldn't find DllRegisterServer proc in '%s'.\n", stdInput);
     
    983996    if (retVal != S_OK)
    984997      printf("regapi: DLLRegisterServer error 0x%x in '%s'.\n", retVal, stdInput);
     998#endif
    985999
    9861000    FreeLibrary(theLib);
    9871001  }
     1002#ifndef ODININST
    9881003  else
    9891004  {
    9901005    printf("regapi: Could not load DLL '%s'.\n", stdInput);
    9911006  }
     1007#endif
    9921008}
    9931009
     
    10111027    if (lpfnDLLRegProc)
    10121028      retVal = lpfnDLLRegProc();
     1029#ifndef ODININST
    10131030    else
    10141031      printf("regapi: Couldn't find DllUnregisterServer proc in '%s'.\n", stdInput);
     
    10161033    if (retVal != S_OK)
    10171034      printf("regapi: DLLUnregisterServer error 0x%x in '%s'.\n", retVal, stdInput);
     1035#endif
    10181036
    10191037    FreeLibrary(theLib);
    10201038  }
     1039#ifndef ODININST
    10211040  else
    10221041  {
    10231042    printf("regapi: Could not load DLL '%s'.\n", stdInput);
    10241043  }
    1025 }
     1044#endif
     1045}
     1046
     1047#ifndef ODININST
    10261048
    10271049/******************************************************************************
     
    11441166  return SUCCESS;
    11451167}
     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 */
     1175int 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.