Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

DtActionLabel(3)

DtActionDescription(3)

DtActionExists(3)

DtActionInvoke(3)

dtdtfile(3)

DtDndDropRegister(3)

dtcreateaction(1)

dttypes(1)

DtDataTyping(3)  —  Subroutines

NAME

DtDataTyping, DtDtsLoadDataTypes, DtDtsDataToDataType, DtDtsFileToDataType, DtDtsFileToAttributeList, DtDtsFileToAttributeValue , DtDtsBufferToDataType, DtDtsBufferToAttributeList, DtDtsBufferToAttributeValue, DtDtsDataTypeToAttributeList, DtDtsDataTypeToAttributeValue, DtDtsFreeDataType, DtDtsFreeAttributeList, DtDtsFreeAttributeValue, DtDtsRelease, DtDtsDataTypeNames, DtDtsFindAttribute, DtDtsFreeDataTypeNames, DtDtsSetDataType, DtDtsDataTypeIsAction − Data Typing operations

SYNOPSIS

#include <Dt/Dts.h>
  voidDtDtsLoadDataTypes(void);
voidDtDtsRelease(void);
 char∗DtDtsDataToDataType(
const char∗filepath,
const void∗buffer,
const intsize,
const struct stat∗stat_buff,
const char∗link_path,
const struct stat∗link_stat_buff,
const char∗opt_name);
 char∗DtDtsFileToDataType(const char ∗filepath);
char∗DtDtsFileToAttributeValue(
const char∗filepath,
const char∗attr_name);
DtDtsAttribute∗∗DtDtsFileToAttributeList(const char ∗filepath);
 char∗DtDtsBufferToDataType(
const void∗buffer,
const intsize,
const char∗opt_name);
char∗DtDtsBufferToAttributeValue(
const void∗buffer,
const intsize,
const char∗attr_name,
const char∗opt_name);
DtDtsAttribute∗∗DtDtsBufferToAttributeList(
const void∗buffer,
const intsize,
const char∗opt_name);
 char∗DtDtsDataTypeToAttributeValue(
const char∗datatype,
const char∗attr_name,
const char∗opt_name);
DtDtsAttribute∗∗DtDtsDataTypeToAttributeList(
const char∗datatype,
const char∗opt_name);
 voidDtDtsFreeDataTypeNames(char ∗∗namelist);
voidDtDtsFreeAttributeList(DtDtsAttribute ∗∗attr_list);
voidDtDtsFreeAttributeValue(char ∗attr_value);
voidDtDtsFreeDataType(char ∗datatype);
 char∗∗DtDtsDataTypeNames(void);
 char∗∗DtDtsFindAttribute(
const char∗attr_name,
const char∗attr_value);
 char∗DtDtsSetDataType(
const char∗filepath,
const char∗datatype,
const intoverride);
 intDtDtsDataTypeIsAction(const char ∗datatype);
 Where:
 filepaththe pathname of file.
buffera pointer to the buffer of the data to be typed.
sizethe size of the buffer.
stat_buffthe buffer from stat/fstat call for use in typing.
link_paththe pathname of the original file that a link points to.
link_stat_buffthe buffer from lstat call for use in typing.
opt_namea name that may be associated with a buffer.
datatypea DataType
attr_namea name of an attribute
attr_lista list of attribute/value pairs defined by the DtDtsAttribute
structure.
attr_valuea value of an attribute.
namelista list of datatype names
overrideIf false will not change the value if it is currently set.
 DtDtsAttribute is a structure with the following entries:
char∗name;
char∗value;
  

AVAILABILITY

_description-of-restriction_

DESCRIPTION

 
DtDtsDataToDataType, DtDtsDataTypeToAttributeValue and DtDtsDataTypeToAttributeList are the primary datatyping functions, the DtDtsFileTo∗ and DtDtsBufferTo∗ are convenience functions to these primary routines.
 
DtDtsLoadDataTypes Initialize and loads the Database fields for the DataTyping functions.
 
DtDtsRelease Releases the data structures and data associated with the datatype database, generally in preparation for a reload.
 
 
DtDtsFileToDataType Returns datatype name for a given file path.Note: the file and buffer functions are convenience functions for this routine and should probably be used for simplicity. Call DtDtsFreeDataType to release the memory for the value.
 
 
DtDtsFileToAttributeValue returns a data attribute value for a given file path. Call DtDtsFreeAttributeValue to release the memory for the returned value
 
DtDtsFileToAttributeList Returns a NULL terminated array of pointers of ∗DtDtAttribute for a given file path. Call DtDtsFreeAttributeList to release the memory for the returned value
 
 
DtDtsBufferToDataType Returns a data type name for a given byte stream. Call DtDtsFreeDataType to release the memory for the returned value. If opt_name is not NULL it will be used as a psudeo file name in typing.
 
DtDtsBufferToAttributeValue Returns a data attribute value for a given byte stream. Call DtDtsFreeAttributeValue to release the memory for the returned value. If opt_name is NULL certain attributes will be returned as NULL because the "filename" components could not be determined.
 
DtDtsBufferToAttributeList Returns a NULL terminated array of pointers of ∗DtDtAttribute for a given byte stream. Call DtDtsFreeAttributeList to release the memory for the returned value. If opt_name is NULL certain attributes will be returned as NULL because the "filename" components could not be determined.
 
DtDtsDataToDataType Returns data type for a given set of data. Call DtDtsFreeDataType to release the memory for the returned value. Pointer values may be passed as a NULL. If a pointer value is NULL the system will try and determine the appropriate value for it only if it is need in doing the typing.
 
DtDtsDataTypeToAttributeList Returns a NULL terminated array of pointers of ∗DtDtAttribute for a given datatype name. Call DtDtsFreeAttributeList to release the memory for the returned value. If opt_name is NULL certain attributes will be returned as NULL because the "filename" components could not be determined.
 
DtDtsDataTypeToAttributeValue Returns the data attribute value for a given datatype name. Call DtDtsFreeAttributeValue to release the memory for the returned value. If opt_name is NULL certain attributes will be returned as NULL because the "filename" components could not be determined.
 
DtDtsDataTypeNames Returns a list of all available datatypes that is currently loaded into the DataTypes database. Call DtDtsFreeDataTypeNames to release the memory for the returned value
 
DtDtsFreeDataType Frees the memory of a datatype name.
 
DtDtsFreeDataTypeNames Frees the memory of a list of datatype name.
 
DtDtsFreeAttributeList Frees the memory of an attribute list.
 
DtDtsFreeAttributeValue Frees the memory of an attribute value.
 
DtDtsFindAttribute Finds the list of datatypes that have the attribute "name" that equal "value". Call DtDtsFreeDataTypeNames to release the memory for the returned value
 
DtDtsSetDataType Sets a datatype on a directory and returns the current datatype on the object. If unable to set or retrieve the datatype a NULL is returned.
 
DtDtsDataTypeIsAction Check if the specified datatype is one loaded by the action tables.
 

RETURN VALUES

Pointer See Description. 
 

NULL If no value could be determined. 

EXAMPLES

Simple-FileTyping

This example takes a list of files as arguments and determines the Description of that datatype. 

 #include <Dt/Dts.h>
 #defineATTRIBUTE"DESCRIPTION"
 main(int argc, char ∗∗argv)
{
char∗attribute;
 /∗ load datatypes database ∗/
DtDtsLoadDataTypes();
 argv++;
while(∗argv) {
/∗ get attribute for file ∗/
attribute = DtDtsFileToAttributeValue(∗argv, ATTRIBUTE);
 if(attribute) {
printf("%s: %s0, ∗argv, attribute);
}
argv++;
}
DtDtsRelease();
exit(0);
}
 

Simple-DataTyping

This example takes a list of files as arguments and determines the Description and Actions of for that file. 

 #include <Dt/Dts.h>
 #defineATTRIBUTE1"DESCRIPTION"
#defineATTRIBUTE2"ACTIONS"
 main(int argc, char ∗∗argv)
{
char∗attribute;
char∗datatype;
 /∗ load datatypes database ∗/
DtDtsLoadDataTypes();
 argv++;
while(∗argv) {
/∗ get datatype file file ∗/
datatype = DtDtsFileToDataType(∗argv);
 /∗ get first attribute for datatype ∗/
attribute = DtDtsDataTypeToAttributeValue(datatype,
ATTRIBUTE1, ∗argv);
if(attribute) {
printf("%s for file %s is %s0,
ATTRIBUTE1, ∗argv, attribute);
}
 /∗ get second attribute for datatype ∗/
attribute = DtDtsDataTypeToAttributeValue(datatype,
ATTRIBUTE2, NULL);
if(attribute) {
printf("%s for file %s is %s0,
ATTRIBUTE2, ∗argv, attribute);
}
argv++;
}
DtDtsRelease();
exit(0);
}
 

SEE ALSO

DtActionLabel(3), DtActionDescription(3), DtActionExists(3), DtActionInvoke(3), dtdtfile(3), DtDndDropRegister(3), dtcreateaction(1), dttypes(1),
 

  —  15 Dec. 1993

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026