From 2d3d7c7078cf1646365b0c04b6790b14d64a1a43 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=A9=20van=20Geldorp?= Date: Thu, 26 May 2005 21:55:34 +0000 Subject: [PATCH] Sync to Wine-20050524: Alexander Julliard - Added rules for building import libraries in the individual dll makefiles, and added support for building a .def.a static import library too. Aric Stewart - Fix a few leaking object handles. - Correct user component publication. - Implement MsiEnumComponentQualifiers. - Implement Publish Components in order for MsiGetQualifiedComponent apis to work. Also implement MsiGetQualifiedComponent, or at least some of the functionality as it is supposed to install stuff if it is absent, which it does not do yet. - Correct query quoting based on Mike's patch. Also more error messages about return codes from custom actions and ignore an error that we should be ignoring. - Double terminate SZ_MULTI properly. - ClassInfo and ExtensionInfo are also written for ADVERTISED components. - Write the RegOwner and RegCompany keys as blank if they do not exist when doing the RegisterUser action. - Fix quoting on queries. - Respect '+' and '*' in WriteRegistryValues to only create the key if it does not already exist. Prevents overwriting values with NULL. - We cannot internally load the files in FileCost because that action may be skipped or not called. So do it in CostInitialize. - Quote the file path in SelfRegModules. - Do not write squished null guids to the feature registration. - Correctly use short filenames from uncompressed file sources. Also default feature and component install states to ABSENT instead of UNKNOWN. - Correct a problem with parse_data if binary data was not in full bytes. - More properly handle uncompressed file sources, fix the creating and parsing of Source Directories. - ExecuteAction runs the whole Execute table and not just from InstallValidate onward. To do this make sure we do not do the costing initialization work again if it is already done (by checking the CostingComplete Property). - A lot of work to refine feature states, setting the state affects the state of all child features and also respect features that want to default to something other than LOCAL. - Fix a few leaking object handles. - Correct user component publication. - Implement MsiEnumComponentQualifiers. - We have a stub for MsiGetUserInfoA we should use it. - A few small fixes. - Add a missing msiobj_release that was resulting in a leaked object with each MsiCreateRecord call. - Fix a leaking handle. - Make MsiCollectUserInfo more internally consistent. Thanks to Mike McCormack. - Fix a leaking handle in MsiConfigureProductExW. - Implement MsiGetProductCodeW. - Implement MsiGetUserInfoW. - Implement MsiCollectUserInfoA/W. - Implement MsiQueryFeatureStateW. - Correct a leaking hkey handle. - Expand some handling of special properties in MsiGetProductInfo. - Fix for the return codes for the Qualified component calls. They are not INSTALLSTATEs but rather success values. - Quoting fixes. Mike McCormack - Make sure that dialogs are only created and destroyed in a single thread. - Track memory allocations in the SQL parser. - Create the ORDER BY view in a single call. - Simplify parsing of the FROM keyword. - Improve parser error checking. - Simplify parsing of select query. - remove the unused utf8 field of an expression - make the parse result a single assignment at top level of parsing - abort parsing on a memory allocation failure - Only tables can be backquoted, strings must be single quoted. - Declare MsiExportDatabase* in the spec file, and fix a typo. - make sure to free the string table when closing the database - don't free szPersist in MsiOpenDatabase if it's not a string - Avoid some non-standard str functions. Francois Gouget - Tweak the documentation to make winapi_check happy. Juan Lang - Don't fail in RegisterFonts if the Fonts table is missing. - Partially implement AppSearch for RegLocator-type searches. - Turn handled errors from ERRs to WARNs or TRACEs. Vincent Beron - Use SUBLANG_NEUTRAL for French resources. Stefan Leichter - Update version resource of msi.dll to current version shipped from windows update. - Added minimal implementation of MsiCreateAndVerifyInstallerDirectory. Marcus Meissner - Set PhysicalMemory property from system data. svn path=/trunk/; revision=15537 --- reactos/include/wine/msidefs.h | 27 + reactos/lib/msi/Makefile.in | 1 + reactos/lib/msi/action.c | 782 ++++-- reactos/lib/msi/action.h | 1 + reactos/lib/msi/appsearch.c | 127 +- reactos/lib/msi/cond.tab.c | 4261 ++++++++++++++--------------- reactos/lib/msi/cond.y | 6 +- reactos/lib/msi/create.c | 12 +- reactos/lib/msi/custom.c | 31 +- reactos/lib/msi/database.c | 6 +- reactos/lib/msi/dialog.c | 228 +- reactos/lib/msi/insert.c | 1 - reactos/lib/msi/msi.c | 394 ++- reactos/lib/msi/msi.spec | 10 +- reactos/lib/msi/msi_Fr.rc | 2 +- reactos/lib/msi/msipriv.h | 10 +- reactos/lib/msi/msiquery.c | 15 +- reactos/lib/msi/order.c | 70 +- reactos/lib/msi/package.c | 20 +- reactos/lib/msi/query.h | 14 +- reactos/lib/msi/record.c | 1 + reactos/lib/msi/registry.c | 167 +- reactos/lib/msi/sql.tab.c | 4662 +++++++++++++++----------------- reactos/lib/msi/sql.y | 394 ++- reactos/lib/msi/suminfo.c | 64 +- reactos/lib/msi/table.c | 54 +- reactos/lib/msi/tokenize.c | 5 +- reactos/lib/msi/update.c | 1 - reactos/lib/msi/version.rc | 8 +- reactos/lib/msi/where.c | 3 - 30 files changed, 5973 insertions(+), 5404 deletions(-) diff --git a/reactos/include/wine/msidefs.h b/reactos/include/wine/msidefs.h index f266b32172c..71b054b80ca 100644 --- a/reactos/include/wine/msidefs.h +++ b/reactos/include/wine/msidefs.h @@ -23,6 +23,17 @@ extern "C" { #endif +enum msidbFileAttributes { + msidbFileAttributesReadOnly = 0x00000001, + msidbFileAttributesHidden = 0x00000002, + msidbFileAttributesSystem = 0x00000004, + msidbFileAttributesVital = 0x00000200, + msidbFileAttributesChecksum = 0x00000400, + msidbFileAttributesPatchAdded = 0x00001000, + msidbFileAttributesNoncompressed = 0x00002000, + msidbFileAttributesCompressed = 0x00004000 +}; + enum msidbDialogAttributes { msidbDialogAttributesVisible = 0x00000001, msidbDialogAttributesModal = 0x00000002, @@ -103,6 +114,22 @@ enum msidbComponentAttributes msidbComponentAttributes64bit = 0x00000100 }; +enum msidbRegistryRoot +{ + msidbRegistryRootClassesRoot = 0, + msidbRegistryRootCurrentUser = 1, + msidbRegistryRootLocalMachine = 2, + msidbRegistryRootUsers = 3, +}; + +enum msidbLocatorType +{ + msidbLocatorTypeDirectory = 0x000, + msidbLocatorTypeFileName = 0x001, + msidbLocatorTypeRawValue = 0x002, + msidbLocatorType64bit = 0x010, +}; + /* * Windows SDK braindamage alert * diff --git a/reactos/lib/msi/Makefile.in b/reactos/lib/msi/Makefile.in index 85c1eee55e3..12f85fdf719 100644 --- a/reactos/lib/msi/Makefile.in +++ b/reactos/lib/msi/Makefile.in @@ -3,6 +3,7 @@ TOPOBJDIR = ../.. SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = msi.dll +IMPORTLIB = libmsi.$(IMPLIBEXT) IMPORTS = shell32 cabinet oleaut32 ole32 version user32 gdi32 advapi32 kernel32 EXTRALIBS = -luuid $(LIBUNICODE) diff --git a/reactos/lib/msi/action.c b/reactos/lib/msi/action.c index ae48e3bcf75..caa26868694 100644 --- a/reactos/lib/msi/action.c +++ b/reactos/lib/msi/action.c @@ -99,6 +99,7 @@ static UINT ACTION_ForceReboot(MSIPACKAGE *package); static UINT ACTION_ResolveSource(MSIPACKAGE *package); static UINT ACTION_ExecuteAction(MSIPACKAGE *package); static UINT ACTION_RegisterFonts(MSIPACKAGE *package); +static UINT ACTION_PublishComponents(MSIPACKAGE *package); /* @@ -324,7 +325,7 @@ static struct _actions StandardActions[] = { { szInstallServices, NULL}, { szPatchFiles, NULL}, { szProcessComponents, ACTION_ProcessComponents }, - { szPublishComponents, NULL}, + { szPublishComponents, ACTION_PublishComponents }, { szPublishFeatures, ACTION_PublishFeatures }, { szPublishProduct, ACTION_PublishProduct }, { szRegisterClassInfo, ACTION_RegisterClassInfo }, @@ -380,6 +381,13 @@ inline static void reduce_to_longfilename(WCHAR* filename) memmove(filename, p+1, (strlenW(p+1)+1)*sizeof(WCHAR)); } +inline static void reduce_to_shortfilename(WCHAR* filename) +{ + LPWSTR p = strchrW(filename,'|'); + if (p) + *p = 0; +} + WCHAR *load_dynamic_stringW(MSIRECORD *row, INT index) { UINT rc; @@ -598,6 +606,7 @@ void ACTION_free_package_structures( MSIPACKAGE* package) { HeapFree(GetProcessHeap(),0,package->files[i].File); HeapFree(GetProcessHeap(),0,package->files[i].FileName); + HeapFree(GetProcessHeap(),0,package->files[i].ShortName); HeapFree(GetProcessHeap(),0,package->files[i].Version); HeapFree(GetProcessHeap(),0,package->files[i].Language); HeapFree(GetProcessHeap(),0,package->files[i].SourcePath); @@ -630,15 +639,16 @@ static void ui_progress(MSIPACKAGE *package, int a, int b, int c, int d ) MSI_ProcessMessage(package, INSTALLMESSAGE_PROGRESS, row); msiobj_release(&row->hdr); - msi_dialog_check_messages(package->dialog, NULL); + msi_dialog_check_messages(NULL); } static void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * record) { static const WCHAR Query_t[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'A','c','t','i','o', 'n','T','e','x','t',' ','W','H','E','R','E',' ', - 'A','c','t','i','o','n',' ','=', ' ','\'','%','s','\'',0}; + '`','A','c','t','i','o', 'n','T','e','x','t','`',' ', + 'W','H','E','R','E',' ', '`','A','c','t','i','o','n','`',' ','=', + ' ','\'','%','s','\'',0}; WCHAR message[1024]; UINT rc; MSIQUERY * view; @@ -655,12 +665,14 @@ static void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * recor if (rc != ERROR_SUCCESS) { MSI_ViewClose(view); + msiobj_release(&view->hdr); return; } rc = MSI_ViewFetch(view,&row); if (rc != ERROR_SUCCESS) { MSI_ViewClose(view); + msiobj_release(&view->hdr); return; } @@ -705,8 +717,9 @@ static void ui_actionstart(MSIPACKAGE *package, LPCWSTR action) {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0}; static const WCHAR Query_t[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'A','c','t','i','o', 'n','T','e','x','t',' ','W','H','E','R','E', ' ', - 'A','c','t','i','o','n',' ','=', ' ','\'','%','s','\'',0}; + '`','A','c','t','i','o', 'n','T','e','x','t','`',' ', + 'W','H','E','R','E', ' ','`','A','c','t','i','o','n','`',' ','=', + ' ','\'','%','s','\'',0}; WCHAR message[1024]; WCHAR timet[0x100]; UINT rc; @@ -1005,14 +1018,14 @@ static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq, BOOL UI) MSIRECORD * row = 0; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'I','n','s','t','a','l','l','E','x','e','c','u','t','e', - 'S','e','q','u','e','n','c','e',' ', 'W','H','E','R','E',' ', - 'S','e','q','u','e','n','c','e',' ', '=',' ','%','i',0}; + '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e', + 'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ', + '`','S','e','q','u','e','n','c','e','`',' ', '=',' ','%','i',0}; static const WCHAR UISeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e', - ' ', 'W','H','E','R','E',' ', 'S','e','q','u','e','n','c','e', + '`','I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e', + '`', ' ', 'W','H','E','R','E',' ','`','S','e','q','u','e','n','c','e','`', ' ', '=',' ','%','i',0}; if (UI) @@ -1090,18 +1103,19 @@ static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran) UINT rc; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ', - 'I','n','s','t','a','l','l','E','x','e','c','u','t','e', - 'S','e','q','u','e','n','c','e',' ', 'W','H','E','R','E',' ', - 'S','e','q','u','e','n','c','e',' ', '>',' ','%','i',' ', + '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e', + 'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ', + '`','S','e','q','u','e','n','c','e','`',' ', '>',' ','%','i',' ', 'O','R','D','E','R',' ', 'B','Y',' ', - 'S','e','q','u','e','n','c','e',0 }; + '`','S','e','q','u','e','n','c','e','`',0 }; MSIRECORD * row = 0; static const WCHAR IVQuery[] = - {'S','E','L','E','C','T',' ','S','e','q','u','e','n','c','e',' ', - 'F','R','O','M',' ','I','n','s','t','a','l','l', - 'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e',' ', - 'W','H','E','R','E',' ','A','c','t','i','o','n',' ','=',' ','`', - 'I','n','s','t','a','l','l','V','a','l','i','d','a','t','e','`', 0}; + {'S','E','L','E','C','T',' ','`','S','e','q','u','e','n','c','e','`', + ' ', 'F','R','O','M',' ','`','I','n','s','t','a','l','l', + 'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e','`',' ', + 'W','H','E','R','E',' ','`','A','c','t','i','o','n','`',' ','=', + ' ','\'', 'I','n','s','t','a','l','l', + 'V','a','l','i','d','a','t','e','\'', 0}; INT seq = 0; @@ -1225,10 +1239,12 @@ static UINT ACTION_ProcessUISequence(MSIPACKAGE *package) UINT rc; static const WCHAR ExecSeqQuery [] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e', - ' ','W','H','E','R','E',' ', 'S','e','q','u','e','n','c','e',' ', + '`','I','n','s','t','a','l','l', + 'U','I','S','e','q','u','e','n','c','e','`', + ' ','W','H','E','R','E',' ', + '`','S','e','q','u','e','n','c','e','`',' ', '>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ', - 'S','e','q','u','e','n','c','e',0}; + '`','S','e','q','u','e','n','c','e','`',0}; rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); @@ -1420,7 +1436,7 @@ UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action) if (!handled) handled = ACTION_HandleDialogBox(package, action, &rc); - msi_dialog_check_messages( package->dialog, NULL ); + msi_dialog_check_messages( NULL ); if (!handled) { @@ -1493,9 +1509,10 @@ static BOOL create_full_pathW(const WCHAR *path) static UINT ACTION_CreateFolders(MSIPACKAGE *package) { static const WCHAR ExecSeqQuery[] = - {'S','E','L','E','C','T',' ','D','i','r','e','c','t','o','r','y','_', + {'S','E','L','E','C','T',' ', + '`','D','i','r','e','c','t','o','r','y','_','`', ' ','F','R','O','M',' ', - 'C','r','e','a','t','e','F','o','l','d','e','r',0 }; + '`','C','r','e','a','t','e','F','o','l','d','e','r','`',0 }; UINT rc; MSIQUERY *view; MSIFOLDER *folder; @@ -1606,7 +1623,7 @@ static int load_component(MSIPACKAGE* package, MSIRECORD * row) sz = 96; MSI_RecordGetStringW(row,6,package->components[index].KeyPath,&sz); - package->components[index].Installed = INSTALLSTATE_UNKNOWN; + package->components[index].Installed = INSTALLSTATE_ABSENT; package->components[index].Action = INSTALLSTATE_UNKNOWN; package->components[index].ActionRequest = INSTALLSTATE_UNKNOWN; @@ -1620,14 +1637,18 @@ static void load_feature(MSIPACKAGE* package, MSIRECORD * row) int index = package->loaded_features; DWORD sz; static const WCHAR Query1[] = - {'S','E','L','E','C','T',' ','C','o','m','p','o','n','e','n','t','_', - ' ','F','R','O','M',' ','F','e','a','t','u','r','e', - 'C','o','m','p','o','n','e','n','t','s',' ','W','H','E','R','E',' ', - 'F','e', 'a','t','u','r','e','_','=','\'','%','s','\'',0}; + {'S','E','L','E','C','T',' ', + '`','C','o','m','p','o','n','e','n','t','_','`', + ' ','F','R','O','M',' ','`','F','e','a','t','u','r','e', + 'C','o','m','p','o','n','e','n','t','s','`',' ', + 'W','H','E','R','E',' ', + '`','F','e', 'a','t','u','r','e','_','`',' ','=','\'','%','s','\'',0}; static const WCHAR Query2[] = {'S','E','L','E','C','T',' ','*',' ','F','R', 'O','M',' ', - 'C','o','m','p','o','n','e','n','t',' ','W','H','E','R','E',' ', - 'C','o','m','p','o','n','e','n','t','=','\'','%','s','\'',0}; + '`','C','o','m','p','o','n','e','n','t','`',' ', + 'W','H','E','R','E',' ', + '`','C','o','m','p','o','n','e','n','t','`',' ', + '=','\'','%','s','\'',0}; MSIQUERY * view; MSIQUERY * view2; MSIRECORD * row2; @@ -1673,7 +1694,7 @@ static void load_feature(MSIPACKAGE* package, MSIRECORD * row) package->features[index].Attributes= MSI_RecordGetInteger(row,8); - package->features[index].Installed = INSTALLSTATE_UNKNOWN; + package->features[index].Installed = INSTALLSTATE_ABSENT; package->features[index].Action = INSTALLSTATE_UNKNOWN; package->features[index].ActionRequest = INSTALLSTATE_UNKNOWN; @@ -1712,6 +1733,7 @@ static void load_feature(MSIPACKAGE* package, MSIRECORD * row) c_indx); package->features[index].Components[cnt] = c_indx; package->features[index].ComponentCount ++; + msiobj_release( &row2->hdr ); continue; } @@ -1751,61 +1773,6 @@ static void load_feature(MSIPACKAGE* package, MSIRECORD * row) msiobj_release(&view->hdr); } -/* - * I am not doing any of the costing functionality yet. - * Mostly looking at doing the Component and Feature loading - * - * The native MSI does A LOT of modification to tables here. Mostly adding - * a lot of temporary columns to the Feature and Component tables. - * - * note: Native msi also tracks the short filename. But I am only going to - * track the long ones. Also looking at this directory table - * it appears that the directory table does not get the parents - * resolved base on property only based on their entries in the - * directory table. - */ -static UINT ACTION_CostInitialize(MSIPACKAGE *package) -{ - MSIQUERY * view; - MSIRECORD * row; - UINT rc; - static const WCHAR Query_all[] = - {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ', - 'F','e','a','t','u','r','e',0}; - static const WCHAR szCosting[] = - {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 }; - static const WCHAR szZero[] = { '0', 0 }; - - MSI_SetPropertyW(package, szCosting, szZero); - MSI_SetPropertyW(package, cszRootDrive , c_colon); - - rc = MSI_DatabaseOpenViewW(package->db,Query_all,&view); - if (rc != ERROR_SUCCESS) - return rc; - rc = MSI_ViewExecute(view,0); - if (rc != ERROR_SUCCESS) - { - MSI_ViewClose(view); - msiobj_release(&view->hdr); - return rc; - } - while (1) - { - DWORD rc; - - rc = MSI_ViewFetch(view,&row); - if (rc != ERROR_SUCCESS) - break; - - load_feature(package,row); - msiobj_release(&row->hdr); - } - MSI_ViewClose(view); - msiobj_release(&view->hdr); - - return ERROR_SUCCESS; -} - static UINT load_file(MSIPACKAGE* package, MSIRECORD * row) { DWORD index = package->loaded_files; @@ -1838,8 +1805,10 @@ static UINT load_file(MSIPACKAGE* package, MSIRECORD * row) HeapFree(GetProcessHeap(), 0, buffer); package->files[index].FileName = load_dynamic_stringW(row,3); - reduce_to_longfilename(package->files[index].FileName); + + package->files[index].ShortName = load_dynamic_stringW(row,3); + reduce_to_shortfilename(package->files[index].ShortName); package->files[index].FileSize = MSI_RecordGetInteger(row,4); package->files[index].Version = load_dynamic_stringW(row, 5); @@ -1855,15 +1824,15 @@ static UINT load_file(MSIPACKAGE* package, MSIRECORD * row) return ERROR_SUCCESS; } -static UINT ACTION_FileCost(MSIPACKAGE *package) +static UINT load_all_files(MSIPACKAGE *package) { MSIQUERY * view; MSIRECORD * row; UINT rc; static const WCHAR Query[] = {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ', - 'F','i','l','e',' ', 'O','R','D','E','R',' ','B','Y',' ', - 'S','e','q','u','e','n','c','e', 0}; + '`','F','i','l','e','`',' ', 'O','R','D','E','R',' ','B','Y',' ', + '`','S','e','q','u','e','n','c','e','`', 0}; if (!package) return ERROR_INVALID_HANDLE; @@ -1897,16 +1866,88 @@ static UINT ACTION_FileCost(MSIPACKAGE *package) return ERROR_SUCCESS; } + +/* + * I am not doing any of the costing functionality yet. + * Mostly looking at doing the Component and Feature loading + * + * The native MSI does A LOT of modification to tables here. Mostly adding + * a lot of temporary columns to the Feature and Component tables. + * + * note: Native msi also tracks the short filename. But I am only going to + * track the long ones. Also looking at this directory table + * it appears that the directory table does not get the parents + * resolved base on property only based on their entries in the + * directory table. + */ +static UINT ACTION_CostInitialize(MSIPACKAGE *package) +{ + MSIQUERY * view; + MSIRECORD * row; + UINT rc; + static const WCHAR Query_all[] = + {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ', + '`','F','e','a','t','u','r','e','`',0}; + static const WCHAR szCosting[] = + {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 }; + static const WCHAR szZero[] = { '0', 0 }; + WCHAR buffer[3]; + DWORD sz = 3; + + MSI_GetPropertyW(package, szCosting, buffer, &sz); + if (buffer[0]=='1') + return ERROR_SUCCESS; + + MSI_SetPropertyW(package, szCosting, szZero); + MSI_SetPropertyW(package, cszRootDrive , c_colon); + + rc = MSI_DatabaseOpenViewW(package->db,Query_all,&view); + if (rc != ERROR_SUCCESS) + return rc; + rc = MSI_ViewExecute(view,0); + if (rc != ERROR_SUCCESS) + { + MSI_ViewClose(view); + msiobj_release(&view->hdr); + return rc; + } + while (1) + { + DWORD rc; + + rc = MSI_ViewFetch(view,&row); + if (rc != ERROR_SUCCESS) + break; + + load_feature(package,row); + msiobj_release(&row->hdr); + } + MSI_ViewClose(view); + msiobj_release(&view->hdr); + + load_all_files(package); + + return ERROR_SUCCESS; +} + +static UINT ACTION_FileCost(MSIPACKAGE *package) +{ + return ERROR_SUCCESS; +} + + static INT load_folder(MSIPACKAGE *package, const WCHAR* dir) { static const WCHAR Query[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'D','i','r','e','c', 't','o','r','y',' ','W','H','E','R','E',' ','`', - 'D','i','r','e','c','t', 'o','r','y','`',' ','=',' ','`','%','s','`', + '`','D','i','r','e','c', 't','o','r','y','`',' ', + 'W','H','E','R','E',' ', '`', 'D','i','r','e','c','t', 'o','r','y','`', + ' ','=',' ','\'','%','s','\'', 0}; UINT rc; MSIQUERY * view; LPWSTR ptargetdir, targetdir, parent, srcdir; + LPWSTR shortname = NULL; MSIRECORD * row = 0; INT index = -1; DWORD i; @@ -1972,15 +2013,16 @@ static INT load_folder(MSIPACKAGE *package, const WCHAR* dir) /* for now only pick long filename versions */ if (strchrW(targetdir,'|')) { + shortname = targetdir; targetdir = strchrW(targetdir,'|'); *targetdir = 0; targetdir ++; } + /* for the sourcedir pick the short filename */ if (srcdir && strchrW(srcdir,'|')) { - srcdir= strchrW(srcdir,'|'); - *srcdir= 0; - srcdir ++; + LPWSTR p = strchrW(srcdir,'|'); + *p = 0; } /* now check for root dirs */ @@ -1999,9 +2041,12 @@ static INT load_folder(MSIPACKAGE *package, const WCHAR* dir) if (srcdir) package->folders[index].SourceDefault = strdupW(srcdir); + else if (shortname) + package->folders[index].SourceDefault = strdupW(shortname); else if (targetdir) package->folders[index].SourceDefault = strdupW(targetdir); HeapFree(GetProcessHeap(), 0, ptargetdir); + TRACE(" SourceDefault = %s\n",debugstr_w(package->folders[index].SourceDefault)); parent = load_dynamic_stringW(row,2); if (parent) @@ -2105,6 +2150,7 @@ LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source, else if (source && package->folders[i].ResolvedSource) { path = strdupW(package->folders[i].ResolvedSource); + TRACE(" (source)already resolved to %s\n",debugstr_w(path)); return path; } else if (!source && package->folders[i].Property) @@ -2136,6 +2182,7 @@ LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source, else { path = build_directory_name(3, p, package->folders[i].SourceDefault, NULL); + TRACE(" (source)resolved into %s\n",debugstr_w(path)); package->folders[i].ResolvedSource = strdupW(path); } HeapFree(GetProcessHeap(),0,p); @@ -2201,17 +2248,25 @@ void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature) { MSICOMPONENT* component = &package->components[feature->Components[i]]; + TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n", + newstate, debugstr_w(component->Component), component->Installed, + component->Action, component->ActionRequest); + if (!component->Enabled) continue; else { if (newstate == INSTALLSTATE_LOCAL) + { component->ActionRequest = INSTALLSTATE_LOCAL; + component->Action = INSTALLSTATE_LOCAL; + } else { int j,k; component->ActionRequest = newstate; + component->Action = newstate; /*if any other feature wants is local we need to set it local*/ for (j = 0; @@ -2225,12 +2280,19 @@ void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature) { if (package->features[j].ActionRequest == INSTALLSTATE_LOCAL) + { + TRACE("Saved by %s\n", debugstr_w(package->features[j].Feature)); component->ActionRequest = INSTALLSTATE_LOCAL; + component->Action = INSTALLSTATE_LOCAL; + } break; } } } } + TRACE("Result (%i): Component %s (Installed %i, Action %i, Request %i)\n", + newstate, debugstr_w(component->Component), component->Installed, + component->Action, component->ActionRequest); } } @@ -2344,10 +2406,26 @@ static UINT SetFeatureStates(MSIPACKAGE *package) BOOL feature_state = ((package->features[i].Level > 0) && (package->features[i].Level <= install_level)); - if (feature_state) + if ((feature_state) && + (package->features[i].Action == INSTALLSTATE_UNKNOWN)) { - package->features[i].ActionRequest = INSTALLSTATE_LOCAL; - package->features[i].Action = INSTALLSTATE_LOCAL; + if (package->features[i].Attributes & + msidbFeatureAttributesFavorSource) + { + package->features[i].ActionRequest = INSTALLSTATE_SOURCE; + package->features[i].Action = INSTALLSTATE_SOURCE; + } + else if (package->features[i].Attributes & + msidbFeatureAttributesFavorAdvertise) + { + package->features[i].ActionRequest =INSTALLSTATE_ADVERTISED; + package->features[i].Action =INSTALLSTATE_ADVERTISED; + } + else + { + package->features[i].ActionRequest = INSTALLSTATE_LOCAL; + package->features[i].Action = INSTALLSTATE_LOCAL; + } } } } @@ -2380,6 +2458,27 @@ static UINT SetFeatureStates(MSIPACKAGE *package) component->Action = INSTALLSTATE_LOCAL; component->ActionRequest = INSTALLSTATE_LOCAL; } + else if (feature->ActionRequest == INSTALLSTATE_SOURCE) + { + if ((component->Action == INSTALLSTATE_UNKNOWN) || + (component->Action == INSTALLSTATE_ABSENT) || + (component->Action == INSTALLSTATE_ADVERTISED)) + + { + component->Action = INSTALLSTATE_SOURCE; + component->ActionRequest = INSTALLSTATE_SOURCE; + } + } + else if (feature->ActionRequest == INSTALLSTATE_ADVERTISED) + { + if ((component->Action == INSTALLSTATE_UNKNOWN) || + (component->Action == INSTALLSTATE_ABSENT)) + + { + component->Action = INSTALLSTATE_ADVERTISED; + component->ActionRequest = INSTALLSTATE_ADVERTISED; + } + } else if (feature->ActionRequest == INSTALLSTATE_ABSENT) { if (component->Action == INSTALLSTATE_UNKNOWN) @@ -2415,10 +2514,10 @@ static UINT ACTION_CostFinalize(MSIPACKAGE *package) { static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'D','i','r','e','c','t','o','r','y',0}; + '`','D','i','r','e','c','t','o','r','y','`',0}; static const WCHAR ConditionQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'C','o','n','d','i','t','i','o','n',0}; + '`','C','o','n','d','i','t','i','o','n','`',0}; static const WCHAR szCosting[] = {'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 }; static const WCHAR szlevel[] = @@ -2428,6 +2527,12 @@ static UINT ACTION_CostFinalize(MSIPACKAGE *package) MSIQUERY * view; DWORD i; LPWSTR level; + DWORD sz = 3; + WCHAR buffer[3]; + + MSI_GetPropertyW(package, szCosting, buffer, &sz); + if (buffer[0]=='1') + return ERROR_SUCCESS; TRACE("Building Directory properties\n"); @@ -2669,6 +2774,7 @@ static UINT writeout_cabinet_stream(MSIPACKAGE *package, WCHAR* stream_name, if (the_file == INVALID_HANDLE_VALUE) { + ERR("Unable to create file %s\n",debugstr_w(source)); rc = ERROR_FUNCTION_FAILED; goto end; } @@ -2771,7 +2877,7 @@ static INT_PTR cabinet_notify(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin) LPWSTR tracknametmp; static const WCHAR tmpprefix[] = {'C','A','B','T','M','P','_',0}; - if (data->file_name && strcmp(data->file_name,pfdin->psz1)) + if (data->file_name && lstrcmpiA(data->file_name,pfdin->psz1)) return 0; file = cabinet_alloc((len+1)*sizeof(char)); @@ -2884,8 +2990,8 @@ static BOOL extract_a_cabinet_file(MSIPACKAGE* package, const WCHAR* source, return ret; } -static UINT ready_media_for_file(MSIPACKAGE *package, UINT sequence, - WCHAR* path, WCHAR* file) +static UINT ready_media_for_file(MSIPACKAGE *package, WCHAR* path, + MSIFILE* file) { UINT rc; MSIQUERY * view; @@ -2893,24 +2999,30 @@ static UINT ready_media_for_file(MSIPACKAGE *package, UINT sequence, static WCHAR source[MAX_PATH]; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ', - 'M','e','d','i','a',' ','W','H','E','R','E',' ', - 'L','a','s','t','S','e','q','u','e','n','c','e',' ','>','=',' ','%', - 'i',' ','O','R','D','E','R',' ','B','Y',' ', - 'L','a','s','t','S','e','q','u','e','n','c','e',0}; + '`','M','e','d','i','a','`',' ','W','H','E','R','E',' ', + '`','L','a','s','t','S','e','q','u','e','n','c','e','`',' ','>','=', + ' ','%', 'i',' ','O','R','D','E','R',' ','B','Y',' ', + '`','L','a','s','t','S','e','q','u','e','n','c','e','`',0}; WCHAR Query[1024]; WCHAR cab[0x100]; DWORD sz=0x100; INT seq; static UINT last_sequence = 0; - if (sequence <= last_sequence) + if (file->Attributes & msidbFileAttributesNoncompressed) { - TRACE("Media already ready (%u, %u)\n",sequence,last_sequence); - /*extract_a_cabinet_file(package, source,path,file); */ + TRACE("Uncompressed File, no media to ready.\n"); return ERROR_SUCCESS; } - sprintfW(Query,ExecSeqQuery,sequence); + if (file->Sequence <= last_sequence) + { + TRACE("Media already ready (%u, %u)\n",file->Sequence,last_sequence); + /*extract_a_cabinet_file(package, source,path,file->File); */ + return ERROR_SUCCESS; + } + + sprintfW(Query,ExecSeqQuery,file->Sequence); rc = MSI_DatabaseOpenViewW(package->db, Query, &view); if (rc != ERROR_SUCCESS) @@ -3038,12 +3150,10 @@ static UINT ACTION_InstallFiles(MSIPACKAGE *package) if ((file->State == 1) || (file->State == 2)) { LPWSTR p; - INT len; MSICOMPONENT* comp = NULL; TRACE("Installing %s\n",debugstr_w(file->File)); - rc = ready_media_for_file(package,file->Sequence,path_to_source, - file->File); + rc = ready_media_for_file(package, path_to_source, file); /* * WARNING! * our file table could change here because a new temp file @@ -3068,11 +3178,18 @@ static UINT ACTION_InstallFiles(MSIPACKAGE *package) HeapFree(GetProcessHeap(),0,file->TargetPath); file->TargetPath = build_directory_name(2, p, file->FileName); + HeapFree(GetProcessHeap(),0,p); + + if (file->Attributes & msidbFileAttributesNoncompressed) + { + p = resolve_folder(package, comp->Directory, TRUE, FALSE, NULL); + file->SourcePath = build_directory_name(2, p, file->ShortName); + HeapFree(GetProcessHeap(),0,p); + } + else + file->SourcePath = build_directory_name(2, path_to_source, + file->File); - len = strlenW(path_to_source) + strlenW(file->File) + 2; - file->SourcePath = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR)); - strcpyW(file->SourcePath, path_to_source); - strcatW(file->SourcePath, file->File); TRACE("file paths %s to %s\n",debugstr_w(file->SourcePath), debugstr_w(file->TargetPath)); @@ -3088,16 +3205,26 @@ static UINT ACTION_InstallFiles(MSIPACKAGE *package) msiobj_release( &uirow->hdr ); ui_progress(package,2,file->FileSize,0,0); - if (!MoveFileW(file->SourcePath,file->TargetPath)) + + if (file->Attributes & msidbFileAttributesNoncompressed) + rc = CopyFileW(file->SourcePath,file->TargetPath,FALSE); + else + rc = MoveFileW(file->SourcePath, file->TargetPath); + + if (!rc) { rc = GetLastError(); - ERR("Unable to move file (%s -> %s) (error %d)\n", + ERR("Unable to move/copy file (%s -> %s) (error %d)\n", debugstr_w(file->SourcePath), debugstr_w(file->TargetPath), rc); if (rc == ERROR_ALREADY_EXISTS && file->State == 2) { - CopyFileW(file->SourcePath,file->TargetPath,FALSE); - DeleteFileW(file->SourcePath); + if (!CopyFileW(file->SourcePath,file->TargetPath,FALSE)) + ERR("Unable to copy file (%s -> %s) (error %ld)\n", + debugstr_w(file->SourcePath), + debugstr_w(file->TargetPath), GetLastError()); + if (!(file->Attributes & msidbFileAttributesNoncompressed)) + DeleteFileW(file->SourcePath); rc = 0; } else if (rc == ERROR_FILE_NOT_FOUND) @@ -3105,14 +3232,17 @@ static UINT ACTION_InstallFiles(MSIPACKAGE *package) ERR("Source File Not Found! Continuing\n"); rc = 0; } - else + else if (file->Attributes & msidbFileAttributesVital) { - ERR("Ignoring Error and continuing...\n"); + ERR("Ignoring Error and continuing (nonvital file)...\n"); rc = 0; } } else + { file->State = 4; + rc = ERROR_SUCCESS; + } } } @@ -3151,7 +3281,7 @@ static UINT ACTION_DuplicateFiles(MSIPACKAGE *package) MSIRECORD * row = 0; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'D','u','p','l','i','c','a','t','e','F','i','l','e',0}; + '`','D','u','p','l','i','c','a','t','e','F','i','l','e','`',0}; if (!package) return ERROR_INVALID_HANDLE; @@ -3304,21 +3434,35 @@ static LPSTR parse_value(MSIPACKAGE *package, WCHAR *value, DWORD *type, { LPWSTR ptr; CHAR byte[5]; - LPWSTR deformated; + LPWSTR deformated = NULL; int count; deformat_string(package, &value[2], &deformated); /* binary value type */ - ptr = deformated; - *type=REG_BINARY; - *size = strlenW(ptr)/2; + ptr = deformated; + *type = REG_BINARY; + if (strlenW(ptr)%2) + *size = (strlenW(ptr)/2)+1; + else + *size = strlenW(ptr)/2; + data = HeapAlloc(GetProcessHeap(),0,*size); - + byte[0] = '0'; byte[1] = 'x'; byte[4] = 0; count = 0; + /* if uneven pad with a zero in front */ + if (strlenW(ptr)%2) + { + byte[2]= '0'; + byte[3]= *ptr; + ptr++; + data[count] = (BYTE)strtol(byte,NULL,0); + count ++; + TRACE("Uneven byte count\n"); + } while (*ptr) { byte[2]= *ptr; @@ -3395,7 +3539,7 @@ static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package) MSIRECORD * row = 0; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'R','e','g','i','s','t','r','y',0 }; + '`','R','e','g','i','s','t','r','y','`',0 }; if (!package) return ERROR_INVALID_HANDLE; @@ -3438,6 +3582,7 @@ static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package) MSIRECORD * uirow; LPWSTR uikey; INT root; + BOOL check_first = FALSE; rc = MSI_ViewFetch(view,&row); if (rc != ERROR_SUCCESS) @@ -3483,6 +3628,7 @@ static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package) { HeapFree(GetProcessHeap(),0,name); name = NULL; + check_first = TRUE; } } @@ -3545,8 +3691,32 @@ static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package) deformat_string(package, name, &deformated); - TRACE("Setting value %s\n",debugstr_w(deformated)); - RegSetValueExW(hkey, deformated, 0, type, value_data, size); + /* get the double nulls to terminate SZ_MULTI */ + if (type == REG_MULTI_SZ) + size +=sizeof(WCHAR); + + if (!check_first) + { + TRACE("Setting value %s of %s\n",debugstr_w(deformated), + debugstr_w(uikey)); + RegSetValueExW(hkey, deformated, 0, type, value_data, size); + } + else + { + DWORD sz = 0; + rc = RegQueryValueExW(hkey, deformated, NULL, NULL, NULL, &sz); + if (rc == ERROR_SUCCESS || rc == ERROR_MORE_DATA) + { + TRACE("value %s of %s checked already exists\n", + debugstr_w(deformated), debugstr_w(uikey)); + } + else + { + TRACE("Checked and setting value %s of %s\n", + debugstr_w(deformated), debugstr_w(uikey)); + RegSetValueExW(hkey, deformated, 0, type, value_data, size); + } + } uirow = MSI_CreateRecord(3); MSI_RecordSetStringW(uirow,2,deformated); @@ -3589,7 +3759,7 @@ static UINT ACTION_InstallValidate(MSIPACKAGE *package) DWORD total = 0; static const WCHAR q1[]= {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ', - 'R','e','g','i','s','t','r','y',0}; + '`','R','e','g','i','s','t','r','y','`',0}; UINT rc; MSIQUERY * view; MSIRECORD * row = 0; @@ -3629,6 +3799,14 @@ static UINT ACTION_InstallValidate(MSIPACKAGE *package) total += package->files[i].FileSize; ui_progress(package,0,total,0,0); + for(i = 0; i < package->loaded_features; i++) + { + MSIFEATURE* feature = &package->features[i]; + TRACE("Feature: %s; Installed: %i; Action %i; Request %i\n", + debugstr_w(feature->Feature), feature->Installed, feature->Action, + feature->ActionRequest); + } + return ERROR_SUCCESS; } @@ -3639,7 +3817,7 @@ static UINT ACTION_LaunchConditions(MSIPACKAGE *package) MSIRECORD * row = 0; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'L','a','u','n','c','h','C','o','n','d','i','t','i','o','n',0}; + '`','L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','`',0}; static const WCHAR title[]= {'I','n','s','t','a','l','l',' ','F','a', 'i','l','e','d',0}; @@ -3708,8 +3886,9 @@ static LPWSTR resolve_keypath( MSIPACKAGE* package, INT LPWSTR key,deformated,buffer,name,deformated_name; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'R','e','g','i','s','t','r','y',' ','W','H','E','R','E',' ', - 'R','e','g','i','s','t','r','y',' ','=',' ' ,'`','%','s','`',0 }; + '`','R','e','g','i','s','t','r','y','`',' ', + 'W','H','E','R','E',' ', '`','R','e','g','i','s','t','r','y','`', + ' ','=',' ' ,'\'','%','s','\'',0 }; static const WCHAR fmt[]={'%','0','2','i',':','\\','%','s','\\',0}; static const WCHAR fmt2[]= {'%','0','2','i',':','\\','%','s','\\','%','s',0}; @@ -3941,9 +4120,6 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package) MSIRECORD * uirow; squash_guid(package->components[i].ComponentId,squished_cc); - rc = RegCreateKeyW(hkey,squished_cc,&hkey2); - if (rc != ERROR_SUCCESS) - continue; keypath = resolve_keypath(package,i); package->components[i].FullKeypath = keypath; @@ -3951,8 +4127,9 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package) /* do the refcounting */ ACTION_RefCountComponent( package, i); - TRACE("Component %s, Keypath=%s, RefCount=%i\n", - debugstr_w(package->components[i].Component), + TRACE("Component %s (%s), Keypath=%s, RefCount=%i\n", + debugstr_w(package->components[i].Component), + debugstr_w(squished_cc), debugstr_w(package->components[i].FullKeypath), package->components[i].RefCount); /* @@ -3962,6 +4139,10 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package) if (ACTION_VerifyComponentForAction(package, i, INSTALLSTATE_LOCAL)) { + rc = RegCreateKeyW(hkey,squished_cc,&hkey2); + if (rc != ERROR_SUCCESS) + continue; + if (keypath) { RegSetValueExW(hkey2,squished_pc,0,REG_SZ,(LPVOID)keypath, @@ -3996,6 +4177,11 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package) INSTALLSTATE_ABSENT)) { DWORD res; + + rc = RegOpenKeyW(hkey,squished_cc,&hkey2); + if (rc != ERROR_SUCCESS) + continue; + RegDeleteValueW(hkey2,squished_pc); /* if the key is empty delete it */ @@ -4088,7 +4274,7 @@ static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package) MSIRECORD * row = 0; static const WCHAR Query[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'T','y','p','e','L','i','b',0}; + '`','T','y','p','e','L','i','b','`',0}; if (!package) return ERROR_INVALID_HANDLE; @@ -4217,8 +4403,8 @@ static UINT register_appid(MSIPACKAGE *package, LPCWSTR clsid, LPCWSTR app ) MSIRECORD * row = 0; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'A','p','p','I' ,'d',' ','w','h','e','r','e',' ', - 'A','p','p','I','d','=','`','%','s','`',0}; + '`','A','p','p','I' ,'d','`',' ','W','H','E','R','E',' ', + '`','A','p','p','I','d','`',' ','=','\'','%','s','\'',0}; HKEY hkey2,hkey3; LPWSTR buffer=0; @@ -4347,7 +4533,7 @@ static UINT ACTION_RegisterClassInfo(MSIPACKAGE *package) MSIRECORD * row = 0; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'C','l','a','s','s',0}; + '`','C','l','a','s','s','`',0}; static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 }; static const WCHAR szProgID[] = { 'P','r','o','g','I','D',0 }; static const WCHAR szAppID[] = { 'A','p','p','I','D',0 }; @@ -4404,8 +4590,10 @@ static UINT ACTION_RegisterClassInfo(MSIPACKAGE *package) continue; } - if (!ACTION_VerifyComponentForAction(package, index, - INSTALLSTATE_LOCAL)) + if ((!ACTION_VerifyComponentForAction(package, index, + INSTALLSTATE_LOCAL)) && + (!ACTION_VerifyComponentForAction(package, index, + INSTALLSTATE_ADVERTISED))) { TRACE("Skipping class reg due to disabled component\n"); msiobj_release(&row->hdr); @@ -4662,8 +4850,8 @@ static UINT register_parent_progid(MSIPACKAGE *package, LPCWSTR parent, MSIRECORD * row = 0; static const WCHAR Query_t[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'P','r','o','g' ,'I','d',' ','W','H','E','R','E',' ', - 'P','r','o','g','I','d',' ','=',' ','`' ,'%','s','`',0}; + '`','P','r','o','g' ,'I','d','`',' ','W','H','E','R','E',' ', + '`','P','r','o','g','I','d','`',' ','=',' ','\'' ,'%','s','\'',0}; if (!package) return ERROR_INVALID_HANDLE; @@ -4776,7 +4964,7 @@ static UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package) MSIRECORD * row = 0; static const WCHAR Query[] = {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ', - 'P','r','o','g','I','d',0}; + '`','P','r','o','g','I','d','`',0}; if (!package) return ERROR_INVALID_HANDLE; @@ -4851,8 +5039,8 @@ static UINT ACTION_CreateShortcuts(MSIPACKAGE *package) MSIQUERY * view; MSIRECORD * row = 0; static const WCHAR Query[] = - {'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ', - 'S','h','o','r','t','c','u','t',0}; + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','S','h','o','r','t','c','u','t','`',0}; IShellLinkW *sl; IPersistFile *pf; HRESULT res; @@ -5054,7 +5242,7 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package) MSIRECORD * row = 0; static const WCHAR Query[]= {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'I','c','o','n',0}; + '`','I','c','o','n','`',0}; DWORD sz; /* for registry stuff */ LPWSTR productcode; @@ -5215,7 +5403,7 @@ static UINT ACTION_WriteIniValues(MSIPACKAGE *package) MSIRECORD * row = 0; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'I','n','i','F','i','l','e',0}; + '`','I','n','i','F','i','l','e','`',0}; static const WCHAR szWindowsFolder[] = {'W','i','n','d','o','w','s','F','o','l','d','e','r',0}; @@ -5357,10 +5545,11 @@ static UINT ACTION_SelfRegModules(MSIPACKAGE *package) MSIRECORD * row = 0; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'S','e','l','f','R','e','g',0}; + '`','S','e','l','f','R','e','g','`',0}; static const WCHAR ExeStr[] = - {'r','e','g','s','v','r','3','2','.','e','x','e',' ','/','s',' ',0}; + {'r','e','g','s','v','r','3','2','.','e','x','e',' ','\"',0}; + static const WCHAR close[] = {'\"',0}; STARTUPINFOW si; PROCESS_INFORMATION info; BOOL brc; @@ -5414,13 +5603,14 @@ static UINT ACTION_SelfRegModules(MSIPACKAGE *package) filename = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR)); strcpyW(filename,ExeStr); strcatW(filename,package->files[index].TargetPath); + strcatW(filename,close); TRACE("Registering %s\n",debugstr_w(filename)); brc = CreateProcessW(NULL, filename, NULL, NULL, FALSE, 0, NULL, c_colon, &si, &info); if (brc) - msi_dialog_check_messages(package->dialog, info.hProcess); + msi_dialog_check_messages(info.hProcess); HeapFree(GetProcessHeap(),0,filename); msiobj_release(&row->hdr); @@ -5460,9 +5650,12 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package) GUID clsid; int j; INT size; + BOOL absent = FALSE; - if (!ACTION_VerifyFeatureForAction(package,i,INSTALLSTATE_LOCAL)) - continue; + if (!ACTION_VerifyFeatureForAction(package,i,INSTALLSTATE_LOCAL) && + !ACTION_VerifyFeatureForAction(package,i,INSTALLSTATE_SOURCE) && + !ACTION_VerifyFeatureForAction(package,i,INSTALLSTATE_ADVERTISED)) + absent = TRUE; size = package->features[i].ComponentCount*21; size +=1; @@ -5476,14 +5669,18 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package) { WCHAR buf[21]; memset(buf,0,sizeof(buf)); - TRACE("From %s\n",debugstr_w(package->components + if (package->components + [package->features[i].Components[j]].ComponentId[0]!=0) + { + TRACE("From %s\n",debugstr_w(package->components [package->features[i].Components[j]].ComponentId)); - CLSIDFromString(package->components + CLSIDFromString(package->components [package->features[i].Components[j]].ComponentId, &clsid); - encode_base85_guid(&clsid,buf); - TRACE("to %s\n",debugstr_w(buf)); - strcatW(data,buf); + encode_base85_guid(&clsid,buf); + TRACE("to %s\n",debugstr_w(buf)); + strcatW(data,buf); + } } if (package->features[i].Feature_Parent[0]) { @@ -5497,9 +5694,23 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package) (LPSTR)data,size); HeapFree(GetProcessHeap(),0,data); - size = strlenW(package->features[i].Feature_Parent)*sizeof(WCHAR); - RegSetValueExW(hukey,package->features[i].Feature,0,REG_SZ, + if (!absent) + { + size = strlenW(package->features[i].Feature_Parent)*sizeof(WCHAR); + RegSetValueExW(hukey,package->features[i].Feature,0,REG_SZ, (LPSTR)package->features[i].Feature_Parent,size); + } + else + { + size = (strlenW(package->features[i].Feature_Parent)+2)* + sizeof(WCHAR); + data = HeapAlloc(GetProcessHeap(),0,size); + data[0] = 0x6; + strcpyW(&data[1],package->features[i].Feature_Parent); + RegSetValueExW(hukey,package->features[i].Feature,0,REG_SZ, + (LPSTR)data,size); + HeapFree(GetProcessHeap(),0,data); + } } end: @@ -5625,7 +5836,10 @@ static UINT ACTION_RegisterProduct(MSIPACKAGE *package) snprintfW(path,sizeof(path)/sizeof(path[0]),installerPathFmt,windir); create_full_pathW(path); TRACE("Copying to local package %s\n",debugstr_w(packagefile)); - CopyFileW(package->PackagePath,packagefile,FALSE); + if (!CopyFileW(package->PackagePath,packagefile,FALSE)) + ERR("Unable to copy package (%s -> %s) (error %ld)\n", + debugstr_w(package->PackagePath), debugstr_w(packagefile), + GetLastError()); size = strlenW(packagefile)*sizeof(WCHAR); RegSetValueExW(hkey,szLocalPackage,0,REG_SZ,(LPSTR)packagefile,size); @@ -5793,7 +6007,7 @@ static UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package) MSIRECORD * row = 0; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'E','x','t','e','n','s','i','o','n',0}; + '`','E','x','t','e','n','s','i','o','n','`',0}; static const WCHAR szContentType[] = {'C','o','n','t','e','n','t',' ','T','y','p','e',0 }; HKEY hkey; @@ -5842,8 +6056,10 @@ static UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package) continue; } - if (!ACTION_VerifyComponentForAction(package, index, - INSTALLSTATE_LOCAL)) + if ((!ACTION_VerifyComponentForAction(package, index, + INSTALLSTATE_LOCAL)) && + (!ACTION_VerifyComponentForAction(package, index, + INSTALLSTATE_ADVERTISED))) { TRACE("Skipping extension reg due to disabled component\n"); msiobj_release(&row->hdr); @@ -5916,7 +6132,7 @@ static UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package) MSIRECORD * row = 0; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'M','I','M','E',0}; + '`','M','I','M','E','`',0}; static const WCHAR szExten[] = {'E','x','t','e','n','s','i','o','n',0 }; HKEY hkey; @@ -6042,6 +6258,8 @@ static UINT ACTION_RegisterUser(MSIPACKAGE *package) size = strlenW(buffer)*sizeof(WCHAR); RegSetValueExW(hkey,szRegKeys[i],0,REG_SZ,(LPSTR)buffer,size); } + else + RegSetValueExW(hkey,szRegKeys[i],0,REG_SZ,NULL,0); i++; } @@ -6057,7 +6275,7 @@ end: static UINT ACTION_ExecuteAction(MSIPACKAGE *package) { UINT rc; - rc = ACTION_ProcessExecSequence(package,TRUE); + rc = ACTION_ProcessExecSequence(package,FALSE); return rc; } @@ -6187,6 +6405,8 @@ static LPWSTR load_ttfname_from(LPCWSTR filename) } CloseHandle(handle); } + else + ERR("Unable to open font file %s\n", debugstr_w(filename)); TRACE("Returning fontname %s\n",debugstr_w(ret)); return ret; @@ -6199,7 +6419,7 @@ static UINT ACTION_RegisterFonts(MSIPACKAGE *package) MSIRECORD * row = 0; static const WCHAR ExecSeqQuery[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - 'F','o','n','t',0}; + '`','F','o','n','t','`',0}; static const WCHAR regfont1[] = {'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\', @@ -6215,16 +6435,22 @@ static UINT ACTION_RegisterFonts(MSIPACKAGE *package) HKEY hkey1; HKEY hkey2; + TRACE("%p\n", package); + rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); if (rc != ERROR_SUCCESS) - return rc; + { + TRACE("MSI_DatabaseOpenViewW failed: %d\n", rc); + return ERROR_SUCCESS; + } rc = MSI_ViewExecute(view, 0); if (rc != ERROR_SUCCESS) { MSI_ViewClose(view); msiobj_release(&view->hdr); - return rc; + TRACE("MSI_ViewExecute returned %d\n", rc); + return ERROR_SUCCESS; } RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont1,&hkey1); @@ -6289,10 +6515,143 @@ static UINT ACTION_RegisterFonts(MSIPACKAGE *package) RegCloseKey(hkey1); RegCloseKey(hkey2); + TRACE("returning %d\n", rc); + return rc; +} + +static UINT ITERATE_PublishComponent(MSIRECORD *rec, LPVOID param) +{ + MSIPACKAGE *package = (MSIPACKAGE*)param; + LPWSTR productid=NULL, compgroupid=NULL; + LPWSTR feature=NULL; + LPWSTR text = NULL; + LPWSTR qualifier = NULL; + LPWSTR component = NULL; + GUID clsid; + WCHAR productid_85[21]; + WCHAR component_85[21]; + HKEY hkey; + UINT rc = ERROR_SUCCESS; + UINT index; + /* + * I have a fair bit of confusion as to when a < is used and when a > is + * used. I do not think i have it right... + * + * Ok it appears that the > is used if there is a guid for the compoenent + * and the < is used if not. + */ + static WCHAR fmt1[] = {'%','s','%','s','<',0,0}; + static WCHAR fmt2[] = {'%','s','%','s','>','%','s',0,0}; + LPWSTR output = NULL; + DWORD sz = 0; + INT component_index; + + component = load_dynamic_stringW(rec,3); + component_index = get_loaded_component(package,component); + + if (!ACTION_VerifyComponentForAction(package, component_index, + INSTALLSTATE_LOCAL) && + !ACTION_VerifyComponentForAction(package, component_index, + INSTALLSTATE_SOURCE) && + !ACTION_VerifyComponentForAction(package, component_index, + INSTALLSTATE_ADVERTISED)) + { + TRACE("Skipping: Component %s not scheduled for install\n", + debugstr_w(component)); + HeapFree(GetProcessHeap(),0,component); + return ERROR_SUCCESS; + } + + memset(productid_85,0,sizeof(productid_85)); + memset(component_85,0,sizeof(component_85)); + compgroupid = load_dynamic_stringW(rec,1); + + rc = MSIREG_OpenUserComponentsKey(compgroupid, &hkey, TRUE); + if (rc != ERROR_SUCCESS) + goto end; + + productid = load_dynamic_property(package,szProductCode,NULL); + CLSIDFromString(productid, &clsid); + + encode_base85_guid(&clsid,productid_85); + + text = load_dynamic_stringW(rec,4); + qualifier = load_dynamic_stringW(rec,2); + + feature = load_dynamic_stringW(rec,5); + + index = get_loaded_component(package, component); + CLSIDFromString(package->components[index].ComponentId, &clsid); + encode_base85_guid(&clsid,component_85); + + TRACE("Doing something with this... %s = %s %s %s %s\n", + debugstr_w(qualifier), debugstr_w(productid_85), + debugstr_w(feature), debugstr_w(text), debugstr_w(component_85)); + + sz = lstrlenW(productid_85) + lstrlenW(feature); + if (text) + sz += lstrlenW(text); + if (component && index >= 0) + sz += lstrlenW(component_85); + + sz+=3; + sz *= sizeof(WCHAR); + + output = HeapAlloc(GetProcessHeap(),0,sz); + memset(output,0,sz); + + if (component && index >= 0) + sprintfW(output,fmt2,productid_85,feature,component_85); + else + sprintfW(output,fmt1,productid_85,feature); + + if (text) + strcatW(output,text); + + sz = (lstrlenW(output)+2) * sizeof(WCHAR); + RegSetValueExW(hkey, qualifier,0,REG_MULTI_SZ, (LPBYTE)output, sz); + +end: + RegCloseKey(hkey); + HeapFree(GetProcessHeap(),0,output); + HeapFree(GetProcessHeap(),0,compgroupid); + HeapFree(GetProcessHeap(),0,component); + HeapFree(GetProcessHeap(),0,productid); + HeapFree(GetProcessHeap(),0,feature); + HeapFree(GetProcessHeap(),0,text); + HeapFree(GetProcessHeap(),0,qualifier); + + return rc; +} + +/* + * At present I am ignorning the advertised components part of this and only + * focusing on the qualified component sets + */ +static UINT ACTION_PublishComponents(MSIPACKAGE *package) +{ + UINT rc; + MSIQUERY * view; + static const WCHAR ExecSeqQuery[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','P','u','b','l','i','s','h', + 'C','o','m','p','o','n','e','n','t','`',0}; + + rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords(view, NULL, ITERATE_PublishComponent, package); + msiobj_release(&view->hdr); + return rc; } /* Msi functions that seem appropriate here */ + +/*********************************************************************** + * MsiDoActionA (MSI.@) + */ UINT WINAPI MsiDoActionA( MSIHANDLE hInstall, LPCSTR szAction ) { LPWSTR szwAction; @@ -6316,6 +6675,9 @@ UINT WINAPI MsiDoActionA( MSIHANDLE hInstall, LPCSTR szAction ) return rc; } +/*********************************************************************** + * MsiDoActionW (MSI.@) + */ UINT WINAPI MsiDoActionW( MSIHANDLE hInstall, LPCWSTR szAction ) { MSIPACKAGE *package; @@ -6461,6 +6823,9 @@ UINT WINAPI MsiGetSourcePathW( MSIHANDLE hInstall, LPCWSTR szFolder, LPWSTR } +/*********************************************************************** + * MsiSetTargetPathA (MSI.@) + */ UINT WINAPI MsiSetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder, LPCSTR szFolderPath) { @@ -6519,7 +6884,7 @@ UINT MSI_SetTargetPathW(MSIPACKAGE *package, LPCWSTR szFolder, HeapFree(GetProcessHeap(),0,folder->Property); folder->Property = build_directory_name(2, szFolderPath, NULL); - if (strcmpiW(path, folder->Property) == 0) + if (lstrcmpiW(path, folder->Property) == 0) { /* * Resolved Target has not really changed, so just @@ -6550,6 +6915,9 @@ UINT MSI_SetTargetPathW(MSIPACKAGE *package, LPCWSTR szFolder, return ERROR_SUCCESS; } +/*********************************************************************** + * MsiSetTargetPathW (MSI.@) + */ UINT WINAPI MsiSetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder, LPCWSTR szFolderPath) { @@ -6604,7 +6972,9 @@ BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode) return TRUE; } -/* +/*********************************************************************** + * MsiSetFeatureStateA (MSI.@) + * * According to the docs, when this is called it immediately recalculates * all the component states as well */ @@ -6626,11 +6996,42 @@ UINT WINAPI MsiSetFeatureStateA(MSIHANDLE hInstall, LPCSTR szFeature, return rc; } + + +UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE* package, LPCWSTR szFeature, + INSTALLSTATE iState) +{ + INT index, i; + UINT rc = ERROR_SUCCESS; + + TRACE(" %s to %i\n",debugstr_w(szFeature), iState); + + index = get_loaded_feature(package,szFeature); + if (index < 0) + return ERROR_UNKNOWN_FEATURE; + + package->features[index].ActionRequest= iState; + package->features[index].Action= iState; + + ACTION_UpdateComponentStates(package,szFeature); + + /* update all the features that are children of this feature */ + for (i = 0; i < package->loaded_features; i++) + { + if (strcmpW(szFeature, package->features[i].Feature_Parent) == 0) + MSI_SetFeatureStateW(package, package->features[i].Feature, iState); + } + + return rc; +} + +/*********************************************************************** + * MsiSetFeatureStateW (MSI.@) + */ UINT WINAPI MsiSetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature, INSTALLSTATE iState) { MSIPACKAGE* package; - INT index; UINT rc = ERROR_SUCCESS; TRACE(" %s to %i\n",debugstr_w(szFeature), iState); @@ -6639,17 +7040,8 @@ UINT WINAPI MsiSetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature, if (!package) return ERROR_INVALID_HANDLE; - index = get_loaded_feature(package,szFeature); - if (index < 0) - { - rc = ERROR_UNKNOWN_FEATURE; - goto end; - } - - package->features[index].ActionRequest= iState; - ACTION_UpdateComponentStates(package,szFeature); + rc = MSI_SetFeatureStateW(package,szFeature,iState); -end: msiobj_release( &package->hdr ); return rc; } @@ -6706,6 +7098,9 @@ piAction); return ret; } +/*********************************************************************** + * MsiGetComponentStateA (MSI.@) + */ UINT WINAPI MsiGetComponentStateA(MSIHANDLE hInstall, LPSTR szComponent, INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) { @@ -6745,6 +7140,9 @@ piAction); return ERROR_SUCCESS; } +/*********************************************************************** + * MsiGetComponentStateW (MSI.@) + */ UINT WINAPI MsiGetComponentStateW(MSIHANDLE hInstall, LPWSTR szComponent, INSTALLSTATE *piInstalled, INSTALLSTATE *piAction) { diff --git a/reactos/lib/msi/action.h b/reactos/lib/msi/action.h index af718bee464..a88a07f5e15 100644 --- a/reactos/lib/msi/action.h +++ b/reactos/lib/msi/action.h @@ -82,6 +82,7 @@ typedef struct tagMSIFILE LPWSTR File; INT ComponentIndex; LPWSTR FileName; + LPWSTR ShortName; INT FileSize; LPWSTR Version; LPWSTR Language; diff --git a/reactos/lib/msi/appsearch.c b/reactos/lib/msi/appsearch.c index ca9fc65a305..f499caa43c0 100644 --- a/reactos/lib/msi/appsearch.c +++ b/reactos/lib/msi/appsearch.c @@ -23,8 +23,10 @@ #include "windef.h" #include "winbase.h" +#include "winreg.h" #include "msi.h" #include "msiquery.h" +#include "msidefs.h" #include "winver.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -243,6 +245,9 @@ static UINT ACTION_AppSearchReg(MSIPACKAGE *package, BOOL *appFound, 'R','e','g','L','o','c','a','t','o','r',' ', 'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e','_',' ','=',' ', '\'','%','s','\'',0}; + static const WCHAR dwordFmt[] = { '#','%','d','\0' }; + static const WCHAR expandSzFmt[] = { '#','%','%','%','s','\0' }; + static const WCHAR binFmt[] = { '#','x','%','x','\0' }; TRACE("(package %p, appFound %p, sig %p)\n", package, appFound, sig); *appFound = FALSE; @@ -250,7 +255,11 @@ static UINT ACTION_AppSearchReg(MSIPACKAGE *package, BOOL *appFound, if (rc == ERROR_SUCCESS) { MSIRECORD *row = 0; - LPWSTR keyPath; + LPWSTR keyPath = NULL, valueName = NULL, propertyValue = NULL; + int root, type; + HKEY rootKey, key = NULL; + DWORD sz = 0, regType, i; + LPBYTE value = NULL; rc = MSI_ViewExecute(view, 0); if (rc != ERROR_SUCCESS) @@ -266,13 +275,121 @@ static UINT ACTION_AppSearchReg(MSIPACKAGE *package, BOOL *appFound, goto end; } - /* get key path */ + root = MSI_RecordGetInteger(row,2); keyPath = load_dynamic_stringW(row,3); - FIXME("AppSearch unimplemented for RegLocator (key path %s)\n", - debugstr_w(keyPath)); - HeapFree(GetProcessHeap(), 0, keyPath); + /* FIXME: keyPath needs to be expanded for properties */ + valueName = load_dynamic_stringW(row,4); + /* FIXME: valueName probably does too */ + type = MSI_RecordGetInteger(row,5); + + if ((type & 0x0f) != msidbLocatorTypeRawValue) + { + FIXME("AppSearch unimplemented for type %d (key path %s, value %s)\n", + type, debugstr_w(keyPath), debugstr_w(valueName)); + goto end; + } + + switch (root) + { + case msidbRegistryRootClassesRoot: + rootKey = HKEY_CLASSES_ROOT; + break; + case msidbRegistryRootCurrentUser: + rootKey = HKEY_CURRENT_USER; + break; + case msidbRegistryRootLocalMachine: + rootKey = HKEY_LOCAL_MACHINE; + break; + case msidbRegistryRootUsers: + rootKey = HKEY_USERS; + break; + default: + WARN("Unknown root key %d\n", root); + goto end; + } + + rc = RegCreateKeyW(rootKey, keyPath, &key); + if (rc) + { + TRACE("RegCreateKeyW returned %d\n", rc); + rc = ERROR_SUCCESS; + goto end; + } + rc = RegQueryValueExW(key, valueName, NULL, NULL, NULL, &sz); + if (rc) + { + TRACE("RegQueryValueExW returned %d\n", rc); + rc = ERROR_SUCCESS; + goto end; + } + /* FIXME: sanity-check sz before allocating (is there an upper-limit + * on the value of a property?) + */ + value = HeapAlloc(GetProcessHeap(), 0, sz); + rc = RegQueryValueExW(key, valueName, NULL, ®Type, value, &sz); + if (rc) + { + TRACE("RegQueryValueExW returned %d\n", rc); + rc = ERROR_SUCCESS; + goto end; + } + + switch (regType) + { + case REG_SZ: + if (*(LPWSTR)value == '#') + { + /* escape leading pound with another */ + propertyValue = HeapAlloc(GetProcessHeap(), 0, + sz + sizeof(WCHAR)); + propertyValue[0] = '#'; + strcpyW(propertyValue + 1, (LPWSTR)value); + } + else + { + propertyValue = HeapAlloc(GetProcessHeap(), 0, sz); + strcpyW(propertyValue, (LPWSTR)value); + } + break; + case REG_DWORD: + /* 7 chars for digits, 1 for NULL, 1 for #, and 1 for sign + * char if needed + */ + propertyValue = HeapAlloc(GetProcessHeap(), 0, + 10 * sizeof(WCHAR)); + sprintfW(propertyValue, dwordFmt, *(DWORD *)value); + break; + case REG_EXPAND_SZ: + /* space for extra #% characters in front */ + propertyValue = HeapAlloc(GetProcessHeap(), 0, + sz + 2 * sizeof(WCHAR)); + sprintfW(propertyValue, expandSzFmt, (LPWSTR)value); + break; + case REG_BINARY: + /* 3 == length of "#x" */ + propertyValue = HeapAlloc(GetProcessHeap(), 0, + (sz * 3 + 1) * sizeof(WCHAR)); + for (i = 0; i < sz; i++) + sprintfW(propertyValue + i * 3, binFmt, value[i]); + break; + default: + WARN("unimplemented for values of type %ld\n", regType); + goto end; + } + + TRACE("found registry value, setting %s to %s\n", + debugstr_w(sig->Property), debugstr_w(propertyValue)); + rc = MSI_SetPropertyW(package, sig->Property, propertyValue); + *appFound = TRUE; end: + HeapFree(GetProcessHeap(), 0, propertyValue); + HeapFree(GetProcessHeap(), 0, value); + RegCloseKey(key); + + HeapFree(GetProcessHeap(), 0, keyPath); + HeapFree(GetProcessHeap(), 0, valueName); + msiobj_release(&row->hdr); MSI_ViewClose(view); msiobj_release(&view->hdr); diff --git a/reactos/lib/msi/cond.tab.c b/reactos/lib/msi/cond.tab.c index 56af92f32e5..72fe698b431 100644 --- a/reactos/lib/msi/cond.tab.c +++ b/reactos/lib/msi/cond.tab.c @@ -1,2230 +1,2031 @@ -/* A Bison parser, made by GNU Bison 1.875c. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 1 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - -/* If NAME_PREFIX is specified substitute the variables and functions - names. */ -#define yyparse COND_parse -#define yylex COND_lex -#define yyerror COND_error -#define yylval COND_lval -#define yychar COND_char -#define yydebug COND_debug -#define yynerrs COND_nerrs - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - COND_SPACE = 258, - COND_EOF = 259, - COND_OR = 260, - COND_AND = 261, - COND_NOT = 262, - COND_LT = 263, - COND_GT = 264, - COND_EQ = 265, - COND_LPAR = 266, - COND_RPAR = 267, - COND_TILDA = 268, - COND_PERCENT = 269, - COND_DOLLARS = 270, - COND_QUESTION = 271, - COND_AMPER = 272, - COND_EXCLAM = 273, - COND_IDENT = 274, - COND_NUMBER = 275, - COND_LITER = 276, - COND_ERROR = 277 - }; -#endif -#define COND_SPACE 258 -#define COND_EOF 259 -#define COND_OR 260 -#define COND_AND 261 -#define COND_NOT 262 -#define COND_LT 263 -#define COND_GT 264 -#define COND_EQ 265 -#define COND_LPAR 266 -#define COND_RPAR 267 -#define COND_TILDA 268 -#define COND_PERCENT 269 -#define COND_DOLLARS 270 -#define COND_QUESTION 271 -#define COND_AMPER 272 -#define COND_EXCLAM 273 -#define COND_IDENT 274 -#define COND_NUMBER 275 -#define COND_LITER 276 -#define COND_ERROR 277 - - - - -/* Copy the first part of user declarations. */ -#line 1 "./cond.y" - - -/* - * 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 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#include -#include -#include - -#include "windef.h" -#include "winbase.h" -#include "wine/debug.h" -#include "wine/unicode.h" - -#include "msi.h" -#include "msiquery.h" -#include "msipriv.h" - -#define YYLEX_PARAM info -#define YYPARSE_PARAM info - -static int COND_error(char *str); - -WINE_DEFAULT_DEBUG_CHANNEL(msi); - -typedef struct tag_yyinput -{ - MSIPACKAGE *package; - LPCWSTR str; - INT n; - MSICONDITION result; -} COND_input; - -struct cond_str { - LPCWSTR data; - INT len; -}; - -static LPWSTR COND_GetString( struct cond_str *str ); -static LPWSTR COND_GetLiteral( struct cond_str *str ); -static int COND_lex( void *COND_lval, COND_input *info); - -typedef INT (*comp_int)(INT a, INT b); -typedef INT (*comp_str)(LPWSTR a, LPWSTR b, BOOL caseless); -typedef INT (*comp_m1)(LPWSTR a,int b); -typedef INT (*comp_m2)(int a,LPWSTR b); - -static INT comp_lt_i(INT a, INT b); -static INT comp_gt_i(INT a, INT b); -static INT comp_le_i(INT a, INT b); -static INT comp_ge_i(INT a, INT b); -static INT comp_eq_i(INT a, INT b); -static INT comp_ne_i(INT a, INT b); -static INT comp_bitand(INT a, INT b); -static INT comp_highcomp(INT a, INT b); -static INT comp_lowcomp(INT a, INT b); - -static INT comp_eq_s(LPWSTR a, LPWSTR b, BOOL casless); -static INT comp_ne_s(LPWSTR a, LPWSTR b, BOOL casless); -static INT comp_lt_s(LPWSTR a, LPWSTR b, BOOL casless); -static INT comp_gt_s(LPWSTR a, LPWSTR b, BOOL casless); -static INT comp_le_s(LPWSTR a, LPWSTR b, BOOL casless); -static INT comp_ge_s(LPWSTR a, LPWSTR b, BOOL casless); -static INT comp_substring(LPWSTR a, LPWSTR b, BOOL casless); -static INT comp_start(LPWSTR a, LPWSTR b, BOOL casless); -static INT comp_end(LPWSTR a, LPWSTR b, BOOL casless); - -static INT comp_eq_m1(LPWSTR a, INT b); -static INT comp_ne_m1(LPWSTR a, INT b); -static INT comp_lt_m1(LPWSTR a, INT b); -static INT comp_gt_m1(LPWSTR a, INT b); -static INT comp_le_m1(LPWSTR a, INT b); -static INT comp_ge_m1(LPWSTR a, INT b); - -static INT comp_eq_m2(INT a, LPWSTR b); -static INT comp_ne_m2(INT a, LPWSTR b); -static INT comp_lt_m2(INT a, LPWSTR b); -static INT comp_gt_m2(INT a, LPWSTR b); -static INT comp_le_m2(INT a, LPWSTR b); -static INT comp_ge_m2(INT a, LPWSTR b); - - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 106 "./cond.y" -typedef union YYSTYPE { - struct cond_str str; - LPWSTR string; - INT value; - comp_int fn_comp_int; - comp_str fn_comp_str; - comp_m1 fn_comp_m1; - comp_m2 fn_comp_m2; -} YYSTYPE; -/* Line 191 of yacc.c. */ -#line 241 "cond.tab.c" -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -/* Line 214 of yacc.c. */ -#line 253 "cond.tab.c" - -#if ! defined (yyoverflow) || YYERROR_VERBOSE - -# ifndef YYFREE -# define YYFREE free -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# endif - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# endif -# else -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ - - -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - short yyss; - YYSTYPE yyvs; - }; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined (__GNUC__) && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - register YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 30 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 146 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 23 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 17 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 65 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 74 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 277 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const unsigned char yyprhs[] = -{ - 0, 0, 3, 5, 7, 11, 13, 17, 19, 22, - 24, 26, 30, 34, 39, 43, 47, 51, 53, 56, - 58, 60, 63, 66, 69, 72, 75, 77, 80, 82, - 84, 87, 90, 93, 96, 99, 101, 104, 106, 108, - 111, 114, 117, 120, 123, 125, 128, 130, 132, 135, - 138, 141, 144, 147, 149, 151, 153, 155, 157, 160, - 163, 166, 169, 171, 174, 176 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yysigned_char yyrhs[] = -{ - 24, 0, -1, 25, -1, 26, -1, 26, 5, 25, - -1, 27, -1, 26, 6, 27, -1, 28, -1, 7, - 28, -1, 33, -1, 34, -1, 33, 29, 33, -1, - 34, 30, 34, -1, 34, 13, 30, 34, -1, 34, - 31, 33, -1, 33, 32, 34, -1, 11, 25, 12, - -1, 10, -1, 8, 9, -1, 8, -1, 9, -1, - 8, 10, -1, 9, 10, -1, 9, 8, -1, 8, - 8, -1, 9, 9, -1, 10, -1, 8, 9, -1, - 8, -1, 9, -1, 8, 10, -1, 9, 10, -1, - 9, 8, -1, 8, 8, -1, 9, 9, -1, 10, - -1, 8, 9, -1, 8, -1, 9, -1, 8, 10, - -1, 9, 10, -1, 9, 8, -1, 8, 8, -1, - 9, 9, -1, 10, -1, 8, 9, -1, 8, -1, - 9, -1, 8, 10, -1, 9, 10, -1, 9, 8, - -1, 8, 8, -1, 9, 9, -1, 36, -1, 39, - -1, 37, -1, 35, -1, 21, -1, 15, 38, -1, - 16, 38, -1, 17, 38, -1, 18, 38, -1, 38, - -1, 14, 38, -1, 19, -1, 20, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short yyrline[] = -{ - 0, 136, 136, 144, 148, 155, 159, 166, 170, 178, - 182, 186, 190, 194, 198, 202, 206, 214, 218, 222, - 226, 230, 234, 239, 243, 247, 255, 259, 263, 267, - 271, 275, 280, 284, 288, 296, 300, 304, 308, 312, - 316, 321, 325, 329, 337, 341, 345, 349, 353, 357, - 362, 366, 370, 377, 381, 388, 392, 399, 408, 417, - 426, 435, 447, 470, 484, 493 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "COND_SPACE", "COND_EOF", "COND_OR", - "COND_AND", "COND_NOT", "COND_LT", "COND_GT", "COND_EQ", "COND_LPAR", - "COND_RPAR", "COND_TILDA", "COND_PERCENT", "COND_DOLLARS", - "COND_QUESTION", "COND_AMPER", "COND_EXCLAM", "COND_IDENT", - "COND_NUMBER", "COND_LITER", "COND_ERROR", "$accept", "condition", - "expression", "boolean_term", "boolean_factor", "term", "comp_op_i", - "comp_op_s", "comp_op_m1", "comp_op_m2", "value_i", "value_s", "literal", - "symbol_i", "symbol_s", "identifier", "integer", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const unsigned short yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = -{ - 0, 23, 24, 25, 25, 26, 26, 27, 27, 28, - 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 33, 33, 34, 34, 35, 36, 36, - 36, 36, 37, 37, 38, 39 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = -{ - 0, 2, 1, 1, 3, 1, 3, 1, 2, 1, - 1, 3, 3, 4, 3, 3, 3, 1, 2, 1, - 1, 2, 2, 2, 2, 2, 1, 2, 1, 1, - 2, 2, 2, 2, 2, 1, 2, 1, 1, 2, - 2, 2, 2, 2, 1, 2, 1, 1, 2, 2, - 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, - 2, 2, 1, 2, 1, 1 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const unsigned char yydefact[] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, 64, 65, - 57, 0, 2, 3, 5, 7, 9, 10, 56, 53, - 55, 62, 54, 8, 0, 63, 58, 59, 60, 61, - 1, 0, 0, 19, 20, 17, 0, 0, 37, 38, - 35, 0, 0, 0, 16, 4, 6, 24, 18, 21, - 23, 25, 22, 11, 15, 42, 36, 39, 41, 43, - 40, 28, 29, 26, 0, 12, 14, 33, 27, 30, - 32, 34, 31, 13 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yysigned_char yydefgoto[] = -{ - -1, 11, 12, 13, 14, 15, 36, 42, 43, 37, - 16, 17, 18, 19, 20, 21, 22 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -37 -static const short yypact[] = -{ - -4, 51, -4, -11, -11, -11, -11, -11, -37, -37, - -37, 18, -37, -1, -37, -37, 49, 14, -37, -37, - -37, -37, -37, -37, 19, -37, -37, -37, -37, -37, - -37, -4, -4, 11, 25, 34, 111, 59, 28, 42, - 60, 130, 59, 111, -37, -37, -37, 63, 69, 72, - 73, 81, 82, -37, -37, 85, 91, 94, 95, 103, - 104, 133, 136, -37, 59, -37, -37, -37, -37, -37, - -37, -37, -37, -37 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const short yypgoto[] = -{ - -37, -37, -2, -37, -6, 39, -37, 0, -37, -37, - -34, -36, -37, -37, -37, 129, -37 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -53 -static const yysigned_char yytable[] = -{ - 24, 54, 53, 1, 31, 32, 65, 2, 8, 66, - 3, 4, 5, 6, 7, 8, 9, 10, 30, 47, - 48, 49, 38, 39, 40, -46, 46, 41, 73, 45, - -46, 44, -46, 50, 51, 52, 55, 56, 57, -47, - 23, 64, -28, 0, -47, 0, -47, -28, -44, -28, - 58, 59, 60, -44, 0, -44, -29, 33, 34, 35, - 0, -29, 2, -29, 0, 3, 4, 5, 6, 7, - 8, 9, 10, 3, -26, 0, 0, -51, 8, -26, - 10, -26, -51, -45, -51, 0, -48, -50, -45, 0, - -45, -48, -50, -48, -50, -52, -49, 0, 0, -33, - -52, -49, -52, -49, -33, -27, -33, 0, -30, -32, - -27, 0, -27, -30, -32, -30, -32, -34, -31, 0, - 0, 0, -34, -31, -34, -31, 4, 5, 6, 7, - 0, 9, 25, 26, 27, 28, 29, 0, 61, 62, - 63, 67, 68, 69, 70, 71, 72 -}; - -static const yysigned_char yycheck[] = -{ - 2, 37, 36, 7, 5, 6, 42, 11, 19, 43, - 14, 15, 16, 17, 18, 19, 20, 21, 0, 8, - 9, 10, 8, 9, 10, 14, 32, 13, 64, 31, - 19, 12, 21, 8, 9, 10, 8, 9, 10, 14, - 1, 41, 14, -1, 19, -1, 21, 19, 14, 21, - 8, 9, 10, 19, -1, 21, 14, 8, 9, 10, - -1, 19, 11, 21, -1, 14, 15, 16, 17, 18, - 19, 20, 21, 14, 14, -1, -1, 14, 19, 19, - 21, 21, 19, 14, 21, -1, 14, 14, 19, -1, - 21, 19, 19, 21, 21, 14, 14, -1, -1, 14, - 19, 19, 21, 21, 19, 14, 21, -1, 14, 14, - 19, -1, 21, 19, 19, 21, 21, 14, 14, -1, - -1, -1, 19, 19, 21, 21, 15, 16, 17, 18, - -1, 20, 3, 4, 5, 6, 7, -1, 8, 9, - 10, 8, 9, 10, 8, 9, 10 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const unsigned char yystos[] = -{ - 0, 7, 11, 14, 15, 16, 17, 18, 19, 20, - 21, 24, 25, 26, 27, 28, 33, 34, 35, 36, - 37, 38, 39, 28, 25, 38, 38, 38, 38, 38, - 0, 5, 6, 8, 9, 10, 29, 32, 8, 9, - 10, 13, 30, 31, 12, 25, 27, 8, 9, 10, - 8, 9, 10, 33, 34, 8, 9, 10, 8, 9, - 10, 8, 9, 10, 30, 34, 33, 8, 9, 10, - 8, 9, 10, 34 -}; - -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror ("syntax error: cannot back up");\ - YYERROR; \ - } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). */ - -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - ((Current).first_line = (Rhs)[1].first_line, \ - (Current).first_column = (Rhs)[1].first_column, \ - (Current).last_line = (Rhs)[N].last_line, \ - (Current).last_column = (Rhs)[N].last_column) -#endif - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval) -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - -# define YYDSYMPRINT(Args) \ -do { \ - if (yydebug) \ - yysymprint Args; \ -} while (0) - -# define YYDSYMPRINTF(Title, Token, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Token, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_stack_print (short *bottom, short *top) -#else -static void -yy_stack_print (bottom, top) - short *bottom; - short *top; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_reduce_print (int yyrule) -#else -static void -yy_reduce_print (yyrule) - int yyrule; -#endif -{ - int yyi; - unsigned int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", - yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YYDSYMPRINT(Args) -# define YYDSYMPRINTF(Title, Token, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif -{ - register const char *yys = yystr; - - while (*yys++ != '\0') - continue; - - return yys - yystr - 1; -} -# endif -# endif - -# ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif -{ - register char *yyd = yydest; - register const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -#endif /* !YYERROR_VERBOSE */ - - - -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - if (yytype < YYNTOKENS) - { - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); -# ifdef YYPRINT - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - } - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - switch (yytype) - { - default: - break; - } - YYFPRINTF (yyoutput, ")"); -} - -#endif /* ! YYDEBUG */ -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yydestruct (int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yytype, yyvaluep) - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - switch (yytype) - { - - default: - break; - } -} - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM); -# else -int yyparse (); -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - - - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int -yyparse (void) -#else -int -yyparse () - -#endif -#endif -{ - /* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - register int yystate; - register int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; - - - -#define YYPOPSTACK (yyvsp--, yyssp--) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyoverflowlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyoverflowlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - short *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - yystate = yyn; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: -#line 137 "./cond.y" - { - COND_input* cond = (COND_input*) info; - cond->result = yyvsp[0].value; - ;} - break; - - case 3: -#line 145 "./cond.y" - { - yyval.value = yyvsp[0].value; - ;} - break; - - case 4: -#line 149 "./cond.y" - { - yyval.value = yyvsp[-2].value || yyvsp[0].value; - ;} - break; - - case 5: -#line 156 "./cond.y" - { - yyval.value = yyvsp[0].value; - ;} - break; - - case 6: -#line 160 "./cond.y" - { - yyval.value = yyvsp[-2].value && yyvsp[0].value; - ;} - break; - - case 7: -#line 167 "./cond.y" - { - yyval.value = yyvsp[0].value; - ;} - break; - - case 8: -#line 171 "./cond.y" - { - yyval.value = ! yyvsp[0].value; - ;} - break; - - case 9: -#line 179 "./cond.y" - { - yyval.value = yyvsp[0].value; - ;} - break; - - case 10: -#line 183 "./cond.y" - { - yyval.value = yyvsp[0].string[0] ? MSICONDITION_TRUE : MSICONDITION_FALSE; - ;} - break; - - case 11: -#line 187 "./cond.y" - { - yyval.value = yyvsp[-1].fn_comp_int( yyvsp[-2].value, yyvsp[0].value ); - ;} - break; - - case 12: -#line 191 "./cond.y" - { - yyval.value = yyvsp[-1].fn_comp_str( yyvsp[-2].string, yyvsp[0].string, FALSE ); - ;} - break; - - case 13: -#line 195 "./cond.y" - { - yyval.value = yyvsp[-1].fn_comp_str( yyvsp[-3].string, yyvsp[0].string, TRUE ); - ;} - break; - - case 14: -#line 199 "./cond.y" - { - yyval.value = yyvsp[-1].fn_comp_m1( yyvsp[-2].string, yyvsp[0].value ); - ;} - break; - - case 15: -#line 203 "./cond.y" - { - yyval.value = yyvsp[-1].fn_comp_m2( yyvsp[-2].value, yyvsp[0].string ); - ;} - break; - - case 16: -#line 207 "./cond.y" - { - yyval.value = yyvsp[-1].value; - ;} - break; - - case 17: -#line 215 "./cond.y" - { - yyval.fn_comp_int = comp_eq_i; - ;} - break; - - case 18: -#line 219 "./cond.y" - { - yyval.fn_comp_int = comp_ne_i; - ;} - break; - - case 19: -#line 223 "./cond.y" - { - yyval.fn_comp_int = comp_lt_i; - ;} - break; - - case 20: -#line 227 "./cond.y" - { - yyval.fn_comp_int = comp_gt_i; - ;} - break; - - case 21: -#line 231 "./cond.y" - { - yyval.fn_comp_int = comp_le_i; - ;} - break; - - case 22: -#line 235 "./cond.y" - { - yyval.fn_comp_int = comp_ge_i; - ;} - break; - - case 23: -#line 240 "./cond.y" - { - yyval.fn_comp_int = comp_bitand; - ;} - break; - - case 24: -#line 244 "./cond.y" - { - yyval.fn_comp_int = comp_highcomp; - ;} - break; - - case 25: -#line 248 "./cond.y" - { - yyval.fn_comp_int = comp_lowcomp; - ;} - break; - - case 26: -#line 256 "./cond.y" - { - yyval.fn_comp_str = comp_eq_s; - ;} - break; - - case 27: -#line 260 "./cond.y" - { - yyval.fn_comp_str = comp_ne_s; - ;} - break; - - case 28: -#line 264 "./cond.y" - { - yyval.fn_comp_str = comp_lt_s; - ;} - break; - - case 29: -#line 268 "./cond.y" - { - yyval.fn_comp_str = comp_gt_s; - ;} - break; - - case 30: -#line 272 "./cond.y" - { - yyval.fn_comp_str = comp_le_s; - ;} - break; - - case 31: -#line 276 "./cond.y" - { - yyval.fn_comp_str = comp_ge_s; - ;} - break; - - case 32: -#line 281 "./cond.y" - { - yyval.fn_comp_str = comp_substring; - ;} - break; - - case 33: -#line 285 "./cond.y" - { - yyval.fn_comp_str = comp_start; - ;} - break; - - case 34: -#line 289 "./cond.y" - { - yyval.fn_comp_str = comp_end; - ;} - break; - - case 35: -#line 297 "./cond.y" - { - yyval.fn_comp_m1 = comp_eq_m1; - ;} - break; - - case 36: -#line 301 "./cond.y" - { - yyval.fn_comp_m1 = comp_ne_m1; - ;} - break; - - case 37: -#line 305 "./cond.y" - { - yyval.fn_comp_m1 = comp_lt_m1; - ;} - break; - - case 38: -#line 309 "./cond.y" - { - yyval.fn_comp_m1 = comp_gt_m1; - ;} - break; - - case 39: -#line 313 "./cond.y" - { - yyval.fn_comp_m1 = comp_le_m1; - ;} - break; - - case 40: -#line 317 "./cond.y" - { - yyval.fn_comp_m1 = comp_ge_m1; - ;} - break; - - case 41: -#line 322 "./cond.y" - { - yyval.fn_comp_m1 = 0; - ;} - break; - - case 42: -#line 326 "./cond.y" - { - yyval.fn_comp_m1 = 0; - ;} - break; - - case 43: -#line 330 "./cond.y" - { - yyval.fn_comp_m1 = 0; - ;} - break; - - case 44: -#line 338 "./cond.y" - { - yyval.fn_comp_m2 = comp_eq_m2; - ;} - break; - - case 45: -#line 342 "./cond.y" - { - yyval.fn_comp_m2 = comp_ne_m2; - ;} - break; - - case 46: -#line 346 "./cond.y" - { - yyval.fn_comp_m2 = comp_lt_m2; - ;} - break; - - case 47: -#line 350 "./cond.y" - { - yyval.fn_comp_m2 = comp_gt_m2; - ;} - break; - - case 48: -#line 354 "./cond.y" - { - yyval.fn_comp_m2 = comp_le_m2; - ;} - break; - - case 49: -#line 358 "./cond.y" - { - yyval.fn_comp_m2 = comp_ge_m2; - ;} - break; - - case 50: -#line 363 "./cond.y" - { - yyval.fn_comp_m2 = 0; - ;} - break; - - case 51: -#line 367 "./cond.y" - { - yyval.fn_comp_m2 = 0; - ;} - break; - - case 52: -#line 371 "./cond.y" - { - yyval.fn_comp_m2 = 0; - ;} - break; - - case 53: -#line 378 "./cond.y" - { - yyval.value = yyvsp[0].value; - ;} - break; - - case 54: -#line 382 "./cond.y" - { - yyval.value = yyvsp[0].value; - ;} - break; - - case 55: -#line 389 "./cond.y" - { - yyval.string = yyvsp[0].string; - ;} - break; - - case 56: -#line 393 "./cond.y" - { - yyval.string = yyvsp[0].string; - ;} - break; - - case 57: -#line 400 "./cond.y" - { - yyval.string = COND_GetLiteral(&yyvsp[0].str); - if( !yyval.string ) - YYABORT; - ;} - break; - - case 58: -#line 409 "./cond.y" - { - COND_input* cond = (COND_input*) info; - INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN; - - MSI_GetComponentStateW(cond->package, yyvsp[0].string, &install, &action ); - yyval.value = action; - HeapFree( GetProcessHeap(), 0, yyvsp[0].string ); - ;} - break; - - case 59: -#line 418 "./cond.y" - { - COND_input* cond = (COND_input*) info; - INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN; - - MSI_GetComponentStateW(cond->package, yyvsp[0].string, &install, &action ); - yyval.value = install; - HeapFree( GetProcessHeap(), 0, yyvsp[0].string ); - ;} - break; - - case 60: -#line 427 "./cond.y" - { - COND_input* cond = (COND_input*) info; - INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN; - - MSI_GetFeatureStateW(cond->package, yyvsp[0].string, &install, &action ); - yyval.value = action; - HeapFree( GetProcessHeap(), 0, yyvsp[0].string ); - ;} - break; - - case 61: -#line 436 "./cond.y" - { - COND_input* cond = (COND_input*) info; - INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN; - - MSI_GetFeatureStateW(cond->package, yyvsp[0].string, &install, &action ); - yyval.value = install; - HeapFree( GetProcessHeap(), 0, yyvsp[0].string ); - ;} - break; - - case 62: -#line 448 "./cond.y" - { - DWORD sz; - COND_input* cond = (COND_input*) info; - - sz = 0; - MSI_GetPropertyW(cond->package, yyvsp[0].string, NULL, &sz); - if (sz == 0) - { - yyval.string = HeapAlloc( GetProcessHeap(), 0 ,sizeof(WCHAR)); - yyval.string[0] = 0; - } - else - { - sz ++; - yyval.string = HeapAlloc( GetProcessHeap(), 0, sz*sizeof (WCHAR) ); - - /* Lookup the identifier */ - - MSI_GetPropertyW(cond->package,yyvsp[0].string,yyval.string,&sz); - } - HeapFree( GetProcessHeap(), 0, yyvsp[0].string ); - ;} - break; - - case 63: -#line 471 "./cond.y" - { - UINT len = GetEnvironmentVariableW( yyvsp[0].string, NULL, 0 ); - if( len++ ) - { - yyval.string = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR) ); - if( yyval.string ) - GetEnvironmentVariableW( yyvsp[0].string, yyval.string, len ); - } - HeapFree( GetProcessHeap(), 0, yyvsp[0].string ); - ;} - break; - - case 64: -#line 485 "./cond.y" - { - yyval.string = COND_GetString(&yyvsp[0].str); - if( !yyval.string ) - YYABORT; - ;} - break; - - case 65: -#line 494 "./cond.y" - { - LPWSTR szNum = COND_GetString(&yyvsp[0].str); - if( !szNum ) - YYABORT; - yyval.value = atoiW( szNum ); - HeapFree( GetProcessHeap(), 0, szNum ); - ;} - break; - - - } - -/* Line 1000 of yacc.c. */ -#line 1726 "cond.tab.c" - - yyvsp -= yylen; - yyssp -= yylen; - - - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); - const char* yyprefix; - char *yymsg; - int yyx; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 0; - - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); - yycount += 1; - if (yycount == 5) - { - yysize = 0; - break; - } - } - yysize += (sizeof ("syntax error, unexpected ") - + yystrlen (yytname[yytype])); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); - - if (yycount < 5) - { - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - yyp = yystpcpy (yyp, yyprefix); - yyp = yystpcpy (yyp, yytname[yyx]); - yyprefix = " or "; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("syntax error; also virtual memory exhausted"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror ("syntax error"); - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* If at end of input, pop the error token, - then the rest of the stack, then return failure. */ - if (yychar == YYEOF) - for (;;) - { - YYPOPSTACK; - if (yyssp == yyss) - YYABORT; - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[*yyssp], yyvsp); - } - } - else - { - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); - yychar = YYEMPTY; - - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - -#ifdef __GNUC__ - /* Pacify GCC when the user code never invokes YYERROR and the label - yyerrorlab therefore never appears in user code. */ - if (0) - goto yyerrorlab; -#endif - - yyvsp -= yylen; - yyssp -= yylen; - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[yystate], yyvsp); - YYPOPSTACK; - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - if (yyn == YYFINAL) - YYACCEPT; - - YYDPRINTF ((stderr, "Shifting error token, ")); - - *++yyvsp = yylval; - - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif - return yyresult; -} - - -#line 503 "./cond.y" - - - -static int COND_IsAlpha( WCHAR x ) -{ - return( ( ( x >= 'A' ) && ( x <= 'Z' ) ) || - ( ( x >= 'a' ) && ( x <= 'z' ) ) || - ( ( x == '_' ) ) ); -} - -static int COND_IsNumber( WCHAR x ) -{ - return( (( x >= '0' ) && ( x <= '9' )) || (x =='-') || (x =='.') ); -} - - -/* the mess of comparison functions */ - -static INT comp_lt_i(INT a, INT b) -{ return (a < b); } -static INT comp_gt_i(INT a, INT b) -{ return (a > b); } -static INT comp_le_i(INT a, INT b) -{ return (a <= b); } -static INT comp_ge_i(INT a, INT b) -{ return (a >= b); } -static INT comp_eq_i(INT a, INT b) -{ return (a == b); } -static INT comp_ne_i(INT a, INT b) -{ return (a != b); } -static INT comp_bitand(INT a, INT b) -{ return a & b;} -static INT comp_highcomp(INT a, INT b) -{ return HIWORD(a)==b; } -static INT comp_lowcomp(INT a, INT b) -{ return LOWORD(a)==b; } - -static INT comp_eq_s(LPWSTR a, LPWSTR b, BOOL casless) -{ if (casless) return !strcmpiW(a,b); else return !strcmpW(a,b);} -static INT comp_ne_s(LPWSTR a, LPWSTR b, BOOL casless) -{ if (casless) return strcmpiW(a,b); else return strcmpW(a,b);} -static INT comp_lt_s(LPWSTR a, LPWSTR b, BOOL casless) -{ if (casless) return strcmpiW(a,b)<0; else return strcmpW(a,b)<0;} -static INT comp_gt_s(LPWSTR a, LPWSTR b, BOOL casless) -{ if (casless) return strcmpiW(a,b)>0; else return strcmpW(a,b)>0;} -static INT comp_le_s(LPWSTR a, LPWSTR b, BOOL casless) -{ if (casless) return strcmpiW(a,b)<=0; else return strcmpW(a,b)<=0;} -static INT comp_ge_s(LPWSTR a, LPWSTR b, BOOL casless) -{ if (casless) return strcmpiW(a,b)>=0; else return strcmpW(a,b)>=0;} -static INT comp_substring(LPWSTR a, LPWSTR b, BOOL casless) -/* ERROR NOT WORKING REWRITE */ -{ if (casless) return strstrW(a,b)!=NULL; else return strstrW(a,b)!=NULL;} -static INT comp_start(LPWSTR a, LPWSTR b, BOOL casless) -{ if (casless) return strncmpiW(a,b,strlenW(b))==0; - else return strncmpW(a,b,strlenW(b))==0;} -static INT comp_end(LPWSTR a, LPWSTR b, BOOL casless) -{ - int i = strlenW(a); - int j = strlenW(b); - if (j>i) - return 0; - if (casless) return (!strcmpiW(&a[i-j-1],b)); - else return (!strcmpW(&a[i-j-1],b)); -} - - -static INT comp_eq_m1(LPWSTR a, INT b) -{ if (COND_IsNumber(a[0])) return atoiW(a)==b; else return 0;} -static INT comp_ne_m1(LPWSTR a, INT b) -{ if (COND_IsNumber(a[0])) return atoiW(a)!=b; else return 1;} -static INT comp_lt_m1(LPWSTR a, INT b) -{ if (COND_IsNumber(a[0])) return atoiW(a)b; else return 0;} -static INT comp_le_m1(LPWSTR a, INT b) -{ if (COND_IsNumber(a[0])) return atoiW(a)<=b; else return 0;} -static INT comp_ge_m1(LPWSTR a, INT b) -{ if (COND_IsNumber(a[0])) return atoiW(a)>=b; else return 0;} - -static INT comp_eq_m2(INT a, LPWSTR b) -{ if (COND_IsNumber(b[0])) return a == atoiW(b); else return 0;} -static INT comp_ne_m2(INT a, LPWSTR b) -{ if (COND_IsNumber(b[0])) return a != atoiW(b); else return 1;} -static INT comp_lt_m2(INT a, LPWSTR b) -{ if (COND_IsNumber(b[0])) return a < atoiW(b); else return 0;} -static INT comp_gt_m2(INT a, LPWSTR b) -{ if (COND_IsNumber(b[0])) return a > atoiW(b); else return 0;} -static INT comp_le_m2(INT a, LPWSTR b) -{ if (COND_IsNumber(b[0])) return a <= atoiW(b); else return 0;} -static INT comp_ge_m2(INT a, LPWSTR b) -{ if (COND_IsNumber(b[0])) return a >= atoiW(b); else return 0;} - - - -static int COND_IsIdent( WCHAR x ) -{ - return( COND_IsAlpha( x ) || COND_IsNumber( x ) || ( x == '_' ) - || ( x == '#' ) || (x == '.') ); -} - -static int COND_GetOne( struct cond_str *str, COND_input *cond ) -{ - static const WCHAR szNot[] = {'N','O','T',0}; - static const WCHAR szAnd[] = {'A','N','D',0}; - static const WCHAR szOr[] = {'O','R',0}; - WCHAR ch; - int rc, len = 1; - - str->data = &cond->str[cond->n]; - - ch = str->data[0]; - switch( ch ) - { - case 0: return 0; - 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; - case '~': rc = COND_TILDA; break; - case '<': rc = COND_LT; break; - case '>': rc = COND_GT; break; - case '"': - { - const WCHAR *ch2 = str->data + 1; - - - while ( *ch2 && *ch2 != '"' ) - ++ch2; - if (*ch2 == '"') - { - len = ch2 - str->data + 1; - rc = COND_LITER; - break; - } - } - ERR("Unterminated string\n"); - rc = COND_ERROR; - break; - default: - if( COND_IsAlpha( ch ) ) - { - while( COND_IsIdent( str->data[len] ) ) - len++; - rc = COND_IDENT; - break; - } - - if( COND_IsNumber( ch ) ) - { - while( COND_IsNumber( str->data[len] ) ) - len++; - rc = COND_NUMBER; - break; - } - - ERR("Got unknown character %c(%x)\n",ch,ch); - rc = COND_ERROR; - break; - } - - /* keyword identifiers */ - if( rc == COND_IDENT ) - { - if( (len==3) && (strncmpiW(str->data,szNot,len)==0) ) - rc = COND_NOT; - else if( (len==3) && (strncmpiW(str->data,szAnd,len)==0) ) - rc = COND_AND; - else if( (len==2) && (strncmpiW(str->data,szOr,len)==0) ) - rc = COND_OR; - } - - cond->n += len; - str->len = len; - - return rc; -} - -static int COND_lex( void *COND_lval, COND_input *cond ) -{ - int rc; - struct cond_str *str = COND_lval; - - do { - rc = COND_GetOne( str, cond ); - } while (rc == COND_SPACE); - - return rc; -} - -static LPWSTR COND_GetString( struct cond_str *str ) -{ - LPWSTR ret; - - ret = HeapAlloc( GetProcessHeap(), 0, (str->len+1) * sizeof (WCHAR) ); - if( ret ) - { - memcpy( ret, str->data, str->len * sizeof(WCHAR)); - ret[str->len]=0; - } - TRACE("Got identifier %s\n",debugstr_w(ret)); - return ret; -} - -static LPWSTR COND_GetLiteral( struct cond_str *str ) -{ - LPWSTR ret; - - ret = HeapAlloc( GetProcessHeap(), 0, (str->len-1) * sizeof (WCHAR) ); - 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; -} - -static int COND_error(char *str) -{ - return 0; -} - -MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *package, LPCWSTR szCondition ) -{ - COND_input cond; - MSICONDITION r; - - cond.package = package; - cond.str = szCondition; - cond.n = 0; - cond.result = -1; - - TRACE("Evaluating %s\n",debugstr_w(szCondition)); - - if( szCondition && !COND_parse( &cond ) ) - r = cond.result; - else - r = MSICONDITION_ERROR; - - TRACE("Evaluates to %i\n",r); - return r; -} - -MSICONDITION WINAPI MsiEvaluateConditionW( MSIHANDLE hInstall, LPCWSTR szCondition ) -{ - MSIPACKAGE *package; - UINT ret; - - package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE); - if( !package) - return ERROR_INVALID_HANDLE; - ret = MSI_EvaluateConditionW( package, szCondition ); - msiobj_release( &package->hdr ); - return ret; -} - -MSICONDITION WINAPI MsiEvaluateConditionA( MSIHANDLE hInstall, LPCSTR szCondition ) -{ - LPWSTR szwCond = NULL; - MSICONDITION r; - - if( szCondition ) - { - UINT len = MultiByteToWideChar( CP_ACP, 0, szCondition, -1, NULL, 0 ); - szwCond = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) ); - MultiByteToWideChar( CP_ACP, 0, szCondition, -1, szwCond, len ); - } - - r = MsiEvaluateConditionW( hInstall, szwCond ); - - HeapFree( GetProcessHeap(), 0, szwCond ); - - return r; -} - +/* A Bison parser, made from ./cond.y + by GNU bison 1.35. */ + +#define YYBISON 1 /* Identify Bison output. */ + +#define yyparse COND_parse +#define yylex COND_lex +#define yyerror COND_error +#define yylval COND_lval +#define yychar COND_char +#define yydebug COND_debug +#define yynerrs COND_nerrs +# define COND_SPACE 257 +# define COND_EOF 258 +# define COND_OR 259 +# define COND_AND 260 +# define COND_NOT 261 +# define COND_LT 262 +# define COND_GT 263 +# define COND_EQ 264 +# define COND_LPAR 265 +# define COND_RPAR 266 +# define COND_TILDA 267 +# define COND_PERCENT 268 +# define COND_DOLLARS 269 +# define COND_QUESTION 270 +# define COND_AMPER 271 +# define COND_EXCLAM 272 +# define COND_IDENT 273 +# define COND_NUMBER 274 +# define COND_LITER 275 +# define COND_ERROR 276 + +#line 1 "./cond.y" + + +/* + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" + +#include +#include +#include + +#include "windef.h" +#include "winbase.h" +#include "wine/debug.h" +#include "wine/unicode.h" + +#include "msi.h" +#include "msiquery.h" +#include "msipriv.h" + +#define YYLEX_PARAM info +#define YYPARSE_PARAM info + +static int COND_error(char *str); + +WINE_DEFAULT_DEBUG_CHANNEL(msi); + +typedef struct tag_yyinput +{ + MSIPACKAGE *package; + LPCWSTR str; + INT n; + MSICONDITION result; +} COND_input; + +struct cond_str { + LPCWSTR data; + INT len; +}; + +static LPWSTR COND_GetString( struct cond_str *str ); +static LPWSTR COND_GetLiteral( struct cond_str *str ); +static int COND_lex( void *COND_lval, COND_input *info); + +typedef INT (*comp_int)(INT a, INT b); +typedef INT (*comp_str)(LPWSTR a, LPWSTR b, BOOL caseless); +typedef INT (*comp_m1)(LPWSTR a,int b); +typedef INT (*comp_m2)(int a,LPWSTR b); + +static INT comp_lt_i(INT a, INT b); +static INT comp_gt_i(INT a, INT b); +static INT comp_le_i(INT a, INT b); +static INT comp_ge_i(INT a, INT b); +static INT comp_eq_i(INT a, INT b); +static INT comp_ne_i(INT a, INT b); +static INT comp_bitand(INT a, INT b); +static INT comp_highcomp(INT a, INT b); +static INT comp_lowcomp(INT a, INT b); + +static INT comp_eq_s(LPWSTR a, LPWSTR b, BOOL casless); +static INT comp_ne_s(LPWSTR a, LPWSTR b, BOOL casless); +static INT comp_lt_s(LPWSTR a, LPWSTR b, BOOL casless); +static INT comp_gt_s(LPWSTR a, LPWSTR b, BOOL casless); +static INT comp_le_s(LPWSTR a, LPWSTR b, BOOL casless); +static INT comp_ge_s(LPWSTR a, LPWSTR b, BOOL casless); +static INT comp_substring(LPWSTR a, LPWSTR b, BOOL casless); +static INT comp_start(LPWSTR a, LPWSTR b, BOOL casless); +static INT comp_end(LPWSTR a, LPWSTR b, BOOL casless); + +static INT comp_eq_m1(LPWSTR a, INT b); +static INT comp_ne_m1(LPWSTR a, INT b); +static INT comp_lt_m1(LPWSTR a, INT b); +static INT comp_gt_m1(LPWSTR a, INT b); +static INT comp_le_m1(LPWSTR a, INT b); +static INT comp_ge_m1(LPWSTR a, INT b); + +static INT comp_eq_m2(INT a, LPWSTR b); +static INT comp_ne_m2(INT a, LPWSTR b); +static INT comp_lt_m2(INT a, LPWSTR b); +static INT comp_gt_m2(INT a, LPWSTR b); +static INT comp_le_m2(INT a, LPWSTR b); +static INT comp_ge_m2(INT a, LPWSTR b); + + +#line 105 "./cond.y" +#ifndef YYSTYPE +typedef union +{ + struct cond_str str; + LPWSTR string; + INT value; + comp_int fn_comp_int; + comp_str fn_comp_str; + comp_m1 fn_comp_m1; + comp_m2 fn_comp_m2; +} yystype; +# define YYSTYPE yystype +# define YYSTYPE_IS_TRIVIAL 1 +#endif +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + + + +#define YYFINAL 74 +#define YYFLAG -32768 +#define YYNTBASE 23 + +/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ +#define YYTRANSLATE(x) ((unsigned)(x) <= 276 ? yytranslate[x] : 39) + +/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ +static const char yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22 +}; + +#if YYDEBUG +static const short yyprhs[] = +{ + 0, 0, 2, 4, 8, 10, 14, 16, 19, 21, + 23, 27, 31, 36, 40, 44, 48, 50, 53, 55, + 57, 60, 63, 66, 69, 72, 74, 77, 79, 81, + 84, 87, 90, 93, 96, 98, 101, 103, 105, 108, + 111, 114, 117, 120, 122, 125, 127, 129, 132, 135, + 138, 141, 144, 146, 148, 150, 152, 154, 157, 160, + 163, 166, 168, 171, 173 +}; +static const short yyrhs[] = +{ + 24, 0, 25, 0, 25, 5, 24, 0, 26, 0, + 25, 6, 26, 0, 27, 0, 7, 27, 0, 32, + 0, 33, 0, 32, 28, 32, 0, 33, 29, 33, + 0, 33, 13, 29, 33, 0, 33, 30, 32, 0, + 32, 31, 33, 0, 11, 24, 12, 0, 10, 0, + 8, 9, 0, 8, 0, 9, 0, 8, 10, 0, + 9, 10, 0, 9, 8, 0, 8, 8, 0, 9, + 9, 0, 10, 0, 8, 9, 0, 8, 0, 9, + 0, 8, 10, 0, 9, 10, 0, 9, 8, 0, + 8, 8, 0, 9, 9, 0, 10, 0, 8, 9, + 0, 8, 0, 9, 0, 8, 10, 0, 9, 10, + 0, 9, 8, 0, 8, 8, 0, 9, 9, 0, + 10, 0, 8, 9, 0, 8, 0, 9, 0, 8, + 10, 0, 9, 10, 0, 9, 8, 0, 8, 8, + 0, 9, 9, 0, 35, 0, 38, 0, 36, 0, + 34, 0, 21, 0, 15, 37, 0, 16, 37, 0, + 17, 37, 0, 18, 37, 0, 37, 0, 14, 37, + 0, 19, 0, 20, 0 +}; + +#endif + +#if YYDEBUG +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const short yyrline[] = +{ + 0, 135, 143, 148, 154, 159, 165, 170, 177, 182, + 186, 190, 194, 198, 202, 206, 212, 218, 222, 226, + 230, 234, 239, 243, 247, 253, 259, 263, 267, 271, + 275, 280, 284, 288, 294, 300, 304, 308, 312, 316, + 321, 325, 329, 335, 341, 345, 349, 353, 357, 362, + 366, 370, 376, 381, 387, 392, 398, 407, 417, 426, + 435, 446, 470, 483, 492 +}; +#endif + + +#if (YYDEBUG) || defined YYERROR_VERBOSE + +/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ +static const char *const yytname[] = +{ + "$", "error", "$undefined.", "COND_SPACE", "COND_EOF", "COND_OR", + "COND_AND", "COND_NOT", "COND_LT", "COND_GT", "COND_EQ", "COND_LPAR", + "COND_RPAR", "COND_TILDA", "COND_PERCENT", "COND_DOLLARS", + "COND_QUESTION", "COND_AMPER", "COND_EXCLAM", "COND_IDENT", + "COND_NUMBER", "COND_LITER", "COND_ERROR", "condition", "expression", + "boolean_term", "boolean_factor", "term", "comp_op_i", "comp_op_s", + "comp_op_m1", "comp_op_m2", "value_i", "value_s", "literal", "symbol_i", + "symbol_s", "identifier", "integer", 0 +}; +#endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const short yyr1[] = +{ + 0, 23, 24, 24, 25, 25, 26, 26, 27, 27, + 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 32, 32, 33, 33, 34, 35, 35, 35, + 35, 36, 36, 37, 38 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const short yyr2[] = +{ + 0, 1, 1, 3, 1, 3, 1, 2, 1, 1, + 3, 3, 4, 3, 3, 3, 1, 2, 1, 1, + 2, 2, 2, 2, 2, 1, 2, 1, 1, 2, + 2, 2, 2, 2, 1, 2, 1, 1, 2, 2, + 2, 2, 2, 1, 2, 1, 1, 2, 2, 2, + 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, + 2, 1, 2, 1, 1 +}; + +/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE + doesn't specify something else to do. Zero means the default is an + error. */ +static const short yydefact[] = +{ + 0, 0, 0, 0, 0, 0, 0, 0, 63, 64, + 56, 1, 2, 4, 6, 8, 9, 55, 52, 54, + 61, 53, 7, 0, 62, 57, 58, 59, 60, 0, + 0, 18, 19, 16, 0, 0, 36, 37, 34, 0, + 0, 0, 15, 3, 5, 23, 17, 20, 22, 24, + 21, 10, 14, 41, 35, 38, 40, 42, 39, 27, + 28, 25, 0, 11, 13, 32, 26, 29, 31, 33, + 30, 12, 0, 0, 0 +}; + +static const short yydefgoto[] = +{ + 72, 11, 12, 13, 14, 34, 40, 41, 35, 15, + 16, 17, 18, 19, 20, 21 +}; + +static const short yypact[] = +{ + -5, 50, -5, -12, -12, -12, -12, -12,-32768,-32768, + -32768,-32768, -2,-32768,-32768, 48, 123,-32768,-32768,-32768, + -32768,-32768,-32768, -4,-32768,-32768,-32768,-32768,-32768, -5, + -5, 10, 24, 33, 110, 58, 27, 41, 59, 135, + 58, 110,-32768,-32768,-32768, 62, 68, 71, 72, 80, + 81,-32768,-32768, 84, 90, 93, 94, 102, 103, 138, + 141,-32768, 58,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + -32768,-32768, 17, 21,-32768 +}; + +static const short yypgoto[] = +{ + -32768, -1,-32768, -8, 25,-32768, -14,-32768,-32768, -11, + -35,-32768,-32768,-32768, 134,-32768 +}; + + +#define YYLAST 151 + + +static const short yytable[] = +{ + 52, 23, 1, 29, 30, 63, 2, 8, 42, 3, + 4, 5, 6, 7, 8, 9, 10, 73, 45, 46, + 47, 74, 44, 51, -45, 62, 22, 71, 43, -45, + 64, -45, 48, 49, 50, 53, 54, 55, -46, 0, + 0, -27, 0, -46, 0, -46, -27, -43, -27, 56, + 57, 58, -43, 0, -43, -28, 31, 32, 33, 0, + -28, 2, -28, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 3, -25, 0, 0, -50, 8, -25, 10, + -25, -50, -44, -50, 0, -47, -49, -44, 0, -44, + -47, -49, -47, -49, -51, -48, 0, 0, -32, -51, + -48, -51, -48, -32, -26, -32, 0, -29, -31, -26, + 0, -26, -29, -31, -29, -31, -33, -30, 0, 0, + 0, -33, -30, -33, -30, 4, 5, 6, 7, 0, + 9, 36, 37, 38, 0, 0, 39, 24, 25, 26, + 27, 28, 0, 59, 60, 61, 65, 66, 67, 68, + 69, 70 +}; + +static const short yycheck[] = +{ + 35, 2, 7, 5, 6, 40, 11, 19, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 0, 8, 9, + 10, 0, 30, 34, 14, 39, 1, 62, 29, 19, + 41, 21, 8, 9, 10, 8, 9, 10, 14, -1, + -1, 14, -1, 19, -1, 21, 19, 14, 21, 8, + 9, 10, 19, -1, 21, 14, 8, 9, 10, -1, + 19, 11, 21, -1, 14, 15, 16, 17, 18, 19, + 20, 21, 14, 14, -1, -1, 14, 19, 19, 21, + 21, 19, 14, 21, -1, 14, 14, 19, -1, 21, + 19, 19, 21, 21, 14, 14, -1, -1, 14, 19, + 19, 21, 21, 19, 14, 21, -1, 14, 14, 19, + -1, 21, 19, 19, 21, 21, 14, 14, -1, -1, + -1, 19, 19, 21, 21, 15, 16, 17, 18, -1, + 20, 8, 9, 10, -1, -1, 13, 3, 4, 5, + 6, 7, -1, 8, 9, 10, 8, 9, 10, 8, + 9, 10 +}; +#define YYPURE 1 + +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/share/bison/bison.simple" + +/* Skeleton output parser for bison, + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser when + the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# else +# ifndef YYSTACK_USE_ALLOCA +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC malloc +# define YYSTACK_FREE free +# endif +#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; +# if YYLSP_NEEDED + YYLTYPE yyls; +# endif +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# if YYLSP_NEEDED +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + + 2 * YYSTACK_GAP_MAX) +# else +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAX) +# endif + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up"); \ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). + + When YYLLOC_DEFAULT is run, CURRENT is set the location of the + first token. By default, to implement support for ranges, extend + its range to the last symbol. */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + Current.last_line = Rhs[N].last_line; \ + Current.last_column = Rhs[N].last_column; +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#if YYPURE +# if YYLSP_NEEDED +# ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) +# else +# define YYLEX yylex (&yylval, &yylloc) +# endif +# else /* !YYLSP_NEEDED */ +# ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +# else +# define YYLEX yylex (&yylval) +# endif +# endif /* !YYLSP_NEEDED */ +#else /* !YYPURE */ +# define YYLEX yylex () +#endif /* !YYPURE */ + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +#endif /* !YYDEBUG */ + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + +#ifdef YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif +#endif + +#line 315 "/usr/share/bison/bison.simple" + + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +# define YYPARSE_PARAM_DECL +# else +# define YYPARSE_PARAM_ARG YYPARSE_PARAM +# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +# endif +#else /* !YYPARSE_PARAM */ +# define YYPARSE_PARAM_ARG +# define YYPARSE_PARAM_DECL +#endif /* !YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +# ifdef YYPARSE_PARAM +int yyparse (void *); +# else +int yyparse (void); +# endif +#endif + +/* YY_DECL_VARIABLES -- depending whether we use a pure parser, + variables are global, or local to YYPARSE. */ + +#define YY_DECL_NON_LSP_VARIABLES \ +/* The lookahead symbol. */ \ +int yychar; \ + \ +/* The semantic value of the lookahead symbol. */ \ +YYSTYPE yylval; \ + \ +/* Number of parse errors so far. */ \ +int yynerrs; + +#if YYLSP_NEEDED +# define YY_DECL_VARIABLES \ +YY_DECL_NON_LSP_VARIABLES \ + \ +/* Location data for the lookahead symbol. */ \ +YYLTYPE yylloc; +#else +# define YY_DECL_VARIABLES \ +YY_DECL_NON_LSP_VARIABLES +#endif + + +/* If nonreentrant, generate the variables here. */ + +#if !YYPURE +YY_DECL_VARIABLES +#endif /* !YYPURE */ + +int +yyparse (YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + /* If reentrant, generate the variables here. */ +#if YYPURE + YY_DECL_VARIABLES +#endif /* !YYPURE */ + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yychar1 = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + +#if YYLSP_NEEDED + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; +#endif + +#if YYLSP_NEEDED +# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +# define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + YYSIZE_T yystacksize = YYINITDEPTH; + + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; +#if YYLSP_NEEDED + YYLTYPE yyloc; +#endif + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; +#if YYLSP_NEEDED + yylsp = yyls; +#endif + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. */ +# if YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yyls1, yysize * sizeof (*yylsp), + &yystacksize); + yyls = yyls1; +# else + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); +# endif + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + goto yyoverflowlab; + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); +# if YYLSP_NEEDED + YYSTACK_RELOCATE (yyls); +# endif +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; +#if YYLSP_NEEDED + yylsp = yyls + yysize - 1; +#endif + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yychar1 = YYTRANSLATE (yychar); + +#if YYDEBUG + /* We have to keep this `#if YYDEBUG', since we use variables + which are defined only if `YYDEBUG' is set. */ + if (yydebug) + { + YYFPRINTF (stderr, "Next token is %d (%s", + yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise + meaning of a token, for further debugging info. */ +# ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +# endif + YYFPRINTF (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %d (%s), ", + yychar, yytname[yychar1])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#if YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + yystate = yyn; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to the semantic value of + the lookahead token. This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + +#if YYLSP_NEEDED + /* Similarly for the default location. Let the user run additional + commands if for instance locations are ranges. */ + yyloc = yylsp[1-yylen]; + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); +#endif + +#if YYDEBUG + /* We have to keep this `#if YYDEBUG', since we use variables which + are defined only if `YYDEBUG' is set. */ + if (yydebug) + { + int yyi; + + YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) + YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); + YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + switch (yyn) { + +case 1: +#line 137 "./cond.y" +{ + COND_input* cond = (COND_input*) info; + cond->result = yyvsp[0].value; + ; + break;} +case 2: +#line 145 "./cond.y" +{ + yyval.value = yyvsp[0].value; + ; + break;} +case 3: +#line 149 "./cond.y" +{ + yyval.value = yyvsp[-2].value || yyvsp[0].value; + ; + break;} +case 4: +#line 156 "./cond.y" +{ + yyval.value = yyvsp[0].value; + ; + break;} +case 5: +#line 160 "./cond.y" +{ + yyval.value = yyvsp[-2].value && yyvsp[0].value; + ; + break;} +case 6: +#line 167 "./cond.y" +{ + yyval.value = yyvsp[0].value; + ; + break;} +case 7: +#line 171 "./cond.y" +{ + yyval.value = ! yyvsp[0].value; + ; + break;} +case 8: +#line 179 "./cond.y" +{ + yyval.value = yyvsp[0].value; + ; + break;} +case 9: +#line 183 "./cond.y" +{ + yyval.value = (yyvsp[0].string && yyvsp[0].string[0]) ? MSICONDITION_TRUE : MSICONDITION_FALSE; + ; + break;} +case 10: +#line 187 "./cond.y" +{ + yyval.value = yyvsp[-1].fn_comp_int( yyvsp[-2].value, yyvsp[0].value ); + ; + break;} +case 11: +#line 191 "./cond.y" +{ + yyval.value = yyvsp[-1].fn_comp_str( yyvsp[-2].string, yyvsp[0].string, FALSE ); + ; + break;} +case 12: +#line 195 "./cond.y" +{ + yyval.value = yyvsp[-1].fn_comp_str( yyvsp[-3].string, yyvsp[0].string, TRUE ); + ; + break;} +case 13: +#line 199 "./cond.y" +{ + yyval.value = yyvsp[-1].fn_comp_m1( yyvsp[-2].string, yyvsp[0].value ); + ; + break;} +case 14: +#line 203 "./cond.y" +{ + yyval.value = yyvsp[-1].fn_comp_m2( yyvsp[-2].value, yyvsp[0].string ); + ; + break;} +case 15: +#line 207 "./cond.y" +{ + yyval.value = yyvsp[-1].value; + ; + break;} +case 16: +#line 215 "./cond.y" +{ + yyval.fn_comp_int = comp_eq_i; + ; + break;} +case 17: +#line 219 "./cond.y" +{ + yyval.fn_comp_int = comp_ne_i; + ; + break;} +case 18: +#line 223 "./cond.y" +{ + yyval.fn_comp_int = comp_lt_i; + ; + break;} +case 19: +#line 227 "./cond.y" +{ + yyval.fn_comp_int = comp_gt_i; + ; + break;} +case 20: +#line 231 "./cond.y" +{ + yyval.fn_comp_int = comp_le_i; + ; + break;} +case 21: +#line 235 "./cond.y" +{ + yyval.fn_comp_int = comp_ge_i; + ; + break;} +case 22: +#line 240 "./cond.y" +{ + yyval.fn_comp_int = comp_bitand; + ; + break;} +case 23: +#line 244 "./cond.y" +{ + yyval.fn_comp_int = comp_highcomp; + ; + break;} +case 24: +#line 248 "./cond.y" +{ + yyval.fn_comp_int = comp_lowcomp; + ; + break;} +case 25: +#line 256 "./cond.y" +{ + yyval.fn_comp_str = comp_eq_s; + ; + break;} +case 26: +#line 260 "./cond.y" +{ + yyval.fn_comp_str = comp_ne_s; + ; + break;} +case 27: +#line 264 "./cond.y" +{ + yyval.fn_comp_str = comp_lt_s; + ; + break;} +case 28: +#line 268 "./cond.y" +{ + yyval.fn_comp_str = comp_gt_s; + ; + break;} +case 29: +#line 272 "./cond.y" +{ + yyval.fn_comp_str = comp_le_s; + ; + break;} +case 30: +#line 276 "./cond.y" +{ + yyval.fn_comp_str = comp_ge_s; + ; + break;} +case 31: +#line 281 "./cond.y" +{ + yyval.fn_comp_str = comp_substring; + ; + break;} +case 32: +#line 285 "./cond.y" +{ + yyval.fn_comp_str = comp_start; + ; + break;} +case 33: +#line 289 "./cond.y" +{ + yyval.fn_comp_str = comp_end; + ; + break;} +case 34: +#line 297 "./cond.y" +{ + yyval.fn_comp_m1 = comp_eq_m1; + ; + break;} +case 35: +#line 301 "./cond.y" +{ + yyval.fn_comp_m1 = comp_ne_m1; + ; + break;} +case 36: +#line 305 "./cond.y" +{ + yyval.fn_comp_m1 = comp_lt_m1; + ; + break;} +case 37: +#line 309 "./cond.y" +{ + yyval.fn_comp_m1 = comp_gt_m1; + ; + break;} +case 38: +#line 313 "./cond.y" +{ + yyval.fn_comp_m1 = comp_le_m1; + ; + break;} +case 39: +#line 317 "./cond.y" +{ + yyval.fn_comp_m1 = comp_ge_m1; + ; + break;} +case 40: +#line 322 "./cond.y" +{ + yyval.fn_comp_m1 = 0; + ; + break;} +case 41: +#line 326 "./cond.y" +{ + yyval.fn_comp_m1 = 0; + ; + break;} +case 42: +#line 330 "./cond.y" +{ + yyval.fn_comp_m1 = 0; + ; + break;} +case 43: +#line 338 "./cond.y" +{ + yyval.fn_comp_m2 = comp_eq_m2; + ; + break;} +case 44: +#line 342 "./cond.y" +{ + yyval.fn_comp_m2 = comp_ne_m2; + ; + break;} +case 45: +#line 346 "./cond.y" +{ + yyval.fn_comp_m2 = comp_lt_m2; + ; + break;} +case 46: +#line 350 "./cond.y" +{ + yyval.fn_comp_m2 = comp_gt_m2; + ; + break;} +case 47: +#line 354 "./cond.y" +{ + yyval.fn_comp_m2 = comp_le_m2; + ; + break;} +case 48: +#line 358 "./cond.y" +{ + yyval.fn_comp_m2 = comp_ge_m2; + ; + break;} +case 49: +#line 363 "./cond.y" +{ + yyval.fn_comp_m2 = 0; + ; + break;} +case 50: +#line 367 "./cond.y" +{ + yyval.fn_comp_m2 = 0; + ; + break;} +case 51: +#line 371 "./cond.y" +{ + yyval.fn_comp_m2 = 0; + ; + break;} +case 52: +#line 378 "./cond.y" +{ + yyval.value = yyvsp[0].value; + ; + break;} +case 53: +#line 382 "./cond.y" +{ + yyval.value = yyvsp[0].value; + ; + break;} +case 54: +#line 389 "./cond.y" +{ + yyval.string = yyvsp[0].string; + ; + break;} +case 55: +#line 393 "./cond.y" +{ + yyval.string = yyvsp[0].string; + ; + break;} +case 56: +#line 400 "./cond.y" +{ + yyval.string = COND_GetLiteral(&yyvsp[0].str); + if( !yyval.string ) + YYABORT; + ; + break;} +case 57: +#line 409 "./cond.y" +{ + COND_input* cond = (COND_input*) info; + INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN; + + MSI_GetComponentStateW(cond->package, yyvsp[0].string, &install, &action ); + yyval.value = action; + HeapFree( GetProcessHeap(), 0, yyvsp[0].string ); + ; + break;} +case 58: +#line 418 "./cond.y" +{ + COND_input* cond = (COND_input*) info; + INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN; + + MSI_GetComponentStateW(cond->package, yyvsp[0].string, &install, &action ); + yyval.value = install; + HeapFree( GetProcessHeap(), 0, yyvsp[0].string ); + ; + break;} +case 59: +#line 427 "./cond.y" +{ + COND_input* cond = (COND_input*) info; + INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN; + + MSI_GetFeatureStateW(cond->package, yyvsp[0].string, &install, &action ); + yyval.value = action; + HeapFree( GetProcessHeap(), 0, yyvsp[0].string ); + ; + break;} +case 60: +#line 436 "./cond.y" +{ + COND_input* cond = (COND_input*) info; + INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN; + + MSI_GetFeatureStateW(cond->package, yyvsp[0].string, &install, &action ); + yyval.value = install; + HeapFree( GetProcessHeap(), 0, yyvsp[0].string ); + ; + break;} +case 61: +#line 448 "./cond.y" +{ + DWORD sz; + COND_input* cond = (COND_input*) info; + + sz = 0; + MSI_GetPropertyW(cond->package, yyvsp[0].string, NULL, &sz); + if (sz == 0) + { + yyval.string = HeapAlloc( GetProcessHeap(), 0 ,sizeof(WCHAR)); + yyval.string[0] = 0; + } + else + { + sz ++; + yyval.string = HeapAlloc( GetProcessHeap(), 0, sz*sizeof (WCHAR) ); + + /* Lookup the identifier */ + + MSI_GetPropertyW(cond->package,yyvsp[0].string,yyval.string,&sz); + } + HeapFree( GetProcessHeap(), 0, yyvsp[0].string ); + ; + break;} +case 62: +#line 471 "./cond.y" +{ + UINT len = GetEnvironmentVariableW( yyvsp[0].string, NULL, 0 ); + if( len++ ) + { + yyval.string = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR) ); + if( yyval.string ) + GetEnvironmentVariableW( yyvsp[0].string, yyval.string, len ); + } + HeapFree( GetProcessHeap(), 0, yyvsp[0].string ); + ; + break;} +case 63: +#line 485 "./cond.y" +{ + yyval.string = COND_GetString(&yyvsp[0].str); + if( !yyval.string ) + YYABORT; + ; + break;} +case 64: +#line 494 "./cond.y" +{ + LPWSTR szNum = COND_GetString(&yyvsp[0].str); + if( !szNum ) + YYABORT; + yyval.value = atoiW( szNum ); + HeapFree( GetProcessHeap(), 0, szNum ); + ; + break;} +} + +#line 705 "/usr/share/bison/bison.simple" + + + yyvsp -= yylen; + yyssp -= yylen; +#if YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG + if (yydebug) + { + short *yyssp1 = yyss - 1; + YYFPRINTF (stderr, "state stack now"); + while (yyssp1 != yyssp) + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; +#if YYLSP_NEEDED + *++yylsp = yyloc; +#endif + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + char *yymsg; + int yyx, yycount; + + yycount = 0; + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) + if (yycheck[yyx + yyn] == yyx) + yysize += yystrlen (yytname[yyx]) + 15, yycount++; + yysize += yystrlen ("parse error, unexpected ") + 1; + yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "parse error, unexpected "); + yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); + + if (yycount < 5) + { + yycount = 0; + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); + yyx++) + if (yycheck[yyx + yyn] == yyx) + { + const char *yyq = ! yycount ? ", expecting " : " or "; + yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yytname[yyx]); + yycount++; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("parse error; also virtual memory exhausted"); + } + else +#endif /* defined (YYERROR_VERBOSE) */ + yyerror ("parse error"); + } + goto yyerrlab1; + + +/*--------------------------------------------------. +| yyerrlab1 -- error raised explicitly by an action | +`--------------------------------------------------*/ +yyerrlab1: + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + YYDPRINTF ((stderr, "Discarding token %d (%s).\n", + yychar, yytname[yychar1])); + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + + +/*-------------------------------------------------------------------. +| yyerrdefault -- current state does not do anything special for the | +| error token. | +`-------------------------------------------------------------------*/ +yyerrdefault: +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + + /* If its default is to accept any token, ok. Otherwise pop it. */ + yyn = yydefact[yystate]; + if (yyn) + goto yydefault; +#endif + + +/*---------------------------------------------------------------. +| yyerrpop -- pop the current state because it cannot handle the | +| error token | +`---------------------------------------------------------------*/ +yyerrpop: + if (yyssp == yyss) + YYABORT; + yyvsp--; + yystate = *--yyssp; +#if YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG + if (yydebug) + { + short *yyssp1 = yyss - 1; + YYFPRINTF (stderr, "Error: state stack now"); + while (yyssp1 != yyssp) + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); + } +#endif + +/*--------------. +| yyerrhandle. | +`--------------*/ +yyerrhandle: + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; +#if YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +/*---------------------------------------------. +| yyoverflowab -- parser overflow comes here. | +`---------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} +#line 503 "./cond.y" + + + +static int COND_IsAlpha( WCHAR x ) +{ + return( ( ( x >= 'A' ) && ( x <= 'Z' ) ) || + ( ( x >= 'a' ) && ( x <= 'z' ) ) || + ( ( x == '_' ) ) ); +} + +static int COND_IsNumber( WCHAR x ) +{ + return( (( x >= '0' ) && ( x <= '9' )) || (x =='-') || (x =='.') ); +} + + +/* the mess of comparison functions */ + +static INT comp_lt_i(INT a, INT b) +{ return (a < b); } +static INT comp_gt_i(INT a, INT b) +{ return (a > b); } +static INT comp_le_i(INT a, INT b) +{ return (a <= b); } +static INT comp_ge_i(INT a, INT b) +{ return (a >= b); } +static INT comp_eq_i(INT a, INT b) +{ return (a == b); } +static INT comp_ne_i(INT a, INT b) +{ return (a != b); } +static INT comp_bitand(INT a, INT b) +{ return a & b;} +static INT comp_highcomp(INT a, INT b) +{ return HIWORD(a)==b; } +static INT comp_lowcomp(INT a, INT b) +{ return LOWORD(a)==b; } + +static INT comp_eq_s(LPWSTR a, LPWSTR b, BOOL casless) +{ if (casless) return !strcmpiW(a,b); else return !strcmpW(a,b);} +static INT comp_ne_s(LPWSTR a, LPWSTR b, BOOL casless) +{ if (casless) return strcmpiW(a,b); else return strcmpW(a,b);} +static INT comp_lt_s(LPWSTR a, LPWSTR b, BOOL casless) +{ if (casless) return strcmpiW(a,b)<0; else return strcmpW(a,b)<0;} +static INT comp_gt_s(LPWSTR a, LPWSTR b, BOOL casless) +{ if (casless) return strcmpiW(a,b)>0; else return strcmpW(a,b)>0;} +static INT comp_le_s(LPWSTR a, LPWSTR b, BOOL casless) +{ if (casless) return strcmpiW(a,b)<=0; else return strcmpW(a,b)<=0;} +static INT comp_ge_s(LPWSTR a, LPWSTR b, BOOL casless) +{ if (casless) return strcmpiW(a,b)>=0; else return strcmpW(a,b)>=0;} +static INT comp_substring(LPWSTR a, LPWSTR b, BOOL casless) +/* ERROR NOT WORKING REWRITE */ +{ if (casless) return strstrW(a,b)!=NULL; else return strstrW(a,b)!=NULL;} +static INT comp_start(LPWSTR a, LPWSTR b, BOOL casless) +{ if (casless) return strncmpiW(a,b,strlenW(b))==0; + else return strncmpW(a,b,strlenW(b))==0;} +static INT comp_end(LPWSTR a, LPWSTR b, BOOL casless) +{ + int i = strlenW(a); + int j = strlenW(b); + if (j>i) + return 0; + if (casless) return (!strcmpiW(&a[i-j-1],b)); + else return (!strcmpW(&a[i-j-1],b)); +} + + +static INT comp_eq_m1(LPWSTR a, INT b) +{ if (COND_IsNumber(a[0])) return atoiW(a)==b; else return 0;} +static INT comp_ne_m1(LPWSTR a, INT b) +{ if (COND_IsNumber(a[0])) return atoiW(a)!=b; else return 1;} +static INT comp_lt_m1(LPWSTR a, INT b) +{ if (COND_IsNumber(a[0])) return atoiW(a)b; else return 0;} +static INT comp_le_m1(LPWSTR a, INT b) +{ if (COND_IsNumber(a[0])) return atoiW(a)<=b; else return 0;} +static INT comp_ge_m1(LPWSTR a, INT b) +{ if (COND_IsNumber(a[0])) return atoiW(a)>=b; else return 0;} + +static INT comp_eq_m2(INT a, LPWSTR b) +{ if (COND_IsNumber(b[0])) return a == atoiW(b); else return 0;} +static INT comp_ne_m2(INT a, LPWSTR b) +{ if (COND_IsNumber(b[0])) return a != atoiW(b); else return 1;} +static INT comp_lt_m2(INT a, LPWSTR b) +{ if (COND_IsNumber(b[0])) return a < atoiW(b); else return 0;} +static INT comp_gt_m2(INT a, LPWSTR b) +{ if (COND_IsNumber(b[0])) return a > atoiW(b); else return 0;} +static INT comp_le_m2(INT a, LPWSTR b) +{ if (COND_IsNumber(b[0])) return a <= atoiW(b); else return 0;} +static INT comp_ge_m2(INT a, LPWSTR b) +{ if (COND_IsNumber(b[0])) return a >= atoiW(b); else return 0;} + + + +static int COND_IsIdent( WCHAR x ) +{ + return( COND_IsAlpha( x ) || COND_IsNumber( x ) || ( x == '_' ) + || ( x == '#' ) || (x == '.') ); +} + +static int COND_GetOne( struct cond_str *str, COND_input *cond ) +{ + static const WCHAR szNot[] = {'N','O','T',0}; + static const WCHAR szAnd[] = {'A','N','D',0}; + static const WCHAR szOr[] = {'O','R',0}; + WCHAR ch; + int rc, len = 1; + + str->data = &cond->str[cond->n]; + + ch = str->data[0]; + switch( ch ) + { + case 0: return 0; + 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; + case '~': rc = COND_TILDA; break; + case '<': rc = COND_LT; break; + case '>': rc = COND_GT; break; + case '"': + { + const WCHAR *ch2 = str->data + 1; + + + while ( *ch2 && *ch2 != '"' ) + ++ch2; + if (*ch2 == '"') + { + len = ch2 - str->data + 1; + rc = COND_LITER; + break; + } + } + ERR("Unterminated string\n"); + rc = COND_ERROR; + break; + default: + if( COND_IsAlpha( ch ) ) + { + while( COND_IsIdent( str->data[len] ) ) + len++; + rc = COND_IDENT; + break; + } + + if( COND_IsNumber( ch ) ) + { + while( COND_IsNumber( str->data[len] ) ) + len++; + rc = COND_NUMBER; + break; + } + + ERR("Got unknown character %c(%x)\n",ch,ch); + rc = COND_ERROR; + break; + } + + /* keyword identifiers */ + if( rc == COND_IDENT ) + { + if( (len==3) && (strncmpiW(str->data,szNot,len)==0) ) + rc = COND_NOT; + else if( (len==3) && (strncmpiW(str->data,szAnd,len)==0) ) + rc = COND_AND; + else if( (len==2) && (strncmpiW(str->data,szOr,len)==0) ) + rc = COND_OR; + } + + cond->n += len; + str->len = len; + + return rc; +} + +static int COND_lex( void *COND_lval, COND_input *cond ) +{ + int rc; + struct cond_str *str = COND_lval; + + do { + rc = COND_GetOne( str, cond ); + } while (rc == COND_SPACE); + + return rc; +} + +static LPWSTR COND_GetString( struct cond_str *str ) +{ + LPWSTR ret; + + ret = HeapAlloc( GetProcessHeap(), 0, (str->len+1) * sizeof (WCHAR) ); + if( ret ) + { + memcpy( ret, str->data, str->len * sizeof(WCHAR)); + ret[str->len]=0; + } + TRACE("Got identifier %s\n",debugstr_w(ret)); + return ret; +} + +static LPWSTR COND_GetLiteral( struct cond_str *str ) +{ + LPWSTR ret; + + ret = HeapAlloc( GetProcessHeap(), 0, (str->len-1) * sizeof (WCHAR) ); + 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; +} + +static int COND_error(char *str) +{ + return 0; +} + +MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *package, LPCWSTR szCondition ) +{ + COND_input cond; + MSICONDITION r; + + cond.package = package; + cond.str = szCondition; + cond.n = 0; + cond.result = -1; + + TRACE("Evaluating %s\n",debugstr_w(szCondition)); + + if ( szCondition == NULL || szCondition[0] == 0) + r = MSICONDITION_NONE; + else if ( !COND_parse( &cond ) ) + r = cond.result; + else + r = MSICONDITION_ERROR; + + TRACE("Evaluates to %i\n",r); + return r; +} + +MSICONDITION WINAPI MsiEvaluateConditionW( MSIHANDLE hInstall, LPCWSTR szCondition ) +{ + MSIPACKAGE *package; + UINT ret; + + package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE); + if( !package) + return ERROR_INVALID_HANDLE; + ret = MSI_EvaluateConditionW( package, szCondition ); + msiobj_release( &package->hdr ); + return ret; +} + +MSICONDITION WINAPI MsiEvaluateConditionA( MSIHANDLE hInstall, LPCSTR szCondition ) +{ + LPWSTR szwCond = NULL; + MSICONDITION r; + + if( szCondition ) + { + UINT len = MultiByteToWideChar( CP_ACP, 0, szCondition, -1, NULL, 0 ); + szwCond = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, szCondition, -1, szwCond, len ); + } + + r = MsiEvaluateConditionW( hInstall, szwCond ); + + HeapFree( GetProcessHeap(), 0, szwCond ); + + return r; +} diff --git a/reactos/lib/msi/cond.y b/reactos/lib/msi/cond.y index 8be1d2e6c04..fd995b8cb38 100644 --- a/reactos/lib/msi/cond.y +++ b/reactos/lib/msi/cond.y @@ -181,7 +181,7 @@ term: } | value_s { - $$ = $1[0] ? MSICONDITION_TRUE : MSICONDITION_FALSE; + $$ = ($1 && $1[0]) ? MSICONDITION_TRUE : MSICONDITION_FALSE; } | value_i comp_op_i value_i { @@ -739,7 +739,9 @@ MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *package, LPCWSTR szCondition ) TRACE("Evaluating %s\n",debugstr_w(szCondition)); - if( szCondition && !COND_parse( &cond ) ) + if ( szCondition == NULL || szCondition[0] == 0) + r = MSICONDITION_NONE; + else if ( !COND_parse( &cond ) ) r = cond.result; else r = MSICONDITION_ERROR; diff --git a/reactos/lib/msi/create.c b/reactos/lib/msi/create.c index b22a2aac61f..bbf90425dca 100644 --- a/reactos/lib/msi/create.c +++ b/reactos/lib/msi/create.c @@ -201,20 +201,10 @@ static UINT CREATE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode, static UINT CREATE_delete( struct tagMSIVIEW *view ) { MSICREATEVIEW *cv = (MSICREATEVIEW*)view; - create_col_info *col; TRACE("%p\n", cv ); - col = cv->col_info; - while( col ) - { - create_col_info *t = col; - col = col->next; - HeapFree( GetProcessHeap(), 0, t->colname ); - HeapFree( GetProcessHeap(), 0, t ); - } msiobj_release( &cv->db->hdr ); - HeapFree( GetProcessHeap(), 0, cv->name ); HeapFree( GetProcessHeap(), 0, cv ); return ERROR_SUCCESS; @@ -250,7 +240,7 @@ UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, cv->view.ops = &create_ops; msiobj_addref( &db->hdr ); cv->db = db; - cv->name = table; /* FIXME: strdupW it? */ + cv->name = table; cv->col_info = col_info; cv->bIsTemp = temp; *view = (MSIVIEW*) cv; diff --git a/reactos/lib/msi/custom.c b/reactos/lib/msi/custom.c index b9e70cf9d6e..4465fc2ebf2 100644 --- a/reactos/lib/msi/custom.c +++ b/reactos/lib/msi/custom.c @@ -80,9 +80,10 @@ UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute) MSIQUERY * view; MSIRECORD * row = 0; static const WCHAR ExecSeqQuery[] = - {'s','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','C','u','s','t','o' - ,'m','A','c','t','i','o','n',' ','w','h','e','r','e',' ','`','A','c','t','i' - ,'o','n','`',' ','=',' ','`','%','s','`',0}; + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','C','u','s','t','o' ,'m','A','c','t','i','o','n','`', + ' ','W','H','E','R','E',' ','`','A','c','t','i' ,'o','n','`',' ', + '=',' ','\'','%','s','\'',0}; UINT type; LPWSTR source; LPWSTR target; @@ -251,8 +252,9 @@ static UINT store_binary_to_temp(MSIPACKAGE *package, LPCWSTR source, MSIQUERY * view; MSIRECORD * row = 0; static const WCHAR fmt[] = - {'s','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','B','i' -,'n','a','r','y',' ','w','h','e','r','e',' ','N','a','m','e','=','`','%','s','`',0}; + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E', + ' ','`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0}; HANDLE the_file; CHAR buffer[1024]; @@ -333,7 +335,7 @@ static void file_running_action(MSIPACKAGE* package, HANDLE Handle, static UINT process_action_return_value(UINT type, HANDLE ThreadHandle) { - DWORD rc; + DWORD rc=0; if (type == 2) { @@ -357,7 +359,8 @@ static UINT process_action_return_value(UINT type, HANDLE ThreadHandle) case ERROR_NO_MORE_ITEMS: return ERROR_SUCCESS; default: - return ERROR_FUNCTION_FAILED; + ERR("Invalid Return Code %lx\n",rc); + return ERROR_INSTALL_FAILURE; } } @@ -372,9 +375,9 @@ static UINT process_handle(MSIPACKAGE* package, UINT type, /* synchronous */ TRACE("Synchronous Execution of action %s\n",debugstr_w(Name)); if (ProcessHandle) - msi_dialog_check_messages(package->dialog, ProcessHandle); + msi_dialog_check_messages(ProcessHandle); else - msi_dialog_check_messages(package->dialog, ThreadHandle); + msi_dialog_check_messages(ThreadHandle); if (!(type & 0x40)) { @@ -479,7 +482,7 @@ static DWORD WINAPI DllThread(LPVOID info) stuff = (thread_struct*)info; rc = ACTION_CallDllFunction(stuff); - TRACE("MSI Thread (0x%lx) finished\n",GetCurrentThreadId()); + TRACE("MSI Thread (0x%lx) finished (rc %li)\n",GetCurrentThreadId(), rc); /* clse all handles for this thread */ MsiCloseAllHandles(); return rc; @@ -630,7 +633,8 @@ static UINT HANDLE_CustomType19(MSIPACKAGE *package, LPCWSTR source, static const WCHAR query[] = { 'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ', 'F','R','O','M',' ','`','E','r','r','o','r','`',' ', - 'W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ','%','s',0 + 'W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ', + '\'','%','s','\'',0 }; MSIQUERY *view = NULL; MSIRECORD *row = 0; @@ -685,7 +689,7 @@ static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source, prop = load_dynamic_property(package,source,&prc); if (!prop) - return prc; + return ERROR_SUCCESS; deformat_string(package,target,&deformated); len = strlenW(prop) + 2; @@ -782,8 +786,7 @@ void ACTION_FinishCustomActions(MSIPACKAGE* package) { TRACE("Waiting on action %s\n", debugstr_w(package->RunningAction[i].name)); - msi_dialog_check_messages(package->dialog, - package->RunningAction[i].handle); + msi_dialog_check_messages(package->RunningAction[i].handle); } HeapFree(GetProcessHeap(),0,package->RunningAction[i].name); diff --git a/reactos/lib/msi/database.c b/reactos/lib/msi/database.c index 6d7bd1b9e5b..800b1db2f57 100644 --- a/reactos/lib/msi/database.c +++ b/reactos/lib/msi/database.c @@ -65,6 +65,7 @@ VOID MSI_CloseDatabase( MSIOBJECTHDR *arg ) DWORD r; free_cached_tables( db ); + msi_destroy_stringtable( db->strings ); r = IStorage_Release( db->storage ); if( r ) ERR("database reference count was not zero (%ld)\n", r); @@ -213,7 +214,8 @@ UINT WINAPI MsiOpenDatabaseA(LPCSTR szDBPath, LPCSTR szPersist, MSIHANDLE *phDB) r = MsiOpenDatabaseW( szwDBPath, szwPersist, phDB ); end: - HeapFree( GetProcessHeap(), 0, szwPersist ); + if( HIWORD(szPersist) ) + HeapFree( GetProcessHeap(), 0, szwPersist ); HeapFree( GetProcessHeap(), 0, szwDBPath ); return r; @@ -334,7 +336,7 @@ UINT WINAPI MsiDatabaseExportA( MSIHANDLE handle, LPCSTR szTable, goto end; } - r = MsiDatabaseImportW( handle, path, file ); + r = MsiDatabaseExportW( handle, table, path, file ); end: HeapFree( GetProcessHeap(), 0, table ); diff --git a/reactos/lib/msi/dialog.c b/reactos/lib/msi/dialog.c index 19ab2d5d402..4977329f471 100644 --- a/reactos/lib/msi/dialog.c +++ b/reactos/lib/msi/dialog.c @@ -44,6 +44,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(msi); const WCHAR szMsiDialogClass[] = { 'M','s','i','D','i','a','l','o','g','C','l','o','s','e','C','l','a','s','s',0 }; +const WCHAR szMsiHiddenWindow[] = { + 'M','s','i','H','i','d','d','e','n','W','i','n','d','o','w',0 +}; const static WCHAR szStatic[] = { 'S','t','a','t','i','c',0 }; const static WCHAR szButton[] = { 'B','U','T','T','O','N', 0 }; @@ -106,6 +109,14 @@ static UINT msi_dialog_radiogroup_handler( msi_dialog *, msi_control *, WPARAM p static LRESULT WINAPI MSIRadioGroup_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +/* dialog sequencing */ + +#define WM_MSI_DIALOG_CREATE (WM_USER+0x100) +#define WM_MSI_DIALOG_DESTROY (WM_USER+0x101) + +static DWORD uiThreadId; +static HWND hMsiHiddenWindow; + INT msi_dialog_scale_unit( msi_dialog *dialog, INT val ) { return (dialog->scale * val + 5) / 10; @@ -725,41 +736,51 @@ static INT msi_dialog_get_sans_serif_height( HWND hwnd ) return height; } -static LRESULT msi_dialog_oncreate( HWND hwnd, LPCREATESTRUCTW cs ) +/* fetch the associated record from the Dialog table */ +static MSIRECORD *msi_get_dialog_record( msi_dialog *dialog ) { static const WCHAR query[] = { 'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ','D','i','a','l','o','g',' ', 'W','H','E','R','E',' ', '`','D','i','a','l','o','g','`',' ','=',' ','\'','%','s','\'',0}; - static const WCHAR df[] = { - 'D','e','f','a','u','l','t','U','I','F','o','n','t',0 }; - msi_dialog *dialog = (msi_dialog*) cs->lpCreateParams; MSIPACKAGE *package = dialog->package; MSIQUERY *view = NULL; MSIRECORD *rec = NULL; - DWORD width, height; - LPCWSTR text; - LPWSTR title = NULL; UINT r; - TRACE("%p %p\n", dialog, package); - - dialog->hwnd = hwnd; - SetWindowLongPtrW( hwnd, GWLP_USERDATA, (LONG_PTR) dialog ); + TRACE("%p %s\n", dialog, debugstr_w(dialog->name) ); - /* fetch the associated record from the Dialog table */ r = MSI_OpenQuery( package->db, &view, query, dialog->name ); if( r != ERROR_SUCCESS ) { ERR("query failed for dialog %s\n", debugstr_w(dialog->name)); - return -1; + return NULL; } MSI_ViewExecute( view, NULL ); MSI_ViewFetch( view, &rec ); MSI_ViewClose( view ); msiobj_release( &view->hdr ); + return rec; +} + +static LRESULT msi_dialog_oncreate( HWND hwnd, LPCREATESTRUCTW cs ) +{ + static const WCHAR df[] = { + 'D','e','f','a','u','l','t','U','I','F','o','n','t',0 }; + msi_dialog *dialog = (msi_dialog*) cs->lpCreateParams; + MSIRECORD *rec = NULL; + DWORD width, height; + LPCWSTR text; + LPWSTR title = NULL; + + TRACE("%p %p\n", dialog, dialog->package); + + dialog->hwnd = hwnd; + SetWindowLongPtrW( hwnd, GWLP_USERDATA, (LONG_PTR) dialog ); + + rec = msi_get_dialog_record( dialog ); if( !rec ) { TRACE("No record found for dialog %s\n", debugstr_w(dialog->name)); @@ -1004,7 +1025,8 @@ static LRESULT WINAPI MSIDialog_WndProc( HWND hwnd, UINT msg, { msi_dialog *dialog = (LPVOID) GetWindowLongPtrW( hwnd, GWLP_USERDATA ); - TRACE(" 0x%04x\n", msg); + TRACE("0x%04x\n", msg); + switch (msg) { case WM_CREATE: @@ -1020,13 +1042,43 @@ static LRESULT WINAPI MSIDialog_WndProc( HWND hwnd, UINT msg, return DefWindowProcW(hwnd, msg, wParam, lParam); } +static LRESULT WINAPI MSIRadioGroup_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + WNDPROC oldproc = (WNDPROC) GetPropW(hWnd, szButtonData); + + TRACE("hWnd %p msg %04x wParam 0x%08x lParam 0x%08lx\n", hWnd, msg, wParam, lParam); + + if (msg == WM_COMMAND) /* Forward notifications to dialog */ + SendMessageW(GetParent(hWnd), msg, wParam, lParam); + + return CallWindowProcW(oldproc, hWnd, msg, wParam, lParam); +} + +static LRESULT WINAPI MSIHiddenWindowProc( HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam ) +{ + msi_dialog *dialog = (msi_dialog*) lParam; + + TRACE("%d %p\n", msg, dialog); + + switch (msg) + { + case WM_MSI_DIALOG_CREATE: + return msi_dialog_run_message_loop( dialog ); + case WM_MSI_DIALOG_DESTROY: + msi_dialog_destroy( dialog ); + return 0; + } + return DefWindowProcW( hwnd, msg, wParam, lParam ); +} + /* functions that interface to other modules within MSI */ msi_dialog *msi_dialog_create( MSIPACKAGE* package, LPCWSTR szDialogName, msi_dialog_event_handler event_handler ) { + MSIRECORD *rec = NULL; msi_dialog *dialog; - HWND hwnd; TRACE("%p %s\n", package, debugstr_w(szDialogName)); @@ -1036,73 +1088,112 @@ msi_dialog *msi_dialog_create( MSIPACKAGE* package, LPCWSTR szDialogName, if( !dialog ) return NULL; strcpyW( dialog->name, szDialogName ); + msiobj_addref( &package->hdr ); dialog->package = package; dialog->event_handler = event_handler; + dialog->finished = 0; - /* create the dialog window, don't show it yet */ - hwnd = CreateWindowW( szMsiDialogClass, szDialogName, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, NULL, dialog ); - if( !hwnd ) + /* verify that the dialog exists */ + rec = msi_get_dialog_record( dialog ); + if( !rec ) { - ERR("Failed to create dialog %s\n", debugstr_w( szDialogName )); - msi_dialog_destroy( dialog ); + HeapFree( GetProcessHeap(), 0, dialog ); return NULL; } + dialog->attributes = MSI_RecordGetInteger( rec, 6 ); + msiobj_release( &rec->hdr ); return dialog; } +static void msi_process_pending_messages(void) +{ + MSG msg; + + while( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ) ) + { + TranslateMessage( &msg ); + DispatchMessageW( &msg ); + } +} + void msi_dialog_end_dialog( msi_dialog *dialog ) { + TRACE("%p\n", dialog); dialog->finished = 1; + PostMessageW(dialog->hwnd, WM_NULL, 0, 0); } -UINT msi_dialog_run_message_loop( msi_dialog *dialog ) +void msi_dialog_check_messages( HANDLE handle ) { - MSG msg; + DWORD r; - if( dialog->attributes & msidbDialogAttributesVisible ) + /* in threads other than the UI thread, block */ + if( uiThreadId != GetCurrentThreadId() ) { - ShowWindow( dialog->hwnd, SW_SHOW ); - UpdateWindow( dialog->hwnd ); + if( handle ) + WaitForSingleObject( handle, INFINITE ); + return; } - if( dialog->attributes & msidbDialogAttributesModal ) + /* there's two choices for the UI thread */ + while (1) { - while( !dialog->finished && GetMessageW( &msg, 0, 0, 0 ) ) - { - TranslateMessage( &msg ); - DispatchMessageW( &msg ); - } - } - else - return ERROR_IO_PENDING; + msi_process_pending_messages(); - return ERROR_SUCCESS; + if( !handle ) + break; + + /* + * block here until somebody creates a new dialog or + * the handle we're waiting on becomes ready + */ + r = MsgWaitForMultipleObjects( 1, &handle, 0, INFINITE, QS_ALLINPUT ); + if( r == WAIT_OBJECT_0 ) + break; + } } -void msi_dialog_check_messages( msi_dialog *dialog, HANDLE handle ) +UINT msi_dialog_run_message_loop( msi_dialog *dialog ) { - MSG msg; - DWORD r; + HWND hwnd; + + if( !(dialog->attributes & msidbDialogAttributesVisible) ) + return ERROR_SUCCESS; + + if( uiThreadId != GetCurrentThreadId() ) + return SendMessageW( hMsiHiddenWindow, WM_MSI_DIALOG_CREATE, 0, (LPARAM) dialog ); + + /* create the dialog window, don't show it yet */ + hwnd = CreateWindowW( szMsiDialogClass, dialog->name, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + NULL, NULL, NULL, dialog ); + if( !hwnd ) + { + ERR("Failed to create dialog %s\n", debugstr_w( dialog->name )); + return ERROR_FUNCTION_FAILED; + } - do + ShowWindow( hwnd, SW_SHOW ); + UpdateWindow( hwnd ); + + if( dialog->attributes & msidbDialogAttributesModal ) { - while( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ) ) + while( !dialog->finished ) { - TranslateMessage( &msg ); - DispatchMessageW( &msg ); + MsgWaitForMultipleObjects( 0, NULL, 0, INFINITE, QS_ALLEVENTS ); + msi_process_pending_messages(); } - if( !handle ) - break; - r = MsgWaitForMultipleObjects( 1, &handle, 0, INFINITE, QS_ALLEVENTS ); } - while( WAIT_OBJECT_0 != r ); + else + return ERROR_IO_PENDING; + + return ERROR_SUCCESS; } void msi_dialog_do_preview( msi_dialog *dialog ) { + TRACE("\n"); dialog->attributes |= msidbDialogAttributesVisible; dialog->attributes &= ~msidbDialogAttributesModal; msi_dialog_run_message_loop( dialog ); @@ -1110,6 +1201,12 @@ void msi_dialog_do_preview( msi_dialog *dialog ) void msi_dialog_destroy( msi_dialog *dialog ) { + if( uiThreadId != GetCurrentThreadId() ) + { + SendMessageW( hMsiHiddenWindow, WM_MSI_DIALOG_DESTROY, 0, (LPARAM) dialog ); + return; + } + if( dialog->hwnd ) ShowWindow( dialog->hwnd, SW_HIDE ); @@ -1138,11 +1235,12 @@ void msi_dialog_destroy( msi_dialog *dialog ) if( dialog->hwnd ) DestroyWindow( dialog->hwnd ); + msiobj_release( &dialog->package->hdr ); dialog->package = NULL; HeapFree( GetProcessHeap(), 0, dialog ); } -void msi_dialog_register_class( void ) +BOOL msi_dialog_register_class( void ) { WNDCLASSW cls; @@ -1155,22 +1253,28 @@ void msi_dialog_register_class( void ) cls.lpszMenuName = NULL; cls.lpszClassName = szMsiDialogClass; - RegisterClassW( &cls ); -} + if( !RegisterClassW( &cls ) ) + return FALSE; -void msi_dialog_unregister_class( void ) -{ - UnregisterClassW( szMsiDialogClass, NULL ); -} + cls.lpfnWndProc = MSIHiddenWindowProc; + cls.lpszClassName = szMsiHiddenWindow; -static LRESULT WINAPI MSIRadioGroup_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - WNDPROC oldproc = (WNDPROC) GetPropW(hWnd, szButtonData); + if( !RegisterClassW( &cls ) ) + return FALSE; - TRACE("hWnd %p msg %04x wParam 0x%08x lParam 0x%08lx\n", hWnd, msg, wParam, lParam); + uiThreadId = GetCurrentThreadId(); - if (msg == WM_COMMAND) /* Forward notifications to dialog */ - SendMessageW(GetParent(hWnd), msg, wParam, lParam); + hMsiHiddenWindow = CreateWindowW( szMsiHiddenWindow, NULL, WS_OVERLAPPED, + 0, 0, 100, 100, NULL, NULL, NULL, NULL ); + if( !hMsiHiddenWindow ) + return FALSE; - return CallWindowProcW(oldproc, hWnd, msg, wParam, lParam); + return TRUE; +} + +void msi_dialog_unregister_class( void ) +{ + DestroyWindow( hMsiHiddenWindow ); + UnregisterClassW( szMsiDialogClass, NULL ); + uiThreadId = 0; } diff --git a/reactos/lib/msi/insert.c b/reactos/lib/msi/insert.c index 40dba1a9d4f..b8e69980943 100644 --- a/reactos/lib/msi/insert.c +++ b/reactos/lib/msi/insert.c @@ -233,7 +233,6 @@ static UINT INSERT_delete( struct tagMSIVIEW *view ) sv = iv->sv; if( sv ) sv->ops->delete( sv ); - delete_value_list( iv->vals ); msiobj_release( &iv->db->hdr ); HeapFree( GetProcessHeap(), 0, iv ); diff --git a/reactos/lib/msi/msi.c b/reactos/lib/msi/msi.c index aabcd522e77..b1f3babf69d 100644 --- a/reactos/lib/msi/msi.c +++ b/reactos/lib/msi/msi.c @@ -35,6 +35,8 @@ #include "wincrypt.h" #include "winver.h" #include "winuser.h" +#include "wine/unicode.h" +#include "action.h" UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf, DWORD* pcchVersionBuf, LPWSTR lpLangBuf, DWORD* pcchLangBuf); @@ -59,6 +61,8 @@ LPVOID gUIContext = NULL; WCHAR gszLogFile[MAX_PATH]; HINSTANCE msi_hInstance; +static const WCHAR installerW[] = {'\\','I','n','s','t','a','l','l','e','r',0}; + UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct) { UINT r; @@ -252,7 +256,7 @@ UINT WINAPI MsiApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szInstallPackage, UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel, INSTALLSTATE eInstallState, LPCWSTR szCommandLine) { - MSIHANDLE handle; + MSIHANDLE handle = -1; MSIPACKAGE* package; UINT rc; HKEY hkey=0,hkey1=0; @@ -330,6 +334,8 @@ UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel, HeapFree(GetProcessHeap(),0,commandline); end: RegCloseKey(hkey); + if (handle != -1) + MsiCloseHandle(handle); return rc; } @@ -420,11 +426,38 @@ UINT WINAPI MsiGetProductCodeA(LPCSTR szComponent, LPSTR szBuffer) UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer) { - FIXME("%s %p\n",debugstr_w(szComponent), szBuffer); + UINT rc; + HKEY hkey; + WCHAR szSquished[GUID_SIZE]; + DWORD sz = GUID_SIZE; + static const WCHAR szPermKey[] = + { '0','0','0','0','0','0','0','0','0','0','0','0', + '0','0','0','0','0','0','0', '0','0','0','0','0', + '0','0','0','0','0','0','0','0',0}; + + TRACE("%s %p\n",debugstr_w(szComponent), szBuffer); if (NULL == szComponent) return ERROR_INVALID_PARAMETER; - return ERROR_CALL_NOT_IMPLEMENTED; + + rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE); + if (rc != ERROR_SUCCESS) + return ERROR_UNKNOWN_COMPONENT; + + rc = RegEnumValueW(hkey, 0, szSquished, &sz, NULL, NULL, NULL, NULL); + if (rc == ERROR_SUCCESS && strcmpW(szSquished,szPermKey)==0) + { + sz = GUID_SIZE; + rc = RegEnumValueW(hkey, 1, szSquished, &sz, NULL, NULL, NULL, NULL); + } + + RegCloseKey(hkey); + + if (rc != ERROR_SUCCESS) + return ERROR_INSTALL_FAILURE; + + unsquash_guid(szSquished, szBuffer); + return ERROR_SUCCESS; } UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute, @@ -475,6 +508,14 @@ UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute, { MSIHANDLE hProduct; UINT r; + static const WCHAR szPackageCode[] = + {'P','a','c','k','a','g','e','C','o','d','e',0}; + static const WCHAR szVersionString[] = + {'V','e','r','s','i','o','n','S','t','r','i','n','g',0}; + static const WCHAR szProductVersion[] = + {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0}; + static const WCHAR szAssignmentType[] = + {'A','s','s','i','g','n','m','e','n','t','T','y','p','e',0}; FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szAttribute), szBuffer, pcchValueBuf); @@ -483,13 +524,66 @@ UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute, return ERROR_INVALID_PARAMETER; if (NULL == szProduct || NULL == szAttribute) return ERROR_INVALID_PARAMETER; + + /* check for special properties */ + if (strcmpW(szAttribute, szPackageCode)==0) + { + HKEY hkey; + WCHAR squished[GUID_SIZE]; + WCHAR package[200]; + DWORD sz = sizeof(squished); + + r = MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE); + if (r != ERROR_SUCCESS) + return ERROR_UNKNOWN_PRODUCT; + + r = RegQueryValueExW(hkey, szPackageCode, NULL, NULL, + (LPBYTE)squished, &sz); + if (r != ERROR_SUCCESS) + { + RegCloseKey(hkey); + return ERROR_UNKNOWN_PRODUCT; + } - r = MsiOpenProductW(szProduct, &hProduct); - if (ERROR_SUCCESS != r) - return r; + unsquash_guid(squished, package); + *pcchValueBuf = strlenW(package); + if (strlenW(package) > *pcchValueBuf) + { + RegCloseKey(hkey); + return ERROR_MORE_DATA; + } + else + strcpyW(szBuffer, package); + + RegCloseKey(hkey); + r = ERROR_SUCCESS; + } + else if (strcmpW(szAttribute, szVersionString)==0) + { + r = MsiOpenProductW(szProduct, &hProduct); + if (ERROR_SUCCESS != r) + return r; + + r = MsiGetPropertyW(hProduct, szProductVersion, szBuffer, pcchValueBuf); + MsiCloseHandle(hProduct); + } + else if (strcmpW(szAttribute, szAssignmentType)==0) + { + FIXME("0 (zero) if advertised, 1(one) if per machine.\n"); + if (szBuffer) + szBuffer[0] = 1; + r = ERROR_SUCCESS; + } + else + { + r = MsiOpenProductW(szProduct, &hProduct); + if (ERROR_SUCCESS != r) + return r; + + r = MsiGetPropertyW(hProduct, szAttribute, szBuffer, pcchValueBuf); + MsiCloseHandle(hProduct); + } - r = MsiGetPropertyW(hProduct, szAttribute, szBuffer, pcchValueBuf); - MsiCloseHandle(hProduct); return r; } @@ -970,6 +1064,9 @@ end: return rrc; } +/****************************************************************** + * MsiQueryFeatureStateA [MSI.@] + */ INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature) { INSTALLSTATE rc; @@ -1001,15 +1098,37 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature) return rc; } +/****************************************************************** + * MsiQueryFeatureStateW [MSI.@] + * + * This does not verify that the Feature is functional. So i am only going to + * check the existence of the key in the registry. This should tell me if it is + * installed. + */ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature) { - FIXME("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature)); - /* - * Iterates all the features components and the features parents components - */ - return INSTALLSTATE_LOCAL; + UINT rc; + DWORD sz = 0; + HKEY hkey; + + TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature)); + + rc = MSIREG_OpenFeaturesKey(szProduct, &hkey, FALSE); + if (rc != ERROR_SUCCESS) + return INSTALLSTATE_UNKNOWN; + + rc = RegQueryValueExW( hkey, szFeature, NULL, NULL, NULL, &sz); + RegCloseKey(hkey); + + if (rc == ERROR_SUCCESS) + return INSTALLSTATE_LOCAL; + else + return INSTALLSTATE_ABSENT; } +/****************************************************************** + * MsiGetFileVersionA [MSI.@] + */ UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf, DWORD* pcchVersionBuf, LPSTR lpLangBuf, DWORD* pcchLangBuf) { @@ -1055,6 +1174,9 @@ end: return ret; } +/****************************************************************** + * MsiGetFileVersionW [MSI.@] + */ UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf, DWORD* pcchVersionBuf, LPWSTR lpLangBuf, DWORD* pcchLangBuf) { @@ -1195,7 +1317,7 @@ static IClassFactoryVtbl MsiCF_Vtbl = static IClassFactoryImpl Msi_CF = { &MsiCF_Vtbl }; /****************************************************************** - * DllGetClassObject [MSI.@] + * DllGetClassObject [MSI.@] */ HRESULT WINAPI MSI_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) { @@ -1214,7 +1336,7 @@ HRESULT WINAPI MSI_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) } /****************************************************************** - * DllGetVersion [MSI.@] + * DllGetVersion [MSI.@] */ HRESULT WINAPI MSI_DllGetVersion(DLLVERSIONINFO *pdvi) { @@ -1232,7 +1354,7 @@ HRESULT WINAPI MSI_DllGetVersion(DLLVERSIONINFO *pdvi) } /****************************************************************** - * DllCanUnloadNow [MSI.@] + * DllCanUnloadNow [MSI.@] */ BOOL WINAPI MSI_DllCanUnloadNow(void) { @@ -1272,6 +1394,9 @@ INSTALLSTATE WINAPI MsiUseFeatureExW(LPCWSTR szProduct, LPCWSTR szFeature, return INSTALLSTATE_LOCAL; } +/*********************************************************************** + * MsiUseFeatureExA [MSI.@] + */ INSTALLSTATE WINAPI MsiUseFeatureExA(LPCSTR szProduct, LPCSTR szFeature, DWORD dwInstallMode, DWORD dwReserved) { @@ -1300,22 +1425,191 @@ UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent, DWORD Unused1, DWORD Unused2, LPWSTR lpPathBuf, DWORD* pcchPathBuf) { - FIXME("%s %s %li %s %li %li %p %p\n", debugstr_w(szComponent), + HKEY hkey; + UINT rc; + LPWSTR info; + DWORD sz; + LPWSTR product = NULL; + LPWSTR component = NULL; + LPWSTR ptr; + GUID clsid; + + TRACE("%s %s %li %s %li %li %p %p\n", debugstr_w(szComponent), debugstr_w(szQualifier), dwInstallMode, debugstr_w(szProduct), Unused1, Unused2, lpPathBuf, pcchPathBuf); + + rc = MSIREG_OpenUserComponentsKey(szComponent, &hkey, FALSE); + if (rc != ERROR_SUCCESS) + return ERROR_INDEX_ABSENT; - return ERROR_INDEX_ABSENT; + sz = 0; + rc = RegQueryValueExW( hkey, szQualifier, NULL, NULL, NULL, &sz); + if (sz <= 0) + { + RegCloseKey(hkey); + return ERROR_INDEX_ABSENT; + } + + info = HeapAlloc(GetProcessHeap(),0,sz); + rc = RegQueryValueExW( hkey, szQualifier, NULL, NULL, (LPBYTE)info, &sz); + if (rc != ERROR_SUCCESS) + { + RegCloseKey(hkey); + HeapFree(GetProcessHeap(),0,info); + return ERROR_INDEX_ABSENT; + } + + /* find the component */ + ptr = strchrW(&info[20],'>'); + if (ptr) + ptr++; + else + { + RegCloseKey(hkey); + HeapFree(GetProcessHeap(),0,info); + return ERROR_INDEX_ABSENT; + } + + if (!szProduct) + { + decode_base85_guid(info,&clsid); + StringFromCLSID(&clsid, &product); + } + decode_base85_guid(ptr,&clsid); + StringFromCLSID(&clsid, &component); + + if (!szProduct) + rc = MsiGetComponentPathW(product, component, lpPathBuf, pcchPathBuf); + else + rc = MsiGetComponentPathW(szProduct, component, lpPathBuf, pcchPathBuf); + + RegCloseKey(hkey); + HeapFree(GetProcessHeap(),0,info); + HeapFree(GetProcessHeap(),0,product); + HeapFree(GetProcessHeap(),0,component); + + if (rc == INSTALLSTATE_LOCAL) + return ERROR_SUCCESS; + else + return ERROR_FILE_NOT_FOUND; +} + +/*********************************************************************** + * MsiProvideQualifiedComponentW [MSI.@] + */ +UINT WINAPI MsiProvideQualifiedComponentW( LPCWSTR szComponent, + LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR lpPathBuf, + DWORD* pcchPathBuf) +{ + return MsiProvideQualifiedComponentExW(szComponent, szQualifier, + dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf); +} + +/*********************************************************************** + * MsiProvideQualifiedComponentA [MSI.@] + */ +UINT WINAPI MsiProvideQualifiedComponentA( LPCSTR szComponent, + LPCSTR szQualifier, DWORD dwInstallMode, LPSTR lpPathBuf, + DWORD* pcchPathBuf) +{ + LPWSTR szwComponent, szwQualifier, lpwPathBuf; + DWORD pcchwPathBuf; + UINT rc; + + TRACE("%s %s %li %p %p\n",szComponent, szQualifier, + dwInstallMode, lpPathBuf, pcchPathBuf); + + szwComponent= strdupAtoW( szComponent); + szwQualifier= strdupAtoW( szQualifier); + + lpwPathBuf = HeapAlloc(GetProcessHeap(),0,*pcchPathBuf * sizeof(WCHAR)); + + pcchwPathBuf = *pcchPathBuf; + + rc = MsiProvideQualifiedComponentW(szwComponent, szwQualifier, + dwInstallMode, lpwPathBuf, &pcchwPathBuf); + + HeapFree(GetProcessHeap(),0,szwComponent); + HeapFree(GetProcessHeap(),0,szwQualifier); + *pcchPathBuf = WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, pcchwPathBuf, + lpPathBuf, *pcchPathBuf, NULL, NULL); + + HeapFree(GetProcessHeap(),0,lpwPathBuf); + return rc; } USERINFOSTATE WINAPI MsiGetUserInfoW(LPCWSTR szProduct, LPWSTR lpUserNameBuf, DWORD* pcchUserNameBuf, LPWSTR lpOrgNameBuf, DWORD* pcchOrgNameBuf, LPWSTR lpSerialBuf, DWORD* pcchSerialBuf) { - FIXME("%s %p %p %p %p %p %p\n",debugstr_w(szProduct), lpUserNameBuf, + HKEY hkey; + DWORD sz; + UINT rc = ERROR_SUCCESS,rc2 = ERROR_SUCCESS; + static const WCHAR szOwner[] = {'R','e','g','O','w','n','e','r',0}; + static const WCHAR szCompany[] = {'R','e','g','C','o','m','p','a','n','y',0}; + static const WCHAR szSerial[] = {'P','r','o','d','u','c','t','I','D',0}; + + TRACE("%s %p %p %p %p %p %p\n",debugstr_w(szProduct), lpUserNameBuf, pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf, pcchSerialBuf); - return USERINFOSTATE_UNKNOWN; + rc = MSIREG_OpenUninstallKey(szProduct, &hkey, FALSE); + if (rc != ERROR_SUCCESS) + return USERINFOSTATE_UNKNOWN; + + if (lpUserNameBuf) + { + sz = *lpUserNameBuf * sizeof(WCHAR); + rc = RegQueryValueExW( hkey, szOwner, NULL, NULL, (LPBYTE)lpUserNameBuf, + &sz); + } + if (!lpUserNameBuf && pcchUserNameBuf) + { + sz = 0; + rc = RegQueryValueExW( hkey, szOwner, NULL, NULL, NULL, &sz); + } + + if (pcchUserNameBuf) + *pcchUserNameBuf = sz / sizeof(WCHAR); + + if (lpOrgNameBuf) + { + sz = *pcchOrgNameBuf * sizeof(WCHAR); + rc2 = RegQueryValueExW( hkey, szCompany, NULL, NULL, + (LPBYTE)lpOrgNameBuf, &sz); + } + if (!lpOrgNameBuf && pcchOrgNameBuf) + { + sz = 0; + rc2 = RegQueryValueExW( hkey, szCompany, NULL, NULL, NULL, &sz); + } + + if (pcchOrgNameBuf) + *pcchOrgNameBuf = sz / sizeof(WCHAR); + + if (rc != ERROR_SUCCESS && rc != ERROR_MORE_DATA && + rc2 != ERROR_SUCCESS && rc2 != ERROR_MORE_DATA) + { + RegCloseKey(hkey); + return USERINFOSTATE_ABSENT; + } + + if (lpSerialBuf) + { + sz = *pcchSerialBuf * sizeof(WCHAR); + RegQueryValueExW( hkey, szSerial, NULL, NULL, (LPBYTE)lpSerialBuf, + &sz); + } + if (!lpSerialBuf && pcchSerialBuf) + { + sz = 0; + rc = RegQueryValueExW( hkey, szSerial, NULL, NULL, NULL, &sz); + } + if (pcchSerialBuf) + *pcchSerialBuf = sz / sizeof(WCHAR); + + RegCloseKey(hkey); + return USERINFOSTATE_PRESENT; } USERINFOSTATE WINAPI MsiGetUserInfoA(LPCSTR szProduct, LPSTR lpUserNameBuf, @@ -1331,20 +1625,68 @@ USERINFOSTATE WINAPI MsiGetUserInfoA(LPCSTR szProduct, LPSTR lpUserNameBuf, UINT WINAPI MsiCollectUserInfoW(LPCWSTR szProduct) { - FIXME("%s\n",debugstr_w(szProduct)); - return ERROR_CALL_NOT_IMPLEMENTED; + MSIHANDLE handle; + UINT rc; + MSIPACKAGE *package; + static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0}; + + TRACE("(%s)\n",debugstr_w(szProduct)); + + rc = MsiOpenProductW(szProduct,&handle); + if (rc != ERROR_SUCCESS) + return ERROR_INVALID_PARAMETER; + + package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE); + rc = ACTION_PerformUIAction(package, szFirstRun); + msiobj_release( &package->hdr ); + + MsiCloseHandle(handle); + + return rc; } UINT WINAPI MsiCollectUserInfoA(LPCSTR szProduct) { - FIXME("%s\n",debugstr_a(szProduct)); - return ERROR_CALL_NOT_IMPLEMENTED; + MSIHANDLE handle; + UINT rc; + MSIPACKAGE *package; + static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0}; + + TRACE("(%s)\n",debugstr_a(szProduct)); + + rc = MsiOpenProductA(szProduct,&handle); + if (rc != ERROR_SUCCESS) + return ERROR_INVALID_PARAMETER; + + package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE); + rc = ACTION_PerformUIAction(package, szFirstRun); + msiobj_release( &package->hdr ); + + MsiCloseHandle(handle); + + return rc; } UINT WINAPI MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved) { - FIXME("%ld\n", dwReserved); - return ERROR_CALL_NOT_IMPLEMENTED; + WCHAR path[MAX_PATH]; + + if(dwReserved) { + FIXME("Don't know how to handle argument %ld\n", dwReserved); + return ERROR_CALL_NOT_IMPLEMENTED; + } + + if(!GetWindowsDirectoryW(path, MAX_PATH)) { + FIXME("GetWindowsDirectory failed unexpected! Error %ld\n", + GetLastError()); + return ERROR_CALL_NOT_IMPLEMENTED; + } + + strcatW(path, installerW); + + CreateDirectoryW(path, NULL); + + return 0; } UINT WINAPI MsiGetShortcutTargetA( LPCSTR szShortcutTarget, diff --git a/reactos/lib/msi/msi.spec b/reactos/lib/msi/msi.spec index 4bf2712ecb1..91464064b0d 100644 --- a/reactos/lib/msi/msi.spec +++ b/reactos/lib/msi/msi.spec @@ -18,8 +18,8 @@ 18 stdcall MsiDatabaseApplyTransformA(long str long) 19 stdcall MsiDatabaseApplyTransformW(long wstr long) 20 stdcall MsiDatabaseCommit(long) -21 stub MsiDatabaseExportA -22 stub MsiDatabaseExportW +21 stdcall MsiDatabaseExportA(long str str str) +22 stdcall MsiDatabaseExportW(long wstr wstr wstr) 23 stdcall MsiDatabaseGenerateTransformA(long long str long long) 24 stdcall MsiDatabaseGenerateTransformW(long long wstr long long) 25 stdcall MsiDatabaseGetPrimaryKeysA(long str ptr) @@ -78,7 +78,7 @@ 78 stdcall MsiGetSummaryInformationW(long wstr long ptr) 79 stdcall MsiGetTargetPathA(long str ptr ptr) 80 stdcall MsiGetTargetPathW(long wstr ptr ptr) -81 stub MsiGetUserInfoA +81 stdcall MsiGetUserInfoA(str ptr ptr ptr ptr ptr ptr) 82 stdcall MsiGetUserInfoW(wstr ptr ptr ptr ptr ptr ptr) 83 stub MsiInstallMissingComponentA 84 stub MsiInstallMissingComponentW @@ -105,8 +105,8 @@ 105 stdcall MsiProvideComponentFromDescriptorA(str ptr ptr ptr) 106 stdcall MsiProvideComponentFromDescriptorW(wstr ptr ptr ptr) 107 stub MsiProvideComponentW -108 stub MsiProvideQualifiedComponentA -109 stub MsiProvideQualifiedComponentW +108 stdcall MsiProvideQualifiedComponentA(str str long ptr ptr) +109 stdcall MsiProvideQualifiedComponentW(str str long ptr ptr) 110 stdcall MsiQueryFeatureStateA(str str) 111 stdcall MsiQueryFeatureStateW(wstr wstr) 112 stdcall MsiQueryProductStateA(str) diff --git a/reactos/lib/msi/msi_Fr.rc b/reactos/lib/msi/msi_Fr.rc index d1551aba270..6ed10340aac 100644 --- a/reactos/lib/msi/msi_Fr.rc +++ b/reactos/lib/msi/msi_Fr.rc @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -LANGUAGE LANG_FRENCH, SUBLANG_DEFAULT +LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE { diff --git a/reactos/lib/msi/msipriv.h b/reactos/lib/msi/msipriv.h index 290de68e075..2aad08a9d82 100644 --- a/reactos/lib/msi/msipriv.h +++ b/reactos/lib/msi/msipriv.h @@ -30,6 +30,7 @@ #include "objbase.h" #include "objidl.h" #include "wine/unicode.h" +#include "wine/list.h" #define MSI_DATASIZEMASK 0x00ff #define MSITYPE_VALID 0x0100 @@ -77,6 +78,7 @@ typedef struct tagMSIQUERY MSIVIEW *view; UINT row; MSIDATABASE *db; + struct list mem; } MSIQUERY; /* maybe we can use a Variant instead of doing it ourselves? */ @@ -288,7 +290,7 @@ extern const WCHAR *msi_string_lookup_id( string_table *st, UINT id ); extern UINT msi_string_get_codepage( string_table *st ); -extern UINT VIEW_find_column( MSIVIEW *view, LPWSTR name, UINT *n ); +extern UINT VIEW_find_column( MSIVIEW *view, LPCWSTR name, UINT *n ); extern BOOL TABLE_Exists( MSIDATABASE *db, LPWSTR name ); @@ -342,6 +344,7 @@ extern MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *, LPCWSTR ); extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR ); extern UINT MSI_GetComponentStateW( MSIPACKAGE *, LPWSTR, INSTALLSTATE *, INSTALLSTATE * ); extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPWSTR, INSTALLSTATE *, INSTALLSTATE * ); +extern UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE*, LPCWSTR, INSTALLSTATE ); /* for deformating */ extern UINT MSI_FormatRecordW(MSIPACKAGE* package, MSIRECORD* record, @@ -357,6 +360,7 @@ extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create extern UINT MSIREG_OpenFeatures(HKEY* key); extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create); extern UINT MSIREG_OpenComponents(HKEY* key); +extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create); extern UINT MSIREG_OpenComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create); extern UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create); extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create); @@ -367,10 +371,10 @@ typedef VOID (*msi_dialog_event_handler)( MSIPACKAGE*, LPCWSTR, LPCWSTR, msi_dia extern msi_dialog *msi_dialog_create( MSIPACKAGE*, LPCWSTR, msi_dialog_event_handler ); extern UINT msi_dialog_run_message_loop( msi_dialog* ); extern void msi_dialog_end_dialog( msi_dialog* ); -extern void msi_dialog_check_messages( msi_dialog*, HANDLE ); +extern void msi_dialog_check_messages( HANDLE ); extern void msi_dialog_do_preview( msi_dialog* ); extern void msi_dialog_destroy( msi_dialog* ); -extern void msi_dialog_register_class( void ); +extern BOOL msi_dialog_register_class( void ); extern void msi_dialog_unregister_class( void ); /* UI globals */ diff --git a/reactos/lib/msi/msiquery.c b/reactos/lib/msi/msiquery.c index eb50d0991cc..cdd4457e612 100644 --- a/reactos/lib/msi/msiquery.c +++ b/reactos/lib/msi/msiquery.c @@ -41,13 +41,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(msi); void MSI_CloseView( MSIOBJECTHDR *arg ) { MSIQUERY *query = (MSIQUERY*) arg; + struct list *ptr, *t; if( query->view && query->view->ops->delete ) query->view->ops->delete( query->view ); msiobj_release( &query->db->hdr ); + + LIST_FOR_EACH_SAFE( ptr, t, &query->mem ) + { + HeapFree( GetProcessHeap(), 0, ptr ); + } } -UINT VIEW_find_column( MSIVIEW *table, LPWSTR name, UINT *n ) +UINT VIEW_find_column( MSIVIEW *table, LPCWSTR name, UINT *n ) { LPWSTR col_name; UINT i, count, r; @@ -120,8 +126,9 @@ UINT MSI_DatabaseOpenViewW(MSIDATABASE *db, query->row = 0; query->db = db; query->view = NULL; + list_init( &query->mem ); - r = MSI_ParseSQL( db, szQuery, &query->view ); + r = MSI_ParseSQL( db, szQuery, &query->view, &query->mem ); if( r == ERROR_SUCCESS ) { msiobj_addref( &query->hdr ); @@ -141,7 +148,7 @@ UINT MSI_OpenQuery( MSIDATABASE *db, MSIQUERY **view, LPCWSTR fmt, ... ) /* figure out how much space we need to allocate */ va_start(va, fmt); - sz = strlenW(fmt) + 1; + sz = lstrlenW(fmt) + 1; p = fmt; while (*p) { @@ -152,7 +159,7 @@ UINT MSI_OpenQuery( MSIDATABASE *db, MSIQUERY **view, LPCWSTR fmt, ... ) switch (*p) { case 's': /* a string */ - sz += strlenW(va_arg(va,LPCWSTR)); + sz += lstrlenW(va_arg(va,LPCWSTR)); break; case 'd': case 'i': /* an integer -2147483648 seems to be longest */ diff --git a/reactos/lib/msi/order.c b/reactos/lib/msi/order.c index c23b1ef89ef..33947a0620f 100644 --- a/reactos/lib/msi/order.c +++ b/reactos/lib/msi/order.c @@ -264,40 +264,8 @@ MSIVIEWOPS order_ops = ORDER_delete }; -UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table ) +static UINT ORDER_AddColumn( MSIORDERVIEW *ov, LPCWSTR name ) { - MSIORDERVIEW *ov = NULL; - UINT count = 0, r; - - TRACE("%p\n", ov ); - - r = table->ops->get_dimensions( table, NULL, &count ); - if( r != ERROR_SUCCESS ) - { - ERR("can't get table dimensions\n"); - return r; - } - - ov = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof *ov + sizeof (UINT) * count ); - if( !ov ) - return ERROR_FUNCTION_FAILED; - - /* fill the structure */ - ov->view.ops = &order_ops; - msiobj_addref( &db->hdr ); - ov->db = db; - ov->table = table; - ov->reorder = NULL; - ov->num_cols = 0; - *view = (MSIVIEW*) ov; - - return ERROR_SUCCESS; -} - -UINT ORDER_AddColumn( MSIVIEW *view, LPWSTR name ) -{ - MSIORDERVIEW *ov = (MSIORDERVIEW*)view; UINT n, count, r; MSIVIEW *table; @@ -332,3 +300,39 @@ UINT ORDER_AddColumn( MSIVIEW *view, LPWSTR name ) return ERROR_SUCCESS; } + +UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, + string_list *columns ) +{ + MSIORDERVIEW *ov = NULL; + UINT count = 0, r; + string_list *x; + + TRACE("%p\n", ov ); + + r = table->ops->get_dimensions( table, NULL, &count ); + if( r != ERROR_SUCCESS ) + { + ERR("can't get table dimensions\n"); + return r; + } + + ov = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof *ov + sizeof (UINT) * count ); + if( !ov ) + return ERROR_FUNCTION_FAILED; + + /* fill the structure */ + ov->view.ops = &order_ops; + msiobj_addref( &db->hdr ); + ov->db = db; + ov->table = table; + ov->reorder = NULL; + ov->num_cols = 0; + *view = (MSIVIEW*) ov; + + for( x = columns; x ; x = x->next ) + ORDER_AddColumn( ov, x->string ); + + return ERROR_SUCCESS; +} diff --git a/reactos/lib/msi/package.c b/reactos/lib/msi/package.c index 938de885d70..be257e1d9d0 100644 --- a/reactos/lib/msi/package.c +++ b/reactos/lib/msi/package.c @@ -73,7 +73,7 @@ static UINT clone_properties(MSIDATABASE *db) 'Y',' ','K','E','Y',' ','`','_','P','r','o','p','e','r','t','y','`',')',0}; static const WCHAR Query[] = { 'S','E','L','E','C','T',' ','*',' ', - 'f','r','o','m',' ','P','r','o','p','e','r','t','y',0}; + 'F','R','O','M',' ','`','P','r','o','p','e','r','t','y','`',0}; static const WCHAR Insert[] = { 'I','N','S','E','R','T',' ','i','n','t','o',' ', '`','_','P','r','o','p','e','r','t','y','`',' ', @@ -139,6 +139,7 @@ static VOID set_installer_properties(MSIPACKAGE *package) WCHAR pth[MAX_PATH]; WCHAR *ptr; OSVERSIONINFOA OSVersion; + MEMORYSTATUSEX msex; DWORD verval; WCHAR verstr[10], bufstr[20]; HDC dc; @@ -202,6 +203,7 @@ static VOID set_installer_properties(MSIPACKAGE *package) static const WCHAR szSix[] = {'6',0 }; static const WCHAR szVersionMsi[] = { 'V','e','r','s','i','o','n','M','s','i',0 }; + static const WCHAR szPhysicalMemory[] = { 'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0 }; static const WCHAR szFormat2[] = {'%','l','i','.','%','l','i',0}; /* Screen properties */ static const WCHAR szScreenX[] = {'S','c','r','e','e','n','X',0}; @@ -217,7 +219,6 @@ ComputerName UserLanguageID LogonUser VirtualMemory -PhysicalMemory Intel ShellAdvSupport DefaultUIFont @@ -306,6 +307,12 @@ Privileged SHGetFolderPathW(NULL,CSIDL_WINDOWS,NULL,0,pth); strcatW(pth,cszbs); MSI_SetPropertyW(package, WF, pth); + + /* Physical Memory is specified in MB. Using total amount. */ + msex.dwLength = sizeof(msex); + GlobalMemoryStatusEx( &msex ); + sprintfW( bufstr, szScreenFormat, (int)(msex.ullTotalPhys/1024/1024)); + MSI_SetPropertyW(package, szPhysicalMemory, bufstr); SHGetFolderPathW(NULL,CSIDL_WINDOWS,NULL,0,pth); ptr = strchrW(pth,'\\'); @@ -740,9 +747,10 @@ static UINT MSI_GetPropertyRow(MSIPACKAGE *package, LPCWSTR szName, MSIRECORD ** MSIQUERY *view; UINT rc, sz; static const WCHAR select[]= - {'s','e','l','e','c','t',' ','V','a','l','u','e',' ','f','r','o','m',' ' - ,'_','P','r','o','p','e','r','t','y',' ','w','h','e','r','e',' ' - ,'_','P','r','o','p','e','r','t','y','=','`','%','s','`',0}; + {'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ', + 'F','R','O','M',' ' ,'`','_','P','r','o','p','e','r','t','y','`', + ' ','W','H','E','R','E',' ' ,'`','_','P','r','o','p','e','r','t','y','`', + '=','\'','%','s','\'',0}; LPWSTR query; if (!szName) @@ -793,7 +801,7 @@ UINT MSI_GetPropertyW(MSIPACKAGE *package, LPCWSTR szName, else { *pchValueBuf = 0; - TRACE("property not found\n"); + TRACE("property %s not found\n", debugstr_w(szName)); } return rc; diff --git a/reactos/lib/msi/query.h b/reactos/lib/msi/query.h index b66cc589df4..7227129405d 100644 --- a/reactos/lib/msi/query.h +++ b/reactos/lib/msi/query.h @@ -30,6 +30,7 @@ #include "msi.h" #include "msiquery.h" #include "msipriv.h" +#include "wine/list.h" #define OP_EQ 1 @@ -50,7 +51,6 @@ #define EXPR_SVAL 5 #define EXPR_UVAL 6 #define EXPR_STRCMP 7 -#define EXPR_UTF8 8 #define EXPR_WILDCARD 9 #define EXPR_COL_NUMBER_STRING 10 @@ -83,7 +83,6 @@ struct expr LPWSTR sval; LPWSTR column; UINT col_number; - char *utf8; } u; }; @@ -107,7 +106,8 @@ typedef struct _column_assignment } column_assignment; -UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phView); +UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview, + struct list *mem ); UINT TABLE_CreateView( MSIDATABASE *db, LPCWSTR name, MSIVIEW **view ); @@ -116,8 +116,8 @@ UINT SELECT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, UINT DISTINCT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table ); -UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table ); -UINT ORDER_AddColumn( MSIVIEW *group, LPWSTR name ); +UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, + string_list *columns ); UINT WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, struct expr *cond ); @@ -133,10 +133,6 @@ UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **, LPWSTR table, UINT DELETE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table ); -void delete_expr( struct expr *e ); -void delete_string_list( string_list *sl ); -void delete_value_list( value_list *vl ); - int sqliteGetToken(const WCHAR *z, int *tokenType); #endif /* __WINE_MSI_QUERY_H */ diff --git a/reactos/lib/msi/record.c b/reactos/lib/msi/record.c index a06b0a58658..2b0469040c2 100644 --- a/reactos/lib/msi/record.c +++ b/reactos/lib/msi/record.c @@ -98,6 +98,7 @@ MSIHANDLE WINAPI MsiCreateRecord( unsigned int cParams ) rec = MSI_CreateRecord( cParams ); if( rec ) ret = alloc_msihandle( &rec->hdr ); + msiobj_release( &rec->hdr ); return ret; } diff --git a/reactos/lib/msi/registry.c b/reactos/lib/msi/registry.c index c6de5692a96..15e91090dc5 100644 --- a/reactos/lib/msi/registry.c +++ b/reactos/lib/msi/registry.c @@ -85,6 +85,13 @@ static const WCHAR szInstaller_Components_fmt[] = { 'C','o','m','p','o','n','e','n','t','s','\\', '%','s',0}; +static const WCHAR szUser_Components_fmt[] = { +'S','o','f','t','w','a','r','e','\\', +'M','i','c','r','o','s','o','f','t','\\', +'I','n','s','t','a','l','l','e','r','\\', +'C','o','m','p','o','n','e','n','t','s','\\', +'%','s',0}; + static const WCHAR szUninstall_fmt[] = { 'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\', @@ -388,6 +395,26 @@ UINT MSIREG_OpenComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create) return rc; } +UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create) +{ + UINT rc; + WCHAR squished_cc[GUID_SIZE]; + WCHAR keypath[0x200]; + + TRACE("%s\n",debugstr_w(szComponent)); + squash_guid(szComponent,squished_cc); + TRACE("squished (%s)\n", debugstr_w(squished_cc)); + + sprintfW(keypath,szUser_Components_fmt,squished_cc); + + if (create) + rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key); + else + rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key); + + return rc; +} + UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create) { UINT rc; @@ -695,26 +722,154 @@ UINT WINAPI MsiEnumClientsW(LPCWSTR szComponent, DWORD index, LPWSTR szProduct) return r; } +/************************************************************************* + * MsiEnumComponentQualifiersA [MSI.@] + * + */ UINT WINAPI MsiEnumComponentQualifiersA( LPSTR szComponent, DWORD iIndex, LPSTR lpQualifierBuf, DWORD* pcchQualifierBuf, LPSTR lpApplicationDataBuf, DWORD* pcchApplicationDataBuf) { - FIXME("%s %08lx %p %p %p %p\n", debugstr_a(szComponent), iIndex, + LPWSTR szwComponent; + LPWSTR lpwQualifierBuf; + DWORD pcchwQualifierBuf; + LPWSTR lpwApplicationDataBuf; + DWORD pcchwApplicationDataBuf; + DWORD rc; + DWORD length; + + TRACE("%s %08lx %p %p %p %p\n", debugstr_a(szComponent), iIndex, lpQualifierBuf, pcchQualifierBuf, lpApplicationDataBuf, pcchApplicationDataBuf); - return ERROR_CALL_NOT_IMPLEMENTED; + + szwComponent = strdupAtoW(szComponent); + + if (lpQualifierBuf) + lpwQualifierBuf = HeapAlloc(GetProcessHeap(),0, (*pcchQualifierBuf) * + sizeof(WCHAR)); + else + lpwQualifierBuf = NULL; + + if (pcchQualifierBuf) + pcchwQualifierBuf = *pcchQualifierBuf; + else + pcchwQualifierBuf = 0; + + if (lpApplicationDataBuf) + lpwApplicationDataBuf = HeapAlloc(GetProcessHeap(),0 , + (*pcchApplicationDataBuf) * sizeof(WCHAR)); + else + lpwApplicationDataBuf = NULL; + + if (pcchApplicationDataBuf) + pcchwApplicationDataBuf = *pcchApplicationDataBuf; + else + pcchwApplicationDataBuf = 0; + + rc = MsiEnumComponentQualifiersW( szwComponent, iIndex, lpwQualifierBuf, + &pcchwQualifierBuf, lpwApplicationDataBuf, + &pcchwApplicationDataBuf); + + /* + * A bit of wizardry to report back the length without the null. + * just in case the buffer is too small and is filled. + */ + if (lpQualifierBuf) + { + length = WideCharToMultiByte(CP_ACP, 0, lpwQualifierBuf, -1, + lpQualifierBuf, *pcchQualifierBuf, NULL, NULL); + + if (*pcchQualifierBuf == length && lpQualifierBuf[length-1]) + *pcchQualifierBuf = length; + else + *pcchQualifierBuf = length - 1; + } + if (lpApplicationDataBuf) + { + length = WideCharToMultiByte(CP_ACP, 0, + lpwApplicationDataBuf, -1, lpApplicationDataBuf, + *pcchApplicationDataBuf, NULL, NULL); + + if (*pcchApplicationDataBuf == length && lpApplicationDataBuf[length-1]) + *pcchApplicationDataBuf = length; + else + *pcchApplicationDataBuf = length - 1; + } + + HeapFree(GetProcessHeap(),0,lpwApplicationDataBuf); + HeapFree(GetProcessHeap(),0,lpwQualifierBuf); + HeapFree(GetProcessHeap(),0,szwComponent); + + return rc; } +/************************************************************************* + * MsiEnumComponentQualifiersW [MSI.@] + * + */ UINT WINAPI MsiEnumComponentQualifiersW( LPWSTR szComponent, DWORD iIndex, LPWSTR lpQualifierBuf, DWORD* pcchQualifierBuf, LPWSTR lpApplicationDataBuf, DWORD* pcchApplicationDataBuf ) { - FIXME("%s %08lx %p %p %p %p\n", debugstr_w(szComponent), iIndex, + UINT rc; + HKEY key; + DWORD actual_pcchQualifierBuf = 0; + DWORD actual_pcchApplicationDataBuf = 0; + LPWSTR full_buffer = NULL; + DWORD full_buffer_size = 0; + LPWSTR ptr; + + TRACE("%s %08lx %p %p %p %p\n", debugstr_w(szComponent), iIndex, lpQualifierBuf, pcchQualifierBuf, lpApplicationDataBuf, pcchApplicationDataBuf); - return ERROR_CALL_NOT_IMPLEMENTED; + + if (pcchQualifierBuf) + actual_pcchQualifierBuf = *pcchQualifierBuf * sizeof(WCHAR); + if (pcchApplicationDataBuf) + actual_pcchApplicationDataBuf = *pcchApplicationDataBuf * sizeof(WCHAR); + + rc = MSIREG_OpenUserComponentsKey(szComponent, &key, FALSE); + if (rc != ERROR_SUCCESS) + return ERROR_UNKNOWN_COMPONENT; + + full_buffer_size = (52 * sizeof(WCHAR)) + actual_pcchApplicationDataBuf; + full_buffer = HeapAlloc(GetProcessHeap(),0,full_buffer_size); + + rc = RegEnumValueW(key, iIndex, lpQualifierBuf, pcchQualifierBuf, NULL, + NULL, (LPBYTE)full_buffer, &full_buffer_size); + + RegCloseKey(key); + + if (rc == ERROR_SUCCESS || rc == ERROR_MORE_DATA) + { + if (lpApplicationDataBuf && pcchApplicationDataBuf) + { + ptr = full_buffer; + /* Skip the first guid */ + ptr += 21; + + /* Skip the name and the component guid if it exists */ + if (strchrW(ptr,'<')) + ptr = strchrW(ptr,'<'); + else + ptr = strchrW(ptr,'>') + 21; + + lstrcpynW(lpApplicationDataBuf,ptr,*pcchApplicationDataBuf); + *pcchApplicationDataBuf = strlenW(ptr); + } + if (lpQualifierBuf && pcchQualifierBuf) + *pcchQualifierBuf /= sizeof(WCHAR); + TRACE("Providing %s and %s\n", debugstr_w(lpQualifierBuf), + debugstr_w(lpApplicationDataBuf)); + } + + return rc; } +/************************************************************************* + * MsiEnumRelatedProductsW [MSI.@] + * + */ UINT WINAPI MsiEnumRelatedProductsW(LPCWSTR szUpgradeCode, DWORD dwReserved, DWORD iProductIndex, LPWSTR lpProductBuf) { @@ -742,6 +897,10 @@ UINT WINAPI MsiEnumRelatedProductsW(LPCWSTR szUpgradeCode, DWORD dwReserved, return r; } +/************************************************************************* + * MsiEnumRelatedProductsA [MSI.@] + * + */ UINT WINAPI MsiEnumRelatedProductsA(LPCSTR szUpgradeCode, DWORD dwReserved, DWORD iProductIndex, LPSTR lpProductBuf) { diff --git a/reactos/lib/msi/sql.tab.c b/reactos/lib/msi/sql.tab.c index 874691c4c28..524ddda0788 100644 --- a/reactos/lib/msi/sql.tab.c +++ b/reactos/lib/msi/sql.tab.c @@ -1,2514 +1,2148 @@ -/* A Bison parser, made by GNU Bison 1.875b. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 1 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - -/* If NAME_PREFIX is specified substitute the variables and functions - names. */ -#define yyparse SQL_parse -#define yylex SQL_lex -#define yyerror SQL_error -#define yylval SQL_lval -#define yychar SQL_char -#define yydebug SQL_debug -#define yynerrs SQL_nerrs - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TK_ABORT = 258, - TK_AFTER = 259, - TK_AGG_FUNCTION = 260, - TK_ALL = 261, - TK_AND = 262, - TK_AS = 263, - TK_ASC = 264, - TK_BEFORE = 265, - TK_BEGIN = 266, - TK_BETWEEN = 267, - TK_BITAND = 268, - TK_BITNOT = 269, - TK_BITOR = 270, - TK_BY = 271, - TK_CASCADE = 272, - TK_CASE = 273, - TK_CHAR = 274, - TK_CHECK = 275, - TK_CLUSTER = 276, - TK_COLLATE = 277, - TK_COLUMN = 278, - TK_COMMA = 279, - TK_COMMENT = 280, - TK_COMMIT = 281, - TK_CONCAT = 282, - TK_CONFLICT = 283, - TK_CONSTRAINT = 284, - TK_COPY = 285, - TK_CREATE = 286, - TK_DEFAULT = 287, - TK_DEFERRABLE = 288, - TK_DEFERRED = 289, - TK_DELETE = 290, - TK_DELIMITERS = 291, - TK_DESC = 292, - TK_DISTINCT = 293, - TK_DOT = 294, - TK_DROP = 295, - TK_EACH = 296, - TK_ELSE = 297, - TK_END = 298, - TK_END_OF_FILE = 299, - TK_EQ = 300, - TK_EXCEPT = 301, - TK_EXPLAIN = 302, - TK_FAIL = 303, - TK_FLOAT = 304, - TK_FOR = 305, - TK_FOREIGN = 306, - TK_FROM = 307, - TK_FUNCTION = 308, - TK_GE = 309, - TK_GLOB = 310, - TK_GROUP = 311, - TK_GT = 312, - TK_HAVING = 313, - TK_HOLD = 314, - TK_IGNORE = 315, - TK_ILLEGAL = 316, - TK_IMMEDIATE = 317, - TK_IN = 318, - TK_INDEX = 319, - TK_INITIALLY = 320, - TK_ID = 321, - TK_INSERT = 322, - TK_INSTEAD = 323, - TK_INT = 324, - TK_INTEGER = 325, - TK_INTERSECT = 326, - TK_INTO = 327, - TK_IS = 328, - TK_ISNULL = 329, - TK_JOIN = 330, - TK_JOIN_KW = 331, - TK_KEY = 332, - TK_LE = 333, - TK_LIKE = 334, - TK_LIMIT = 335, - TK_LONG = 336, - TK_LONGCHAR = 337, - TK_LP = 338, - TK_LSHIFT = 339, - TK_LT = 340, - TK_LOCALIZABLE = 341, - TK_MATCH = 342, - TK_MINUS = 343, - TK_NE = 344, - TK_NOT = 345, - TK_NOTNULL = 346, - TK_NULL = 347, - TK_OBJECT = 348, - TK_OF = 349, - TK_OFFSET = 350, - TK_ON = 351, - TK_OR = 352, - TK_ORACLE_OUTER_JOIN = 353, - TK_ORDER = 354, - TK_PLUS = 355, - TK_PRAGMA = 356, - TK_PRIMARY = 357, - TK_RAISE = 358, - TK_REFERENCES = 359, - TK_REM = 360, - TK_REPLACE = 361, - TK_RESTRICT = 362, - TK_ROLLBACK = 363, - TK_ROW = 364, - TK_RP = 365, - TK_RSHIFT = 366, - TK_SELECT = 367, - TK_SEMI = 368, - TK_SET = 369, - TK_SHORT = 370, - TK_SLASH = 371, - TK_SPACE = 372, - TK_STAR = 373, - TK_STATEMENT = 374, - TK_STRING = 375, - TK_TABLE = 376, - TK_TEMP = 377, - TK_THEN = 378, - TK_TRANSACTION = 379, - TK_TRIGGER = 380, - TK_UMINUS = 381, - TK_UNCLOSED_STRING = 382, - TK_UNION = 383, - TK_UNIQUE = 384, - TK_UPDATE = 385, - TK_UPLUS = 386, - TK_USING = 387, - TK_VACUUM = 388, - TK_VALUES = 389, - TK_VIEW = 390, - TK_WHEN = 391, - TK_WHERE = 392, - TK_WILDCARD = 393, - COLUMN = 395, - FUNCTION = 396, - COMMENT = 397, - UNCLOSED_STRING = 398, - SPACE = 399, - ILLEGAL = 400, - END_OF_FILE = 401 - }; -#endif -#define TK_ABORT 258 -#define TK_AFTER 259 -#define TK_AGG_FUNCTION 260 -#define TK_ALL 261 -#define TK_AND 262 -#define TK_AS 263 -#define TK_ASC 264 -#define TK_BEFORE 265 -#define TK_BEGIN 266 -#define TK_BETWEEN 267 -#define TK_BITAND 268 -#define TK_BITNOT 269 -#define TK_BITOR 270 -#define TK_BY 271 -#define TK_CASCADE 272 -#define TK_CASE 273 -#define TK_CHAR 274 -#define TK_CHECK 275 -#define TK_CLUSTER 276 -#define TK_COLLATE 277 -#define TK_COLUMN 278 -#define TK_COMMA 279 -#define TK_COMMENT 280 -#define TK_COMMIT 281 -#define TK_CONCAT 282 -#define TK_CONFLICT 283 -#define TK_CONSTRAINT 284 -#define TK_COPY 285 -#define TK_CREATE 286 -#define TK_DEFAULT 287 -#define TK_DEFERRABLE 288 -#define TK_DEFERRED 289 -#define TK_DELETE 290 -#define TK_DELIMITERS 291 -#define TK_DESC 292 -#define TK_DISTINCT 293 -#define TK_DOT 294 -#define TK_DROP 295 -#define TK_EACH 296 -#define TK_ELSE 297 -#define TK_END 298 -#define TK_END_OF_FILE 299 -#define TK_EQ 300 -#define TK_EXCEPT 301 -#define TK_EXPLAIN 302 -#define TK_FAIL 303 -#define TK_FLOAT 304 -#define TK_FOR 305 -#define TK_FOREIGN 306 -#define TK_FROM 307 -#define TK_FUNCTION 308 -#define TK_GE 309 -#define TK_GLOB 310 -#define TK_GROUP 311 -#define TK_GT 312 -#define TK_HAVING 313 -#define TK_HOLD 314 -#define TK_IGNORE 315 -#define TK_ILLEGAL 316 -#define TK_IMMEDIATE 317 -#define TK_IN 318 -#define TK_INDEX 319 -#define TK_INITIALLY 320 -#define TK_ID 321 -#define TK_INSERT 322 -#define TK_INSTEAD 323 -#define TK_INT 324 -#define TK_INTEGER 325 -#define TK_INTERSECT 326 -#define TK_INTO 327 -#define TK_IS 328 -#define TK_ISNULL 329 -#define TK_JOIN 330 -#define TK_JOIN_KW 331 -#define TK_KEY 332 -#define TK_LE 333 -#define TK_LIKE 334 -#define TK_LIMIT 335 -#define TK_LONG 336 -#define TK_LONGCHAR 337 -#define TK_LP 338 -#define TK_LSHIFT 339 -#define TK_LT 340 -#define TK_LOCALIZABLE 341 -#define TK_MATCH 342 -#define TK_MINUS 343 -#define TK_NE 344 -#define TK_NOT 345 -#define TK_NOTNULL 346 -#define TK_NULL 347 -#define TK_OBJECT 348 -#define TK_OF 349 -#define TK_OFFSET 350 -#define TK_ON 351 -#define TK_OR 352 -#define TK_ORACLE_OUTER_JOIN 353 -#define TK_ORDER 354 -#define TK_PLUS 355 -#define TK_PRAGMA 356 -#define TK_PRIMARY 357 -#define TK_RAISE 358 -#define TK_REFERENCES 359 -#define TK_REM 360 -#define TK_REPLACE 361 -#define TK_RESTRICT 362 -#define TK_ROLLBACK 363 -#define TK_ROW 364 -#define TK_RP 365 -#define TK_RSHIFT 366 -#define TK_SELECT 367 -#define TK_SEMI 368 -#define TK_SET 369 -#define TK_SHORT 370 -#define TK_SLASH 371 -#define TK_SPACE 372 -#define TK_STAR 373 -#define TK_STATEMENT 374 -#define TK_STRING 375 -#define TK_TABLE 376 -#define TK_TEMP 377 -#define TK_THEN 378 -#define TK_TRANSACTION 379 -#define TK_TRIGGER 380 -#define TK_UMINUS 381 -#define TK_UNCLOSED_STRING 382 -#define TK_UNION 383 -#define TK_UNIQUE 384 -#define TK_UPDATE 385 -#define TK_UPLUS 386 -#define TK_USING 387 -#define TK_VACUUM 388 -#define TK_VALUES 389 -#define TK_VIEW 390 -#define TK_WHEN 391 -#define TK_WHERE 392 -#define TK_WILDCARD 393 -#define COLUMN 395 -#define FUNCTION 396 -#define COMMENT 397 -#define UNCLOSED_STRING 398 -#define SPACE 399 -#define ILLEGAL 400 -#define END_OF_FILE 401 - - - - -/* Copy the first part of user declarations. */ -#line 1 "./sql.y" - - -/* - * Implementation of the Microsoft Installer (msi.dll) - * - * Copyright 2002-2004 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 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "config.h" - -#include -#include -#include - -#include "windef.h" -#include "winbase.h" -#include "query.h" -#include "wine/debug.h" -#include "wine/unicode.h" - -#define YYLEX_PARAM info -#define YYPARSE_PARAM info - -extern int SQL_error(const char *str); - -WINE_DEFAULT_DEBUG_CHANNEL(msi); - -typedef struct tag_SQL_input -{ - MSIDATABASE *db; - LPCWSTR command; - DWORD n, len; - MSIVIEW **view; /* view structure for the resulting query */ -} SQL_input; - -static LPWSTR SQL_getstring( struct sql_str *str ); -static INT SQL_getint( SQL_input *sql ); -static int SQL_lex( void *SQL_lval, SQL_input *info); - -static MSIVIEW *do_one_select( MSIDATABASE *db, MSIVIEW *in, - string_list *columns ); -static MSIVIEW *do_order_by( MSIDATABASE *db, MSIVIEW *in, - string_list *columns ); - -static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, - string_list *keys); - -static struct expr * EXPR_complex( struct expr *l, UINT op, struct expr *r ); -static struct expr * EXPR_column( LPWSTR ); -static struct expr * EXPR_ival( struct sql_str *, int sign); -static struct expr * EXPR_sval( struct sql_str *); -static struct expr * EXPR_wildcard(); - - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 74 "./sql.y" -typedef union YYSTYPE { - struct sql_str str; - LPWSTR string; - string_list *column_list; - value_list *val_list; - MSIVIEW *query; - struct expr *expr; - USHORT column_type; - create_col_info *column_info; - column_assignment update_col_info; -} YYSTYPE; -/* Line 191 of yacc.c. */ -#line 457 "sql.tab.c" -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -/* Line 214 of yacc.c. */ -#line 469 "sql.tab.c" - -#if ! defined (yyoverflow) || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# else -# ifndef YYSTACK_USE_ALLOCA -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free -# endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ - - -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - short yyss; - YYSTYPE yyvs; - }; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - register YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 27 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 128 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 147 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 26 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 65 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 126 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 401 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, - 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 146 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const unsigned char yyprhs[] = -{ - 0, 0, 3, 5, 7, 9, 11, 13, 24, 36, - 43, 51, 58, 61, 66, 71, 74, 76, 79, 81, - 85, 87, 92, 94, 96, 98, 100, 102, 104, 109, - 111, 115, 120, 122, 126, 128, 131, 136, 140, 144, - 148, 152, 156, 160, 164, 168, 172, 176, 180, 185, - 187, 189, 191, 195, 197, 201, 205, 207, 210, 212, - 214, 216, 220, 222, 224, 226 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const short yyrhs[] = -{ - 148, 0, -1, 159, -1, 150, -1, 149, -1, 151, - -1, 152, -1, 67, 72, 171, 83, 161, 110, 134, - 83, 165, 110, -1, 67, 72, 171, 83, 161, 110, - 134, 83, 165, 110, 122, -1, 31, 121, 171, 83, - 153, 110, -1, 31, 121, 171, 83, 153, 110, 59, - -1, 130, 171, 114, 166, 137, 163, -1, 35, 162, - -1, 154, 102, 77, 161, -1, 154, 24, 170, 155, - -1, 170, 155, -1, 156, -1, 156, 86, -1, 157, - -1, 157, 90, 92, -1, 19, -1, 19, 83, 158, - 110, -1, 82, -1, 115, -1, 69, -1, 81, -1, - 93, -1, 70, -1, 160, 99, 16, 161, -1, 160, - -1, 112, 161, 162, -1, 112, 38, 161, 162, -1, - 170, -1, 170, 24, 161, -1, 118, -1, 52, 171, - -1, 52, 171, 137, 163, -1, 83, 163, 110, -1, - 169, 45, 169, -1, 163, 7, 163, -1, 163, 97, - 163, -1, 169, 45, 164, -1, 169, 57, 164, -1, - 169, 85, 164, -1, 169, 78, 164, -1, 169, 54, - 164, -1, 169, 89, 164, -1, 169, 73, 92, -1, - 169, 73, 90, 92, -1, 169, -1, 168, -1, 168, - -1, 168, 24, 165, -1, 167, -1, 167, 24, 166, - -1, 170, 45, 168, -1, 70, -1, 88, 70, -1, - 120, -1, 138, -1, 170, -1, 171, 39, 172, -1, - 172, -1, 172, -1, 66, -1, 120, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short yyrline[] = -{ - 0, 143, 143, 148, 153, 158, 163, 171, 179, 190, - 200, 213, 224, 235, 245, 264, 276, 280, 288, 292, - 299, 303, 307, 311, 315, 319, 323, 330, 341, 352, - 356, 370, 388, 401, 414, 421, 432, 451, 455, 459, - 463, 467, 471, 475, 479, 483, 487, 491, 495, 502, - 503, 507, 519, 534, 535, 544, 560, 564, 568, 572, - 579, 586, 590, 597, 604, 608 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "TK_ABORT", "TK_AFTER", "TK_AGG_FUNCTION", - "TK_ALL", "TK_AND", "TK_AS", "TK_ASC", "TK_BEFORE", "TK_BEGIN", - "TK_BETWEEN", "TK_BITAND", "TK_BITNOT", "TK_BITOR", "TK_BY", - "TK_CASCADE", "TK_CASE", "TK_CHAR", "TK_CHECK", "TK_CLUSTER", - "TK_COLLATE", "TK_COLUMN", "TK_COMMA", "TK_COMMENT", "TK_COMMIT", - "TK_CONCAT", "TK_CONFLICT", "TK_CONSTRAINT", "TK_COPY", "TK_CREATE", - "TK_DEFAULT", "TK_DEFERRABLE", "TK_DEFERRED", "TK_DELETE", - "TK_DELIMITERS", "TK_DESC", "TK_DISTINCT", "TK_DOT", "TK_DROP", - "TK_EACH", "TK_ELSE", "TK_END", "TK_END_OF_FILE", "TK_EQ", "TK_EXCEPT", - "TK_EXPLAIN", "TK_FAIL", "TK_FLOAT", "TK_FOR", "TK_FOREIGN", "TK_FROM", - "TK_FUNCTION", "TK_GE", "TK_GLOB", "TK_GROUP", "TK_GT", "TK_HAVING", - "TK_HOLD", "TK_IGNORE", "TK_ILLEGAL", "TK_IMMEDIATE", "TK_IN", - "TK_INDEX", "TK_INITIALLY", "TK_ID", "TK_INSERT", "TK_INSTEAD", - "TK_INT", "TK_INTEGER", "TK_INTERSECT", "TK_INTO", "TK_IS", "TK_ISNULL", - "TK_JOIN", "TK_JOIN_KW", "TK_KEY", "TK_LE", "TK_LIKE", "TK_LIMIT", - "TK_LONG", "TK_LONGCHAR", "TK_LP", "TK_LSHIFT", "TK_LT", - "TK_LOCALIZABLE", "TK_MATCH", "TK_MINUS", "TK_NE", "TK_NOT", - "TK_NOTNULL", "TK_NULL", "TK_OBJECT", "TK_OF", "TK_OFFSET", "TK_ON", - "TK_OR", "TK_ORACLE_OUTER_JOIN", "TK_ORDER", "TK_PLUS", "TK_PRAGMA", - "TK_PRIMARY", "TK_RAISE", "TK_REFERENCES", "TK_REM", "TK_REPLACE", - "TK_RESTRICT", "TK_ROLLBACK", "TK_ROW", "TK_RP", "TK_RSHIFT", - "TK_SELECT", "TK_SEMI", "TK_SET", "TK_SHORT", "TK_SLASH", "TK_SPACE", - "TK_STAR", "TK_STATEMENT", "TK_STRING", "TK_TABLE", "TK_TEMP", - "TK_THEN", "TK_TRANSACTION", "TK_TRIGGER", "TK_UMINUS", - "TK_UNCLOSED_STRING", "TK_UNION", "TK_UNIQUE", "TK_UPDATE", "TK_UPLUS", - "TK_USING", "TK_VACUUM", "TK_VALUES", "TK_VIEW", "TK_WHEN", "TK_WHERE", - "TK_WILDCARD", "AGG_FUNCTION.", "COLUMN", "FUNCTION", "COMMENT", - "UNCLOSED_STRING", "SPACE", "ILLEGAL", "END_OF_FILE", "$accept", - "onequery", "oneinsert", "onecreate", "oneupdate", "onedelete", - "table_def", "column_def", "column_type", "data_type_l", "data_type", - "data_count", "oneselect", "unorderedsel", "selcollist", "from", "expr", - "val", "constlist", "update_assign_list", "column_assignment", - "const_val", "column_val", "column", "table", "string_or_id", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const unsigned short yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, - 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, - 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, - 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, - 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, - 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, - 395, 396, 397, 398, 399, 400, 401 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = -{ - 0, 147, 148, 148, 148, 148, 148, 149, 149, 150, - 150, 151, 152, 153, 154, 154, 155, 155, 156, 156, - 157, 157, 157, 157, 157, 157, 157, 158, 159, 159, - 160, 160, 161, 161, 161, 162, 162, 163, 163, 163, - 163, 163, 163, 163, 163, 163, 163, 163, 163, 164, - 164, 165, 165, 166, 166, 167, 168, 168, 168, 168, - 169, 170, 170, 171, 172, 172 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = -{ - 0, 2, 1, 1, 1, 1, 1, 10, 11, 6, - 7, 6, 2, 4, 4, 2, 1, 2, 1, 3, - 1, 4, 1, 1, 1, 1, 1, 1, 4, 1, - 3, 4, 1, 3, 1, 2, 4, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 4, 1, - 1, 1, 3, 1, 3, 3, 1, 2, 1, 1, - 1, 3, 1, 1, 1, 1 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const unsigned char yydefact[] = -{ - 0, 0, 0, 0, 0, 0, 0, 4, 3, 5, - 6, 2, 29, 0, 0, 12, 0, 0, 64, 34, - 65, 0, 32, 0, 62, 0, 63, 1, 0, 0, - 35, 0, 0, 30, 0, 0, 0, 0, 0, 0, - 0, 31, 33, 61, 0, 53, 0, 28, 0, 0, - 0, 0, 36, 0, 60, 0, 0, 0, 0, 9, - 0, 0, 20, 24, 25, 22, 26, 23, 15, 16, - 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 11, 54, 56, 0, 58, 59, 55, 10, - 0, 0, 0, 17, 0, 37, 39, 40, 58, 41, - 50, 38, 45, 49, 42, 0, 47, 44, 43, 46, - 0, 57, 14, 13, 27, 0, 19, 48, 0, 21, - 0, 51, 7, 0, 8, 52 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yysigned_char yydefgoto[] = -{ - -1, 6, 7, 8, 9, 10, 48, 49, 68, 69, - 70, 115, 11, 12, 21, 15, 52, 99, 120, 44, - 45, 100, 53, 54, 23, 24 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -106 -static const yysigned_char yypact[] = -{ - -30, -105, -33, -54, -34, -51, 22, -106, -106, -106, - -106, -106, -79, -51, -51, -106, -51, -60, -106, -106, - -106, -33, 17, 10, 11, -63, -106, -106, 41, -24, - -75, -13, -33, -106, -60, -51, -51, -60, -51, -45, - -60, -106, -106, -106, -65, 50, 32, -106, -32, -15, - -17, -45, -4, 26, -106, -22, -45, -51, -59, 30, - -51, 24, 19, -106, -106, -106, -106, -106, -106, 21, - 15, -7, -45, -45, -53, -53, -53, -78, -53, -53, - -53, -28, -4, -106, -106, 46, -106, -106, -106, -106, - -17, -60, 47, -106, 27, -106, -4, -4, 79, -106, - -106, -106, -106, -106, -106, 28, -106, -106, -106, -106, - 38, -106, -106, -106, -106, 12, -106, -106, -59, -106, - 13, 100, 3, -59, -106, -106 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yysigned_char yypgoto[] = -{ - -106, -106, -106, -106, -106, -106, -106, -106, 36, -106, - -106, -106, -106, -106, -10, 7, -25, 16, 4, 71, - -106, -50, 34, 6, 40, 20 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -66 -static const yysigned_char yytable[] = -{ - 72, 1, 62, 72, 17, 2, 18, 32, 88, 60, - 22, 84, 105, 18, 106, 18, 13, 84, 16, 14, - 28, 18, 27, 22, 42, 26, 71, 47, 33, 85, - 55, 82, 18, 26, 26, 85, 26, 3, 51, 41, - 22, 34, 46, 22, 50, 25, 22, 96, 97, 35, - -63, 36, 63, 29, 30, 43, 31, 37, 19, 38, - 20, 86, 39, 46, 64, 65, 90, 98, 121, 20, - 40, 74, 56, 121, 57, 20, 66, 58, 59, 87, - 75, 113, 4, 76, 19, 87, 20, 61, 81, 89, - 73, 102, 104, 73, 107, 108, 109, 22, 67, 77, - 5, 91, 92, 95, 78, 94, 110, 93, 101, 103, - 103, 79, 103, 103, 103, 80, 111, 114, -65, 116, - 117, 118, 119, 122, 123, 124, 112, 125, 83 -}; - -static const unsigned char yycheck[] = -{ - 7, 31, 19, 7, 38, 35, 66, 17, 58, 24, - 4, 70, 90, 66, 92, 66, 121, 70, 72, 52, - 99, 66, 0, 17, 34, 5, 51, 37, 21, 88, - 40, 56, 66, 13, 14, 88, 16, 67, 83, 32, - 34, 24, 36, 37, 38, 5, 40, 72, 73, 39, - 39, 114, 69, 13, 14, 35, 16, 16, 118, 83, - 120, 120, 137, 57, 81, 82, 60, 120, 118, 120, - 83, 45, 137, 123, 24, 120, 93, 45, 110, 138, - 54, 91, 112, 57, 118, 138, 120, 102, 110, 59, - 97, 75, 76, 97, 78, 79, 80, 91, 115, 73, - 130, 77, 83, 110, 78, 90, 134, 86, 74, 75, - 76, 85, 78, 79, 80, 89, 70, 70, 39, 92, - 92, 83, 110, 110, 24, 122, 90, 123, 57 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const unsigned char yystos[] = -{ - 0, 31, 35, 67, 112, 130, 148, 149, 150, 151, - 152, 159, 160, 121, 52, 162, 72, 38, 66, 118, - 120, 161, 170, 171, 172, 171, 172, 0, 99, 171, - 171, 171, 161, 162, 24, 39, 114, 16, 83, 137, - 83, 162, 161, 172, 166, 167, 170, 161, 153, 154, - 170, 83, 163, 169, 170, 161, 137, 24, 45, 110, - 24, 102, 19, 69, 81, 82, 93, 115, 155, 156, - 157, 163, 7, 97, 45, 54, 57, 73, 78, 85, - 89, 110, 163, 166, 70, 88, 120, 138, 168, 59, - 170, 77, 83, 86, 90, 110, 163, 163, 120, 164, - 168, 169, 164, 169, 164, 90, 92, 164, 164, 164, - 134, 70, 155, 161, 70, 158, 92, 92, 83, 110, - 165, 168, 110, 24, 122, 165 -}; - -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror ("syntax error: cannot back up");\ - YYERROR; \ - } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). */ - -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - Current.first_line = Rhs[1].first_line; \ - Current.first_column = Rhs[1].first_column; \ - Current.last_line = Rhs[N].last_line; \ - Current.last_column = Rhs[N].last_column; -#endif - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval) -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - -# define YYDSYMPRINT(Args) \ -do { \ - if (yydebug) \ - yysymprint Args; \ -} while (0) - -# define YYDSYMPRINTF(Title, Token, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Token, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (cinluded). | -`------------------------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_stack_print (short *bottom, short *top) -#else -static void -yy_stack_print (bottom, top) - short *bottom; - short *top; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_reduce_print (int yyrule) -#else -static void -yy_reduce_print (yyrule) - int yyrule; -#endif -{ - int yyi; - unsigned int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", - yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YYDSYMPRINT(Args) -# define YYDSYMPRINTF(Title, Token, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#if YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif -{ - register const char *yys = yystr; - - while (*yys++ != '\0') - continue; - - return yys - yystr - 1; -} -# endif -# endif - -# ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif -{ - register char *yyd = yydest; - register const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -#endif /* !YYERROR_VERBOSE */ - - - -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - if (yytype < YYNTOKENS) - { - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); -# ifdef YYPRINT - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - } - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - switch (yytype) - { - default: - break; - } - YYFPRINTF (yyoutput, ")"); -} - -#endif /* ! YYDEBUG */ -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yydestruct (int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yytype, yyvaluep) - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - switch (yytype) - { - - default: - break; - } -} - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM); -# else -int yyparse (); -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - - - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int -yyparse (void) -#else -int -yyparse () - -#endif -#endif -{ - /* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - register int yystate; - register int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; - - - -#define YYPOPSTACK (yyvsp--, yyssp--) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyoverflowlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyoverflowlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - short *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - yystate = yyn; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: -#line 144 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - *sql->view = yyvsp[0].query; - ;} - break; - - case 3: -#line 149 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - *sql->view = yyvsp[0].query; - ;} - break; - - case 4: -#line 154 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - *sql->view = yyvsp[0].query; - ;} - break; - - case 5: -#line 159 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - *sql->view = yyvsp[0].query; - ;} - break; - - case 6: -#line 164 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - *sql->view = yyvsp[0].query; - ;} - break; - - case 7: -#line 172 "./sql.y" - { - SQL_input *sql = (SQL_input*) info; - MSIVIEW *insert = NULL; - - INSERT_CreateView( sql->db, &insert, yyvsp[-7].string, yyvsp[-5].column_list, yyvsp[-1].val_list, FALSE ); - yyval.query = insert; - ;} - break; - - case 8: -#line 180 "./sql.y" - { - SQL_input *sql = (SQL_input*) info; - MSIVIEW *insert = NULL; - - INSERT_CreateView( sql->db, &insert, yyvsp[-8].string, yyvsp[-6].column_list, yyvsp[-2].val_list, TRUE ); - yyval.query = insert; - ;} - break; - - case 9: -#line 191 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - MSIVIEW *create = NULL; - - if( !yyvsp[-1].column_info ) - YYABORT; - CREATE_CreateView( sql->db, &create, yyvsp[-3].string, yyvsp[-1].column_info, FALSE ); - yyval.query = create; - ;} - break; - - case 10: -#line 201 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - MSIVIEW *create = NULL; - - if( !yyvsp[-2].column_info ) - YYABORT; - CREATE_CreateView( sql->db, &create, yyvsp[-4].string, yyvsp[-2].column_info, TRUE ); - yyval.query = create; - ;} - break; - - case 11: -#line 214 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - MSIVIEW *update = NULL; - - UPDATE_CreateView( sql->db, &update, yyvsp[-4].string, &yyvsp[-2].update_col_info, yyvsp[0].expr ); - yyval.query = update; - ;} - break; - - case 12: -#line 225 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - MSIVIEW *delete = NULL; - - DELETE_CreateView( sql->db, &delete, yyvsp[0].query ); - yyval.query = delete; - ;} - break; - - case 13: -#line 236 "./sql.y" - { - if( SQL_MarkPrimaryKeys( yyvsp[-3].column_info, yyvsp[0].column_list ) ) - yyval.column_info = yyvsp[-3].column_info; - else - yyval.column_info = NULL; - ;} - break; - - case 14: -#line 246 "./sql.y" - { - create_col_info *ci; - - for( ci = yyvsp[-3].column_info; ci->next; ci = ci->next ) - ; - - ci->next = HeapAlloc( GetProcessHeap(), 0, sizeof *yyval.column_info ); - if( !ci->next ) - { - /* FIXME: free $1 */ - YYABORT; - } - ci->next->colname = yyvsp[-1].string; - ci->next->type = yyvsp[0].column_type; - ci->next->next = NULL; - - yyval.column_info = yyvsp[-3].column_info; - ;} - break; - - case 15: -#line 265 "./sql.y" - { - yyval.column_info = HeapAlloc( GetProcessHeap(), 0, sizeof *yyval.column_info ); - if( ! yyval.column_info ) - YYABORT; - yyval.column_info->colname = yyvsp[-1].string; - yyval.column_info->type = yyvsp[0].column_type; - yyval.column_info->next = NULL; - ;} - break; - - case 16: -#line 277 "./sql.y" - { - yyval.column_type = yyvsp[0].column_type | MSITYPE_VALID; - ;} - break; - - case 17: -#line 281 "./sql.y" - { - FIXME("LOCALIZABLE ignored\n"); - yyval.column_type = yyvsp[-1].column_type | MSITYPE_VALID; - ;} - break; - - case 18: -#line 289 "./sql.y" - { - yyval.column_type |= MSITYPE_NULLABLE; - ;} - break; - - case 19: -#line 293 "./sql.y" - { - yyval.column_type = yyvsp[-2].column_type; - ;} - break; - - case 20: -#line 300 "./sql.y" - { - yyval.column_type = MSITYPE_STRING | 1; - ;} - break; - - case 21: -#line 304 "./sql.y" - { - yyval.column_type = MSITYPE_STRING | 0x400 | yyvsp[-1].column_type; - ;} - break; - - case 22: -#line 308 "./sql.y" - { - yyval.column_type = 2; - ;} - break; - - case 23: -#line 312 "./sql.y" - { - yyval.column_type = 2; - ;} - break; - - case 24: -#line 316 "./sql.y" - { - yyval.column_type = 2; - ;} - break; - - case 25: -#line 320 "./sql.y" - { - yyval.column_type = 4; - ;} - break; - - case 26: -#line 324 "./sql.y" - { - yyval.column_type = 0; - ;} - break; - - case 27: -#line 331 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - int val = SQL_getint(sql); - if( ( val > 255 ) || ( val < 0 ) ) - YYABORT; - yyval.column_type = val; - ;} - break; - - case 28: -#line 342 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - - if( !yyvsp[-3].query ) - YYABORT; - if( yyvsp[0].column_list ) - yyval.query = do_order_by( sql->db, yyvsp[-3].query, yyvsp[0].column_list ); - else - yyval.query = yyvsp[-3].query; - ;} - break; - - case 30: -#line 357 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - if( !yyvsp[0].query ) - YYABORT; - if( yyvsp[-1].column_list ) - { - yyval.query = do_one_select( sql->db, yyvsp[0].query, yyvsp[-1].column_list ); - if( !yyval.query ) - YYABORT; - } - else - yyval.query = yyvsp[0].query; - ;} - break; - - case 31: -#line 371 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - MSIVIEW *view = yyvsp[0].query; - - if( !view ) - YYABORT; - if( yyvsp[-1].column_list ) - { - view = do_one_select( sql->db, view, yyvsp[-1].column_list ); - if( !view ) - YYABORT; - } - DISTINCT_CreateView( sql->db, & yyval.query, view ); - ;} - break; - - case 32: -#line 389 "./sql.y" - { - string_list *list; - - list = HeapAlloc( GetProcessHeap(), 0, sizeof *list ); - if( !list ) - YYABORT; - list->string = yyvsp[0].string; - list->next = NULL; - - yyval.column_list = list; - TRACE("Collist %s\n",debugstr_w(yyval.column_list->string)); - ;} - break; - - case 33: -#line 402 "./sql.y" - { - string_list *list; - - list = HeapAlloc( GetProcessHeap(), 0, sizeof *list ); - if( !list ) - YYABORT; - list->string = yyvsp[-2].string; - list->next = yyvsp[0].column_list; - - yyval.column_list = list; - TRACE("From table: %s\n",debugstr_w(yyval.column_list->string)); - ;} - break; - - case 34: -#line 415 "./sql.y" - { - yyval.column_list = NULL; - ;} - break; - - case 35: -#line 422 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - UINT r; - - yyval.query = NULL; - TRACE("From table: %s\n",debugstr_w(yyvsp[0].string)); - r = TABLE_CreateView( sql->db, yyvsp[0].string, & yyval.query ); - if( r != ERROR_SUCCESS ) - YYABORT; - ;} - break; - - case 36: -#line 433 "./sql.y" - { - SQL_input* sql = (SQL_input*) info; - MSIVIEW *view = NULL; - UINT r; - - yyval.query = NULL; - TRACE("From table: %s\n",debugstr_w(yyvsp[-2].string)); - r = TABLE_CreateView( sql->db, yyvsp[-2].string, &view ); - if( r != ERROR_SUCCESS ) - YYABORT; - r = WHERE_CreateView( sql->db, &view, view, yyvsp[0].expr ); - if( r != ERROR_SUCCESS ) - YYABORT; - yyval.query = view; - ;} - break; - - case 37: -#line 452 "./sql.y" - { - yyval.expr = yyvsp[-1].expr; - ;} - break; - - case 38: -#line 456 "./sql.y" - { - yyval.expr = EXPR_complex( yyvsp[-2].expr, OP_EQ, yyvsp[0].expr ); - ;} - break; - - case 39: -#line 460 "./sql.y" - { - yyval.expr = EXPR_complex( yyvsp[-2].expr, OP_AND, yyvsp[0].expr ); - ;} - break; - - case 40: -#line 464 "./sql.y" - { - yyval.expr = EXPR_complex( yyvsp[-2].expr, OP_OR, yyvsp[0].expr ); - ;} - break; - - case 41: -#line 468 "./sql.y" - { - yyval.expr = EXPR_complex( yyvsp[-2].expr, OP_EQ, yyvsp[0].expr ); - ;} - break; - - case 42: -#line 472 "./sql.y" - { - yyval.expr = EXPR_complex( yyvsp[-2].expr, OP_GT, yyvsp[0].expr ); - ;} - break; - - case 43: -#line 476 "./sql.y" - { - yyval.expr = EXPR_complex( yyvsp[-2].expr, OP_LT, yyvsp[0].expr ); - ;} - break; - - case 44: -#line 480 "./sql.y" - { - yyval.expr = EXPR_complex( yyvsp[-2].expr, OP_LE, yyvsp[0].expr ); - ;} - break; - - case 45: -#line 484 "./sql.y" - { - yyval.expr = EXPR_complex( yyvsp[-2].expr, OP_GE, yyvsp[0].expr ); - ;} - break; - - case 46: -#line 488 "./sql.y" - { - yyval.expr = EXPR_complex( yyvsp[-2].expr, OP_NE, yyvsp[0].expr ); - ;} - break; - - case 47: -#line 492 "./sql.y" - { - yyval.expr = EXPR_complex( yyvsp[-2].expr, OP_ISNULL, NULL ); - ;} - break; - - case 48: -#line 496 "./sql.y" - { - yyval.expr = EXPR_complex( yyvsp[-3].expr, OP_NOTNULL, NULL ); - ;} - break; - - case 51: -#line 508 "./sql.y" - { - value_list *vals; - - vals = HeapAlloc( GetProcessHeap(), 0, sizeof *vals ); - if( vals ) - { - vals->val = yyvsp[0].expr; - vals->next = NULL; - } - yyval.val_list = vals; - ;} - break; - - case 52: -#line 520 "./sql.y" - { - value_list *vals; - - vals = HeapAlloc( GetProcessHeap(), 0, sizeof *vals ); - if( vals ) - { - vals->val = yyvsp[-2].expr; - vals->next = yyvsp[0].val_list; - } - yyval.val_list = vals; - ;} - break; - - case 54: -#line 536 "./sql.y" - { - yyvsp[-2].update_col_info.col_list->next = yyvsp[0].update_col_info.col_list; - yyvsp[-2].update_col_info.val_list->next = yyvsp[0].update_col_info.val_list; - yyval.update_col_info = yyvsp[-2].update_col_info; - ;} - break; - - case 55: -#line 545 "./sql.y" - { - yyval.update_col_info.col_list = HeapAlloc( GetProcessHeap(), 0, sizeof *yyval.update_col_info.col_list ); - if( !yyval.update_col_info.col_list ) - YYABORT; - yyval.update_col_info.col_list->string = yyvsp[-2].string; - yyval.update_col_info.col_list->next = NULL; - yyval.update_col_info.val_list = HeapAlloc( GetProcessHeap(), 0, sizeof *yyval.update_col_info.val_list ); - if( !yyval.update_col_info.val_list ) - YYABORT; - yyval.update_col_info.val_list->val = yyvsp[0].expr; - yyval.update_col_info.val_list->next = 0; - ;} - break; - - case 56: -#line 561 "./sql.y" - { - yyval.expr = EXPR_ival( &yyvsp[0].str, 1 ); - ;} - break; - - case 57: -#line 565 "./sql.y" - { - yyval.expr = EXPR_ival( &yyvsp[0].str, -1 ); - ;} - break; - - case 58: -#line 569 "./sql.y" - { - yyval.expr = EXPR_sval( &yyvsp[0].str ); - ;} - break; - - case 59: -#line 573 "./sql.y" - { - yyval.expr = EXPR_wildcard(); - ;} - break; - - case 60: -#line 580 "./sql.y" - { - yyval.expr = EXPR_column( yyvsp[0].string ); - ;} - break; - - case 61: -#line 587 "./sql.y" - { - yyval.string = yyvsp[0].string; /* FIXME */ - ;} - break; - - case 62: -#line 591 "./sql.y" - { - yyval.string = yyvsp[0].string; - ;} - break; - - case 63: -#line 598 "./sql.y" - { - yyval.string = yyvsp[0].string; - ;} - break; - - case 64: -#line 605 "./sql.y" - { - yyval.string = SQL_getstring( &yyvsp[0].str ); - ;} - break; - - case 65: -#line 609 "./sql.y" - { - yyval.string = SQL_getstring( &yyvsp[0].str ); - ;} - break; - - - } - -/* Line 999 of yacc.c. */ -#line 2073 "sql.tab.c" - - yyvsp -= yylen; - yyssp -= yylen; - - - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); - const char* yyprefix; - char *yymsg; - int yyx; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 0; - - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); - yycount += 1; - if (yycount == 5) - { - yysize = 0; - break; - } - } - yysize += (sizeof ("syntax error, unexpected ") - + yystrlen (yytname[yytype])); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); - - if (yycount < 5) - { - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - yyp = yystpcpy (yyp, yyprefix); - yyp = yystpcpy (yyp, yytname[yyx]); - yyprefix = " or "; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("syntax error; also virtual memory exhausted"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror ("syntax error"); - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - /* Return failure if at end of input. */ - if (yychar == YYEOF) - { - /* Pop the error token. */ - YYPOPSTACK; - /* Pop the rest of the stack. */ - while (yyss < yyssp) - { - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[*yyssp], yyvsp); - YYPOPSTACK; - } - YYABORT; - } - - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); - yychar = YYEMPTY; - - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*----------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action. | -`----------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[yystate], yyvsp); - yyvsp--; - yystate = *--yyssp; - - YY_STACK_PRINT (yyss, yyssp); - } - - if (yyn == YYFINAL) - YYACCEPT; - - YYDPRINTF ((stderr, "Shifting error token, ")); - - *++yyvsp = yylval; - - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif - return yyresult; -} - - -#line 614 "./sql.y" - - -int SQL_lex( void *SQL_lval, SQL_input *sql) -{ - int token; - struct sql_str * str = SQL_lval; - - do - { - sql->n += sql->len; - if( ! sql->command[sql->n] ) - return 0; /* end of input */ - - TRACE("string : %s\n", debugstr_w(&sql->command[sql->n])); - sql->len = sqliteGetToken( &sql->command[sql->n], &token ); - if( sql->len==0 ) - break; - str->data = &sql->command[sql->n]; - str->len = sql->len; - } - while( token == TK_SPACE ); - - TRACE("token : %d (%s)\n", token, debugstr_wn(&sql->command[sql->n], sql->len)); - - return token; -} - -LPWSTR SQL_getstring( struct sql_str *strdata) -{ - LPCWSTR p = strdata->data; - UINT len = strdata->len; - LPWSTR str; - - /* if there's quotes, remove them */ - if( ( (p[0]=='`') && (p[len-1]=='`') ) || - ( (p[0]=='\'') && (p[len-1]=='\'') ) ) - { - p++; - len -= 2; - } - str = HeapAlloc( GetProcessHeap(), 0, (len + 1)*sizeof(WCHAR)); - if(!str ) - return str; - memcpy(str, p, len*sizeof(WCHAR) ); - str[len]=0; - - return str; -} - -INT SQL_getint( SQL_input *sql ) -{ - LPCWSTR p = &sql->command[sql->n]; - - return atoiW( p ); -} - -int SQL_error(const char *str) -{ - return 0; -} - -static MSIVIEW *do_one_select( MSIDATABASE *db, MSIVIEW *in, - string_list *columns ) -{ - MSIVIEW *view = NULL; - - SELECT_CreateView( db, &view, in, columns ); - delete_string_list( columns ); - if( !view ) - ERR("Error creating select query\n"); - return view; -} - -static MSIVIEW *do_order_by( MSIDATABASE *db, MSIVIEW *in, - string_list *columns ) -{ - MSIVIEW *view = NULL; - - ORDER_CreateView( db, &view, in ); - if( view ) - { - string_list *x = columns; - - for( x = columns; x ; x = x->next ) - ORDER_AddColumn( view, x->string ); - } - else - ERR("Error creating select query\n"); - delete_string_list( columns ); - return view; -} - -static struct expr * EXPR_wildcard() -{ - struct expr *e = HeapAlloc( GetProcessHeap(), 0, sizeof *e ); - if( e ) - { - e->type = EXPR_WILDCARD; - } - return e; -} - -static struct expr * EXPR_complex( struct expr *l, UINT op, struct expr *r ) -{ - struct expr *e = HeapAlloc( GetProcessHeap(), 0, sizeof *e ); - if( e ) - { - e->type = EXPR_COMPLEX; - e->u.expr.left = l; - e->u.expr.op = op; - e->u.expr.right = r; - } - return e; -} - -static struct expr * EXPR_column( LPWSTR str ) -{ - struct expr *e = HeapAlloc( GetProcessHeap(), 0, sizeof *e ); - if( e ) - { - e->type = EXPR_COLUMN; - e->u.sval = str; - } - return e; -} - -static struct expr * EXPR_ival( struct sql_str *str , int sign) -{ - struct expr *e = HeapAlloc( GetProcessHeap(), 0, sizeof *e ); - if( e ) - { - e->type = EXPR_IVAL; - e->u.ival = atoiW( str->data ) * sign; - } - return e; -} - -static struct expr * EXPR_sval( struct sql_str *str ) -{ - struct expr *e = HeapAlloc( GetProcessHeap(), 0, sizeof *e ); - if( e ) - { - e->type = EXPR_SVAL; - e->u.sval = SQL_getstring( str ); - } - return e; -} - -void delete_expr( struct expr *e ) -{ - if( !e ) - return; - if( e->type == EXPR_COMPLEX ) - { - delete_expr( e->u.expr.left ); - delete_expr( e->u.expr.right ); - } - else if( e->type == EXPR_UTF8 ) - HeapFree( GetProcessHeap(), 0, e->u.utf8 ); - else if( e->type == EXPR_SVAL ) - HeapFree( GetProcessHeap(), 0, e->u.sval ); - HeapFree( GetProcessHeap(), 0, e ); -} - -void delete_string_list( string_list *sl ) -{ - while( sl ) - { - string_list *t = sl->next; - HeapFree( GetProcessHeap(), 0, sl->string ); - HeapFree( GetProcessHeap(), 0, sl ); - sl = t; - } -} - -void delete_value_list( value_list *vl ) -{ - while( vl ) - { - value_list *t = vl->next; - delete_expr( vl->val ); - HeapFree( GetProcessHeap(), 0, vl ); - vl = t; - } -} - -static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, - string_list *keys ) -{ - string_list *k; - BOOL found = TRUE; - - for( k = keys; k && found; k = k->next ) - { - create_col_info *c; - - found = FALSE; - for( c = cols; c && !found; c = c->next ) - { - if( lstrcmpW( k->string, c->colname ) ) - continue; - c->type |= MSITYPE_KEY; - found = TRUE; - } - } - - return found; -} - -UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview ) -{ - SQL_input sql; - int r; - - *phview = NULL; - - sql.db = db; - sql.command = command; - sql.n = 0; - sql.len = 0; - sql.view = phview; - - r = SQL_parse(&sql); - - TRACE("Parse returned %d\n", r); - if( r ) - { - if( *sql.view ) - (*sql.view)->ops->delete( *sql.view ); - *sql.view = NULL; - return ERROR_BAD_QUERY_SYNTAX; - } - - return ERROR_SUCCESS; -} - +/* A Bison parser, made from ./sql.y + by GNU bison 1.35. */ + +#define YYBISON 1 /* Identify Bison output. */ + +#define yyparse SQL_parse +#define yylex SQL_lex +#define yyerror SQL_error +#define yylval SQL_lval +#define yychar SQL_char +#define yydebug SQL_debug +#define yynerrs SQL_nerrs +# define TK_ABORT 257 +# define TK_AFTER 258 +# define TK_AGG_FUNCTION 259 +# define TK_ALL 260 +# define TK_AND 261 +# define TK_AS 262 +# define TK_ASC 263 +# define TK_BEFORE 264 +# define TK_BEGIN 265 +# define TK_BETWEEN 266 +# define TK_BITAND 267 +# define TK_BITNOT 268 +# define TK_BITOR 269 +# define TK_BY 270 +# define TK_CASCADE 271 +# define TK_CASE 272 +# define TK_CHAR 273 +# define TK_CHECK 274 +# define TK_CLUSTER 275 +# define TK_COLLATE 276 +# define TK_COLUMN 277 +# define TK_COMMA 278 +# define TK_COMMENT 279 +# define TK_COMMIT 280 +# define TK_CONCAT 281 +# define TK_CONFLICT 282 +# define TK_CONSTRAINT 283 +# define TK_COPY 284 +# define TK_CREATE 285 +# define TK_DEFAULT 286 +# define TK_DEFERRABLE 287 +# define TK_DEFERRED 288 +# define TK_DELETE 289 +# define TK_DELIMITERS 290 +# define TK_DESC 291 +# define TK_DISTINCT 292 +# define TK_DOT 293 +# define TK_DROP 294 +# define TK_EACH 295 +# define TK_ELSE 296 +# define TK_END 297 +# define TK_END_OF_FILE 298 +# define TK_EQ 299 +# define TK_EXCEPT 300 +# define TK_EXPLAIN 301 +# define TK_FAIL 302 +# define TK_FLOAT 303 +# define TK_FOR 304 +# define TK_FOREIGN 305 +# define TK_FROM 306 +# define TK_FUNCTION 307 +# define TK_GE 308 +# define TK_GLOB 309 +# define TK_GROUP 310 +# define TK_GT 311 +# define TK_HAVING 312 +# define TK_HOLD 313 +# define TK_IGNORE 314 +# define TK_ILLEGAL 315 +# define TK_IMMEDIATE 316 +# define TK_IN 317 +# define TK_INDEX 318 +# define TK_INITIALLY 319 +# define TK_ID 320 +# define TK_INSERT 321 +# define TK_INSTEAD 322 +# define TK_INT 323 +# define TK_INTEGER 324 +# define TK_INTERSECT 325 +# define TK_INTO 326 +# define TK_IS 327 +# define TK_ISNULL 328 +# define TK_JOIN 329 +# define TK_JOIN_KW 330 +# define TK_KEY 331 +# define TK_LE 332 +# define TK_LIKE 333 +# define TK_LIMIT 334 +# define TK_LONG 335 +# define TK_LONGCHAR 336 +# define TK_LP 337 +# define TK_LSHIFT 338 +# define TK_LT 339 +# define TK_LOCALIZABLE 340 +# define TK_MATCH 341 +# define TK_MINUS 342 +# define TK_NE 343 +# define TK_NOT 344 +# define TK_NOTNULL 345 +# define TK_NULL 346 +# define TK_OBJECT 347 +# define TK_OF 348 +# define TK_OFFSET 349 +# define TK_ON 350 +# define TK_OR 351 +# define TK_ORACLE_OUTER_JOIN 352 +# define TK_ORDER 353 +# define TK_PLUS 354 +# define TK_PRAGMA 355 +# define TK_PRIMARY 356 +# define TK_RAISE 357 +# define TK_REFERENCES 358 +# define TK_REM 359 +# define TK_REPLACE 360 +# define TK_RESTRICT 361 +# define TK_ROLLBACK 362 +# define TK_ROW 363 +# define TK_RP 364 +# define TK_RSHIFT 365 +# define TK_SELECT 366 +# define TK_SEMI 367 +# define TK_SET 368 +# define TK_SHORT 369 +# define TK_SLASH 370 +# define TK_SPACE 371 +# define TK_STAR 372 +# define TK_STATEMENT 373 +# define TK_STRING 374 +# define TK_TABLE 375 +# define TK_TEMP 376 +# define TK_THEN 377 +# define TK_TRANSACTION 378 +# define TK_TRIGGER 379 +# define TK_UMINUS 380 +# define TK_UNCLOSED_STRING 381 +# define TK_UNION 382 +# define TK_UNIQUE 383 +# define TK_UPDATE 384 +# define TK_UPLUS 385 +# define TK_USING 386 +# define TK_VACUUM 387 +# define TK_VALUES 388 +# define TK_VIEW 389 +# define TK_WHEN 390 +# define TK_WHERE 391 +# define TK_WILDCARD 392 +# define END_OF_FILE 393 +# define ILLEGAL 394 +# define SPACE 395 +# define UNCLOSED_STRING 396 +# define COMMENT 397 +# define FUNCTION 398 +# define COLUMN 399 + +#line 1 "./sql.y" + + +/* + * Implementation of the Microsoft Installer (msi.dll) + * + * Copyright 2002-2004 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "config.h" + +#include +#include +#include + +#include "windef.h" +#include "winbase.h" +#include "query.h" +#include "wine/list.h" +#include "wine/debug.h" +#include "wine/unicode.h" + +#define YYLEX_PARAM info +#define YYPARSE_PARAM info + +extern int SQL_error(const char *str); + +WINE_DEFAULT_DEBUG_CHANNEL(msi); + +typedef struct tag_SQL_input +{ + MSIDATABASE *db; + LPCWSTR command; + DWORD n, len; + MSIVIEW **view; /* view structure for the resulting query */ + struct list *mem; +} SQL_input; + +static LPWSTR SQL_getstring( void *info, struct sql_str *str ); +static INT SQL_getint( void *info ); +static int SQL_lex( void *SQL_lval, SQL_input *info ); + +static void *parser_alloc( void *info, unsigned int sz ); + +static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, string_list *keys); + +static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r ); +static struct expr * EXPR_column( void *info, LPWSTR column ); +static struct expr * EXPR_ival( void *info, struct sql_str *, int sign ); +static struct expr * EXPR_sval( void *info, struct sql_str * ); +static struct expr * EXPR_wildcard( void *info ); + + +#line 71 "./sql.y" +#ifndef YYSTYPE +typedef union +{ + struct sql_str str; + LPWSTR string; + string_list *column_list; + value_list *val_list; + MSIVIEW *query; + struct expr *expr; + USHORT column_type; + create_col_info *column_info; + column_assignment update_col_info; +} yystype; +# define YYSTYPE yystype +# define YYSTYPE_IS_TRIVIAL 1 +#endif +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + + + +#define YYFINAL 126 +#define YYFLAG -32768 +#define YYNTBASE 147 + +/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ +#define YYTRANSLATE(x) ((unsigned)(x) <= 400 ? yytranslate[x] : 175) + +/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ +static const short yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, + 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, + 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, + 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, + 146 +}; + +#if YYDEBUG +static const short yyprhs[] = +{ + 0, 0, 2, 4, 6, 8, 10, 12, 23, 35, + 42, 50, 57, 60, 65, 70, 73, 75, 78, 80, + 84, 86, 91, 93, 95, 97, 99, 101, 103, 108, + 110, 113, 117, 120, 122, 126, 128, 130, 134, 137, + 141, 145, 149, 153, 157, 161, 165, 169, 173, 177, + 181, 186, 188, 190, 192, 196, 198, 202, 206, 208, + 211, 213, 215, 217, 221, 223, 225 +}; +static const short yyrhs[] = +{ + 148, 0, 159, 0, 150, 0, 149, 0, 151, 0, + 152, 0, 67, 72, 173, 83, 162, 110, 134, 83, + 167, 110, 0, 67, 72, 173, 83, 162, 110, 134, + 83, 167, 110, 122, 0, 31, 121, 173, 83, 153, + 110, 0, 31, 121, 173, 83, 153, 110, 59, 0, + 130, 173, 114, 168, 137, 165, 0, 35, 163, 0, + 154, 102, 77, 162, 0, 154, 24, 172, 155, 0, + 172, 155, 0, 156, 0, 156, 86, 0, 157, 0, + 157, 90, 92, 0, 19, 0, 19, 83, 158, 110, + 0, 82, 0, 115, 0, 69, 0, 81, 0, 93, + 0, 70, 0, 160, 99, 16, 162, 0, 160, 0, + 112, 161, 0, 112, 38, 161, 0, 162, 163, 0, + 172, 0, 172, 24, 162, 0, 118, 0, 164, 0, + 164, 137, 165, 0, 52, 173, 0, 83, 165, 110, + 0, 171, 45, 171, 0, 165, 7, 165, 0, 165, + 97, 165, 0, 171, 45, 166, 0, 171, 57, 166, + 0, 171, 85, 166, 0, 171, 78, 166, 0, 171, + 54, 166, 0, 171, 89, 166, 0, 171, 73, 92, + 0, 171, 73, 90, 92, 0, 171, 0, 170, 0, + 170, 0, 170, 24, 167, 0, 169, 0, 169, 24, + 168, 0, 172, 45, 170, 0, 70, 0, 88, 70, + 0, 120, 0, 138, 0, 172, 0, 173, 39, 174, + 0, 174, 0, 174, 0, 66, 0 +}; + +#endif + +#if YYDEBUG +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const short yyrline[] = +{ + 0, 140, 148, 150, 151, 152, 153, 156, 168, 180, + 193, 207, 220, 233, 243, 263, 274, 279, 286, 291, + 297, 302, 306, 310, 314, 318, 322, 328, 339, 352, + 355, 360, 371, 387, 401, 414, 420, 422, 434, 447, + 454, 460, 466, 472, 478, 484, 490, 496, 502, 508, + 514, 522, 524, 527, 539, 552, 554, 562, 578, 585, + 591, 597, 605, 614, 619, 625, 632 +}; +#endif + + +#if (YYDEBUG) || defined YYERROR_VERBOSE + +/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ +static const char *const yytname[] = +{ + "$", "error", "$undefined.", "TK_ABORT", "TK_AFTER", "TK_AGG_FUNCTION", + "TK_ALL", "TK_AND", "TK_AS", "TK_ASC", "TK_BEFORE", "TK_BEGIN", + "TK_BETWEEN", "TK_BITAND", "TK_BITNOT", "TK_BITOR", "TK_BY", + "TK_CASCADE", "TK_CASE", "TK_CHAR", "TK_CHECK", "TK_CLUSTER", + "TK_COLLATE", "TK_COLUMN", "TK_COMMA", "TK_COMMENT", "TK_COMMIT", + "TK_CONCAT", "TK_CONFLICT", "TK_CONSTRAINT", "TK_COPY", "TK_CREATE", + "TK_DEFAULT", "TK_DEFERRABLE", "TK_DEFERRED", "TK_DELETE", + "TK_DELIMITERS", "TK_DESC", "TK_DISTINCT", "TK_DOT", "TK_DROP", + "TK_EACH", "TK_ELSE", "TK_END", "TK_END_OF_FILE", "TK_EQ", "TK_EXCEPT", + "TK_EXPLAIN", "TK_FAIL", "TK_FLOAT", "TK_FOR", "TK_FOREIGN", "TK_FROM", + "TK_FUNCTION", "TK_GE", "TK_GLOB", "TK_GROUP", "TK_GT", "TK_HAVING", + "TK_HOLD", "TK_IGNORE", "TK_ILLEGAL", "TK_IMMEDIATE", "TK_IN", + "TK_INDEX", "TK_INITIALLY", "TK_ID", "TK_INSERT", "TK_INSTEAD", + "TK_INT", "TK_INTEGER", "TK_INTERSECT", "TK_INTO", "TK_IS", "TK_ISNULL", + "TK_JOIN", "TK_JOIN_KW", "TK_KEY", "TK_LE", "TK_LIKE", "TK_LIMIT", + "TK_LONG", "TK_LONGCHAR", "TK_LP", "TK_LSHIFT", "TK_LT", + "TK_LOCALIZABLE", "TK_MATCH", "TK_MINUS", "TK_NE", "TK_NOT", + "TK_NOTNULL", "TK_NULL", "TK_OBJECT", "TK_OF", "TK_OFFSET", "TK_ON", + "TK_OR", "TK_ORACLE_OUTER_JOIN", "TK_ORDER", "TK_PLUS", "TK_PRAGMA", + "TK_PRIMARY", "TK_RAISE", "TK_REFERENCES", "TK_REM", "TK_REPLACE", + "TK_RESTRICT", "TK_ROLLBACK", "TK_ROW", "TK_RP", "TK_RSHIFT", + "TK_SELECT", "TK_SEMI", "TK_SET", "TK_SHORT", "TK_SLASH", "TK_SPACE", + "TK_STAR", "TK_STATEMENT", "TK_STRING", "TK_TABLE", "TK_TEMP", + "TK_THEN", "TK_TRANSACTION", "TK_TRIGGER", "TK_UMINUS", + "TK_UNCLOSED_STRING", "TK_UNION", "TK_UNIQUE", "TK_UPDATE", "TK_UPLUS", + "TK_USING", "TK_VACUUM", "TK_VALUES", "TK_VIEW", "TK_WHEN", "TK_WHERE", + "TK_WILDCARD", "END_OF_FILE", "ILLEGAL", "SPACE", "UNCLOSED_STRING", + "COMMENT", "FUNCTION", "COLUMN", "AGG_FUNCTION.", "query", "onequery", + "oneinsert", "onecreate", "oneupdate", "onedelete", "table_def", + "column_def", "column_type", "data_type_l", "data_type", "data_count", + "oneselect", "unorderedsel", "selectfrom", "selcollist", "from", + "fromtable", "expr", "val", "constlist", "update_assign_list", + "column_assignment", "const_val", "column_val", "column", "table", "id", 0 +}; +#endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const short yyr1[] = +{ + 0, 147, 148, 148, 148, 148, 148, 149, 149, 150, + 150, 151, 152, 153, 154, 154, 155, 155, 156, 156, + 157, 157, 157, 157, 157, 157, 157, 158, 159, 159, + 160, 160, 161, 162, 162, 162, 163, 163, 164, 165, + 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, + 165, 166, 166, 167, 167, 168, 168, 169, 170, 170, + 170, 170, 171, 172, 172, 173, 174 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const short yyr2[] = +{ + 0, 1, 1, 1, 1, 1, 1, 10, 11, 6, + 7, 6, 2, 4, 4, 2, 1, 2, 1, 3, + 1, 4, 1, 1, 1, 1, 1, 1, 4, 1, + 2, 3, 2, 1, 3, 1, 1, 3, 2, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 4, 1, 1, 1, 3, 1, 3, 3, 1, 2, + 1, 1, 1, 3, 1, 1, 1 +}; + +/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE + doesn't specify something else to do. Zero means the default is an + error. */ +static const short yydefact[] = +{ + 0, 0, 0, 0, 0, 0, 1, 4, 3, 5, + 6, 2, 29, 0, 0, 12, 36, 0, 0, 66, + 35, 30, 0, 33, 0, 64, 0, 65, 0, 0, + 38, 0, 0, 31, 32, 0, 0, 0, 0, 0, + 0, 37, 0, 62, 0, 34, 63, 0, 55, 0, + 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, + 0, 20, 24, 25, 22, 26, 23, 15, 16, 18, + 39, 41, 42, 58, 0, 60, 61, 43, 52, 40, + 47, 51, 44, 0, 49, 46, 45, 48, 0, 11, + 56, 57, 10, 0, 0, 0, 17, 0, 59, 50, + 0, 14, 13, 27, 0, 19, 0, 21, 0, 53, + 7, 0, 8, 54, 0, 0, 0 +}; + +static const short yydefgoto[] = +{ + 124, 6, 7, 8, 9, 10, 51, 52, 77, 78, + 79, 114, 11, 12, 21, 22, 15, 16, 41, 87, + 118, 47, 48, 88, 42, 43, 24, 25 +}; + +static const short yypact[] = +{ + -28, -102, -32, -48, -29, -39,-32768,-32768,-32768,-32768, + -32768,-32768, -61, -39, -39,-32768, -97, -39, -50,-32768, + -32768,-32768, -32, 19, 6, 9, -65,-32768, 34, -30, + -32768, -37, -26,-32768,-32768, -50, -39, -39, -50, -39, + -37, -2, -31,-32768, -50,-32768,-32768, -86, 32, 10, + -32768, -51, -20, -17, -7, -37, -37, -60, -60, -60, + -59, -60, -60, -60, -36, -37, -39, -58, 16, -39, + 2, 0,-32768,-32768,-32768,-32768,-32768,-32768, -5, 1, + -32768, -2, -2,-32768, 15,-32768,-32768,-32768,-32768,-32768, + -32768,-32768,-32768, -4,-32768,-32768,-32768,-32768, -42, -2, + -32768,-32768,-32768, -17, -50, 23,-32768, 5,-32768,-32768, + 11,-32768,-32768,-32768, -11,-32768, -58,-32768, -10, 83, + -9, -58,-32768,-32768, 117, 118,-32768 +}; + +static const short yypgoto[] = +{ + -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 17,-32768, + -32768,-32768,-32768,-32768, 101, -27, 99,-32768, 31, 53, + 3, 57,-32768, -49, 47, -3, 56, 8 +}; + + +#define YYLAST 124 + + +static const short yytable[] = +{ + 55, 23, 71, 1, 69, 55, 19, 2, 45, 18, + 83, 50, 83, 27, 57, 23, 19, 64, 101, 13, + 14, 27, 27, 58, 17, 27, 59, 19, 84, 19, + 84, 93, 23, 94, 49, 23, 53, 19, 28, 3, + 31, 23, 60, 35, 46, 36, 40, 61, -65, 37, + 38, 65, 72, 39, 62, 67, 66, 44, 63, 68, + 85, 26, 85, 49, 73, 74, 103, 119, 20, 29, + 30, 54, 119, 32, 98, 102, 75, 112, 86, 104, + 86, 106, 70, 105, 4, 108, 81, 82, 109, 20, + 56, 107, 110, 113, 116, 56, 99, 115, 76, 117, + 120, 23, 5, 80, 89, 91, 91, 121, 91, 91, + 91, 90, 92, 122, 95, 96, 97, 125, 126, 33, + 111, 34, 0, 100, 123 +}; + +static const short yycheck[] = +{ + 7, 4, 19, 31, 24, 7, 66, 35, 35, 38, + 70, 38, 70, 5, 45, 18, 66, 44, 67, 121, + 52, 13, 14, 54, 72, 17, 57, 66, 88, 66, + 88, 90, 35, 92, 37, 38, 39, 66, 99, 67, + 137, 44, 73, 24, 36, 39, 83, 78, 39, 114, + 16, 137, 69, 83, 85, 45, 24, 83, 89, 110, + 120, 5, 120, 66, 81, 82, 69, 116, 118, 13, + 14, 40, 121, 17, 110, 59, 93, 104, 138, 77, + 138, 86, 102, 83, 112, 70, 55, 56, 92, 118, + 97, 90, 134, 70, 83, 97, 65, 92, 115, 110, + 110, 104, 130, 110, 57, 58, 59, 24, 61, 62, + 63, 58, 59, 122, 61, 62, 63, 0, 0, 18, + 103, 22, -1, 66, 121 +}; +#define YYPURE 1 + +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/share/bison/bison.simple" + +/* Skeleton output parser for bison, + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser when + the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# else +# ifndef YYSTACK_USE_ALLOCA +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC malloc +# define YYSTACK_FREE free +# endif +#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; +# if YYLSP_NEEDED + YYLTYPE yyls; +# endif +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# if YYLSP_NEEDED +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + + 2 * YYSTACK_GAP_MAX) +# else +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAX) +# endif + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up"); \ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). + + When YYLLOC_DEFAULT is run, CURRENT is set the location of the + first token. By default, to implement support for ranges, extend + its range to the last symbol. */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + Current.last_line = Rhs[N].last_line; \ + Current.last_column = Rhs[N].last_column; +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#if YYPURE +# if YYLSP_NEEDED +# ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) +# else +# define YYLEX yylex (&yylval, &yylloc) +# endif +# else /* !YYLSP_NEEDED */ +# ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +# else +# define YYLEX yylex (&yylval) +# endif +# endif /* !YYLSP_NEEDED */ +#else /* !YYPURE */ +# define YYLEX yylex () +#endif /* !YYPURE */ + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +#endif /* !YYDEBUG */ + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + +#ifdef YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif +#endif + +#line 315 "/usr/share/bison/bison.simple" + + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +# define YYPARSE_PARAM_DECL +# else +# define YYPARSE_PARAM_ARG YYPARSE_PARAM +# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +# endif +#else /* !YYPARSE_PARAM */ +# define YYPARSE_PARAM_ARG +# define YYPARSE_PARAM_DECL +#endif /* !YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +# ifdef YYPARSE_PARAM +int yyparse (void *); +# else +int yyparse (void); +# endif +#endif + +/* YY_DECL_VARIABLES -- depending whether we use a pure parser, + variables are global, or local to YYPARSE. */ + +#define YY_DECL_NON_LSP_VARIABLES \ +/* The lookahead symbol. */ \ +int yychar; \ + \ +/* The semantic value of the lookahead symbol. */ \ +YYSTYPE yylval; \ + \ +/* Number of parse errors so far. */ \ +int yynerrs; + +#if YYLSP_NEEDED +# define YY_DECL_VARIABLES \ +YY_DECL_NON_LSP_VARIABLES \ + \ +/* Location data for the lookahead symbol. */ \ +YYLTYPE yylloc; +#else +# define YY_DECL_VARIABLES \ +YY_DECL_NON_LSP_VARIABLES +#endif + + +/* If nonreentrant, generate the variables here. */ + +#if !YYPURE +YY_DECL_VARIABLES +#endif /* !YYPURE */ + +int +yyparse (YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + /* If reentrant, generate the variables here. */ +#if YYPURE + YY_DECL_VARIABLES +#endif /* !YYPURE */ + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yychar1 = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + +#if YYLSP_NEEDED + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; +#endif + +#if YYLSP_NEEDED +# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +# define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + YYSIZE_T yystacksize = YYINITDEPTH; + + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; +#if YYLSP_NEEDED + YYLTYPE yyloc; +#endif + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; +#if YYLSP_NEEDED + yylsp = yyls; +#endif + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. */ +# if YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yyls1, yysize * sizeof (*yylsp), + &yystacksize); + yyls = yyls1; +# else + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); +# endif + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + goto yyoverflowlab; + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); +# if YYLSP_NEEDED + YYSTACK_RELOCATE (yyls); +# endif +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; +#if YYLSP_NEEDED + yylsp = yyls + yysize - 1; +#endif + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yychar1 = YYTRANSLATE (yychar); + +#if YYDEBUG + /* We have to keep this `#if YYDEBUG', since we use variables + which are defined only if `YYDEBUG' is set. */ + if (yydebug) + { + YYFPRINTF (stderr, "Next token is %d (%s", + yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise + meaning of a token, for further debugging info. */ +# ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +# endif + YYFPRINTF (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %d (%s), ", + yychar, yytname[yychar1])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#if YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + yystate = yyn; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to the semantic value of + the lookahead token. This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + +#if YYLSP_NEEDED + /* Similarly for the default location. Let the user run additional + commands if for instance locations are ranges. */ + yyloc = yylsp[1-yylen]; + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); +#endif + +#if YYDEBUG + /* We have to keep this `#if YYDEBUG', since we use variables which + are defined only if `YYDEBUG' is set. */ + if (yydebug) + { + int yyi; + + YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) + YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); + YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + switch (yyn) { + +case 1: +#line 142 "./sql.y" +{ + SQL_input* sql = (SQL_input*) info; + *sql->view = yyvsp[0].query; + ; + break;} +case 7: +#line 158 "./sql.y" +{ + SQL_input *sql = (SQL_input*) info; + MSIVIEW *insert = NULL; + UINT r; + + r = INSERT_CreateView( sql->db, &insert, yyvsp[-7].string, yyvsp[-5].column_list, yyvsp[-1].val_list, FALSE ); + if( !insert ) + YYABORT; + yyval.query = insert; + ; + break;} +case 8: +#line 169 "./sql.y" +{ + SQL_input *sql = (SQL_input*) info; + MSIVIEW *insert = NULL; + + INSERT_CreateView( sql->db, &insert, yyvsp[-8].string, yyvsp[-6].column_list, yyvsp[-2].val_list, TRUE ); + if( !insert ) + YYABORT; + yyval.query = insert; + ; + break;} +case 9: +#line 182 "./sql.y" +{ + SQL_input* sql = (SQL_input*) info; + MSIVIEW *create = NULL; + + if( !yyvsp[-1].column_info ) + YYABORT; + CREATE_CreateView( sql->db, &create, yyvsp[-3].string, yyvsp[-1].column_info, FALSE ); + if( !create ) + YYABORT; + yyval.query = create; + ; + break;} +case 10: +#line 194 "./sql.y" +{ + SQL_input* sql = (SQL_input*) info; + MSIVIEW *create = NULL; + + if( !yyvsp[-2].column_info ) + YYABORT; + CREATE_CreateView( sql->db, &create, yyvsp[-4].string, yyvsp[-2].column_info, TRUE ); + if( !create ) + YYABORT; + yyval.query = create; + ; + break;} +case 11: +#line 209 "./sql.y" +{ + SQL_input* sql = (SQL_input*) info; + MSIVIEW *update = NULL; + + UPDATE_CreateView( sql->db, &update, yyvsp[-4].string, &yyvsp[-2].update_col_info, yyvsp[0].expr ); + if( !update ) + YYABORT; + yyval.query = update; + ; + break;} +case 12: +#line 222 "./sql.y" +{ + SQL_input* sql = (SQL_input*) info; + MSIVIEW *delete = NULL; + + DELETE_CreateView( sql->db, &delete, yyvsp[0].query ); + if( !delete ) + YYABORT; + yyval.query = delete; + ; + break;} +case 13: +#line 235 "./sql.y" +{ + if( SQL_MarkPrimaryKeys( yyvsp[-3].column_info, yyvsp[0].column_list ) ) + yyval.column_info = yyvsp[-3].column_info; + else + yyval.column_info = NULL; + ; + break;} +case 14: +#line 245 "./sql.y" +{ + create_col_info *ci; + + for( ci = yyvsp[-3].column_info; ci->next; ci = ci->next ) + ; + + ci->next = HeapAlloc( GetProcessHeap(), 0, sizeof *yyval.column_info ); + if( !ci->next ) + { + /* FIXME: free $1 */ + YYABORT; + } + ci->next->colname = yyvsp[-1].string; + ci->next->type = yyvsp[0].column_type; + ci->next->next = NULL; + + yyval.column_info = yyvsp[-3].column_info; + ; + break;} +case 15: +#line 264 "./sql.y" +{ + yyval.column_info = HeapAlloc( GetProcessHeap(), 0, sizeof *yyval.column_info ); + if( ! yyval.column_info ) + YYABORT; + yyval.column_info->colname = yyvsp[-1].string; + yyval.column_info->type = yyvsp[0].column_type; + yyval.column_info->next = NULL; + ; + break;} +case 16: +#line 276 "./sql.y" +{ + yyval.column_type = yyvsp[0].column_type | MSITYPE_VALID; + ; + break;} +case 17: +#line 280 "./sql.y" +{ + FIXME("LOCALIZABLE ignored\n"); + yyval.column_type = yyvsp[-1].column_type | MSITYPE_VALID; + ; + break;} +case 18: +#line 288 "./sql.y" +{ + yyval.column_type |= MSITYPE_NULLABLE; + ; + break;} +case 19: +#line 292 "./sql.y" +{ + yyval.column_type = yyvsp[-2].column_type; + ; + break;} +case 20: +#line 299 "./sql.y" +{ + yyval.column_type = MSITYPE_STRING | 1; + ; + break;} +case 21: +#line 303 "./sql.y" +{ + yyval.column_type = MSITYPE_STRING | 0x400 | yyvsp[-1].column_type; + ; + break;} +case 22: +#line 307 "./sql.y" +{ + yyval.column_type = 2; + ; + break;} +case 23: +#line 311 "./sql.y" +{ + yyval.column_type = 2; + ; + break;} +case 24: +#line 315 "./sql.y" +{ + yyval.column_type = 2; + ; + break;} +case 25: +#line 319 "./sql.y" +{ + yyval.column_type = 4; + ; + break;} +case 26: +#line 323 "./sql.y" +{ + yyval.column_type = 0; + ; + break;} +case 27: +#line 330 "./sql.y" +{ + SQL_input* sql = (SQL_input*) info; + int val = SQL_getint(sql); + if( ( val > 255 ) || ( val < 0 ) ) + YYABORT; + yyval.column_type = val; + ; + break;} +case 28: +#line 341 "./sql.y" +{ + SQL_input* sql = (SQL_input*) info; + + yyval.query = NULL; + if( yyvsp[0].column_list ) + ORDER_CreateView( sql->db, &yyval.query, yyvsp[-3].query, yyvsp[0].column_list ); + else + yyval.query = yyvsp[-3].query; + if( !yyval.query ) + YYABORT; + ; + break;} +case 30: +#line 357 "./sql.y" +{ + yyval.query = yyvsp[0].query; + ; + break;} +case 31: +#line 361 "./sql.y" +{ + SQL_input* sql = (SQL_input*) info; + + yyval.query = NULL; + DISTINCT_CreateView( sql->db, &yyval.query, yyvsp[0].query ); + if( !yyval.query ) + YYABORT; + ; + break;} +case 32: +#line 373 "./sql.y" +{ + SQL_input* sql = (SQL_input*) info; + + yyval.query = NULL; + if( yyvsp[-1].column_list ) + SELECT_CreateView( sql->db, &yyval.query, yyvsp[0].query, yyvsp[-1].column_list ); + else + yyval.query = yyvsp[0].query; + + if( !yyval.query ) + YYABORT; + ; + break;} +case 33: +#line 389 "./sql.y" +{ + string_list *list; + + list = HeapAlloc( GetProcessHeap(), 0, sizeof *list ); + if( !list ) + YYABORT; + list->string = yyvsp[0].string; + list->next = NULL; + + yyval.column_list = list; + TRACE("Collist %s\n",debugstr_w(yyval.column_list->string)); + ; + break;} +case 34: +#line 402 "./sql.y" +{ + string_list *list; + + list = HeapAlloc( GetProcessHeap(), 0, sizeof *list ); + if( !list ) + YYABORT; + list->string = yyvsp[-2].string; + list->next = yyvsp[0].column_list; + + yyval.column_list = list; + TRACE("From table: %s\n",debugstr_w(yyval.column_list->string)); + ; + break;} +case 35: +#line 415 "./sql.y" +{ + yyval.column_list = NULL; + ; + break;} +case 37: +#line 423 "./sql.y" +{ + SQL_input* sql = (SQL_input*) info; + UINT r; + + yyval.query = NULL; + r = WHERE_CreateView( sql->db, &yyval.query, yyvsp[-2].query, yyvsp[0].expr ); + if( r != ERROR_SUCCESS || !yyval.query ) + YYABORT; + ; + break;} +case 38: +#line 436 "./sql.y" +{ + SQL_input* sql = (SQL_input*) info; + UINT r; + + yyval.query = NULL; + r = TABLE_CreateView( sql->db, yyvsp[0].string, &yyval.query ); + if( r != ERROR_SUCCESS || !yyval.query ) + YYABORT; + ; + break;} +case 39: +#line 449 "./sql.y" +{ + yyval.expr = yyvsp[-1].expr; + if( !yyval.expr ) + YYABORT; + ; + break;} +case 40: +#line 455 "./sql.y" +{ + yyval.expr = EXPR_complex( info, yyvsp[-2].expr, OP_EQ, yyvsp[0].expr ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 41: +#line 461 "./sql.y" +{ + yyval.expr = EXPR_complex( info, yyvsp[-2].expr, OP_AND, yyvsp[0].expr ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 42: +#line 467 "./sql.y" +{ + yyval.expr = EXPR_complex( info, yyvsp[-2].expr, OP_OR, yyvsp[0].expr ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 43: +#line 473 "./sql.y" +{ + yyval.expr = EXPR_complex( info, yyvsp[-2].expr, OP_EQ, yyvsp[0].expr ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 44: +#line 479 "./sql.y" +{ + yyval.expr = EXPR_complex( info, yyvsp[-2].expr, OP_GT, yyvsp[0].expr ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 45: +#line 485 "./sql.y" +{ + yyval.expr = EXPR_complex( info, yyvsp[-2].expr, OP_LT, yyvsp[0].expr ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 46: +#line 491 "./sql.y" +{ + yyval.expr = EXPR_complex( info, yyvsp[-2].expr, OP_LE, yyvsp[0].expr ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 47: +#line 497 "./sql.y" +{ + yyval.expr = EXPR_complex( info, yyvsp[-2].expr, OP_GE, yyvsp[0].expr ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 48: +#line 503 "./sql.y" +{ + yyval.expr = EXPR_complex( info, yyvsp[-2].expr, OP_NE, yyvsp[0].expr ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 49: +#line 509 "./sql.y" +{ + yyval.expr = EXPR_complex( info, yyvsp[-2].expr, OP_ISNULL, NULL ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 50: +#line 515 "./sql.y" +{ + yyval.expr = EXPR_complex( info, yyvsp[-3].expr, OP_NOTNULL, NULL ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 53: +#line 529 "./sql.y" +{ + value_list *vals; + + vals = parser_alloc( info, sizeof *vals ); + if( !vals ) + YYABORT; + vals->val = yyvsp[0].expr; + vals->next = NULL; + yyval.val_list = vals; + ; + break;} +case 54: +#line 540 "./sql.y" +{ + value_list *vals; + + vals = parser_alloc( info, sizeof *vals ); + if( !vals ) + YYABORT; + vals->val = yyvsp[-2].expr; + vals->next = yyvsp[0].val_list; + yyval.val_list = vals; + ; + break;} +case 56: +#line 555 "./sql.y" +{ + yyvsp[-2].update_col_info.col_list->next = yyvsp[0].update_col_info.col_list; + yyvsp[-2].update_col_info.val_list->next = yyvsp[0].update_col_info.val_list; + yyval.update_col_info = yyvsp[-2].update_col_info; + ; + break;} +case 57: +#line 564 "./sql.y" +{ + yyval.update_col_info.col_list = HeapAlloc( GetProcessHeap(), 0, sizeof *yyval.update_col_info.col_list ); + if( !yyval.update_col_info.col_list ) + YYABORT; + yyval.update_col_info.col_list->string = yyvsp[-2].string; + yyval.update_col_info.col_list->next = NULL; + yyval.update_col_info.val_list = HeapAlloc( GetProcessHeap(), 0, sizeof *yyval.update_col_info.val_list ); + if( !yyval.update_col_info.val_list ) + YYABORT; + yyval.update_col_info.val_list->val = yyvsp[0].expr; + yyval.update_col_info.val_list->next = 0; + ; + break;} +case 58: +#line 580 "./sql.y" +{ + yyval.expr = EXPR_ival( info, &yyvsp[0].str, 1 ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 59: +#line 586 "./sql.y" +{ + yyval.expr = EXPR_ival( info, &yyvsp[0].str, -1 ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 60: +#line 592 "./sql.y" +{ + yyval.expr = EXPR_sval( info, &yyvsp[0].str ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 61: +#line 598 "./sql.y" +{ + yyval.expr = EXPR_wildcard( info ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 62: +#line 607 "./sql.y" +{ + yyval.expr = EXPR_column( info, yyvsp[0].string ); + if( !yyval.expr ) + YYABORT; + ; + break;} +case 63: +#line 616 "./sql.y" +{ + yyval.string = yyvsp[0].string; /* FIXME */ + ; + break;} +case 64: +#line 620 "./sql.y" +{ + yyval.string = yyvsp[0].string; + ; + break;} +case 65: +#line 627 "./sql.y" +{ + yyval.string = yyvsp[0].string; + ; + break;} +case 66: +#line 634 "./sql.y" +{ + yyval.string = SQL_getstring( info, &yyvsp[0].str ); + if( !yyval.string ) + YYABORT; + ; + break;} +} + +#line 705 "/usr/share/bison/bison.simple" + + + yyvsp -= yylen; + yyssp -= yylen; +#if YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG + if (yydebug) + { + short *yyssp1 = yyss - 1; + YYFPRINTF (stderr, "state stack now"); + while (yyssp1 != yyssp) + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; +#if YYLSP_NEEDED + *++yylsp = yyloc; +#endif + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + char *yymsg; + int yyx, yycount; + + yycount = 0; + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) + if (yycheck[yyx + yyn] == yyx) + yysize += yystrlen (yytname[yyx]) + 15, yycount++; + yysize += yystrlen ("parse error, unexpected ") + 1; + yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "parse error, unexpected "); + yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); + + if (yycount < 5) + { + yycount = 0; + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); + yyx++) + if (yycheck[yyx + yyn] == yyx) + { + const char *yyq = ! yycount ? ", expecting " : " or "; + yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yytname[yyx]); + yycount++; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("parse error; also virtual memory exhausted"); + } + else +#endif /* defined (YYERROR_VERBOSE) */ + yyerror ("parse error"); + } + goto yyerrlab1; + + +/*--------------------------------------------------. +| yyerrlab1 -- error raised explicitly by an action | +`--------------------------------------------------*/ +yyerrlab1: + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + YYDPRINTF ((stderr, "Discarding token %d (%s).\n", + yychar, yytname[yychar1])); + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + + +/*-------------------------------------------------------------------. +| yyerrdefault -- current state does not do anything special for the | +| error token. | +`-------------------------------------------------------------------*/ +yyerrdefault: +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + + /* If its default is to accept any token, ok. Otherwise pop it. */ + yyn = yydefact[yystate]; + if (yyn) + goto yydefault; +#endif + + +/*---------------------------------------------------------------. +| yyerrpop -- pop the current state because it cannot handle the | +| error token | +`---------------------------------------------------------------*/ +yyerrpop: + if (yyssp == yyss) + YYABORT; + yyvsp--; + yystate = *--yyssp; +#if YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG + if (yydebug) + { + short *yyssp1 = yyss - 1; + YYFPRINTF (stderr, "Error: state stack now"); + while (yyssp1 != yyssp) + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); + } +#endif + +/*--------------. +| yyerrhandle. | +`--------------*/ +yyerrhandle: + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; +#if YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +/*---------------------------------------------. +| yyoverflowab -- parser overflow comes here. | +`---------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} +#line 641 "./sql.y" + + +static void *parser_alloc( void *info, unsigned int sz ) +{ + SQL_input* sql = (SQL_input*) info; + struct list *mem; + + mem = HeapAlloc( GetProcessHeap(), 0, sizeof (struct list) + sz ); + list_add_tail( sql->mem, mem ); + return &mem[1]; +} + +int SQL_lex( void *SQL_lval, SQL_input *sql ) +{ + int token; + struct sql_str * str = SQL_lval; + + do + { + sql->n += sql->len; + if( ! sql->command[sql->n] ) + return 0; /* end of input */ + + TRACE("string : %s\n", debugstr_w(&sql->command[sql->n])); + sql->len = sqliteGetToken( &sql->command[sql->n], &token ); + if( sql->len==0 ) + break; + str->data = &sql->command[sql->n]; + str->len = sql->len; + } + while( token == TK_SPACE ); + + TRACE("token : %d (%s)\n", token, debugstr_wn(&sql->command[sql->n], sql->len)); + + return token; +} + +LPWSTR SQL_getstring( void *info, struct sql_str *strdata ) +{ + LPCWSTR p = strdata->data; + UINT len = strdata->len; + LPWSTR str; + + /* if there's quotes, remove them */ + if( ( (p[0]=='`') && (p[len-1]=='`') ) || + ( (p[0]=='\'') && (p[len-1]=='\'') ) ) + { + p++; + len -= 2; + } + str = parser_alloc( info, (len + 1)*sizeof(WCHAR) ); + if( !str ) + return str; + memcpy( str, p, len*sizeof(WCHAR) ); + str[len]=0; + + return str; +} + +INT SQL_getint( void *info ) +{ + SQL_input* sql = (SQL_input*) info; + LPCWSTR p = &sql->command[sql->n]; + + return atoiW( p ); +} + +int SQL_error( const char *str ) +{ + return 0; +} + +static struct expr * EXPR_wildcard( void *info ) +{ + struct expr *e = parser_alloc( info, sizeof *e ); + if( e ) + { + e->type = EXPR_WILDCARD; + } + return e; +} + +static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r ) +{ + struct expr *e = parser_alloc( info, sizeof *e ); + if( e ) + { + e->type = EXPR_COMPLEX; + e->u.expr.left = l; + e->u.expr.op = op; + e->u.expr.right = r; + } + return e; +} + +static struct expr * EXPR_column( void *info, LPWSTR column ) +{ + struct expr *e = parser_alloc( info, sizeof *e ); + if( e ) + { + e->type = EXPR_COLUMN; + e->u.sval = column; + } + return e; +} + +static struct expr * EXPR_ival( void *info, struct sql_str *str, int sign ) +{ + struct expr *e = parser_alloc( info, sizeof *e ); + if( e ) + { + e->type = EXPR_IVAL; + e->u.ival = atoiW( str->data ) * sign; + } + return e; +} + +static struct expr * EXPR_sval( void *info, struct sql_str *str ) +{ + struct expr *e = parser_alloc( info, sizeof *e ); + if( e ) + { + e->type = EXPR_SVAL; + e->u.sval = SQL_getstring( info, str ); + } + return e; +} + +static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, string_list *keys) +{ + string_list *k; + BOOL found = TRUE; + + for( k = keys; k && found; k = k->next ) + { + create_col_info *c; + + found = FALSE; + for( c = cols; c && !found; c = c->next ) + { + if( lstrcmpW( k->string, c->colname ) ) + continue; + c->type |= MSITYPE_KEY; + found = TRUE; + } + } + + return found; +} + +UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview, + struct list *mem ) +{ + SQL_input sql; + int r; + + *phview = NULL; + + sql.db = db; + sql.command = command; + sql.n = 0; + sql.len = 0; + sql.view = phview; + sql.mem = mem; + + r = SQL_parse(&sql); + + TRACE("Parse returned %d\n", r); + if( r ) + { + if( *sql.view ) + (*sql.view)->ops->delete( *sql.view ); + *sql.view = NULL; + return ERROR_BAD_QUERY_SYNTAX; + } + + return ERROR_SUCCESS; +} diff --git a/reactos/lib/msi/sql.y b/reactos/lib/msi/sql.y index 5bd2c7dffd7..7a0edd9f6ab 100644 --- a/reactos/lib/msi/sql.y +++ b/reactos/lib/msi/sql.y @@ -30,6 +30,7 @@ #include "windef.h" #include "winbase.h" #include "query.h" +#include "wine/list.h" #include "wine/debug.h" #include "wine/unicode.h" @@ -46,25 +47,22 @@ typedef struct tag_SQL_input LPCWSTR command; DWORD n, len; MSIVIEW **view; /* view structure for the resulting query */ + struct list *mem; } SQL_input; -static LPWSTR SQL_getstring( struct sql_str *str ); -static INT SQL_getint( SQL_input *sql ); -static int SQL_lex( void *SQL_lval, SQL_input *info); +static LPWSTR SQL_getstring( void *info, struct sql_str *str ); +static INT SQL_getint( void *info ); +static int SQL_lex( void *SQL_lval, SQL_input *info ); -static MSIVIEW *do_one_select( MSIDATABASE *db, MSIVIEW *in, - string_list *columns ); -static MSIVIEW *do_order_by( MSIDATABASE *db, MSIVIEW *in, - string_list *columns ); +static void *parser_alloc( void *info, unsigned int sz ); -static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, - string_list *keys); +static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, string_list *keys); -static struct expr * EXPR_complex( struct expr *l, UINT op, struct expr *r ); -static struct expr * EXPR_column( LPWSTR ); -static struct expr * EXPR_ival( struct sql_str *, int sign); -static struct expr * EXPR_sval( struct sql_str *); -static struct expr * EXPR_wildcard(); +static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r ); +static struct expr * EXPR_column( void *info, LPWSTR column ); +static struct expr * EXPR_ival( void *info, struct sql_str *, int sign ); +static struct expr * EXPR_sval( void *info, struct sql_str * ); +static struct expr * EXPR_wildcard( void *info ); %} @@ -127,10 +125,10 @@ static struct expr * EXPR_wildcard(); %nonassoc END_OF_FILE ILLEGAL SPACE UNCLOSED_STRING COMMENT FUNCTION COLUMN AGG_FUNCTION. -%type column table string_or_id +%type column table id %type selcollist -%type from unorderedsel oneselect onequery onecreate oneinsert -%type oneupdate onedelete +%type query from fromtable unorderedsel selectfrom +%type oneupdate onedelete oneselect onequery onecreate oneinsert %type expr val column_val const_val %type column_type data_type data_type_l data_count %type column_def table_def @@ -139,51 +137,44 @@ static struct expr * EXPR_wildcard(); %% -onequery: - oneselect +query: + onequery { SQL_input* sql = (SQL_input*) info; *sql->view = $1; } + ; + +onequery: + oneselect | onecreate - { - SQL_input* sql = (SQL_input*) info; - *sql->view = $1; - } | oneinsert - { - SQL_input* sql = (SQL_input*) info; - *sql->view = $1; - } | oneupdate - { - SQL_input* sql = (SQL_input*) info; - *sql->view = $1; - } | onedelete - { - SQL_input* sql = (SQL_input*) info; - *sql->view = $1; - } ; oneinsert: TK_INSERT TK_INTO table TK_LP selcollist TK_RP TK_VALUES TK_LP constlist TK_RP - { - SQL_input *sql = (SQL_input*) info; - MSIVIEW *insert = NULL; + { + SQL_input *sql = (SQL_input*) info; + MSIVIEW *insert = NULL; + UINT r; - INSERT_CreateView( sql->db, &insert, $3, $5, $9, FALSE ); - $$ = insert; - } + r = INSERT_CreateView( sql->db, &insert, $3, $5, $9, FALSE ); + if( !insert ) + YYABORT; + $$ = insert; + } | TK_INSERT TK_INTO table TK_LP selcollist TK_RP TK_VALUES TK_LP constlist TK_RP TK_TEMP - { - SQL_input *sql = (SQL_input*) info; - MSIVIEW *insert = NULL; + { + SQL_input *sql = (SQL_input*) info; + MSIVIEW *insert = NULL; - INSERT_CreateView( sql->db, &insert, $3, $5, $9, TRUE ); - $$ = insert; - } + INSERT_CreateView( sql->db, &insert, $3, $5, $9, TRUE ); + if( !insert ) + YYABORT; + $$ = insert; + } ; onecreate: @@ -195,6 +186,8 @@ onecreate: if( !$5 ) YYABORT; CREATE_CreateView( sql->db, &create, $3, $5, FALSE ); + if( !create ) + YYABORT; $$ = create; } | TK_CREATE TK_TABLE table TK_LP table_def TK_RP TK_HOLD @@ -205,6 +198,8 @@ onecreate: if( !$5 ) YYABORT; CREATE_CreateView( sql->db, &create, $3, $5, TRUE ); + if( !create ) + YYABORT; $$ = create; } ; @@ -216,6 +211,8 @@ oneupdate: MSIVIEW *update = NULL; UPDATE_CreateView( sql->db, &update, $2, &$4, $6 ); + if( !update ) + YYABORT; $$ = update; } ; @@ -227,6 +224,8 @@ onedelete: MSIVIEW *delete = NULL; DELETE_CreateView( sql->db, &delete, $2 ); + if( !delete ) + YYABORT; $$ = delete; } ; @@ -342,45 +341,46 @@ oneselect: { SQL_input* sql = (SQL_input*) info; - if( !$1 ) - YYABORT; + $$ = NULL; if( $4 ) - $$ = do_order_by( sql->db, $1, $4 ); + ORDER_CreateView( sql->db, &$$, $1, $4 ); else $$ = $1; + if( !$$ ) + YYABORT; } | unorderedsel ; unorderedsel: - TK_SELECT selcollist from + TK_SELECT selectfrom + { + $$ = $2; + } + | TK_SELECT TK_DISTINCT selectfrom { SQL_input* sql = (SQL_input*) info; - if( !$3 ) + + $$ = NULL; + DISTINCT_CreateView( sql->db, &$$, $3 ); + if( !$$ ) YYABORT; - if( $2 ) - { - $$ = do_one_select( sql->db, $3, $2 ); - if( !$$ ) - YYABORT; - } - else - $$ = $3; } - | TK_SELECT TK_DISTINCT selcollist from + ; + +selectfrom: + selcollist from { SQL_input* sql = (SQL_input*) info; - MSIVIEW *view = $4; - if( !view ) + $$ = NULL; + if( $1 ) + SELECT_CreateView( sql->db, &$$, $2, $1 ); + else + $$ = $2; + + if( !$$ ) YYABORT; - if( $3 ) - { - view = do_one_select( sql->db, view, $3 ); - if( !view ) - YYABORT; - } - DISTINCT_CreateView( sql->db, & $$, view ); } ; @@ -418,32 +418,29 @@ selcollist: ; from: - TK_FROM table + fromtable + | fromtable TK_WHERE expr { SQL_input* sql = (SQL_input*) info; UINT r; $$ = NULL; - TRACE("From table: %s\n",debugstr_w($2)); - r = TABLE_CreateView( sql->db, $2, & $$ ); - if( r != ERROR_SUCCESS ) + r = WHERE_CreateView( sql->db, &$$, $1, $3 ); + if( r != ERROR_SUCCESS || !$$ ) YYABORT; } - | TK_FROM table TK_WHERE expr - { + ; + +fromtable: + TK_FROM table + { SQL_input* sql = (SQL_input*) info; - MSIVIEW *view = NULL; UINT r; $$ = NULL; - TRACE("From table: %s\n",debugstr_w($2)); - r = TABLE_CreateView( sql->db, $2, &view ); - if( r != ERROR_SUCCESS ) - YYABORT; - r = WHERE_CreateView( sql->db, &view, view, $4 ); - if( r != ERROR_SUCCESS ) + r = TABLE_CreateView( sql->db, $2, &$$ ); + if( r != ERROR_SUCCESS || !$$ ) YYABORT; - $$ = view; } ; @@ -451,50 +448,74 @@ expr: TK_LP expr TK_RP { $$ = $2; + if( !$$ ) + YYABORT; } | column_val TK_EQ column_val { - $$ = EXPR_complex( $1, OP_EQ, $3 ); + $$ = EXPR_complex( info, $1, OP_EQ, $3 ); + if( !$$ ) + YYABORT; } | expr TK_AND expr { - $$ = EXPR_complex( $1, OP_AND, $3 ); + $$ = EXPR_complex( info, $1, OP_AND, $3 ); + if( !$$ ) + YYABORT; } | expr TK_OR expr { - $$ = EXPR_complex( $1, OP_OR, $3 ); + $$ = EXPR_complex( info, $1, OP_OR, $3 ); + if( !$$ ) + YYABORT; } | column_val TK_EQ val { - $$ = EXPR_complex( $1, OP_EQ, $3 ); + $$ = EXPR_complex( info, $1, OP_EQ, $3 ); + if( !$$ ) + YYABORT; } | column_val TK_GT val { - $$ = EXPR_complex( $1, OP_GT, $3 ); + $$ = EXPR_complex( info, $1, OP_GT, $3 ); + if( !$$ ) + YYABORT; } | column_val TK_LT val { - $$ = EXPR_complex( $1, OP_LT, $3 ); + $$ = EXPR_complex( info, $1, OP_LT, $3 ); + if( !$$ ) + YYABORT; } | column_val TK_LE val { - $$ = EXPR_complex( $1, OP_LE, $3 ); + $$ = EXPR_complex( info, $1, OP_LE, $3 ); + if( !$$ ) + YYABORT; } | column_val TK_GE val { - $$ = EXPR_complex( $1, OP_GE, $3 ); + $$ = EXPR_complex( info, $1, OP_GE, $3 ); + if( !$$ ) + YYABORT; } | column_val TK_NE val { - $$ = EXPR_complex( $1, OP_NE, $3 ); + $$ = EXPR_complex( info, $1, OP_NE, $3 ); + if( !$$ ) + YYABORT; } | column_val TK_IS TK_NULL { - $$ = EXPR_complex( $1, OP_ISNULL, NULL ); + $$ = EXPR_complex( info, $1, OP_ISNULL, NULL ); + if( !$$ ) + YYABORT; } | column_val TK_IS TK_NOT TK_NULL { - $$ = EXPR_complex( $1, OP_NOTNULL, NULL ); + $$ = EXPR_complex( info, $1, OP_NOTNULL, NULL ); + if( !$$ ) + YYABORT; } ; @@ -508,24 +529,22 @@ constlist: { value_list *vals; - vals = HeapAlloc( GetProcessHeap(), 0, sizeof *vals ); - if( vals ) - { - vals->val = $1; - vals->next = NULL; - } + vals = parser_alloc( info, sizeof *vals ); + if( !vals ) + YYABORT; + vals->val = $1; + vals->next = NULL; $$ = vals; } | const_val TK_COMMA constlist { value_list *vals; - vals = HeapAlloc( GetProcessHeap(), 0, sizeof *vals ); - if( vals ) - { - vals->val = $1; - vals->next = $3; - } + vals = parser_alloc( info, sizeof *vals ); + if( !vals ) + YYABORT; + vals->val = $1; + vals->next = $3; $$ = vals; } ; @@ -559,61 +578,79 @@ column_assignment: const_val: TK_INTEGER { - $$ = EXPR_ival( &$1, 1 ); + $$ = EXPR_ival( info, &$1, 1 ); + if( !$$ ) + YYABORT; } | TK_MINUS TK_INTEGER { - $$ = EXPR_ival( &$2, -1 ); + $$ = EXPR_ival( info, &$2, -1 ); + if( !$$ ) + YYABORT; } | TK_STRING { - $$ = EXPR_sval( &$1 ); + $$ = EXPR_sval( info, &$1 ); + if( !$$ ) + YYABORT; } | TK_WILDCARD { - $$ = EXPR_wildcard(); + $$ = EXPR_wildcard( info ); + if( !$$ ) + YYABORT; } ; column_val: column { - $$ = EXPR_column( $1 ); + $$ = EXPR_column( info, $1 ); + if( !$$ ) + YYABORT; } ; column: - table TK_DOT string_or_id + table TK_DOT id { $$ = $3; /* FIXME */ } - | string_or_id + | id { $$ = $1; } ; table: - string_or_id + id { $$ = $1; } ; -string_or_id: +id: TK_ID { - $$ = SQL_getstring( &$1 ); - } - | TK_STRING - { - $$ = SQL_getstring( &$1 ); + $$ = SQL_getstring( info, &$1 ); + if( !$$ ) + YYABORT; } ; %% -int SQL_lex( void *SQL_lval, SQL_input *sql) +static void *parser_alloc( void *info, unsigned int sz ) +{ + SQL_input* sql = (SQL_input*) info; + struct list *mem; + + mem = HeapAlloc( GetProcessHeap(), 0, sizeof (struct list) + sz ); + list_add_tail( sql->mem, mem ); + return &mem[1]; +} + +int SQL_lex( void *SQL_lval, SQL_input *sql ) { int token; struct sql_str * str = SQL_lval; @@ -638,7 +675,7 @@ int SQL_lex( void *SQL_lval, SQL_input *sql) return token; } -LPWSTR SQL_getstring( struct sql_str *strdata) +LPWSTR SQL_getstring( void *info, struct sql_str *strdata ) { LPCWSTR p = strdata->data; UINT len = strdata->len; @@ -651,61 +688,31 @@ LPWSTR SQL_getstring( struct sql_str *strdata) p++; len -= 2; } - str = HeapAlloc( GetProcessHeap(), 0, (len + 1)*sizeof(WCHAR)); - if(!str ) + str = parser_alloc( info, (len + 1)*sizeof(WCHAR) ); + if( !str ) return str; - memcpy(str, p, len*sizeof(WCHAR) ); + memcpy( str, p, len*sizeof(WCHAR) ); str[len]=0; return str; } -INT SQL_getint( SQL_input *sql ) +INT SQL_getint( void *info ) { + SQL_input* sql = (SQL_input*) info; LPCWSTR p = &sql->command[sql->n]; return atoiW( p ); } -int SQL_error(const char *str) +int SQL_error( const char *str ) { return 0; } -static MSIVIEW *do_one_select( MSIDATABASE *db, MSIVIEW *in, - string_list *columns ) -{ - MSIVIEW *view = NULL; - - SELECT_CreateView( db, &view, in, columns ); - delete_string_list( columns ); - if( !view ) - ERR("Error creating select query\n"); - return view; -} - -static MSIVIEW *do_order_by( MSIDATABASE *db, MSIVIEW *in, - string_list *columns ) +static struct expr * EXPR_wildcard( void *info ) { - MSIVIEW *view = NULL; - - ORDER_CreateView( db, &view, in ); - if( view ) - { - string_list *x = columns; - - for( x = columns; x ; x = x->next ) - ORDER_AddColumn( view, x->string ); - } - else - ERR("Error creating select query\n"); - delete_string_list( columns ); - return view; -} - -static struct expr * EXPR_wildcard() -{ - struct expr *e = HeapAlloc( GetProcessHeap(), 0, sizeof *e ); + struct expr *e = parser_alloc( info, sizeof *e ); if( e ) { e->type = EXPR_WILDCARD; @@ -713,9 +720,9 @@ static struct expr * EXPR_wildcard() return e; } -static struct expr * EXPR_complex( struct expr *l, UINT op, struct expr *r ) +static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r ) { - struct expr *e = HeapAlloc( GetProcessHeap(), 0, sizeof *e ); + struct expr *e = parser_alloc( info, sizeof *e ); if( e ) { e->type = EXPR_COMPLEX; @@ -726,20 +733,20 @@ static struct expr * EXPR_complex( struct expr *l, UINT op, struct expr *r ) return e; } -static struct expr * EXPR_column( LPWSTR str ) +static struct expr * EXPR_column( void *info, LPWSTR column ) { - struct expr *e = HeapAlloc( GetProcessHeap(), 0, sizeof *e ); + struct expr *e = parser_alloc( info, sizeof *e ); if( e ) { e->type = EXPR_COLUMN; - e->u.sval = str; + e->u.sval = column; } return e; } -static struct expr * EXPR_ival( struct sql_str *str , int sign) +static struct expr * EXPR_ival( void *info, struct sql_str *str, int sign ) { - struct expr *e = HeapAlloc( GetProcessHeap(), 0, sizeof *e ); + struct expr *e = parser_alloc( info, sizeof *e ); if( e ) { e->type = EXPR_IVAL; @@ -748,57 +755,18 @@ static struct expr * EXPR_ival( struct sql_str *str , int sign) return e; } -static struct expr * EXPR_sval( struct sql_str *str ) +static struct expr * EXPR_sval( void *info, struct sql_str *str ) { - struct expr *e = HeapAlloc( GetProcessHeap(), 0, sizeof *e ); + struct expr *e = parser_alloc( info, sizeof *e ); if( e ) { e->type = EXPR_SVAL; - e->u.sval = SQL_getstring( str ); + e->u.sval = SQL_getstring( info, str ); } return e; } -void delete_expr( struct expr *e ) -{ - if( !e ) - return; - if( e->type == EXPR_COMPLEX ) - { - delete_expr( e->u.expr.left ); - delete_expr( e->u.expr.right ); - } - else if( e->type == EXPR_UTF8 ) - HeapFree( GetProcessHeap(), 0, e->u.utf8 ); - else if( e->type == EXPR_SVAL ) - HeapFree( GetProcessHeap(), 0, e->u.sval ); - HeapFree( GetProcessHeap(), 0, e ); -} - -void delete_string_list( string_list *sl ) -{ - while( sl ) - { - string_list *t = sl->next; - HeapFree( GetProcessHeap(), 0, sl->string ); - HeapFree( GetProcessHeap(), 0, sl ); - sl = t; - } -} - -void delete_value_list( value_list *vl ) -{ - while( vl ) - { - value_list *t = vl->next; - delete_expr( vl->val ); - HeapFree( GetProcessHeap(), 0, vl ); - vl = t; - } -} - -static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, - string_list *keys ) +static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, string_list *keys) { string_list *k; BOOL found = TRUE; @@ -820,7 +788,8 @@ static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, return found; } -UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview ) +UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview, + struct list *mem ) { SQL_input sql; int r; @@ -832,6 +801,7 @@ UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview ) sql.n = 0; sql.len = 0; sql.view = phview; + sql.mem = mem; r = SQL_parse(&sql); diff --git a/reactos/lib/msi/suminfo.c b/reactos/lib/msi/suminfo.c index 74f00dc64ad..997dacc3698 100644 --- a/reactos/lib/msi/suminfo.c +++ b/reactos/lib/msi/suminfo.c @@ -39,7 +39,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msi); -#define MSI_MAX_PROPS 19 +#define MSI_MAX_PROPS 20 #include "pshpack1.h" @@ -81,6 +81,8 @@ typedef struct { #include "poppack.h" +#define SECT_HDR_SIZE (sizeof(PROPERTYSECTIONHEADER)) + typedef struct { BOOL unicode; union { @@ -162,17 +164,21 @@ static UINT get_property_count( PROPVARIANT *property ) } /* FIXME: doesn't deal with endian conversion */ -static void read_properties_from_data( PROPVARIANT *prop, - PROPERTYIDOFFSET *idofs, DWORD count, LPBYTE data, DWORD sz ) +static void read_properties_from_data( PROPVARIANT *prop, LPBYTE data, DWORD sz ) { UINT type; DWORD i; int size; PROPERTY_DATA *propdata; PROPVARIANT *property; + PROPERTYIDOFFSET *idofs; + PROPERTYSECTIONHEADER *section_hdr; + + section_hdr = (PROPERTYSECTIONHEADER*) &data[0]; + idofs = (PROPERTYIDOFFSET*) &data[SECT_HDR_SIZE]; /* now set all the properties */ - for( i = 0; i < count; i++ ) + for( i = 0; i < section_hdr->cProperties; i++ ) { type = get_type( idofs[i].propid ); if( type == VT_EMPTY ) @@ -181,12 +187,12 @@ static void read_properties_from_data( PROPVARIANT *prop, break; } - propdata = (PROPERTY_DATA*) &data[idofs[i].dwOffset]; + propdata = (PROPERTY_DATA*) &data[ idofs[i].dwOffset ]; /* check the type is the same as we expect */ if( type != propdata->type ) { - ERR("wrong type\n"); + ERR("wrong type %d != %ld\n", type, propdata->type); break; } @@ -200,6 +206,12 @@ static void read_properties_from_data( PROPVARIANT *prop, break; } + if( idofs[i].propid >= MSI_MAX_PROPS ) + { + ERR("Unknown property ID %ld\n", idofs[i].propid ); + break; + } + property = &prop[ idofs[i].propid ]; property->vt = type; @@ -225,7 +237,6 @@ static UINT load_summary_info( MSISUMMARYINFO *si, IStream *stm ) PROPERTYSETHEADER set_hdr; FORMATIDOFFSET format_hdr; PROPERTYSECTIONHEADER section_hdr; - PROPERTYIDOFFSET idofs[MSI_MAX_PROPS]; LPBYTE data = NULL; LARGE_INTEGER ofs; ULONG count, sz; @@ -261,7 +272,7 @@ static UINT load_summary_info( MSISUMMARYINFO *si, IStream *stm ) return ret; /* read the section itself */ - sz = sizeof section_hdr; + sz = SECT_HDR_SIZE; r = IStream_Read( stm, §ion_hdr, sz, &count ); if( FAILED(r) || count != sz ) return ret; @@ -272,23 +283,19 @@ static UINT load_summary_info( MSISUMMARYINFO *si, IStream *stm ) return ret; } - /* read the offsets */ - sz = sizeof idofs[0] * section_hdr.cProperties; - r = IStream_Read( stm, idofs, sz, &count ); - if( FAILED(r) || count != sz ) + data = HeapAlloc( GetProcessHeap(), 0, section_hdr.cbSection); + if( !data ) return ret; + memcpy( data, §ion_hdr, SECT_HDR_SIZE ); + /* read all the data in one go */ - sz = section_hdr.cbSection; - data = HeapAlloc( GetProcessHeap(), 0, sz ); - if( !data ) - return ret; - r = IStream_Read( stm, data, sz, &count ); + sz = section_hdr.cbSection - SECT_HDR_SIZE; + r = IStream_Read( stm, &data[ SECT_HDR_SIZE ], sz, &count ); if( SUCCEEDED(r) && count == sz ) - { - read_properties_from_data( si->property, idofs, - section_hdr.cProperties, data, sz ); - } + read_properties_from_data( si->property, data, sz + SECT_HDR_SIZE ); + else + ERR("failed to read properties %ld %ld\n", count, sz); HeapFree( GetProcessHeap(), 0, data ); return ret; @@ -481,7 +488,7 @@ UINT WINAPI MsiGetSummaryInformationW( MSIHANDLE hDatabase, end: if( db ) - msiobj_release(&db->hdr); + msiobj_release( &db->hdr ); return ret; } @@ -531,24 +538,20 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, { MSISUMMARYINFO *si; PROPVARIANT *prop; - UINT type; TRACE("%ld %d %p %p %p %p %p\n", handle, uiProperty, puiDataType, piValue, pftValue, str, pcchValueBuf); - type = get_type( uiProperty ); - if( puiDataType ) - *puiDataType = type; - si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO ); if( !si ) return ERROR_INVALID_HANDLE; prop = &si->property[uiProperty]; - if( prop->vt != type ) - goto end; - switch( type ) + if( puiDataType ) + *puiDataType = prop->vt; + + switch( prop->vt ) { case VT_I2: if( piValue ) @@ -587,7 +590,6 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, FIXME("Unknown property variant type\n"); break; } -end: msiobj_release( &si->hdr ); return ERROR_SUCCESS; } diff --git a/reactos/lib/msi/table.c b/reactos/lib/msi/table.c index cf0718b19c7..b0fe75b69c3 100644 --- a/reactos/lib/msi/table.c +++ b/reactos/lib/msi/table.c @@ -35,8 +35,6 @@ #include "msipriv.h" #include "winnls.h" -#include "wine/unicode.h" - #include "query.h" WINE_DEFAULT_DEBUG_CHANNEL(msi); @@ -98,7 +96,7 @@ static LPWSTR encode_streamname(BOOL bTable, LPCWSTR in) LPWSTR out, p; if( !bTable ) - count = strlenW( in )+2; + count = lstrlenW( in )+2; out = HeapAlloc( GetProcessHeap(), 0, count*sizeof(WCHAR) ); p = out; @@ -231,13 +229,13 @@ static UINT read_stream_data( IStorage *stg, LPCWSTR stname, r = IStream_Stat(stm, &stat, STATFLAG_NONAME ); if( FAILED( r ) ) { - ERR("open stream failed r = %08lx!\n",r); + WARN("open stream failed r = %08lx!\n",r); goto end; } if( stat.cbSize.QuadPart >> 32 ) { - ERR("Too big!\n"); + WARN("Too big!\n"); goto end; } @@ -245,7 +243,7 @@ static UINT read_stream_data( IStorage *stg, LPCWSTR stname, data = HeapAlloc( GetProcessHeap(), 0, sz ); if( !data ) { - ERR("couldn't allocate memory r=%08lx!\n",r); + WARN("couldn't allocate memory r=%08lx!\n",r); ret = ERROR_NOT_ENOUGH_MEMORY; goto end; } @@ -254,7 +252,7 @@ static UINT read_stream_data( IStorage *stg, LPCWSTR stname, if( FAILED( r ) || ( count != sz ) ) { HeapFree( GetProcessHeap(), 0, data ); - ERR("read stream failed r = %08lx!\n",r); + WARN("read stream failed r = %08lx!\n",r); goto end; } @@ -305,13 +303,13 @@ UINT read_raw_stream_data( MSIDATABASE *db, LPCWSTR stname, r = IStream_Stat(stm, &stat, STATFLAG_NONAME ); if( FAILED( r ) ) { - ERR("open stream failed r = %08lx!\n",r); + WARN("open stream failed r = %08lx!\n",r); goto end; } if( stat.cbSize.QuadPart >> 32 ) { - ERR("Too big!\n"); + WARN("Too big!\n"); goto end; } @@ -319,7 +317,7 @@ UINT read_raw_stream_data( MSIDATABASE *db, LPCWSTR stname, data = HeapAlloc( GetProcessHeap(), 0, sz ); if( !data ) { - ERR("couldn't allocate memory r=%08lx!\n",r); + WARN("couldn't allocate memory r=%08lx!\n",r); ret = ERROR_NOT_ENOUGH_MEMORY; goto end; } @@ -328,7 +326,7 @@ UINT read_raw_stream_data( MSIDATABASE *db, LPCWSTR stname, if( FAILED( r ) || ( count != sz ) ) { HeapFree( GetProcessHeap(), 0, data ); - ERR("read stream failed r = %08lx!\n",r); + WARN("read stream failed r = %08lx!\n",r); goto end; } @@ -364,7 +362,7 @@ static UINT write_stream_data( IStorage *stg, LPCWSTR stname, HeapFree( GetProcessHeap(), 0, encname ); if( FAILED( r ) ) { - ERR("open stream failed r = %08lx\n",r); + WARN("open stream failed r = %08lx\n",r); return ret; } @@ -372,7 +370,7 @@ static UINT write_stream_data( IStorage *stg, LPCWSTR stname, r = IStream_SetSize( stm, size ); if( FAILED( r ) ) { - ERR("Failed to SetSize\n"); + WARN("Failed to SetSize\n"); goto end; } @@ -380,14 +378,14 @@ static UINT write_stream_data( IStorage *stg, LPCWSTR stname, r = IStream_Seek( stm, pos, STREAM_SEEK_SET, NULL ); if( FAILED( r ) ) { - ERR("Failed to Seek\n"); + WARN("Failed to Seek\n"); goto end; } r = IStream_Write(stm, data, sz, &count ); if( FAILED( r ) || ( count != sz ) ) { - ERR("Failed to Write\n"); + WARN("Failed to Write\n"); goto end; } @@ -438,7 +436,7 @@ UINT read_table_from_storage( MSIDATABASE *db, LPCWSTR name, MSITABLE **ptable) if( rawsize % row_size ) { - ERR("Table size is invalid %d/%d\n", rawsize, row_size ); + WARN("Table size is invalid %d/%d\n", rawsize, row_size ); return ERROR_FUNCTION_FAILED; } @@ -773,13 +771,13 @@ UINT save_string_table( MSIDATABASE *db ) pool = HeapAlloc( GetProcessHeap(), 0, poolsize ); if( ! pool ) { - ERR("Failed to alloc pool %d bytes\n", poolsize ); + WARN("Failed to alloc pool %d bytes\n", poolsize ); goto err; } data = HeapAlloc( GetProcessHeap(), 0, datasize ); if( ! data ) { - ERR("Failed to alloc data %d bytes\n", poolsize ); + WARN("Failed to alloc data %d bytes\n", poolsize ); goto err; } @@ -923,7 +921,7 @@ static UINT get_tablecolumns( MSIDATABASE *db, r = get_table( db, szColumns, &table); if( r != ERROR_SUCCESS ) { - ERR("table %s not available\n", debugstr_w(szColumns)); + WARN("table %s not available\n", debugstr_w(szColumns)); return r; } @@ -932,7 +930,7 @@ static UINT get_tablecolumns( MSIDATABASE *db, if( r != ERROR_SUCCESS ) { release_table( db, table ); - ERR("Couldn't find id for %s\n", debugstr_w(szTableName)); + WARN("Couldn't find id for %s\n", debugstr_w(szTableName)); return r; } @@ -1001,7 +999,7 @@ BOOL TABLE_Exists( MSIDATABASE *db, LPWSTR name ) r = get_table( db, szTables, &table); if( r != ERROR_SUCCESS ) { - ERR("table %s not available\n", debugstr_w(szTables)); + TRACE("table %s not available\n", debugstr_w(szTables)); return FALSE; } @@ -1016,7 +1014,7 @@ BOOL TABLE_Exists( MSIDATABASE *db, LPWSTR name ) if (i!=count) return TRUE; - ERR("Searched %d tables, but %d was not found\n", count, table_id ); + TRACE("Searched %d tables, but %d was not found\n", count, table_id ); return FALSE; } @@ -1117,11 +1115,11 @@ static UINT TABLE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, ISt if( !sval ) return ERROR_INVALID_PARAMETER; - len = strlenW( tv->name ) + 2 + strlenW( sval ); + len = lstrlenW( tv->name ) + 2 + lstrlenW( sval ); full_name = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); - strcpyW( full_name, tv->name ); - strcatW( full_name, szDot ); - strcatW( full_name, sval ); + lstrcpyW( full_name, tv->name ); + lstrcatW( full_name, szDot ); + lstrcatW( full_name, sval ); r = db_get_raw_stream( tv->db, full_name, stm ); if( r ) @@ -1397,7 +1395,7 @@ UINT MSI_CommitTables( MSIDATABASE *db ) r = save_string_table( db ); if( r != ERROR_SUCCESS ) { - ERR("failed to save string table r=%08x\n",r); + WARN("failed to save string table r=%08x\n",r); return r; } @@ -1406,7 +1404,7 @@ UINT MSI_CommitTables( MSIDATABASE *db ) r = save_table( db, table ); if( r != ERROR_SUCCESS ) { - ERR("failed to save table %s (r=%08x)\n", + WARN("failed to save table %s (r=%08x)\n", debugstr_w(table->name), r); return r; } diff --git a/reactos/lib/msi/tokenize.c b/reactos/lib/msi/tokenize.c index d3ad0cfaf8f..223414eb47b 100644 --- a/reactos/lib/msi/tokenize.c +++ b/reactos/lib/msi/tokenize.c @@ -346,7 +346,10 @@ int sqliteGetToken(const WCHAR *z, int *tokenType){ } } if( z[i] ) i++; - *tokenType = TK_STRING; + if( delim == '`' ) + *tokenType = TK_ID; + else + *tokenType = TK_STRING; return i; } case '.': { diff --git a/reactos/lib/msi/update.c b/reactos/lib/msi/update.c index 39c19d8d154..88644bd3005 100644 --- a/reactos/lib/msi/update.c +++ b/reactos/lib/msi/update.c @@ -171,7 +171,6 @@ static UINT UPDATE_delete( struct tagMSIVIEW *view ) wv = uv->wv; if( wv ) wv->ops->delete( wv ); - delete_value_list( uv->vals ); msiobj_release( &uv->db->hdr ); HeapFree( GetProcessHeap(), 0, uv ); diff --git a/reactos/lib/msi/version.rc b/reactos/lib/msi/version.rc index 625c7a7e85a..85179ce15e2 100644 --- a/reactos/lib/msi/version.rc +++ b/reactos/lib/msi/version.rc @@ -18,9 +18,9 @@ #define WINE_FILEDESCRIPTION_STR "Wine MSI dll" #define WINE_FILENAME_STR "msi.dll" -#define WINE_FILEVERSION 2,0,2600,0 -#define WINE_FILEVERSION_STR "2.0.2600.0" -#define WINE_PRODUCTVERSION 2,0,2600,0 -#define WINE_PRODUCTVERSION_STR "2.0.2600.0" +#define WINE_FILEVERSION 3,1,4000,2435 +#define WINE_FILEVERSION_STR "3.1.4000.2435" +#define WINE_PRODUCTVERSION 3,1,4000,2435 +#define WINE_PRODUCTVERSION_STR "3.1.4000.2435" #include "wine/wine_common_ver.rc" diff --git a/reactos/lib/msi/where.c b/reactos/lib/msi/where.c index 8b84d3aafab..9a78074ea1b 100644 --- a/reactos/lib/msi/where.c +++ b/reactos/lib/msi/where.c @@ -334,9 +334,6 @@ static UINT WHERE_delete( struct tagMSIVIEW *view ) wv->reorder = NULL; wv->row_count = 0; - if( wv->cond ) - delete_expr( wv->cond ); - msiobj_release( &wv->db->hdr ); HeapFree( GetProcessHeap(), 0, wv ); -- 2.17.1