Fix error handling in MsiEvaluateCondition.
[wine] / dlls / msi / cond.y
1 %{
2
3 /*
4  * Implementation of the Microsoft Installer (msi.dll)
5  *
6  * Copyright 2003 Mike McCormack for CodeWeavers
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #include "config.h"
24
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
33
34 #include "msi.h"
35 #include "msiquery.h"
36 #include "msipriv.h"
37
38 #define YYLEX_PARAM info
39 #define YYPARSE_PARAM info
40
41 static int COND_error(const char *str);
42
43 WINE_DEFAULT_DEBUG_CHANNEL(msi);
44
45 typedef struct tag_yyinput
46 {
47     MSIPACKAGE *package;
48     LPCWSTR str;
49     INT    n;
50     MSICONDITION result;
51 } COND_input;
52
53 struct cond_str {
54     LPCWSTR data;
55     INT len;
56 };
57
58 static LPWSTR COND_GetString( struct cond_str *str );
59 static LPWSTR COND_GetLiteral( struct cond_str *str );
60 static int COND_lex( void *COND_lval, COND_input *info);
61
62 typedef INT (*comp_int)(INT a, INT b);
63 typedef INT (*comp_str)(LPWSTR a, LPWSTR b, BOOL caseless);
64 typedef INT (*comp_m1)(LPWSTR a,int b);
65 typedef INT (*comp_m2)(int a,LPWSTR b);
66
67 static INT comp_lt_i(INT a, INT b);
68 static INT comp_gt_i(INT a, INT b);
69 static INT comp_le_i(INT a, INT b);
70 static INT comp_ge_i(INT a, INT b);
71 static INT comp_eq_i(INT a, INT b);
72 static INT comp_ne_i(INT a, INT b);
73 static INT comp_bitand(INT a, INT b);
74 static INT comp_highcomp(INT a, INT b);
75 static INT comp_lowcomp(INT a, INT b);
76
77 static INT comp_eq_s(LPWSTR a, LPWSTR b, BOOL casless);
78 static INT comp_ne_s(LPWSTR a, LPWSTR b, BOOL casless);
79 static INT comp_lt_s(LPWSTR a, LPWSTR b, BOOL casless);
80 static INT comp_gt_s(LPWSTR a, LPWSTR b, BOOL casless);
81 static INT comp_le_s(LPWSTR a, LPWSTR b, BOOL casless);
82 static INT comp_ge_s(LPWSTR a, LPWSTR b, BOOL casless);
83 static INT comp_substring(LPWSTR a, LPWSTR b, BOOL casless);
84 static INT comp_start(LPWSTR a, LPWSTR b, BOOL casless);
85 static INT comp_end(LPWSTR a, LPWSTR b, BOOL casless);
86
87 static INT comp_eq_m1(LPWSTR a, INT b);
88 static INT comp_ne_m1(LPWSTR a, INT b);
89 static INT comp_lt_m1(LPWSTR a, INT b);
90 static INT comp_gt_m1(LPWSTR a, INT b);
91 static INT comp_le_m1(LPWSTR a, INT b);
92 static INT comp_ge_m1(LPWSTR a, INT b);
93
94 static INT comp_eq_m2(INT a, LPWSTR b);
95 static INT comp_ne_m2(INT a, LPWSTR b);
96 static INT comp_lt_m2(INT a, LPWSTR b);
97 static INT comp_gt_m2(INT a, LPWSTR b);
98 static INT comp_le_m2(INT a, LPWSTR b);
99 static INT comp_ge_m2(INT a, LPWSTR b);
100
101 %}
102
103 %pure-parser
104
105 %union
106 {
107     struct cond_str str;
108     LPWSTR    string;
109     INT       value;
110     comp_int  fn_comp_int;
111     comp_str  fn_comp_str;
112     comp_m1   fn_comp_m1;
113     comp_m2   fn_comp_m2;
114 }
115
116 %token COND_SPACE COND_EOF COND_SPACE
117 %token COND_OR COND_AND COND_NOT
118 %token COND_LT COND_GT COND_EQ 
119 %token COND_LPAR COND_RPAR COND_TILDA
120 %token COND_PERCENT COND_DOLLARS COND_QUESTION COND_AMPER COND_EXCLAM
121 %token <str> COND_IDENT <str> COND_NUMBER <str> COND_LITER
122
123 %nonassoc COND_EOF COND_ERROR
124
125 %type <value> expression boolean_term boolean_factor 
126 %type <value> term value_i symbol_i integer
127 %type <string> identifier value_s symbol_s literal
128 %type <fn_comp_int> comp_op_i
129 %type <fn_comp_str> comp_op_s 
130 %type <fn_comp_m1>  comp_op_m1 
131 %type <fn_comp_m2>  comp_op_m2
132
133 %%
134
135 condition:
136     expression
137         {
138             COND_input* cond = (COND_input*) info;
139             cond->result = $1;
140         }
141   | /* empty */
142         {
143             COND_input* cond = (COND_input*) info;
144             cond->result = MSICONDITION_NONE;
145         }
146     ;
147
148 expression:
149     boolean_term 
150         {
151             $$ = $1;
152         }
153   | boolean_term COND_OR expression
154         {
155             $$ = $1 || $3;
156         }
157     ;
158
159 boolean_term:
160     boolean_factor
161         {
162             $$ = $1;
163         }
164     | boolean_term COND_AND boolean_factor
165         {
166             $$ = $1 && $3;
167         }
168     ;
169
170 boolean_factor:
171     term
172         {
173             $$ = $1;
174         }
175   | COND_NOT term
176         {
177             $$ = ! $2;
178         }
179     ;
180
181
182 term:
183     value_i
184         {
185             $$ = $1;
186         }
187   | value_s
188         {
189             $$ = ($1 && $1[0]) ? MSICONDITION_TRUE : MSICONDITION_FALSE;
190             msi_free( $1 );
191         }
192   | value_i comp_op_i value_i
193         {
194             $$ = $2( $1, $3 );
195         }
196   | value_s comp_op_s value_s
197         {
198             $$ = $2( $1, $3, FALSE );
199             msi_free( $1 );
200             msi_free( $3 );
201         }
202   | value_s COND_TILDA comp_op_s value_s
203         {
204             $$ = $3( $1, $4, TRUE );
205             msi_free( $1 );
206             msi_free( $4 );
207         }
208   | value_s comp_op_m1 value_i
209         {
210             $$ = $2( $1, $3 );
211             msi_free( $1 );
212         }
213   | value_i comp_op_m2 value_s
214         {
215             $$ = $2( $1, $3 );
216             msi_free( $3 );
217         }
218   | COND_LPAR expression COND_RPAR
219         {
220             $$ = $2;
221         }
222     ;
223
224 comp_op_i:
225     /* common functions */
226    COND_EQ
227         {
228             $$ = comp_eq_i;
229         }
230   | COND_LT COND_GT
231         {
232             $$ = comp_ne_i;
233         }
234   | COND_LT
235         {
236             $$ = comp_lt_i;
237         }
238   | COND_GT
239         {
240             $$ = comp_gt_i;
241         }
242   | COND_LT COND_EQ
243         {
244             $$ = comp_le_i;
245         }
246   | COND_GT COND_EQ
247         {
248             $$ = comp_ge_i;
249         }
250   /*Int only*/
251   | COND_GT COND_LT
252         {
253             $$ = comp_bitand;
254         }
255   | COND_LT COND_LT
256         {
257             $$ = comp_highcomp;
258         }
259   | COND_GT COND_GT
260         {
261             $$ = comp_lowcomp;
262         }
263     ;
264
265 comp_op_s:
266     /* common functions */
267    COND_EQ
268         {
269             $$ = comp_eq_s;
270         }
271   | COND_LT COND_GT
272         {
273             $$ = comp_ne_s;
274         }
275   | COND_LT
276         {
277             $$ = comp_lt_s;
278         }
279   | COND_GT
280         {
281             $$ = comp_gt_s;
282         }
283   | COND_LT COND_EQ
284         {
285             $$ = comp_le_s;
286         }
287   | COND_GT COND_EQ
288         {
289             $$ = comp_ge_s;
290         }
291   /*string only*/
292   | COND_GT COND_LT
293         {
294             $$ = comp_substring;
295         }
296   | COND_LT COND_LT
297         {
298             $$ = comp_start;
299         }
300   | COND_GT COND_GT
301         {
302             $$ = comp_end;
303         }
304     ;
305
306 comp_op_m1:
307     /* common functions */
308    COND_EQ
309         {
310             $$ = comp_eq_m1;
311         }
312   | COND_LT COND_GT
313         {
314             $$ = comp_ne_m1;
315         }
316   | COND_LT
317         {
318             $$ = comp_lt_m1;
319         }
320   | COND_GT
321         {
322             $$ = comp_gt_m1;
323         }
324   | COND_LT COND_EQ
325         {
326             $$ = comp_le_m1;
327         }
328   | COND_GT COND_EQ
329         {
330             $$ = comp_ge_m1;
331         }
332   /*Not valid for mixed compares*/
333   | COND_GT COND_LT
334         {
335             $$ = 0;
336         }
337   | COND_LT COND_LT
338         {
339             $$ = 0;
340         }
341   | COND_GT COND_GT
342         {
343             $$ = 0;
344         }
345     ;
346
347 comp_op_m2:
348     /* common functions */
349    COND_EQ
350         {
351             $$ = comp_eq_m2;
352         }
353   | COND_LT COND_GT
354         {
355             $$ = comp_ne_m2;
356         }
357   | COND_LT
358         {
359             $$ = comp_lt_m2;
360         }
361   | COND_GT
362         {
363             $$ = comp_gt_m2;
364         }
365   | COND_LT COND_EQ
366         {
367             $$ = comp_le_m2;
368         }
369   | COND_GT COND_EQ
370         {
371             $$ = comp_ge_m2;
372         }
373   /*Not valid for mixed compares*/
374   | COND_GT COND_LT
375         {
376             $$ = 0;
377         }
378   | COND_LT COND_LT
379         {
380             $$ = 0;
381         }
382   | COND_GT COND_GT
383         {
384             $$ = 0;
385         }
386     ;
387
388 value_i:
389     symbol_i
390         {
391             $$ = $1;
392         }
393   | integer
394         {
395             $$ = $1;
396         }
397     ;
398
399 value_s:
400   symbol_s
401     {
402         $$ = $1;
403     } 
404   | literal
405     {
406         $$ = $1;
407     }
408     ;
409
410 literal:
411     COND_LITER
412         {
413             $$ = COND_GetLiteral(&$1);
414             if( !$$ )
415                 YYABORT;
416         }
417     ;
418
419 symbol_i:
420     COND_DOLLARS identifier
421         {
422             COND_input* cond = (COND_input*) info;
423             INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
424       
425             MSI_GetComponentStateW(cond->package, $2, &install, &action );
426             $$ = action;
427             msi_free( $2 );
428         }
429   | COND_QUESTION identifier
430         {
431             COND_input* cond = (COND_input*) info;
432             INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
433       
434             MSI_GetComponentStateW(cond->package, $2, &install, &action );
435             $$ = install;
436             msi_free( $2 );
437         }
438   | COND_AMPER identifier
439         {
440             COND_input* cond = (COND_input*) info;
441             INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
442       
443             MSI_GetFeatureStateW(cond->package, $2, &install, &action );
444             $$ = action;
445             msi_free( $2 );
446         }
447   | COND_EXCLAM identifier
448         {
449             COND_input* cond = (COND_input*) info;
450             INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
451       
452             MSI_GetFeatureStateW(cond->package, $2, &install, &action );
453             $$ = install;
454             msi_free( $2 );
455         }
456     ;
457
458 symbol_s:
459     identifier
460         {
461             DWORD sz;
462             COND_input* cond = (COND_input*) info;
463
464             sz = 0;
465             MSI_GetPropertyW(cond->package, $1, NULL, &sz);
466             if (sz == 0)
467             {
468                 $$ = msi_alloc( sizeof(WCHAR));
469                 $$[0] = 0;
470             }
471             else
472             {
473                 sz ++;
474                 $$ = msi_alloc( sz*sizeof (WCHAR) );
475
476                 /* Lookup the identifier */
477
478                 MSI_GetPropertyW(cond->package,$1,$$,&sz);
479             }
480             msi_free( $1 );
481         }
482     | COND_PERCENT identifier
483         {
484             UINT len = GetEnvironmentVariableW( $2, NULL, 0 );
485             if( len++ )
486             {
487                 $$ = msi_alloc( len*sizeof (WCHAR) );
488                 if( $$ )
489                     GetEnvironmentVariableW( $2, $$, len );
490             }
491             msi_free( $2 );
492         }
493     ;
494
495 identifier:
496     COND_IDENT
497         {
498             $$ = COND_GetString(&$1);
499             if( !$$ )
500                 YYABORT;
501         }
502     ;
503
504 integer:
505     COND_NUMBER
506         {
507             LPWSTR szNum = COND_GetString(&$1);
508             if( !szNum )
509                 YYABORT;
510             $$ = atoiW( szNum );
511             msi_free( szNum );
512         }
513     ;
514
515 %%
516
517
518 static int COND_IsAlpha( WCHAR x )
519 {
520     return( ( ( x >= 'A' ) && ( x <= 'Z' ) ) ||
521             ( ( x >= 'a' ) && ( x <= 'z' ) ) ||
522             ( ( x == '_' ) ) );
523 }
524
525 static int COND_IsNumber( WCHAR x )
526 {
527     return( (( x >= '0' ) && ( x <= '9' ))  || (x =='-') || (x =='.') );
528 }
529
530
531 /* the mess of comparison functions */
532
533 static INT comp_lt_i(INT a, INT b)
534 { return (a < b); }
535 static INT comp_gt_i(INT a, INT b)
536 { return (a > b); }
537 static INT comp_le_i(INT a, INT b)
538 { return (a <= b); }
539 static INT comp_ge_i(INT a, INT b)
540 { return (a >= b); }
541 static INT comp_eq_i(INT a, INT b)
542 { return (a == b); }
543 static INT comp_ne_i(INT a, INT b)
544 { return (a != b); }
545 static INT comp_bitand(INT a, INT b)
546 { return a & b;}
547 static INT comp_highcomp(INT a, INT b)
548 { return HIWORD(a)==b; }
549 static INT comp_lowcomp(INT a, INT b)
550 { return LOWORD(a)==b; }
551
552 static INT comp_eq_s(LPWSTR a, LPWSTR b, BOOL casless)
553 { if (casless) return !strcmpiW(a,b); else return !strcmpW(a,b);}
554 static INT comp_ne_s(LPWSTR a, LPWSTR b, BOOL casless)
555 { if (casless) return strcmpiW(a,b); else  return strcmpW(a,b);}
556 static INT comp_lt_s(LPWSTR a, LPWSTR b, BOOL casless)
557 { if (casless) return strcmpiW(a,b)<0; else return strcmpW(a,b)<0;}
558 static INT comp_gt_s(LPWSTR a, LPWSTR b, BOOL casless)
559 { if (casless) return strcmpiW(a,b)>0; else return strcmpW(a,b)>0;}
560 static INT comp_le_s(LPWSTR a, LPWSTR b, BOOL casless)
561 { if (casless) return strcmpiW(a,b)<=0; else return strcmpW(a,b)<=0;}
562 static INT comp_ge_s(LPWSTR a, LPWSTR b, BOOL casless)
563 { if (casless) return strcmpiW(a,b)>=0; else return  strcmpW(a,b)>=0;}
564 static INT comp_substring(LPWSTR a, LPWSTR b, BOOL casless)
565 /* ERROR NOT WORKING REWRITE */
566 { if (casless) return strstrW(a,b)!=NULL; else return strstrW(a,b)!=NULL;}
567 static INT comp_start(LPWSTR a, LPWSTR b, BOOL casless)
568 { if (casless) return strncmpiW(a,b,strlenW(b))==0; 
569   else return strncmpW(a,b,strlenW(b))==0;}
570 static INT comp_end(LPWSTR a, LPWSTR b, BOOL casless)
571
572     int i = strlenW(a); 
573     int j = strlenW(b); 
574     if (j>i)
575         return 0;
576     if (casless) return (!strcmpiW(&a[i-j-1],b));
577     else  return (!strcmpW(&a[i-j-1],b));
578 }
579
580
581 static INT comp_eq_m1(LPWSTR a, INT b)
582 { if (COND_IsNumber(a[0])) return atoiW(a)==b; else return 0;}
583 static INT comp_ne_m1(LPWSTR a, INT b)
584 { if (COND_IsNumber(a[0])) return atoiW(a)!=b; else return 1;}
585 static INT comp_lt_m1(LPWSTR a, INT b)
586 { if (COND_IsNumber(a[0])) return atoiW(a)<b; else return 0;}
587 static INT comp_gt_m1(LPWSTR a, INT b)
588 { if (COND_IsNumber(a[0])) return atoiW(a)>b; else return 0;}
589 static INT comp_le_m1(LPWSTR a, INT b)
590 { if (COND_IsNumber(a[0])) return atoiW(a)<=b; else return 0;}
591 static INT comp_ge_m1(LPWSTR a, INT b)
592 { if (COND_IsNumber(a[0])) return atoiW(a)>=b; else return 0;}
593
594 static INT comp_eq_m2(INT a, LPWSTR b)
595 { if (COND_IsNumber(b[0])) return a == atoiW(b); else return 0;}
596 static INT comp_ne_m2(INT a, LPWSTR b)
597 { if (COND_IsNumber(b[0])) return a != atoiW(b); else return 1;}
598 static INT comp_lt_m2(INT a, LPWSTR b)
599 { if (COND_IsNumber(b[0])) return a < atoiW(b); else return 0;}
600 static INT comp_gt_m2(INT a, LPWSTR b)
601 { if (COND_IsNumber(b[0])) return a > atoiW(b); else return 0;}
602 static INT comp_le_m2(INT a, LPWSTR b)
603 { if (COND_IsNumber(b[0])) return a <= atoiW(b); else return 0;}
604 static INT comp_ge_m2(INT a, LPWSTR b)
605 { if (COND_IsNumber(b[0])) return a >= atoiW(b); else return 0;}
606
607
608
609 static int COND_IsIdent( WCHAR x )
610 {
611     return( COND_IsAlpha( x ) || COND_IsNumber( x ) || ( x == '_' ) 
612             || ( x == '#' ) || (x == '.') );
613 }
614
615 static int COND_GetOne( struct cond_str *str, COND_input *cond )
616 {
617     static const WCHAR szNot[] = {'N','O','T',0};
618     static const WCHAR szAnd[] = {'A','N','D',0};
619     static const WCHAR szOr[] = {'O','R',0};
620     WCHAR ch;
621     int rc, len = 1;
622
623     str->data = &cond->str[cond->n];
624
625     ch = str->data[0];
626     switch( ch )
627     {
628     case 0: return 0;
629     case '(': rc = COND_LPAR; break;
630     case ')': rc = COND_RPAR; break;
631     case '&': rc = COND_AMPER; break;
632     case '!': rc = COND_EXCLAM; break;
633     case '$': rc = COND_DOLLARS; break;
634     case '?': rc = COND_QUESTION; break;
635     case '%': rc = COND_PERCENT; break;
636     case ' ': rc = COND_SPACE; break;
637     case '=': rc = COND_EQ; break;
638     case '~': rc = COND_TILDA; break;
639     case '<': rc = COND_LT; break;
640     case '>': rc = COND_GT; break;
641     case '"':
642         {
643             const WCHAR *ch2 = str->data + 1;
644
645
646             while ( *ch2 && *ch2 != '"' )
647                 ++ch2;
648             if (*ch2 == '"')
649             {
650                 len = ch2 - str->data + 1;
651                 rc = COND_LITER;
652                 break;
653             }
654         }
655         ERR("Unterminated string\n");
656         rc = COND_ERROR;
657         break;
658     default: 
659         if( COND_IsAlpha( ch ) )
660         {
661             while( COND_IsIdent( str->data[len] ) )
662                 len++;
663             rc = COND_IDENT;
664             break;
665         }
666
667         if( COND_IsNumber( ch ) )
668         {
669             while( COND_IsNumber( str->data[len] ) )
670                 len++;
671             rc = COND_NUMBER;
672             break;
673         }
674
675         ERR("Got unknown character %c(%x)\n",ch,ch);
676         rc = COND_ERROR;
677         break;
678     }
679
680     /* keyword identifiers */
681     if( rc == COND_IDENT )
682     {
683         if( (len==3) && (strncmpiW(str->data,szNot,len)==0) )
684             rc = COND_NOT;
685         else if( (len==3) && (strncmpiW(str->data,szAnd,len)==0) )
686             rc = COND_AND;
687         else if( (len==2) && (strncmpiW(str->data,szOr,len)==0) )
688             rc = COND_OR;
689     }
690
691     cond->n += len;
692     str->len = len;
693
694     return rc;
695 }
696
697 static int COND_lex( void *COND_lval, COND_input *cond )
698 {
699     int rc;
700     struct cond_str *str = COND_lval;
701
702     do {
703         rc = COND_GetOne( str, cond );
704     } while (rc == COND_SPACE);
705     
706     return rc;
707 }
708
709 static LPWSTR COND_GetString( struct cond_str *str )
710 {
711     LPWSTR ret;
712
713     ret = msi_alloc( (str->len+1) * sizeof (WCHAR) );
714     if( ret )
715     {
716         memcpy( ret, str->data, str->len * sizeof(WCHAR));
717         ret[str->len]=0;
718     }
719     TRACE("Got identifier %s\n",debugstr_w(ret));
720     return ret;
721 }
722
723 static LPWSTR COND_GetLiteral( struct cond_str *str )
724 {
725     LPWSTR ret;
726
727     ret = msi_alloc( (str->len-1) * sizeof (WCHAR) );
728     if( ret )
729     {
730         memcpy( ret, str->data+1, (str->len-2) * sizeof(WCHAR) );
731         ret[str->len - 2]=0;
732     }
733     TRACE("Got literal %s\n",debugstr_w(ret));
734     return ret;
735 }
736
737 static int COND_error(const char *str)
738 {
739     TRACE("%s\n", str );
740     return 0;
741 }
742
743 MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *package, LPCWSTR szCondition )
744 {
745     COND_input cond;
746     MSICONDITION r;
747
748     if ( szCondition == NULL )
749         return MSICONDITION_NONE;
750
751     cond.package = package;
752     cond.str   = szCondition;
753     cond.n     = 0;
754     cond.result = MSICONDITION_ERROR;
755     
756     TRACE("Evaluating %s\n",debugstr_w(szCondition));    
757
758     if ( !COND_parse( &cond ) )
759         r = cond.result;
760     else
761         r = MSICONDITION_ERROR;
762
763     TRACE("Evaluates to %i\n",r);
764     return r;
765 }
766
767 MSICONDITION WINAPI MsiEvaluateConditionW( MSIHANDLE hInstall, LPCWSTR szCondition )
768 {
769     MSIPACKAGE *package;
770     UINT ret;
771
772     package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
773     if( !package)
774         return MSICONDITION_ERROR;
775     ret = MSI_EvaluateConditionW( package, szCondition );
776     msiobj_release( &package->hdr );
777     return ret;
778 }
779
780 MSICONDITION WINAPI MsiEvaluateConditionA( MSIHANDLE hInstall, LPCSTR szCondition )
781 {
782     LPWSTR szwCond = NULL;
783     MSICONDITION r;
784
785     szwCond = strdupAtoW( szCondition );
786     if( szCondition && !szwCond )
787         return MSICONDITION_ERROR;
788
789     r = MsiEvaluateConditionW( hInstall, szwCond );
790     msi_free( szwCond );
791     return r;
792 }