Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
XCOMM $XConsortium: Imakefile /main/3 1995/11/03 15:27:12 rswiston $
#define IHaveSubdirs
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
SUBDIRS = dttypes
LINTSUBDIRS = dttypes
MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
LintSubdirs($(LINTSUBDIRS))

View File

@@ -0,0 +1,46 @@
XCOMM $XConsortium: Imakefile /main/8 1996/10/09 14:11:13 drk $
DEFINES = -DXK_MISCELLANY
INCLUDES = -I.
DEPLIBS = $(DEPDTSVCLIB) $(DEPTTLIB) $(DEPXMLIB) $(DEPXTOOLLIB) $(DEPXPLIB) $(DEPXLIB)
LOCAL_LIBRARIES = $(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XPLIB) $(XLIB)
SYS_LIBRARIES = -lm
#ifdef HPArchitecture
EXTRA_DEFINES = +e
#endif
#ifdef SCOArchitecture
ATLIB=
SYS_LIBRARIES = -lm -lcrypt
#endif
#ifdef RsArchitecture
ATLIB=
#endif
#ifdef USLArchitecture
SYS_LIBRARIES = -lm -lgen
ATLIB=
#endif
#ifdef UXPArchitecture
SYS_LIBRARIES = -lm -lgen
ATLIB=
#endif
#if defined(HPOSFArchitecture)
#endif
#if defined(SunArchitecture)
ATLIB=
SYS_LIBRARIES = -lm -ldl -lgen
#endif /* SunArchitecture */
SRCS = dttypes.c
OBJS = dttypes.o
ComplexProgramTarget(dttypes)

View File

@@ -0,0 +1,102 @@
...\" ** (c) Copyright 1993, 1994 Hewlett-Packard Company
...\" ** (c) Copyright 1993, 1994 International Business Machines Corp.
...\" ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
...\" ** (c) Copyright 1993, 1994 Novell, Inc.
...\" **
.\" $XConsortium: dttypes.1 /main/2 1995/09/06 08:54:08 lehors $
.TH DTTYPES 1X
.SH NAME
\fBdttypes \(em Generates a list of the DT Action and DataTypes definitions. \fP
.sp 1
.SH SYNOPSIS
.B dttypes [-help]
dttypes [-type filename]
dttypes [-db database] [-w [rec_name regexp]
[fld_name regexp] [fld_value regexp]]
[-l [rec_name] [rec_info] [fld_name regexp]
[fld_value]]
.nf
.in 10
.fi
.sp 1
.SH DESCRIPTION
Dttypes is a client that lists the Action and DataTypes definitions. This is
useful in understanding where DT is getting the information for its'
databases and how it is using that information to construct the databases.
By default it prints out the entire set of databases.
.SH OPTIONS
The optional command_list is composed of one or more of the following:
-help
prints out the usage message.
.P
-type filename
where filename is the name of a file to be typed.
.P
-db database
where database uses all the DataBases whose name matches the regular expression database. Currently: DATA_CRITERIA, DATA_ATTRIBUTES or ACTION.
.P
-w search_list
where searclist consist of one or more of the following:
.in 10
.sp 1
1. rec_name reg_exp - finds all records whose name matches the regular expression reg_exp.
.sp
2. fld_name reg_exp - finds all records whose field name matches the regular expression reg_exp.
.sp
3. fld_value reg_exp - finds all records whose field values matches the regular expression reg_exp.
.P
-l display_list
where display_list consist of one or more of the following:
.in 10
.sp 1
1. rec_name - displays the name of the records found.
.sp
2. rec_info - displays the file the record was found in.
.sp
3. fld_name [reg_exp] - displays the names of the attributes found in that record.
If a reg_exp is specified then only those fields that match will be displayed.
.sp
4. fld_value - displays the values of the attributes found in the record.
.P
.SH SEE ALSO
DtDtsLoadDataTypes(3),
DtDtsDataToDataType(3),
DtDtsFileToDataType(3),
DtDtsFileToAttributeList(3),
DtDtsFileToAttributeValue(3),
DtDtsBufferToDataType(3),
DtDtsBufferToAttributeList(3),
DtDtsBufferToAttributeValue(3),
DtDtsDataTypeToAttributeList(3),
DtDtsDataTypeToAttributeValue(3),
DtDtsFreeDataType(3),
DtDtsFreeAttributeList(3),
DtDtsFreeAttributeValue(3),
DtDtsRelease(3),
DtDtsDataTypeNames(3),
DtDtsFindAttribute(3),
DtDtsFreeDataTypeNames(3),
DtDtsSetDataType(3),
DtDtsDataTypeIsAction(3),
DtActionLabel(3),
DtActionDescription(3),
DtActionExists(3),
DtActionInvoke(3),
dtcreateaction(1)

View File

@@ -0,0 +1,604 @@
/* $TOG: dttypes.c /main/6 1998/04/20 13:01:30 mgreess $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include <sys/types.h>
#include <locale.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <Xm/Xm.h>
#include <X11/Shell.h>
#define INIT register char *sp = instring;
#define GETC() (*sp++)
#define PEEKC() (*sp)
#define UNGETC(c) (--sp)
#define RETURN(c) return(c)
#define ERROR(c) {rexp_errno = c; return((char *)0);}
static int rexp_errno = 0;
#ifdef __hpux
#include <regexp.h>
#else
#include <regexp.h>
#endif
#include <nl_types.h>
#include <Dt/Dt.h>
#include <Dt/DtsMM.h>
#include <Dt/Dts.h>
#include <Dt/EnvControlP.h>
#if !defined(NL_CAT_LOCALE)
#define NL_CAT_LOCALE 0
#endif
static enum errors
{
BAD_DB,
NO_ARGUMENT,
REC_INFO_IN_STATE,
NO_STATE,
INVALID_ARG
} MyErrors;
static int read_errors = 0;
static char *error_str[] =
{
"Invalid DataBase\n", /* BAD_DB */
"Not a valid argument\n", /* NO_ARGUMENT */
"invalid rec_info field in -w option\n", /* REC_INFO_IN_STATE */
"Not in -w or -l option\n", /* NO_STATE */
"Unknown option\n" /* INVALIDE_ARG */
};
static enum list_shift
{
r_info,
r_name,
f_name,
f_value
};
typedef struct
{
int display_list;
int *rec_list;
int rec_count;
int rec_total;
char *db_name;
char *rec_name;
char *fld_name;
char *fld_value;
char *display_fld;
} List;
static nl_catd dtcatd = 0;
static int
init(int *argc, char **argv)
{
Widget toplevel;
XtAppContext appContext;
Arg args[20];
toplevel = XtInitialize(argv[0], "Dttype", NULL, 0,
(int *) argc, argv);
XtSetArg(args[0], XmNallowShellResize, 1);
XtSetArg(args[1], XmNmappedWhenManaged, 0);
XtSetArg(args[2], XmNheight, 1);
XtSetArg(args[3], XmNwidth, 1);
XtSetValues(toplevel, args, 4);
XtRealizeWidget(toplevel);
if (DtInitialize(XtDisplay(toplevel), toplevel, argv[0],
"Dttype") == False)
{
fprintf(stderr, "couldn't initialize everthing\n");
return(0);
}
/* Load the filetype/action dbs; DtActionInvoke() requires this */
_DtDtsMMInit(0);
return(1);
}
void
add_rec(int rec, List *l)
{
int i;
if(l->rec_total == 0 || l->rec_count >= l->rec_total-2)
{
l->rec_total += 10;
l->rec_list = (int *)realloc(l->rec_list, (l->rec_total)*sizeof(int));
}
l->rec_list[l->rec_count] = rec;
l->rec_count++;
l->rec_list[l->rec_count] = -1;
}
void
rec_list(List *l)
{
int i;
int db;
int rec;
int fld;
DtDtsMMDatabase *db_ptr;
DtDtsMMDatabase *db_ptr_list;
DtDtsMMRecord *rec_ptr;
DtDtsMMRecord *rec_ptr_list;
DtDtsMMField *fld_ptr;
DtDtsMMField *fld_ptr_list;
char expbuf_rn[2000];
char expbuf_fn[2000];
char expbuf_fv[2000];
char expbuf_df[2000];
memset(expbuf_rn, '\0', sizeof(expbuf_rn));
memset(expbuf_fn, '\0', sizeof(expbuf_fn));
memset(expbuf_fv, '\0', sizeof(expbuf_fv));
memset(expbuf_df, '\0', sizeof(expbuf_df));
if((compile(l->rec_name?l->rec_name:"^.*",
expbuf_rn,
&expbuf_rn[sizeof(expbuf_rn)],
0)) == (char *)0)
{
/* error */
fprintf(stderr, catgets(dtcatd, 1, 36, "error in regular expression %s\n"), l->rec_name?l->rec_name:"(NULL)");
exit(1);
}
if((compile(l->fld_name?l->fld_name:"^.*",
expbuf_fn,
&expbuf_fn[sizeof(expbuf_fn)],
0)) == (char *)0)
{
/* error */
fprintf(stderr, catgets(dtcatd, 1, 36, "error in regular expression %s\n"), l->fld_name?l->fld_name:"(NULL)");
exit(1);
}
if((compile(l->fld_value?l->fld_value:"^.*",
expbuf_fv,
&expbuf_fv[sizeof(expbuf_fv)],
0)) == (char *)0)
{
/* error */
fprintf(stderr, catgets(dtcatd, 1, 36, "error in regular expression %s\n"), l->fld_value?l->fld_value:"(NULL)");
exit(1);
}
if((compile(l->display_fld?l->display_fld:"^.*",
expbuf_df,
&expbuf_df[sizeof(expbuf_df)],
0)) == (char *)0)
{
/* error */
fprintf(stderr, catgets(dtcatd, 1, 36, "error in regular expression %s\n"), l->display_fld?l->display_fld:"(NULL)");
exit(1);
}
db_ptr = _DtDtsMMGet(l->db_name);
rec_ptr_list = _DtDtsMMGetPtr(db_ptr->recordList);
for(rec = 0; rec < db_ptr->recordCount; rec++)
{
rec_ptr = &rec_ptr_list[rec];
fld_ptr_list = _DtDtsMMGetPtr(rec_ptr->fieldList);
if(advance((char *)_DtDtsMMBosonToString(rec_ptr->recordName), expbuf_rn) != 0)
{
for(fld = 0; fld < rec_ptr->fieldCount; fld++)
{
char *fn;
char *fv;
fld_ptr = &fld_ptr_list[fld];
fn = _DtDtsMMExpandValue(_DtDtsMMBosonToString(fld_ptr->fieldName));
fv = _DtDtsMMExpandValue(_DtDtsMMBosonToString(fld_ptr->fieldValue));
if((advance(fn, expbuf_fn) != 0) &&
((fld_ptr->fieldValue==0?advance(catgets(dtcatd, 1, 4, "NULL"), expbuf_fv):advance(fv, expbuf_fv)) != 0))
{
add_rec(rec, l);
_DtDtsMMSafeFree(fn);
_DtDtsMMSafeFree(fv);
break;
}
_DtDtsMMSafeFree(fn);
_DtDtsMMSafeFree(fv);
}
}
}
for(i = 0; l->rec_list && l->rec_list[i] != -1; i++)
{
rec = l->rec_list[i];
rec_ptr = &rec_ptr_list[rec];
if(l->display_list&(1<<r_info) ||
l->display_list&(1<<r_name) &&
(l->display_list&(1<<f_name) ||
l->display_list&(1<<f_value)))
{
printf(catgets(dtcatd, 1, 5, "=============== %s ===============\n"),
rec_ptr->recordName?(char *)_DtDtsMMBosonToString(rec_ptr->recordName):catgets(dtcatd, 1, 6, ""));
}
else if (l->display_list&(1<<r_name))
{
printf(catgets(dtcatd, 1, 7, "%s\n"),
rec_ptr->recordName?(char *)_DtDtsMMBosonToString(rec_ptr->recordName):catgets(dtcatd, 1, 8, ""));
}
if(l->display_list&(1<<r_info))
{
char *path = (char *)_DtDtsMMBosonToString(rec_ptr->pathId);
printf(catgets(dtcatd, 1, 9, "loaded from %s\n"), path?path:catgets(dtcatd, 1, 10, "Unknown"));
}
fld_ptr_list = _DtDtsMMGetPtr(rec_ptr->fieldList);
for(fld = 0; fld < rec_ptr->fieldCount; fld++)
{
int term = 0;
char *fn;
char *fv;
fld_ptr = &fld_ptr_list[fld];
fn = _DtDtsMMExpandValue(_DtDtsMMBosonToString(fld_ptr->fieldName));
fv = _DtDtsMMExpandValue(_DtDtsMMBosonToString(fld_ptr->fieldValue));
if(l->display_fld)
{
if(advance(fn, expbuf_df) !=0)
{
printf(catgets(dtcatd, 1, 11, "\t%s"),
fn?fn:catgets(dtcatd, 1, 12, ""));
printf(catgets(dtcatd, 1, 13, " :\t%s"),
fld_ptr->fieldValue?fv:
catgets(dtcatd, 1, 14, ""));
printf(catgets(dtcatd, 1, 15, "\n"));
}
}
else
{
if(l->display_list&(1<<f_name))
{
printf(catgets(dtcatd, 1, 11, "\t%s"), fld_ptr->fieldName?fn:catgets(dtcatd, 1, 12, ""));
term++;
}
if(l->display_list&(1<<f_value))
{
printf(catgets(dtcatd, 1, 13, " :\t%s"), fld_ptr->fieldValue?fv:catgets(dtcatd, 1, 14, ""));
term++;
}
if(term)printf(catgets(dtcatd, 1, 15, "\n"));
}
_DtDtsMMSafeFree(fn);
_DtDtsMMSafeFree(fv);
}
}
}
int
parse_args(List *l, int argc, char **argv)
{
int *rl;
int df = 0;
int i;
int error = 0;
enum st
{
none,
where,
list
};
enum st state = none;
l->display_list = 0;
l->rec_list = 0;
l->rec_count = 0;
l->db_name = 0;
l->rec_name = 0;
l->fld_name = 0;
l->fld_value = 0;
for(i = 1; i < argc; i++)
{
if(strcmp(argv[i], catgets(dtcatd, 1, 16, "-db")) == 0)
{
if(argv[i+1])
{
if(!_DtDtsMMGet(argv[i+1]))
{
error |= 1<<BAD_DB;
}
l->db_name = argv[++i];
}
else
{
error |= 1<<NO_ARGUMENT;
}
}
else if(strcmp(argv[i], catgets(dtcatd, 1, 17, "-w")) == 0)
{
state = where;
}
else if(strcmp(argv[i], catgets(dtcatd, 1, 18, "-l")) == 0)
{
state = list;
}
else if(strcmp(argv[i], catgets(dtcatd, 1, 19, "rec_info")) == 0)
{
if(state == where)
{
error |= 1<<REC_INFO_IN_STATE;
}
else if(state == list)
{
l->display_list|= 1<<r_info;
}
else
{
error |= 1<<NO_STATE;
}
}
else if(strcmp(argv[i], catgets(dtcatd, 1, 20, "rec_name")) == 0)
{
if(state == where)
{
if(!argv[i+1])
{
error |= 1<<NO_ARGUMENT;
}
else
{
l->rec_name = argv[++i];
}
}
else if(state == list)
{
l->display_list |= 1<<r_name;
}
else
{
error |= 1<<NO_STATE;
}
}
else if(strcmp(argv[i], catgets(dtcatd, 1, 21, "fld_name")) == 0)
{
if(state == where)
{
if(!argv[i+1])
{
error |= 1<<NO_ARGUMENT;
}
else
{
l->fld_name = argv[++i];
}
}
else if(state == list)
{
if(!argv[i+1])
{
error |= 1<<NO_ARGUMENT;
}
else
{
l->display_list |= 1<<f_name;
if(strcmp(argv[i+1], catgets(dtcatd, 1, 22, "fld_value")) &&
strcmp(argv[i+1], catgets(dtcatd, 1, 21, "fld_name")) &&
strcmp(argv[i+1], catgets(dtcatd, 1, 20, "rec_name")) &&
strcmp(argv[i+1], catgets(dtcatd, 1, 19, "rec_info")) )
{
l->display_fld = argv[++i];
}
}
}
else
{
error |= 1<<NO_STATE;
}
}
else if(strcmp(argv[i], catgets(dtcatd, 1, 22, "fld_value")) == 0)
{
if(state == where)
{
if(!argv[i+1])
{
error |= 1<<NO_ARGUMENT;
}
else
{
l->fld_value = argv[++i];
}
}
else if(state == list)
{
l->display_list |= 1<<f_value;
}
else
{
error |= 1<<NO_STATE;
}
}
else if(strcmp(argv[i], catgets(dtcatd, 1, 23, "all")) == 0)
{
if(state == where)
{
if(!argv[i+1])
{
error |= 1<<NO_ARGUMENT;
}
else
{
l->fld_value = argv[++i];
}
}
else if(state == list)
{
l->display_list|= 1<<r_info;
l->display_list |= 1<<r_name;
l->display_list |= 1<<f_name;
l->display_list |= 1<<f_value;
}
else
{
error |= 1<<NO_STATE;
}
}
else if(strcmp(argv[i], catgets(dtcatd, 1, 26, "-type")) == 0)
{
char *type, *new;
if(!argv[i+1])
{
error |= 1<<NO_ARGUMENT;
}
else
{
printf(catgets(dtcatd, 1, 27, "%s is of type %s\n"),
argv[i+1],
type = DtDtsFileToDataType(argv[i+1]));
new = (char *)malloc(strlen(type)+5);
strcpy(new, type);
strcat(new, catgets(dtcatd, 1, 28, "$"));
l->rec_name = new;
l->db_name = "DATA_ATTRIBUTES";
l->display_list|= 1<<r_info;
l->display_list |= 1<<r_name;
l->display_list |= 1<<f_name;
l->display_list |= 1<<f_value;
}
i++;
}
else if(strcmp(argv[i], catgets(dtcatd, 1, 35, "-help")) == 0)
{
usage();
}
else
{
error |= 1<<INVALID_ARG;
}
if(error)
{
int j;
if(!read_errors)
{
for(j = 0; j < XtNumber(error_str); j++)
{
error_str[j] = catgets(dtcatd, 1, 30+j, error_str[j]);
}
read_errors = ~0;
}
fprintf(stderr, catgets(dtcatd, 1, 24, "Arg = %s\n"), argv[i]);
for(j = 0; error; j++)
{
if(error & 1<<j)
{
fprintf(stderr, error_str[j]);
error = error & ~(1<<j);
}
}
usage();
break;
}
}
if(error)
{
return(0);
}
return(1);
}
usage()
{
fprintf(stderr, catgets(dtcatd, 1, 25, "usage: dttypes [-help]\n\tdttypes [-type filename]\n\tdttypes [-db database] [-w [rec_name regexp] [fld_name regexp]\n\t\t\t[fld_value regexp]]\n\t\t[-l [rec_name] [rec_info] [fld_name regexp] [fld_value]]\n"));
exit(1);
}
main(int argc, char **argv)
{
List l;
char **dbs;
int *rl;
int df = 0;
int i;
int error = 0;
char *locale;
enum st
{
none,
where,
list
};
enum st state = none;
locale = setlocale(LC_ALL, "");
if(!locale)
{
perror("setlocale");
}
_DtEnvControl(DT_ENV_SET);
dtcatd = catopen("dttypes", NL_CAT_LOCALE);
if(dtcatd == (nl_catd)-1)
{
perror("catopen");
}
memset(&l, '\0', sizeof(l));
if(!init(&argc, argv))
{
exit(1);
}
if(!parse_args(&l, argc, argv))
{
exit(1);
}
if(!(l.display_list&(1<<r_info) ||
l.display_list&(1<<f_name) ||
l.display_list&(1<<f_value) ||
l.display_list&(1<<r_name) ))
{
l.display_list |= 1<<r_name;
l.display_list |= 1<<r_info;
l.display_list |= 1<<f_name;
l.display_list |= 1<<f_value;
}
if(l.display_list&(1<<r_info)) l.display_list |= 1<<r_name;
if(l.display_list&(1<<f_name)) l.display_list |= 1<<r_name;
if(l.display_list&(1<<f_value)) l.display_list |= 1<<r_name;
if(l.display_list == 0) l.display_list |= 1<<r_name;
if(l.db_name)
{
rec_list(&l);
}
else
{
dbs = (char **)_DtsMMListDb();
for(i = 0; dbs[i]; i++)
{
printf(catgets(dtcatd, 1, 29, "--------------------- %s ----------------\n"),
dbs[i]);
l.db_name = dbs[i];
rec_list(&l);
free(l.rec_list);
l.rec_list = 0;
l.rec_count = 0;
l.rec_total = 0;
}
}
return(0);
}

View File

@@ -0,0 +1,70 @@
$ $XConsortium: dttypes.msg /main/3 1995/11/03 15:27:52 rswiston $
$quote "
$set 1
1 "Dttype"
$ Do not Translate
2 "Dttype"
$ Do not Translate
3 "couldn't initialize everthing\n"
4 "NULL"
$ this should mean a "Empty string".
5 "=============== %s ===============\n"
$ Do not Translate
6 "\0"
$ Do not Translate
7 "%s\n"
$ Do not Translate
8 ""
$ Do not Translate
9 "loaded from %s\n"
10 "Unknown"
11 "\t%s"
$ Do not Translate
12 "\0"
$ Do not Translate
13 " :\t%s"
$ Do not Translate
14 "\0"
$ Do not Translate
15 "\n"
$ Do not Translate
16 "-db"
$ Do not Translate
17 "-w"
$ Do not Translate
18 "-l"
$ Do not Translate
19 "rec_info"
$ Do not Translate
20 "rec_name"
$ Do not Translate
21 "fld_name"
$ Do not Translate
22 "fld_value"
$ Do not Translate
23 "all"
$ Do not Translate
24 "error = %s\n"
$ Translate "error" only
25 "usage: dttypes [-help]\n\tdttypes [-type filename]\n\tdttypes [-db database] [-w [rec_name regexp] [fld_name regexp]\n\t\t\t[fld_value regexp]]\n\t\t[-l [rec_name] [rec_info] [fld_name regexp] [fld_value]]\n"
$ Translate only the following: "filename" "database" "regexp"
26 "-type"
$ Do not Translate
27 "%s is of type %s\n"
28 "$"
$ Do not Translate
29 "--------------------- %s ----------------\n"
$ Do not Translate
30 "Invalid DataBase\n"
31 "Not a valid argument\n"
32 "invalid rec_info field in -w option\n"
$ do not translate "rec_info" or "-w"
33 "Not in -w or -l option\n"
$ do not translate "-w" or "-l"
34 "Unknown option\n"
35 "-help"
$ Do not Translate
36 "error in regular expression %s\n"

View File

@@ -0,0 +1,267 @@
#! /bin/ksh
##############################################################################
#
# convertVf
#
# This shell script converts the VUE 3.0 filetypes database files (*.vf)
# to the CDE 1.0 datatypes database files (*.dt). This script is a
# filter, this allows the user to select the input and output file names.
# To be recognized as a CDE 1.0 desktop datatypes file the output file
# name must be of the form: "*.dt"
#
# The transformations applied to the input are:
# 1) change a number of strings;
# 2) enclose type/action definitions in brackets;
# 3) remove "END" lines;
# 4) break up FILETYPES definitions into DATA_CRITERIA and
# DATA_ATTRIBUTES definitions.
# 5) escape special characters which appear in NAME_PATTERNS
# (PATH_PATTERNS) with a backslash. (e.g. '!')
# 6) Replace LARGE and SMALL ICON references with a single ICON
# reference, while possibly removing size-related suffixes from
# the icon name string. (e.g foo.l --> foo )
# 7) Convert TYPE MAP <action> lines to
# TYPE MAP
# MAP_ACTION <action>
#
# Usage: convertvf < file.vf > file.dt
#
##############################################################################
typeset USAGE="Usage: $(basename $0) < file.vf > file.dt"
###############################################################################
#
# changeStrings()
# This function invokes sed to search and replace a number of
# strings which have been changed between the Vue3.0 ".vf"
# files and the CDE 1.0 ".dt" files.
#
###############################################################################
changeStrings() {
# NOTE:
# LARGE_ICON definitions are retained and converted to their ICON equivalents
# SMALL_ICON definitions are discarded.
#
sed '
s/Filetype/DataType/g
s/filetype/DataType/g
s/%FileName%/%name%/g
s/%PathName%/%dir%/g
s/PATH-PATTERN/PATH_PATTERN/
s/FILETYPE/DATA_CRITERIA/
s/FILE-PATTERN/NAME_PATTERN/
s/ARG-TYPES/ARG_TYPE/
s/ARG-COUNT/ARG_COUNT/
s/WINDOW-TYPE/WINDOW_TYPE/
s/EXEC-STRING/EXEC_STRING/
s/EXEC-HOST/EXEC_HOST/
s/NO-STDIO/NO_STDIO/
s/PERM-TERMINAL/PERM_TERMINAL/
s/SHELL-TERMINAL/SHELL_TERMINAL/
s/OUTPUT-ONLY/PERM_TERMINAL/
s/SHARED-OUTPUT/PERM_TERMINAL/
s/\([^_]\)ATTRIBUTES\([^_]\)/\1PROPERTIES\2/
s/RELOAD-TYPES-DB/RELOAD_TYPES_DB/
s/MSG-TOOL/DT_SVC/
s/MSG-COMMAND/DT_REQUEST_NAME/
s/L-ICON/ICON/
s/LARGE_ICON/ICON/
s/L-INSTANCE-ICON/INSTANCE_ICON/
s/LARGE_INSTANCE_ICON/INSTANCE_ICON/
s/MSG-DATA/DT_ARG0_VALUE/
/S-ICON/d
/SMALL_ICON/d
/S-INSTANCE-ICON/d
/SMALL_INSTANCE_ICON/d
/^[ ]*set[ ]/s/\(.*\)\.[lms]\.bm/\1/
/ICON/s/\(.*\)\.[lms]\.bm/\1/
' $*
}
###############################################################################
#
# replaceFileTypes()
# This function invokes awk to replace FILETYPE definitions with
# DATA_CRITERIA and DATA_ATTRIBUTES definitions. It places brackets
# around the definitions, instead of using "END" to mark the end of
# a definition.
#
###############################################################################
replaceFileTypes() {
awk '
function printCrit( array )
{
if ( names[TypeName] )
print "DATA_CRITERIA", TypeName names[TypeName];
else
print "DATA_CRITERIA", TypeName
print "{"
print " DATA_ATTRIBUTES_NAME",TypeName
for (c in array) {
print array[c];
delete array[c];
}
print "}"
}
function printAtt( array )
{
print "DATA_ATTRIBUTES",TypeName;
print "{"
for (c in array) {
print array[c];
delete array[c];
}
print "}"
}
BEGIN {
criteria[1] = "NAME_PATTERN";
criteria[2] = "PATH_PATTERN";
criteria[3] = "CONTENT";
criteria[4] = "MODE";
criteria[5] = "LINK_PATH";
criteria[6] = "LINK_NAME";
criteria[7] = "DATA_ATTRIBUTES_NAME";
critMax = 7;
gettingLines = 0;
}
#
# Special treatment CRITERIA/ATTRIBUTE Fields
#
$1 == "NAME_PATTERN" {
#
# escape special syntax chars in name patterns
#
if ( $2 ~ /!/) {
gsub(/!/,"\\!")
}
}
$1 == "ICON" || $1 == "INSTANCE_ICON" {
if ( $2 ~ /.l/ ) {
sub(/\.l$/,"",$0);
}
}
$1 == "DATA_CRITERIA" {
TypeName = $2;
names[$2]++;
gettingLines = 1;
next;
}
#
# Special treatment ACTION FIELDS
#
$1 == "TYPE" && $2 == "MAP" && NF == 3 {
print " " $1 " " $2
print " MAP_ACTION " $3
next;
}
#
# TYPE MESSAGE actions were not publically exposed so there should
# not be many message actions to translate. Here we make some
# assumptions about the message action.
#
# Only the ReloadActions broadcast message becomes a DT_NOTIFY message.
# Assume all other messages turn into DT_REQUESTs.
#
$1 == "TYPE" && $2 == "MESSAGE" {
if ( ActionName == "ReloadActions" )
print " TYPE DT_NOTIFY"
else
print " TYPE DT_REQUEST"
next;
}
$1 == "DT_REQUEST_NAME" && ActionName == "ReloadActions" {
print " DT_NOTIFY_NAME " $2
next
}
$1 == "ACTION" {
ActionName = $2
print $0
print "{"
next;
}
(($1 == "END") || ($1 == "}")) && gettingLines {
gettingLines = 0;
if ( names[TypeName] == 1 )
printAtt(newAtt);
printCrit(newCrit);
next;
}
$1 == "END" {
print "}"
next;
}
$1 == "{" {
# do not print any brackets -- we will
# supply any that are necessary
next;
}
gettingLines == 1 {
for ( i = 1; i <= critMax; i++ ) {
# compare to criteria strings
if ( $1 == criteria[i] ) {
tmp = $1;
newCrit[$1] = $0
while ( substr($0,length($0),1) == "\\" ) {
getline;
newCrit[tmp] = newCrit[tmp] "\n" $0;
}
next;
}
}
#
# If we have not found it yet it must be an
# attribute.
#
tmp = $1
newAtt[tmp] = $0;
while ( substr($0,length($0),1) == "\\" ) {
getline;
newAtt[tmp] = newAtt[tmp] "\n" $0;
}
next;
}
gettingLines == 0 { print $0 }
' $*
}
###############################################################################
[ $# -eq 0 ] || {
echo $USAGE;
exit 1;
}
changeStrings $i | replaceFileTypes

View File

@@ -0,0 +1,45 @@
.\" $XConsortium: dtconvertvf.1xo /main/2 1995/07/17 15:40:35 drk $
.TH dtconvertvf 4 "23 Nov 1994"
.\" CDE Common Source Format, Version 1.0.0
.\" *************************************************************************
.\" ** (c) Copyright 1993, 1994 Hewlett-Packard Company
.\" ** (c) Copyright 1993, 1994 International Business Machines Corp.
.\" ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
.\" ** (c) Copyright 1993, 1994 Novell, Inc.
.\" *************************************************************************
.SH NAME
dtconvertvf \- convert VUE 3.0 action/filetype files to DT syntax
.SH SYNOPSIS
.yS
dtconvertvf
.yE
.SH DESCRIPTION
The
.B dtconvertvf
utility is a filter script for converting VUE 3.0 action and filetype
databases to the new CDE 1.0 datatypes syntax.
If the input is a VUE 3.0
filetype file (*.vf) then its output will be converted to a CDE 1.0 datatypes
file.
It is up to the user to name the output file accordingly.
To be
recognized by CDE 1.0 it must have the \fB.dt\fP suffix.
.SH EXAMPLE
To convert a single action/filetype file to CDE 1.0 syntax:
sp 1
.B dtconvertvf < file.vf > file.dt
.sp 1
To convert all action/filetype files in current directory to CDE 1.0 syntax:
.sp 1
for vffile in *.vf; do
.br
.B dtfile=${vffile%.vf}.dt
.B dtconvertvf < $vffile > $dtfile
.br
done