Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
13.  Creating Data Types Manually Defining the Data Criteria for a Data Type Using File Modes as a Typing Criteria Examples  Previous   Contents   Next 
   
 

Content-Based Data Typing

Use the CONTENT field to specify data typing based on the content of the file. Content-based data typing can be used in combination with name- or location-based data typing.

The typing can be based on either string or numeric content for files. The first byte in the file is numbered 0.

  • For string content of a file, use the syntax:

    	CONTENT  starting_byte string string
  • For number content of a file, use the syntax:

    	CONTENT starting_byte byte number
     	CONTENT starting_byte short number
     	CONTENT starting_byte long number
  • For the contents of a directory, use the syntax:

    	CONTENT 0 filename "file_name"

    Use standard C notation for octal (leading o) and hexidecimal (leading oX) numbers.


    Note - Use of content-based data typing will result in slower system performance. Wherever possible, use name- and location-based typing instead.


    For example, the following data type, Writable_Wingz, applies to all files with write permission containing the string WNGZ at the beginning of the file.

    	DATA_ATTRIBUTES Writable_Wingz
    	{	
     		...
     	}
    
     	DATA_CRITERIA Writable_Wingz_Criteria
     	{
     		CONTENT						0 string WNGZ
     		MODE							w&!d
     		DATA_ATTRIBUTES_NAME	Writable_Wingz
     	}

To Create a Data Type with Several Independent Criteria

You can create a data type with several independent criteria--that is, the file is assigned to the data type if it meets either (or both) of the criteria.

  1. Create the DATA_ATTRIBUTES definition for the data type.

  2. Create a DATA_CRITERIA definition for each criteria.

    Use the DATA_ATTRIBUTES_NAME field to connect each criteria to the same DATA_ATTRIBUTES definition.

    For example, the following definitions create the Mif data type. Typing is based on name or content.

    DATA_ATTRIBUTES Mif
    {
     	ICON								Frame
     	ACTION_LIST						Open,Print
     }
    
     DATA_CRITERIA Mif_Name_Criteria
     {
     	DATA_ATTRIBUTES_NAME				Mif
     	NAME_PATTERN							*.mif
     }
    
     DATA_CRITERIA Mif_Content_Criteria
     {
     	DATA_ATTRIBUTES_NAME		Mif
     	CONTENT							1 string MIFFile
     }

Creating Localized Data Types

The search path for data types includes language-dependent locations. The desktop uses the value of LANG to determine the locations searched for data type definitions.

Locations for Localized Data Types

Localized data type definitions must be placed in the proper language-dependent directories along the actions search path.

The default search path is:

  • Personal actions: HomeDirectory/.dt/types

  • System-wide actions: /etc/dt/appconfig/types/language

  • Built-in actions: /usr/dt/appconfig/types/language

To Localize a Data Type

  1. Create a file in the appropriate language-dependent directory (for example, in /etc/dt/appconfig/types/japanese) .

  2. Copy the data type definition to the language-dependent configuration file.

  3. Localize one or more fields in the data type definition.

 
 
 
  Previous   Contents   Next