#include "PATH_MAX.h"
#include "freeArrayOfString.h"
/*--------------------------------------------------------------------------*/
-int sci_winqueryreg(char *fname,unsigned long l)
+int sci_winqueryreg(char *fname, unsigned long l)
{
SciErr sciErr;
int *piAddressVarOne = NULL;
if (Rhs == 3)
{
sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddressVarThree);
- if(sciErr.iErr)
+ if (sciErr.iErr)
{
printError(&sciErr, 0);
Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
if (!isStringType(pvApiCtx, piAddressVarThree))
{
- Scierror(999,_("%s: Wrong type for input argument #%d: String expected.\n"), fname, 3);
+ Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), fname, 3);
return 0;
}
if (!isScalar(pvApiCtx, piAddressVarThree))
{
- Scierror(999,_("%s: Wrong size for input argument #%d: String expected.\n"), fname, 3);
+ Scierror(999, _("%s: Wrong size for input argument #%d: String expected.\n"), fname, 3);
return 0;
}
if (getAllocatedSingleString(pvApiCtx, piAddressVarThree, &pStrParamThree) != 0)
{
- Scierror(999,_("%s: Memory allocation error.\n"), fname);
+ Scierror(999, _("%s: Memory allocation error.\n"), fname);
return 0;
}
}
sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
- if(sciErr.iErr)
+ if (sciErr.iErr)
{
printError(&sciErr, 0);
Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
if (!isStringType(pvApiCtx, piAddressVarOne))
{
- Scierror(999,_("%s: Wrong type for input argument #%d: String expected.\n"), fname, 1);
+ Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), fname, 1);
return 0;
}
if (!isScalar(pvApiCtx, piAddressVarOne))
{
- Scierror(999,_("%s: Wrong size for input argument #%d: String expected.\n"), fname, 1);
+ Scierror(999, _("%s: Wrong size for input argument #%d: String expected.\n"), fname, 1);
return 0;
}
sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddressVarTwo);
- if(sciErr.iErr)
+ if (sciErr.iErr)
{
printError(&sciErr, 0);
Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
if (!isStringType(pvApiCtx, piAddressVarTwo))
{
- Scierror(999,_("%s: Wrong type for input argument #%d: String expected.\n"), fname, 2);
+ Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), fname, 2);
return 0;
}
if (!isScalar(pvApiCtx, piAddressVarTwo))
{
- Scierror(999,_("%s: Wrong size for input argument #%d: String expected.\n"), fname, 2);
+ Scierror(999, _("%s: Wrong size for input argument #%d: String expected.\n"), fname, 2);
return 0;
}
freeAllocatedSingleString(pStrParamThree);
pStrParamThree = NULL;
}
- Scierror(999,_("%s: Memory allocation error.\n"), fname);
+ Scierror(999, _("%s: Memory allocation error.\n"), fname);
return 0;
}
pStrParamTwo = NULL;
}
- Scierror(999,_("%s: Memory allocation error.\n"), fname);
+ Scierror(999, _("%s: Memory allocation error.\n"), fname);
return 0;
}
if (Rhs == 3)
{
- if (strcmp(pStrParamOne, "name") == 0)
+ BOOL bKey = strcmp(pStrParamOne, "key") == 0;
+ BOOL bValue = strcmp(pStrParamOne, "name") == 0;
+
+ if (bValue || bKey)
{
int NumbersElm = 0;
- WindowsQueryRegistryNumberOfElementsInList(pStrParamTwo, pStrParamThree, &NumbersElm);
+ if (bValue)
+ {
+ WindowsQueryRegistryNumberOfValuesInList(pStrParamTwo, pStrParamThree, &NumbersElm);
+ }
+ else
+ {
+ WindowsQueryRegistryNumberOfKeysInList(pStrParamTwo, pStrParamThree, &NumbersElm);
+ }
+
if (NumbersElm)
{
- #define MAX_ELMT_REGLIST 255
+ BOOL bResult = FALSE;
+#define MAX_ELMT_REGLIST 255
char **ListKeysName = NULL;
int i = 0;
- if (NumbersElm > MAX_ELMT_REGLIST) NumbersElm = MAX_ELMT_REGLIST;
+ if (NumbersElm > MAX_ELMT_REGLIST)
+ {
+ NumbersElm = MAX_ELMT_REGLIST;
+ }
ListKeysName = (char **)MALLOC(sizeof(char*) * NumbersElm);
for (i = 0; i < NumbersElm; i++)
{
ListKeysName[i] = NULL;
}
- if (WindowsQueryRegistryList(pStrParamTwo, pStrParamThree, NumbersElm, ListKeysName))
+ if (bValue)
+ {
+ bResult = WindowsQueryRegistryValuesList(pStrParamTwo, pStrParamThree, NumbersElm, ListKeysName);
+ }
+ else
+ {
+ bResult = WindowsQueryRegistryKeysList(pStrParamTwo, pStrParamThree, NumbersElm, ListKeysName);
+ }
+
+ if (bResult)
{
int nOne = 1;
sciErr = createMatrixOfString(pvApiCtx, Rhs + 1, NumbersElm, nOne, ListKeysName);
if (sciErr.iErr)
{
printError(&sciErr, 0);
- Scierror(999,_("%s: Memory allocation error.\n"), fname);
+ Scierror(999, _("%s: Memory allocation error.\n"), fname);
}
else
{
}
else
{
- Scierror(999,_("%s: Cannot open Windows registry.\n"), fname);
+ Scierror(999, _("%s: Cannot open Windows registry.\n"), fname);
}
freeArrayOfString(ListKeysName, NumbersElm);
}
createScalarDouble(pvApiCtx, Rhs + 1, (double)iOutput);
}
- LhsVar(1) = Rhs+1;
+ LhsVar(1) = Rhs + 1;
PutLhsVar();
}
else
{
- Scierror(999,_("%s: Cannot query value of this type.\n"),fname);
+ Scierror(999, _("%s: Cannot query value of this type.\n"), fname);
}
FREE( pStrOutput);
}
else
{
- Scierror(999,_("%s: Memory allocation error.\n"), fname);
+ Scierror(999, _("%s: Memory allocation error.\n"), fname);
}
if (pStrParamThree)