2004-03-16 04:23:43 +01:00
|
|
|
%{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2003 Mike McCormack for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-03-16 04:23:43 +01:00
|
|
|
*/
|
|
|
|
|
2007-07-06 02:53:03 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2004-03-16 04:23:43 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2005-10-29 13:08:05 +02:00
|
|
|
#include "winuser.h"
|
2004-03-16 04:23:43 +01:00
|
|
|
#include "msi.h"
|
|
|
|
#include "msiquery.h"
|
2007-07-06 02:53:03 +02:00
|
|
|
#include "objbase.h"
|
|
|
|
#include "oleauto.h"
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
#include "msipriv.h"
|
2018-04-16 03:52:10 +02:00
|
|
|
#include "winemsi.h"
|
2007-07-06 02:53:03 +02:00
|
|
|
#include "wine/debug.h"
|
2018-09-08 03:17:22 +02:00
|
|
|
#include "wine/exception.h"
|
2010-01-08 04:00:08 +01:00
|
|
|
#include "wine/list.h"
|
2004-03-16 04:23:43 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
|
|
|
typedef struct tag_yyinput
|
|
|
|
{
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIPACKAGE *package;
|
2004-03-16 04:23:43 +01:00
|
|
|
LPCWSTR str;
|
|
|
|
INT n;
|
|
|
|
MSICONDITION result;
|
2010-01-08 04:00:08 +01:00
|
|
|
struct list mem;
|
2004-03-16 04:23:43 +01:00
|
|
|
} COND_input;
|
|
|
|
|
2004-06-29 01:57:11 +02:00
|
|
|
struct cond_str {
|
|
|
|
LPCWSTR data;
|
|
|
|
INT len;
|
|
|
|
};
|
|
|
|
|
2017-10-24 15:02:56 +02:00
|
|
|
struct value {
|
|
|
|
enum value_type {
|
|
|
|
VALUE_INTEGER,
|
|
|
|
VALUE_LITERAL,
|
|
|
|
VALUE_SYMBOL
|
|
|
|
} type;
|
|
|
|
union {
|
|
|
|
INT integer;
|
|
|
|
WCHAR *string;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
2010-01-08 04:00:08 +01:00
|
|
|
static LPWSTR COND_GetString( COND_input *info, const struct cond_str *str );
|
|
|
|
static LPWSTR COND_GetLiteral( COND_input *info, const struct cond_str *str );
|
2006-09-11 21:53:04 +02:00
|
|
|
static int cond_lex( void *COND_lval, COND_input *info);
|
2013-08-01 12:00:04 +02:00
|
|
|
static int cond_error( COND_input *info, const char *str);
|
2004-03-16 04:23:43 +01:00
|
|
|
|
2010-01-08 04:00:08 +01:00
|
|
|
static void *cond_alloc( COND_input *cond, unsigned int sz );
|
|
|
|
static void *cond_track_mem( COND_input *cond, void *ptr, unsigned int sz );
|
|
|
|
static void cond_free( void *ptr );
|
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
static INT compare_int( INT a, INT operator, INT b );
|
2008-05-13 06:49:46 +02:00
|
|
|
static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b, BOOL convert );
|
2005-10-29 13:08:05 +02:00
|
|
|
|
2005-11-14 12:24:14 +01:00
|
|
|
static BOOL num_from_prop( LPCWSTR p, INT *val )
|
|
|
|
{
|
|
|
|
INT ret = 0, sign = 1;
|
|
|
|
|
|
|
|
if (!p)
|
|
|
|
return FALSE;
|
|
|
|
if (*p == '-')
|
|
|
|
{
|
|
|
|
sign = -1;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
if (!*p)
|
|
|
|
return FALSE;
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
if( *p < '0' || *p > '9' )
|
|
|
|
return FALSE;
|
|
|
|
ret = ret*10 + (*p - '0');
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
*val = ret*sign;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-10-24 15:02:56 +02:00
|
|
|
static void value_free( struct value val )
|
|
|
|
{
|
|
|
|
if (val.type != VALUE_INTEGER)
|
|
|
|
cond_free( val.u.string );
|
|
|
|
}
|
|
|
|
|
2004-03-16 04:23:43 +01:00
|
|
|
%}
|
|
|
|
|
2013-08-01 12:00:04 +02:00
|
|
|
%lex-param { COND_input *info }
|
|
|
|
%parse-param { COND_input *info }
|
2019-11-25 14:37:05 +01:00
|
|
|
%define api.pure
|
2004-03-16 04:23:43 +01:00
|
|
|
|
|
|
|
%union
|
|
|
|
{
|
2004-06-29 01:57:11 +02:00
|
|
|
struct cond_str str;
|
2017-10-24 15:02:56 +02:00
|
|
|
struct value value;
|
2017-10-24 15:01:26 +02:00
|
|
|
LPWSTR identifier;
|
|
|
|
INT operator;
|
|
|
|
BOOL bool;
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
|
|
|
|
2006-06-14 16:44:42 +02:00
|
|
|
%token COND_SPACE COND_EOF
|
2005-10-29 13:08:05 +02:00
|
|
|
%token COND_OR COND_AND COND_NOT COND_XOR COND_IMP COND_EQV
|
|
|
|
%token COND_LT COND_GT COND_EQ COND_NE COND_GE COND_LE
|
|
|
|
%token COND_ILT COND_IGT COND_IEQ COND_INE COND_IGE COND_ILE
|
|
|
|
%token COND_LPAR COND_RPAR COND_TILDA COND_SS COND_ISS
|
|
|
|
%token COND_ILHS COND_IRHS COND_LHS COND_RHS
|
2004-03-16 04:23:43 +01:00
|
|
|
%token COND_PERCENT COND_DOLLARS COND_QUESTION COND_AMPER COND_EXCLAM
|
2004-07-29 04:36:06 +02:00
|
|
|
%token <str> COND_IDENT <str> COND_NUMBER <str> COND_LITER
|
2004-03-16 04:23:43 +01:00
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
%nonassoc COND_ERROR COND_EOF
|
2004-03-16 04:23:43 +01:00
|
|
|
|
2017-10-24 15:01:26 +02:00
|
|
|
%type <bool> expression boolean_term boolean_factor
|
2017-10-24 15:02:56 +02:00
|
|
|
%type <value> value
|
2017-10-24 15:01:26 +02:00
|
|
|
%type <identifier> identifier
|
|
|
|
%type <operator> operator
|
2004-03-16 04:23:43 +01:00
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
condition:
|
2020-10-29 11:47:14 +01:00
|
|
|
expression
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
|
|
|
COND_input* cond = (COND_input*) info;
|
|
|
|
cond->result = $1;
|
|
|
|
}
|
2005-10-28 12:41:05 +02:00
|
|
|
| /* empty */
|
|
|
|
{
|
|
|
|
COND_input* cond = (COND_input*) info;
|
|
|
|
cond->result = MSICONDITION_NONE;
|
|
|
|
}
|
2004-03-16 04:23:43 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
expression:
|
2020-10-29 11:47:14 +01:00
|
|
|
boolean_term
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
2005-10-29 13:08:05 +02:00
|
|
|
| expression COND_OR boolean_term
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
|
|
|
$$ = $1 || $3;
|
|
|
|
}
|
2005-10-29 13:08:05 +02:00
|
|
|
| expression COND_IMP boolean_term
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
2005-10-29 13:08:05 +02:00
|
|
|
$$ = !$1 || $3;
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
2005-10-29 13:08:05 +02:00
|
|
|
| expression COND_XOR boolean_term
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
2005-10-29 13:08:05 +02:00
|
|
|
$$ = ( $1 || $3 ) && !( $1 && $3 );
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
2005-10-29 13:08:05 +02:00
|
|
|
| expression COND_EQV boolean_term
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
2005-10-29 13:08:05 +02:00
|
|
|
$$ = ( $1 && $3 ) || ( !$1 && !$3 );
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
boolean_term:
|
|
|
|
boolean_factor
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
2005-10-29 13:08:05 +02:00
|
|
|
| boolean_term COND_AND boolean_factor
|
2004-06-28 22:34:35 +02:00
|
|
|
{
|
2005-10-29 13:08:05 +02:00
|
|
|
$$ = $1 && $3;
|
2004-06-28 22:34:35 +02:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
boolean_factor:
|
|
|
|
COND_NOT boolean_factor
|
2004-06-28 22:34:35 +02:00
|
|
|
{
|
2017-10-24 15:02:56 +02:00
|
|
|
$$ = !$2;
|
2004-06-28 22:34:35 +02:00
|
|
|
}
|
2017-10-24 15:02:56 +02:00
|
|
|
| value
|
2004-06-28 22:34:35 +02:00
|
|
|
{
|
2017-10-24 15:02:56 +02:00
|
|
|
if ($1.type == VALUE_INTEGER)
|
|
|
|
$$ = $1.u.integer ? 1 : 0;
|
|
|
|
else
|
|
|
|
$$ = $1.u.string && $1.u.string[0];
|
|
|
|
value_free( $1 );
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
2017-10-24 15:02:56 +02:00
|
|
|
| value operator value
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
2017-10-24 15:02:56 +02:00
|
|
|
if ($1.type == VALUE_INTEGER && $3.type == VALUE_INTEGER)
|
|
|
|
{
|
|
|
|
$$ = compare_int($1.u.integer, $2, $3.u.integer);
|
|
|
|
}
|
|
|
|
else if ($1.type != VALUE_INTEGER && $3.type != VALUE_INTEGER)
|
|
|
|
{
|
|
|
|
$$ = compare_string($1.u.string, $2, $3.u.string,
|
|
|
|
$1.type == VALUE_SYMBOL || $3.type == VALUE_SYMBOL);
|
|
|
|
}
|
|
|
|
else if ($1.type == VALUE_LITERAL || $3.type == VALUE_LITERAL)
|
|
|
|
{
|
2018-07-13 13:12:51 +02:00
|
|
|
$$ = ($2 == COND_NE || $2 == COND_INE );
|
2017-10-24 15:02:56 +02:00
|
|
|
}
|
|
|
|
else if ($1.type == VALUE_SYMBOL) /* symbol operator integer */
|
|
|
|
{
|
|
|
|
int num;
|
|
|
|
if (num_from_prop( $1.u.string, &num ))
|
|
|
|
$$ = compare_int( num, $2, $3.u.integer );
|
|
|
|
else
|
|
|
|
$$ = ($2 == COND_NE || $2 == COND_INE );
|
|
|
|
}
|
|
|
|
else /* integer operator symbol */
|
|
|
|
{
|
|
|
|
int num;
|
|
|
|
if (num_from_prop( $3.u.string, &num ))
|
|
|
|
$$ = compare_int( $1.u.integer, $2, num );
|
|
|
|
else
|
|
|
|
$$ = ($2 == COND_NE || $2 == COND_INE );
|
|
|
|
}
|
|
|
|
|
|
|
|
value_free( $1 );
|
|
|
|
value_free( $3 );
|
2004-06-28 22:34:35 +02:00
|
|
|
}
|
2005-10-29 13:08:05 +02:00
|
|
|
| COND_LPAR expression COND_RPAR
|
2004-06-28 22:34:35 +02:00
|
|
|
{
|
2005-10-29 13:08:05 +02:00
|
|
|
$$ = $2;
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
operator:
|
2004-06-28 22:34:35 +02:00
|
|
|
/* common functions */
|
2005-11-03 10:55:30 +01:00
|
|
|
COND_EQ { $$ = COND_EQ; }
|
|
|
|
| COND_NE { $$ = COND_NE; }
|
|
|
|
| COND_LT { $$ = COND_LT; }
|
|
|
|
| COND_GT { $$ = COND_GT; }
|
|
|
|
| COND_LE { $$ = COND_LE; }
|
|
|
|
| COND_GE { $$ = COND_GE; }
|
|
|
|
| COND_SS { $$ = COND_SS; }
|
|
|
|
| COND_IEQ { $$ = COND_IEQ; }
|
|
|
|
| COND_INE { $$ = COND_INE; }
|
|
|
|
| COND_ILT { $$ = COND_ILT; }
|
|
|
|
| COND_IGT { $$ = COND_IGT; }
|
|
|
|
| COND_ILE { $$ = COND_ILE; }
|
|
|
|
| COND_IGE { $$ = COND_IGE; }
|
|
|
|
| COND_ISS { $$ = COND_ISS; }
|
|
|
|
| COND_LHS { $$ = COND_LHS; }
|
|
|
|
| COND_RHS { $$ = COND_RHS; }
|
|
|
|
| COND_ILHS { $$ = COND_ILHS; }
|
|
|
|
| COND_IRHS { $$ = COND_IRHS; }
|
2004-03-16 04:23:43 +01:00
|
|
|
;
|
|
|
|
|
2017-10-24 15:02:56 +02:00
|
|
|
value:
|
|
|
|
identifier
|
|
|
|
{
|
|
|
|
COND_input* cond = (COND_input*) info;
|
|
|
|
UINT len;
|
2004-06-28 22:34:35 +02:00
|
|
|
|
2017-10-24 15:02:56 +02:00
|
|
|
$$.type = VALUE_SYMBOL;
|
|
|
|
$$.u.string = msi_dup_property( cond->package->db, $1 );
|
|
|
|
if ($$.u.string)
|
|
|
|
{
|
|
|
|
len = (lstrlenW($$.u.string) + 1) * sizeof (WCHAR);
|
|
|
|
$$.u.string = cond_track_mem( cond, $$.u.string, len );
|
|
|
|
}
|
|
|
|
cond_free( $1 );
|
|
|
|
}
|
|
|
|
| COND_PERCENT identifier
|
2004-07-29 04:36:06 +02:00
|
|
|
{
|
2010-01-08 04:00:08 +01:00
|
|
|
COND_input* cond = (COND_input*) info;
|
2017-10-24 15:02:56 +02:00
|
|
|
UINT len = GetEnvironmentVariableW( $2, NULL, 0 );
|
|
|
|
$$.type = VALUE_SYMBOL;
|
|
|
|
$$.u.string = NULL;
|
|
|
|
if (len++)
|
|
|
|
{
|
|
|
|
$$.u.string = cond_alloc( cond, len*sizeof (WCHAR) );
|
|
|
|
if( !$$.u.string )
|
|
|
|
YYABORT;
|
|
|
|
GetEnvironmentVariableW( $2, $$.u.string, len );
|
|
|
|
}
|
|
|
|
cond_free( $2 );
|
|
|
|
}
|
|
|
|
| COND_LITER
|
|
|
|
{
|
|
|
|
COND_input* cond = (COND_input*) info;
|
|
|
|
$$.type = VALUE_LITERAL;
|
|
|
|
$$.u.string = COND_GetLiteral( cond, &$1 );
|
|
|
|
if( !$$.u.string )
|
2004-07-29 04:36:06 +02:00
|
|
|
YYABORT;
|
|
|
|
}
|
2017-10-24 15:02:56 +02:00
|
|
|
| COND_NUMBER
|
2005-10-29 13:08:05 +02:00
|
|
|
{
|
2017-10-24 15:00:58 +02:00
|
|
|
COND_input* cond = (COND_input*) info;
|
|
|
|
LPWSTR szNum = COND_GetString( cond, &$1 );
|
|
|
|
if( !szNum )
|
|
|
|
YYABORT;
|
2017-10-24 15:02:56 +02:00
|
|
|
$$.type = VALUE_INTEGER;
|
2019-06-13 08:42:35 +02:00
|
|
|
$$.u.integer = wcstol( szNum, NULL, 10 );
|
2017-10-24 15:00:58 +02:00
|
|
|
cond_free( szNum );
|
2005-10-29 13:08:05 +02:00
|
|
|
}
|
|
|
|
| COND_DOLLARS identifier
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
|
|
|
COND_input* cond = (COND_input*) info;
|
|
|
|
INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
|
2020-10-29 11:47:14 +01:00
|
|
|
|
2017-10-24 15:03:00 +02:00
|
|
|
if(MSI_GetComponentStateW(cond->package, $2, &install, &action ) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
$$.type = VALUE_LITERAL;
|
|
|
|
$$.u.string = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$$.type = VALUE_INTEGER;
|
|
|
|
$$.u.integer = action;
|
|
|
|
}
|
2010-01-08 04:00:08 +01:00
|
|
|
cond_free( $2 );
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
|
|
|
| COND_QUESTION identifier
|
|
|
|
{
|
|
|
|
COND_input* cond = (COND_input*) info;
|
|
|
|
INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
|
2020-10-29 11:47:14 +01:00
|
|
|
|
2017-10-24 15:03:00 +02:00
|
|
|
if(MSI_GetComponentStateW(cond->package, $2, &install, &action ) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
$$.type = VALUE_LITERAL;
|
|
|
|
$$.u.string = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$$.type = VALUE_INTEGER;
|
|
|
|
$$.u.integer = install;
|
|
|
|
}
|
2010-01-08 04:00:08 +01:00
|
|
|
cond_free( $2 );
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
|
|
|
| COND_AMPER identifier
|
|
|
|
{
|
|
|
|
COND_input* cond = (COND_input*) info;
|
2017-10-20 22:18:25 +02:00
|
|
|
INSTALLSTATE install, action;
|
2020-10-29 11:47:14 +01:00
|
|
|
|
2017-10-20 22:18:25 +02:00
|
|
|
if (MSI_GetFeatureStateW(cond->package, $2, &install, &action ) != ERROR_SUCCESS)
|
|
|
|
{
|
2017-10-24 15:03:00 +02:00
|
|
|
$$.type = VALUE_LITERAL;
|
|
|
|
$$.u.string = NULL;
|
2017-10-20 22:18:25 +02:00
|
|
|
}
|
2008-02-28 00:47:03 +01:00
|
|
|
else
|
2017-10-24 15:02:56 +02:00
|
|
|
{
|
|
|
|
$$.type = VALUE_INTEGER;
|
|
|
|
$$.u.integer = action;
|
|
|
|
}
|
2010-01-08 04:00:08 +01:00
|
|
|
cond_free( $2 );
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
|
|
|
| COND_EXCLAM identifier
|
|
|
|
{
|
|
|
|
COND_input* cond = (COND_input*) info;
|
|
|
|
INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
|
2020-10-29 11:47:14 +01:00
|
|
|
|
2017-10-24 15:03:00 +02:00
|
|
|
if(MSI_GetFeatureStateW(cond->package, $2, &install, &action ) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
$$.type = VALUE_LITERAL;
|
|
|
|
$$.u.string = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$$.type = VALUE_INTEGER;
|
|
|
|
$$.u.integer = install;
|
|
|
|
}
|
2010-01-08 04:00:08 +01:00
|
|
|
cond_free( $2 );
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2004-06-28 22:34:35 +02:00
|
|
|
identifier:
|
|
|
|
COND_IDENT
|
|
|
|
{
|
2010-01-08 04:00:08 +01:00
|
|
|
COND_input* cond = (COND_input*) info;
|
|
|
|
$$ = COND_GetString( cond, &$1 );
|
2004-06-28 22:34:35 +02:00
|
|
|
if( !$$ )
|
|
|
|
YYABORT;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2004-03-16 04:23:43 +01:00
|
|
|
%%
|
|
|
|
|
|
|
|
|
2004-07-06 20:50:02 +02:00
|
|
|
static int COND_IsAlpha( WCHAR x )
|
|
|
|
{
|
|
|
|
return( ( ( x >= 'A' ) && ( x <= 'Z' ) ) ||
|
|
|
|
( ( x >= 'a' ) && ( x <= 'z' ) ) ||
|
|
|
|
( ( x == '_' ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
static int COND_IsNumber( WCHAR x )
|
|
|
|
{
|
2004-07-19 23:49:15 +02:00
|
|
|
return( (( x >= '0' ) && ( x <= '9' )) || (x =='-') || (x =='.') );
|
2004-07-06 20:50:02 +02:00
|
|
|
}
|
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
static WCHAR *strstriW( const WCHAR *str, const WCHAR *sub )
|
|
|
|
{
|
|
|
|
LPWSTR strlower, sublower, r;
|
|
|
|
strlower = CharLowerW( strdupW( str ) );
|
|
|
|
sublower = CharLowerW( strdupW( sub ) );
|
2019-06-13 08:42:35 +02:00
|
|
|
r = wcsstr( strlower, sublower );
|
2005-10-29 13:08:05 +02:00
|
|
|
if (r)
|
|
|
|
r = (LPWSTR)str + (r - strlower);
|
|
|
|
msi_free( strlower );
|
|
|
|
msi_free( sublower );
|
|
|
|
return r;
|
|
|
|
}
|
2004-07-06 20:50:02 +02:00
|
|
|
|
2006-08-22 01:27:38 +02:00
|
|
|
static BOOL str_is_number( LPCWSTR str )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2008-05-13 06:49:46 +02:00
|
|
|
if (!*str)
|
|
|
|
return FALSE;
|
|
|
|
|
2006-08-22 01:27:38 +02:00
|
|
|
for (i = 0; i < lstrlenW( str ); i++)
|
2019-06-13 08:42:35 +02:00
|
|
|
if (!iswdigit(str[i]))
|
2006-08-22 01:27:38 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT compare_substring( LPCWSTR a, INT operator, LPCWSTR b )
|
|
|
|
{
|
|
|
|
int lhs, rhs;
|
|
|
|
|
|
|
|
/* substring operators return 0 if LHS is missing */
|
|
|
|
if (!a || !*a)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* substring operators return 1 if RHS is missing */
|
|
|
|
if (!b || !*b)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* if both strings contain only numbers, use integer comparison */
|
2019-06-13 08:42:35 +02:00
|
|
|
lhs = wcstol(a, NULL, 10);
|
|
|
|
rhs = wcstol(b, NULL, 10);
|
2006-08-22 01:27:38 +02:00
|
|
|
if (str_is_number(a) && str_is_number(b))
|
|
|
|
return compare_int( lhs, operator, rhs );
|
|
|
|
|
|
|
|
switch (operator)
|
|
|
|
{
|
|
|
|
case COND_SS:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcsstr( a, b ) != 0;
|
2006-08-22 01:27:38 +02:00
|
|
|
case COND_ISS:
|
2010-10-19 11:27:44 +02:00
|
|
|
return strstriW( a, b ) != 0;
|
2006-08-22 01:27:38 +02:00
|
|
|
case COND_LHS:
|
2010-10-19 11:27:44 +02:00
|
|
|
{
|
2019-06-13 08:42:35 +02:00
|
|
|
int l = lstrlenW( a );
|
|
|
|
int r = lstrlenW( b );
|
2010-10-19 11:27:44 +02:00
|
|
|
if (r > l) return 0;
|
2019-06-13 08:42:35 +02:00
|
|
|
return !wcsncmp( a, b, r );
|
2010-10-19 11:27:44 +02:00
|
|
|
}
|
2006-08-22 01:27:38 +02:00
|
|
|
case COND_RHS:
|
2010-09-24 17:09:04 +02:00
|
|
|
{
|
2019-06-13 08:42:35 +02:00
|
|
|
int l = lstrlenW( a );
|
|
|
|
int r = lstrlenW( b );
|
2010-09-24 17:09:04 +02:00
|
|
|
if (r > l) return 0;
|
2019-06-13 08:42:35 +02:00
|
|
|
return !wcsncmp( a + (l - r), b, r );
|
2010-09-24 17:09:04 +02:00
|
|
|
}
|
2006-08-22 01:27:38 +02:00
|
|
|
case COND_ILHS:
|
2010-10-19 11:27:44 +02:00
|
|
|
{
|
2019-06-13 08:42:35 +02:00
|
|
|
int l = lstrlenW( a );
|
|
|
|
int r = lstrlenW( b );
|
2010-10-19 11:27:44 +02:00
|
|
|
if (r > l) return 0;
|
2019-06-13 08:42:35 +02:00
|
|
|
return !wcsnicmp( a, b, r );
|
2010-10-19 11:27:44 +02:00
|
|
|
}
|
2006-08-22 01:27:38 +02:00
|
|
|
case COND_IRHS:
|
2010-09-24 17:09:04 +02:00
|
|
|
{
|
2019-06-13 08:42:35 +02:00
|
|
|
int l = lstrlenW( a );
|
|
|
|
int r = lstrlenW( b );
|
2010-09-24 17:09:04 +02:00
|
|
|
if (r > l) return 0;
|
2019-06-13 08:42:35 +02:00
|
|
|
return !wcsnicmp( a + (l - r), b, r );
|
2010-09-24 17:09:04 +02:00
|
|
|
}
|
2006-08-22 01:27:38 +02:00
|
|
|
default:
|
2011-06-30 12:16:02 +02:00
|
|
|
ERR("invalid substring operator\n");
|
2006-08-22 01:27:38 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-05-13 06:49:46 +02:00
|
|
|
static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b, BOOL convert )
|
2005-10-29 13:08:05 +02:00
|
|
|
{
|
2006-08-22 01:27:38 +02:00
|
|
|
if (operator >= COND_SS && operator <= COND_RHS)
|
|
|
|
return compare_substring( a, operator, b );
|
2011-06-30 12:16:02 +02:00
|
|
|
|
2006-12-14 17:02:23 +01:00
|
|
|
/* null and empty string are equivalent */
|
2020-10-29 11:47:14 +01:00
|
|
|
if (!a) a = L"";
|
|
|
|
if (!b) b = L"";
|
2005-11-02 20:58:01 +01:00
|
|
|
|
2008-05-13 06:49:46 +02:00
|
|
|
if (convert && str_is_number(a) && str_is_number(b))
|
2019-06-13 08:42:35 +02:00
|
|
|
return compare_int( wcstol(a, NULL, 10), operator, wcstol(b, NULL, 10) );
|
2008-05-13 06:49:46 +02:00
|
|
|
|
2006-12-14 17:02:23 +01:00
|
|
|
/* a or b may be NULL */
|
2005-10-29 13:08:05 +02:00
|
|
|
switch (operator)
|
|
|
|
{
|
|
|
|
case COND_LT:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcscmp( a, b ) < 0;
|
2006-12-06 14:29:08 +01:00
|
|
|
case COND_GT:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcscmp( a, b ) > 0;
|
2006-12-06 14:29:08 +01:00
|
|
|
case COND_EQ:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcscmp( a, b ) == 0;
|
2006-12-06 14:29:08 +01:00
|
|
|
case COND_NE:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcscmp( a, b ) != 0;
|
2006-12-06 14:29:08 +01:00
|
|
|
case COND_GE:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcscmp( a, b ) >= 0;
|
2006-12-06 14:29:08 +01:00
|
|
|
case COND_LE:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcscmp( a, b ) <= 0;
|
2006-12-14 17:02:23 +01:00
|
|
|
case COND_ILT:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcsicmp( a, b ) < 0;
|
2006-12-14 17:02:23 +01:00
|
|
|
case COND_IGT:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcsicmp( a, b ) > 0;
|
2006-12-14 17:02:23 +01:00
|
|
|
case COND_IEQ:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcsicmp( a, b ) == 0;
|
2006-12-14 17:02:23 +01:00
|
|
|
case COND_INE:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcsicmp( a, b ) != 0;
|
2006-12-14 17:02:23 +01:00
|
|
|
case COND_IGE:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcsicmp( a, b ) >= 0;
|
2005-10-29 13:08:05 +02:00
|
|
|
case COND_ILE:
|
2019-06-13 08:42:35 +02:00
|
|
|
return wcsicmp( a, b ) <= 0;
|
2005-10-29 13:08:05 +02:00
|
|
|
default:
|
2006-08-22 01:27:38 +02:00
|
|
|
ERR("invalid string operator\n");
|
2006-12-14 17:02:23 +01:00
|
|
|
return 0;
|
2005-10-29 13:08:05 +02:00
|
|
|
}
|
|
|
|
return 0;
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
static INT compare_int( INT a, INT operator, INT b )
|
|
|
|
{
|
|
|
|
switch (operator)
|
|
|
|
{
|
|
|
|
case COND_LT:
|
|
|
|
case COND_ILT:
|
|
|
|
return a < b;
|
|
|
|
case COND_GT:
|
|
|
|
case COND_IGT:
|
|
|
|
return a > b;
|
|
|
|
case COND_EQ:
|
|
|
|
case COND_IEQ:
|
|
|
|
return a == b;
|
|
|
|
case COND_NE:
|
|
|
|
case COND_INE:
|
|
|
|
return a != b;
|
|
|
|
case COND_GE:
|
|
|
|
case COND_IGE:
|
|
|
|
return a >= b;
|
|
|
|
case COND_LE:
|
|
|
|
case COND_ILE:
|
2006-06-05 12:54:20 +02:00
|
|
|
return a <= b;
|
2005-10-29 13:08:05 +02:00
|
|
|
case COND_SS:
|
|
|
|
case COND_ISS:
|
|
|
|
return ( a & b ) ? 1 : 0;
|
|
|
|
case COND_RHS:
|
|
|
|
return ( ( a & 0xffff ) == b ) ? 1 : 0;
|
|
|
|
case COND_LHS:
|
|
|
|
return ( ( (a>>16) & 0xffff ) == b ) ? 1 : 0;
|
|
|
|
default:
|
|
|
|
ERR("invalid integer operator\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2004-03-16 04:23:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
static int COND_IsIdent( WCHAR x )
|
|
|
|
{
|
2020-10-29 11:47:14 +01:00
|
|
|
return( COND_IsAlpha( x ) || COND_IsNumber( x ) || ( x == '_' )
|
2004-06-28 22:34:35 +02:00
|
|
|
|| ( x == '#' ) || (x == '.') );
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
static int COND_GetOperator( COND_input *cond )
|
|
|
|
{
|
|
|
|
static const struct {
|
|
|
|
const WCHAR str[4];
|
|
|
|
int id;
|
|
|
|
} table[] = {
|
2020-10-29 11:47:14 +01:00
|
|
|
{ L"~<=", COND_ILE },
|
|
|
|
{ L"~><", COND_ISS },
|
|
|
|
{ L"~>>", COND_IRHS },
|
|
|
|
{ L"~<>", COND_INE },
|
|
|
|
{ L"~>=", COND_IGE },
|
|
|
|
{ L"~<<", COND_ILHS },
|
|
|
|
{ L"~=", COND_IEQ },
|
|
|
|
{ L"~<", COND_ILT },
|
|
|
|
{ L"~>", COND_IGT },
|
|
|
|
{ L">=", COND_GE },
|
|
|
|
{ L"><", COND_SS },
|
|
|
|
{ L"<<", COND_LHS },
|
|
|
|
{ L"<>", COND_NE },
|
|
|
|
{ L"<=", COND_LE },
|
|
|
|
{ L">>", COND_RHS },
|
|
|
|
{ L">", COND_GT },
|
|
|
|
{ L"<", COND_LT },
|
|
|
|
{ L"", 0 }
|
2005-10-29 13:08:05 +02:00
|
|
|
};
|
|
|
|
LPCWSTR p = &cond->str[cond->n];
|
|
|
|
int i = 0, len;
|
|
|
|
|
|
|
|
while ( 1 )
|
|
|
|
{
|
|
|
|
len = lstrlenW( table[i].str );
|
2019-06-13 08:42:35 +02:00
|
|
|
if ( !len || 0 == wcsncmp( table[i].str, p, len ) )
|
2005-10-29 13:08:05 +02:00
|
|
|
break;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
cond->n += len;
|
|
|
|
return table[i].id;
|
|
|
|
}
|
|
|
|
|
2004-06-29 01:57:11 +02:00
|
|
|
static int COND_GetOne( struct cond_str *str, COND_input *cond )
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
2004-06-29 01:57:11 +02:00
|
|
|
int rc, len = 1;
|
2005-10-29 13:08:05 +02:00
|
|
|
WCHAR ch;
|
2004-06-28 22:34:35 +02:00
|
|
|
|
2004-06-29 01:57:11 +02:00
|
|
|
str->data = &cond->str[cond->n];
|
2004-03-16 04:23:43 +01:00
|
|
|
|
2004-06-29 01:57:11 +02:00
|
|
|
ch = str->data[0];
|
2005-10-29 13:08:05 +02:00
|
|
|
|
2004-03-16 04:23:43 +01:00
|
|
|
switch( ch )
|
|
|
|
{
|
2004-06-29 01:57:11 +02:00
|
|
|
case 0: return 0;
|
2004-06-28 22:34:35 +02:00
|
|
|
case '(': rc = COND_LPAR; break;
|
|
|
|
case ')': rc = COND_RPAR; break;
|
|
|
|
case '&': rc = COND_AMPER; break;
|
|
|
|
case '!': rc = COND_EXCLAM; break;
|
|
|
|
case '$': rc = COND_DOLLARS; break;
|
|
|
|
case '?': rc = COND_QUESTION; break;
|
|
|
|
case '%': rc = COND_PERCENT; break;
|
|
|
|
case ' ': rc = COND_SPACE; break;
|
|
|
|
case '=': rc = COND_EQ; break;
|
2004-03-16 04:23:43 +01:00
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
case '~':
|
|
|
|
case '<':
|
|
|
|
case '>':
|
|
|
|
rc = COND_GetOperator( cond );
|
|
|
|
if (!rc)
|
|
|
|
rc = COND_ERROR;
|
|
|
|
return rc;
|
|
|
|
default:
|
|
|
|
rc = 0;
|
|
|
|
}
|
2004-03-16 04:23:43 +01:00
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
if ( rc )
|
|
|
|
{
|
|
|
|
cond->n += len;
|
|
|
|
return rc;
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
2004-06-29 01:57:11 +02:00
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
if (ch == '"' )
|
2004-06-29 01:57:11 +02:00
|
|
|
{
|
2019-06-13 08:42:35 +02:00
|
|
|
LPCWSTR p = wcschr( str->data + 1, '"' );
|
2011-06-30 12:16:02 +02:00
|
|
|
if (!p) return COND_ERROR;
|
2005-10-29 13:08:05 +02:00
|
|
|
len = p - str->data + 1;
|
|
|
|
rc = COND_LITER;
|
|
|
|
}
|
|
|
|
else if( COND_IsAlpha( ch ) )
|
|
|
|
{
|
|
|
|
while( COND_IsIdent( str->data[len] ) )
|
|
|
|
len++;
|
|
|
|
rc = COND_IDENT;
|
|
|
|
|
|
|
|
if ( len == 3 )
|
|
|
|
{
|
2020-10-29 11:47:14 +01:00
|
|
|
if ( !wcsnicmp( str->data, L"NOT", len ) )
|
2005-10-29 13:08:05 +02:00
|
|
|
rc = COND_NOT;
|
2020-10-29 11:47:14 +01:00
|
|
|
else if( !wcsnicmp( str->data, L"AND", len ) )
|
2005-10-29 13:08:05 +02:00
|
|
|
rc = COND_AND;
|
2020-10-29 11:47:14 +01:00
|
|
|
else if( !wcsnicmp( str->data, L"XOR", len ) )
|
2005-10-29 13:08:05 +02:00
|
|
|
rc = COND_XOR;
|
2020-10-29 11:47:14 +01:00
|
|
|
else if( !wcsnicmp( str->data, L"EQV", len ) )
|
2005-10-29 13:08:05 +02:00
|
|
|
rc = COND_EQV;
|
2020-10-29 11:47:14 +01:00
|
|
|
else if( !wcsnicmp( str->data, L"IMP", len ) )
|
2005-10-29 13:08:05 +02:00
|
|
|
rc = COND_IMP;
|
|
|
|
}
|
2020-10-29 11:47:14 +01:00
|
|
|
else if( (len == 2) && !wcsnicmp( str->data, L"OR", len ) )
|
2004-06-29 01:57:11 +02:00
|
|
|
rc = COND_OR;
|
2004-06-28 22:34:35 +02:00
|
|
|
}
|
2005-10-29 13:08:05 +02:00
|
|
|
else if( COND_IsNumber( ch ) )
|
|
|
|
{
|
|
|
|
while( COND_IsNumber( str->data[len] ) )
|
|
|
|
len++;
|
|
|
|
rc = COND_NUMBER;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Got unknown character %c(%x)\n",ch,ch);
|
|
|
|
return COND_ERROR;
|
|
|
|
}
|
2004-06-29 01:57:11 +02:00
|
|
|
|
|
|
|
cond->n += len;
|
|
|
|
str->len = len;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-09-11 21:53:04 +02:00
|
|
|
static int cond_lex( void *COND_lval, COND_input *cond )
|
2004-06-29 01:57:11 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct cond_str *str = COND_lval;
|
|
|
|
|
|
|
|
do {
|
|
|
|
rc = COND_GetOne( str, cond );
|
|
|
|
} while (rc == COND_SPACE);
|
2020-10-29 11:47:14 +01:00
|
|
|
|
2004-06-28 22:34:35 +02:00
|
|
|
return rc;
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
|
|
|
|
2010-01-08 04:00:08 +01:00
|
|
|
static LPWSTR COND_GetString( COND_input *cond, const struct cond_str *str )
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
2004-06-29 01:57:11 +02:00
|
|
|
LPWSTR ret;
|
2004-03-16 04:23:43 +01:00
|
|
|
|
2010-01-08 04:00:08 +01:00
|
|
|
ret = cond_alloc( cond, (str->len+1) * sizeof (WCHAR) );
|
2004-06-29 01:57:11 +02:00
|
|
|
if( ret )
|
2004-06-28 22:34:35 +02:00
|
|
|
{
|
2005-04-18 12:30:55 +02:00
|
|
|
memcpy( ret, str->data, str->len * sizeof(WCHAR));
|
2004-06-29 01:57:11 +02:00
|
|
|
ret[str->len]=0;
|
2004-06-28 22:34:35 +02:00
|
|
|
}
|
2004-06-29 01:57:11 +02:00
|
|
|
TRACE("Got identifier %s\n",debugstr_w(ret));
|
|
|
|
return ret;
|
2004-03-16 04:23:43 +01:00
|
|
|
}
|
|
|
|
|
2010-01-08 04:00:08 +01:00
|
|
|
static LPWSTR COND_GetLiteral( COND_input *cond, const struct cond_str *str )
|
2004-07-29 04:36:06 +02:00
|
|
|
{
|
|
|
|
LPWSTR ret;
|
|
|
|
|
2010-01-08 04:00:08 +01:00
|
|
|
ret = cond_alloc( cond, (str->len-1) * sizeof (WCHAR) );
|
2004-07-29 04:36:06 +02:00
|
|
|
if( ret )
|
|
|
|
{
|
|
|
|
memcpy( ret, str->data+1, (str->len-2) * sizeof(WCHAR) );
|
|
|
|
ret[str->len - 2]=0;
|
|
|
|
}
|
|
|
|
TRACE("Got literal %s\n",debugstr_w(ret));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-01-08 04:00:08 +01:00
|
|
|
static void *cond_alloc( COND_input *cond, unsigned int sz )
|
|
|
|
{
|
|
|
|
struct list *mem;
|
|
|
|
|
|
|
|
mem = msi_alloc( sizeof (struct list) + sz );
|
|
|
|
if( !mem )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
list_add_head( &(cond->mem), mem );
|
|
|
|
return mem + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *cond_track_mem( COND_input *cond, void *ptr, unsigned int sz )
|
|
|
|
{
|
|
|
|
void *new_ptr;
|
|
|
|
|
|
|
|
if( !ptr )
|
|
|
|
return ptr;
|
|
|
|
|
|
|
|
new_ptr = cond_alloc( cond, sz );
|
|
|
|
if( !new_ptr )
|
|
|
|
{
|
|
|
|
msi_free( ptr );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy( new_ptr, ptr, sz );
|
|
|
|
msi_free( ptr );
|
|
|
|
return new_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cond_free( void *ptr )
|
|
|
|
{
|
|
|
|
struct list *mem = (struct list *)ptr - 1;
|
|
|
|
|
|
|
|
if( ptr )
|
|
|
|
{
|
|
|
|
list_remove( mem );
|
|
|
|
msi_free( mem );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-01 12:00:04 +02:00
|
|
|
static int cond_error( COND_input *info, const char *str )
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
2005-10-28 12:41:05 +02:00
|
|
|
TRACE("%s\n", str );
|
2004-03-16 04:23:43 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *package, LPCWSTR szCondition )
|
2004-03-16 04:23:43 +01:00
|
|
|
{
|
|
|
|
COND_input cond;
|
|
|
|
MSICONDITION r;
|
2010-01-08 04:00:08 +01:00
|
|
|
struct list *mem, *safety;
|
2004-03-16 04:23:43 +01:00
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
TRACE("%s\n", debugstr_w( szCondition ) );
|
|
|
|
|
2011-06-30 12:16:02 +02:00
|
|
|
if (szCondition == NULL) return MSICONDITION_NONE;
|
2005-10-28 12:41:05 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
cond.package = package;
|
2004-03-16 04:23:43 +01:00
|
|
|
cond.str = szCondition;
|
|
|
|
cond.n = 0;
|
2005-10-28 12:41:05 +02:00
|
|
|
cond.result = MSICONDITION_ERROR;
|
2010-01-08 04:00:08 +01:00
|
|
|
|
|
|
|
list_init( &cond.mem );
|
|
|
|
|
2006-09-11 21:53:04 +02:00
|
|
|
if ( !cond_parse( &cond ) )
|
2004-03-16 04:23:43 +01:00
|
|
|
r = cond.result;
|
|
|
|
else
|
|
|
|
r = MSICONDITION_ERROR;
|
|
|
|
|
2010-01-08 04:00:08 +01:00
|
|
|
LIST_FOR_EACH_SAFE( mem, safety, &cond.mem )
|
|
|
|
{
|
|
|
|
/* The tracked memory lives directly after the list struct */
|
|
|
|
void *ptr = mem + 1;
|
|
|
|
if ( r != MSICONDITION_ERROR )
|
|
|
|
WARN( "condition parser failed to free up some memory: %p\n", ptr );
|
|
|
|
cond_free( ptr );
|
|
|
|
}
|
|
|
|
|
2005-10-29 13:08:05 +02:00
|
|
|
TRACE("%i <- %s\n", r, debugstr_w(szCondition));
|
2004-03-16 04:23:43 +01:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
MSICONDITION WINAPI MsiEvaluateConditionW( MSIHANDLE hInstall, LPCWSTR szCondition )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
|
2007-07-06 02:53:03 +02:00
|
|
|
if( !package )
|
|
|
|
{
|
2018-04-16 03:52:10 +02:00
|
|
|
MSIHANDLE remote;
|
2007-07-06 02:53:03 +02:00
|
|
|
|
2018-04-16 03:52:10 +02:00
|
|
|
if (!(remote = msi_get_remote(hInstall)))
|
2007-07-06 02:53:03 +02:00
|
|
|
return MSICONDITION_ERROR;
|
|
|
|
|
2018-04-25 05:27:40 +02:00
|
|
|
if (!szCondition)
|
|
|
|
return MSICONDITION_NONE;
|
2007-07-06 02:53:03 +02:00
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
ret = remote_EvaluateCondition(remote, szCondition);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
ret = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
|
|
|
return ret;
|
2007-07-06 02:53:03 +02:00
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
ret = MSI_EvaluateConditionW( package, szCondition );
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-03-16 04:23:43 +01:00
|
|
|
MSICONDITION WINAPI MsiEvaluateConditionA( MSIHANDLE hInstall, LPCSTR szCondition )
|
|
|
|
{
|
|
|
|
LPWSTR szwCond = NULL;
|
|
|
|
MSICONDITION r;
|
|
|
|
|
2005-10-28 12:41:05 +02:00
|
|
|
szwCond = strdupAtoW( szCondition );
|
|
|
|
if( szCondition && !szwCond )
|
|
|
|
return MSICONDITION_ERROR;
|
2004-03-16 04:23:43 +01:00
|
|
|
|
|
|
|
r = MsiEvaluateConditionW( hInstall, szwCond );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwCond );
|
2004-03-16 04:23:43 +01:00
|
|
|
return r;
|
|
|
|
}
|