Sun Microsystems Logo
Products and Services
 
Support and Training
 
 

Previous Previous     Contents     Index     Next Next
Chapter 9

Accessing the Data-Typing Database

This chapter describes the data-typing functions and how to use the data-typing database.

Summary

Data typing provides an extension to the attributes of files and data beyond what is provided by the traditional UNIX file systems. These extensions consist of attributes, such as icon names, descriptions, and actions, that can be performed on files and data. This information is stored in name/value pairs in the DATA_ATTRIBUTES table (or database). The desktop uses a certain set of DATA_ATTRIBUTES, described in the following paragraphs. The DATA_ATTRIBUTES table is extendable for future and application-specific growth, although extending this table is not recommended because other applications may not check the additions.

Data is matched with a specific file or data entry in a DATA_CRITERIA table. The DATA_CRITERIA table entries are sorted in decreasing order from most specific to least specific. For example, /usr/lib/lib* is more specific than /usr/* and would, therefore, appear first. When a request to type a file or data is made, the table is checked in sequence to find the best match using the information provided either from the file or from the data. When an information and entry match is found, DATA_ATTRIBUTES_NAME is used to find the proper DATA_ATTRIBUTES entry.

If you want your application to present data objects (either files or data buffers) to the user in a manner consistent with the desktop, use the DtDts* API to determine how to display the data object by calling the DtDtsDataTypeToAttributeValue() function for the ICON attribute.

Library and Header Files

To use data typing, you need to link to the libDtSvc library. Actions are usually loaded with the data-typing information. Actions require links to the libXm and libX11 libraries. The header files are Dt/Dts.h and Dt/Dt.h.

Demo Program

A demo program containing an example of how to use the data-typing database is in /usr/dt/examples/dtdts/datatypes/datatyping.c.

Data Criteria and Data Attributes

Data typing consists of two parts:

  • A database that stores data criteria and data attributes

  • A collection of routines that query the database

The attributes of data criteria, in alphabetical order, are:

  • CONTENT

  • DATA_ATTRIBUTES_NAME

  • LINK_NAME

  • LINK_PATH

  • MODE

  • NAME_PATTERN

  • PATH_PATTERN

Table 9-1 describes the data criteria in the order in which you are most likely to use them.

Table 9-1 Data Criteria in Order of Most Likely Use

Criteria

Description

Typical Usage

DATA_ATTRIBUTES_NAME

The name of this type of data. This value is a record_name in the data attributes table.

POSTSCRIPT

NAME_PATTERN

A shell pattern-matching expression describing the file names that could match this data. The default is an empty string, which means to ignore file patterns in matching.

*.ps

CONTENT

Three values that are interpreted as the start, type, and value fields of the magic file used by the file utility. See the file(1) man page for more information. The default is an empty field, which means to ignore contents in matching. The following types are examples of what can be matched: string, byte, short, long, and file name.

0 string !%

MODE

A string of zero to four characters that match the mode field of a stat structure. See the stat(2) man page for more information. The first character indicates:

 

d matches a directory

s matches a socket

l matches a symbolic link

f matches a regular file

b matches a block file

c matches a character special file

f&!x

 

 

 

The characters listed below can be either the first or subsequent characters:

 

r matches any file with any of its user, group, or other read permission bits set.

w matches any file with any of its user, group, or other write permission bits set.

x matches any file with any of its user, group, or other execute or directory-search permission bits set.

 

 

 

For example, the MODE field of frw matches any regular file that is readable or writable; x matches any file with any of its executable or search bits set.

The default is an empty field, which means to ignore the mode in matching.

 

PATH_PATTERN

A shell pattern-matching expression describing the absolute path names that could match this data. The default is an empty string, which means to ignore path patterns in matching.

*/mysubdir/*

LINK_NAME

See dtdtsfile(4) man page.

LINK_PATH

See dtdtsfile(4) man page.

Some of the more common attributes of data types, in alphabetical order, are:

  • ACTIONS

  • COPY_TO_ACTION

  • DESCRIPTION

  • ICON

  • INSTANCE_ICON

  • IS_EXECUTABLE

  • IS_TEXT

  • LINK_TO_ACTION

  • MEDIA

  • MIME_TYPE

  • MOVE_TO_ACTION

  • NAME_TEMPLATE

  • PROPERTIES

  • X400_TYPE

Previous Previous     Contents     Index     Next Next
 

Updated: 2003-09-29, 21:43