packages feed

bamse-0.9.1: Bamse/MSIExtra.hs

--
-- (c) 2007, Galois, Inc.
--
-- The MSI TLB doesn't provide everything we need to
-- use the object model. This module provides these
-- extra bits.
--
module Bamse.MSIExtra where

import Data.Char ( toUpper )
import Util.Path ( fileSuffix )
import Bamse.Package

-- product ID tags (from MsiDefs.h, not provided in the TLB).
data ProductIDTag
 = PID_DICTIONARY
 | PID_CODEPAGE
 | PID_TITLE
 | PID_SUBJECT
 | PID_AUTHOR
 | PID_KEYWORDS
 | PID_COMMENTS
 | PID_TEMPLATE
 | PID_LASTAUTHOR
 | PID_REVNUMBER
 | PID_EDITTIME
 | PID_LASTPRINTED
 | PID_CREATE_DTM
 | PID_LASTSAVE_DTM
 | PID_PAGECOUNT
 | PID_WORDCOUNT
 | PID_CHARCOUNT
 | PID_THUMBNAIL
 | PID_APPNAME
 | PID_SECURITY
    -- The values for the product tags is identical to the Int
    -- values the derived Enum instance maps onto (in the order
    -- given above), so let's make use of 'deriving' here. This
    -- is all somewhat brittle, though..
   deriving ( Eq, Enum, Show )
      
shortLong :: String -> String
shortLong nm = short_form
 where
  badChars = " +,;=[]"
  restricted_nm = map (\ ch -> if ch `elem` badChars then '_' else ch) nm
  ext = fileSuffix nm
  short_form 
   | length restricted_nm > 8 || length ext > 3 = take 6 (map toUpper restricted_nm) ++ "~1|" ++ nm
   | otherwise = restricted_nm

data MsidbFileAttributes
 = MsidbFileAttributesReadOnly      -- = 0x00000001,
 | MsidbFileAttributesHidden        -- = 0x00000002,
 | MsidbFileAttributesSystem        -- = 0x00000004,
 | MsidbFileAttributesReserved0     -- = 0x00000008, // Internal use only - must be 0
 | MsidbFileAttributesReserved1     -- = 0x00000040, // Internal use only - must be 0
 | MsidbFileAttributesReserved2     -- = 0x00000080, // Internal use only - must be 0
 | MsidbFileAttributesReserved3     -- = 0x00000100, // Internal use only - must be 0
 | MsidbFileAttributesVital         -- = 0x00000200,
 | MsidbFileAttributesChecksum      -- = 0x00000400,
 | MsidbFileAttributesPatchAdded    -- = 0x00001000, // Internal use only - set by patches
 | MsidbFileAttributesNoncompressed -- = 0x00002000,
 | MsidbFileAttributesCompressed    -- = 0x00004000,
 | MsidbFileAttributesReserved4     -- = 0x00008000, // Internal use only - must be 0

-- internal record type gathering up parameters for the MSI writer/generator.
-- 
data WriterEnv
 = WriterEnv { w_toolDir     :: FilePath
 	     , w_templateDir :: FilePath
 	     , w_outFile     :: FilePath
	     , w_srcDir      :: FilePath
	     , w_package     :: PackageData
	     }