1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Revert "dtudcfonted, dtudcexch: delete from repository"

This reverts commit e0036e6167.
This commit is contained in:
chase 2018-08-05 15:58:15 -05:00 committed by Jon Trulson
parent 5fb08c15d9
commit 6b713f12b5
122 changed files with 58089 additions and 0 deletions

View file

@ -0,0 +1,50 @@
XCOMM $XConsortium: Imakefile /main/12 1996/10/17 01:48:11 cde-fuj $
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
FONTEDT_PATH1 = ../dtudcfonted
UDC_INC_PATH0 = -I./
UDC_INC_PATH1 = -I$(FONTEDT_PATH1)
UDC_INC_PATH2 = -I$(FONTEDT_PATH1)/include
UDC_INC_PATH3 = -I$(FONTEDT_PATH1)/libfal
UDC_INC_PATH4 = -I$(FONTEDT_PATH1)/libfal/include
UDC_INC_PATH7 = -I$(FONTEDT_PATH1)/dtgpftobdf
INCLUDES = \
$(UDC_INC_PATH0)\
$(UDC_INC_PATH1)\
$(UDC_INC_PATH2)\
$(UDC_INC_PATH3)\
$(UDC_INC_PATH4)\
$(UDC_INC_PATH7)
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
DEFINES = $(OPT2)
DEPLIBS = $(DEPDTSVCLIB) $(DEPTTLIB) $(DEPXMLIB) $(DEPXTOOLLIB) \
$(DEPXLIB) \
$(FONTEDT_PATH1)/libfuty/liboakfuty.a \
$(FONTEDT_PATH1)/libfal/libfal.a
LOCAL_LIBRARIES = $(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XLIB) \
$(FONTEDT_PATH1)/libfuty/liboakfuty.a \
$(FONTEDT_PATH1)/libfal/libfal.a
SYS_LIBRARIES = DtClientSysLibs
SRCS = udcexc.c udcexp.c udcimp.c getbdffn.c excutil.c\
selectx.c exportbdf.c importbdf.c
OBJS = udcexc.o udcexp.o udcimp.o getbdffn.o excutil.o\
selectx.o exportbdf.o importbdf.o
ComplexProgramTarget(dtudcexch)

View file

@ -0,0 +1,31 @@
$XConsortium: README /main/3 1996/10/17 01:48:23 cde-fuj $
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
UDC data exchange utility README
Source code and directory structure
$(TOP)/cde/dtudcexch:
Imakefile
udcexc.c
udcexp.c
udcimp.c
getbdffn.c
excutil.c
excutil.h
selectx.c
exportbdf.c
importbdf.c
The dtudcexch command uses following commands.
dtaddcpf dtbdftocpf dtcpftobdf dtcpftogpf
dtcpgpf dtfonteditor dtgpftobdf dtgpftocpf
dtlsgpf
The dtudcexch command uses following libraries.
libfal.a
liboakfuty.a

View file

@ -0,0 +1,127 @@
$ $XConsortium: dtudcfonted.msg
$ *************************************<+>*************************************
$ *****************************************************************************
$ **
$ ** File: dtudcexch.msg
$ **
$ ** Project: Fujitsu DT UDC Exchange
$ **
$ ** Description:
$ ** -----------
$ ** This file is the source for the message catalog for dtudcexch
$ **
$ **
$ *****************************************************************************
$ **
$ ** (c) Copyright 1996 Fujitsu Ltd.
$ **
$set 2
$ *****************************************************************************
$ ** _DtMessage set for getbdffn.c
$ *****************************************************************************
2 BDF file selection
4 The selected file exists. Overwrite?
6 Failed to open the selected file.
$set 4
$ *****************************************************************************
$ ** _DtMessage set for selectx.c
$ *****************************************************************************
2 This font has no user defined characters.
4 Failed to open the selected font. You do not have permission to access the font file, or the format of the file is incorrect.
6 The font file is in use by another UDC application.
8 There is no font
10 Open
12 Cancel
14 UDC data exchange utility
16 SelectItems
18 - Codeset:
20 - Style:
22 - Width:
24 - Height:
$set 6
$ *****************************************************************************
$ ** _DtMessage set for selectxlfd.c
$ *****************************************************************************
2 Do you want to terminate UDC Exchange?
4 No UDCs exist in this font
6 XLFD name is not selected
8 Cannot open the font file
10 The font file is in use by another UDC application.
$set 8
$ *****************************************************************************
$ ** _DtMessage set for udcexc.c
$ *****************************************************************************
2 UDC data exchange utility
4 Fatal error occurred.
6 Cannot open the font file.
8 Cannot read the font file.
10 There is no more memory.
12 Fatal error occurred.
14 The specified font file does not exist.
16 This font is not a pcf or snf font.
18 Cannot open the fonts.list file.
20 The format of the fonts.list file is incorrect.
22 The descriptions of the fonts.list file are incorrect.
24 The format of the fonts.list file is incorrect.
26 Cannot open the fonts.dir file.
28 Cannot read the fonts.dir file.
30 Cannot read the font properties.
32 Cannot get the FONT property.
34 Cannot get the FAMILY_NAME property.
36 This font file is already in use by another application.
38 Cannot lock the font file.
40 Cannot unlock the font file.
42 Cannot get lock information from the font file.
44 Cannot find the specified font file.
46 Cannot read the NLS database.
48 Cannot get charset names from the NLS database.
50 The charset name is not defined in the NLS database.
52 The specified font has not been opened.
54 A fatal error occurred.
56 XLFD name :
58 Original font (XLFD name) :
60 UDC code area :
62 Style :
64 Size (letter size) :
66 Open
68 Cancel
70 OK
72 cancel
74 Copy origin code(hex) :
76 Copy target code(hex) :
78 Copy
80 Overlay
82 export function
84 import function
86 Cancel
$set 10
$ *****************************************************************************
$ ** _DtMessage set for udcexp.c
$ *****************************************************************************
2 Failed to create the BDF file
4 No indexes are selected
6 OK
8 Cancel
10 glyph indexes
$set 12
$ *****************************************************************************
$ ** _DtMessage set for udcexp.c
$ *****************************************************************************
2 Glyph images in this BDF file cannot be added to the font.
4 Failed to open the selected BDF font. You do not have permission to access the font file, or the format of the file is incorrect.
6 One or more glyph images will be overwritten. Overwrite?
8 Failed to open the selected font. You do not have permission to access the font file, or the format of the file is incorrect.
10 Glyph images in this BDF file cannot be added to the font.
12 Registration of the font file failed.

View file

@ -0,0 +1,336 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: excutil.c /main/3 1996/04/08 15:51:03 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "excutil.h"
extern char *maintitle;
Widget excCreatePushButton(Widget parent, String name, String label,
XtCallbackProc callback_func,
XtPointer client_data)
{
Widget widget;
XmString xms;
Arg args[20];
Cardinal n;
n = 0;
xms = XmStringCreateLocalized(label);
XtSetArg(args[n], XmNlabelString, xms); n++;
widget = XmCreatePushButton(parent, name, args, n);
XmStringFree(xms);
XtAddCallback(widget, XmNactivateCallback,
(XtCallbackProc) callback_func,
(XtPointer) client_data);
XtManageChild(widget);
return (widget);
}
void excerror(Exc_data * ed, int excerrno, char * funcname, char * func)
{
switch (excerrno)
{
case EXCERRMALLOC:
fprintf(stderr, "dtudcexch:memory allocation error\n");
freeExcdata(ed);
exit (-1);
case EXCERRNOUDC:
fprintf(stderr, "dtudcexch:UDC is not defined in current locale\n");
freeExcdata(ed);
exit (-1);
}
}
void dialogokCB(Widget widget, int * ans, XtPointer call_data)
{
/* ok button pushed */
*ans = 1;
}
void dialogcancelCB(Widget widget, int * ans, XtPointer call_data)
{
/* cancel button pushed */
*ans = 2;
}
void AskUser(Widget parent, Exc_data * ed, char *msg, int *r, char * type)
/* If ok button pushed, *r = 1. */
/* If cancel button pushed(if exists), *r = 2. */
{
XmString message;
Widget dialog;
int ans = 0;
Cardinal n;
Arg args[20];
n = 0;
message = XmStringCreateLocalized(msg);
XtSetArg(args[n], XmNmessageString, message); n++;
XtSetArg(args[n], XmNtitle, maintitle); n++;
XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
if (strcmp(type, "warning") == 0) {
dialog = XmCreateWarningDialog(parent, type, args, n);
} else if (strcmp(type, "error") == 0) {
dialog = XmCreateErrorDialog(parent, type, args, n);
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
} else if (strcmp(type, "information") == 0) {
dialog = XmCreateInformationDialog(parent, type, args, n);
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
} else if (strcmp(type, "question") == 0) {
dialog = XmCreateQuestionDialog(parent, type, args, n);
} else {
fprintf(stderr, "error in AskUser\n");
}
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
XmStringFree(message);
XtAddCallback(dialog, XmNokCallback, (XtCallbackProc) dialogokCB,
(XtPointer) &ans);
XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc) dialogcancelCB,
(XtPointer) &ans);
XtManageChild(dialog);
while (ans == 0) {
XtAppProcessEvent(ed->app, XtIMAll);
XSync(XtDisplay(dialog), 0);
}
*r = ans;
XSync(XtDisplay(dialog), 0);
XmUpdateDisplay(dialog);
}
int beki(int n, int num)
{
int a,i;
a = 1;
for (i=0; i<num; i++)
a = a * n;
return a;
}
int c2h(char * num)
{
int i,n;
char *c;
if ((strlen(num)==6)&&(strncmp(num,"0x",2)==0))
{
c = num;
c=c+2;
n=0;
for (i=3;i>=0;i--)
{
if (('0'<= *c)&&(*c <= '9'))
n = n + ((*c - '0')*beki(16,i));
else if (('a' <= *c)&&(*c <= 'f'))
n = n + ((*c - 'a'+10)*beki(16,i));
else
Ecs("error in c2h.here");
c++;
}
} else
Ecs("error in c2h");
return n;
}
char * renge2num(char * renge)
{
char * num;
num = (char *) calloc(7, sizeof(char));
strncpy(num,renge,6);
return num;
}
void Ecs(char * string)
{
fprintf(stderr,"%s\n",string);
}
void Ecd(int data)
{
fprintf(stderr,"%d\n",data);
}
void freecsrec(UDCcsREC *rec)
{
if (rec->charset != NULL)
free(rec->charset);
if (rec->udcrenge != NULL)
free(rec->udcrenge);
}
void freecslist(int n, UDCcsREC *rec)
{
int i;
UDCcsREC *recp;
recp = rec;
for (i = 0; i < n; i++)
{
if (recp != NULL)
{
freecsrec(recp);
recp++;
} else {
break;
}
}
}
void freeExcdata(Exc_data *ed)
{
if (ed == NULL)
return;
/* Don't free ed->toplevel */
if (ed->locale != NULL)
free(ed->locale);
if (ed->cslist != NULL)
free(ed->cslist);
if (ed->xlfdname != NULL)
free(ed->xlfdname);
if (ed->style != NULL)
free(ed->style);
if (ed->size != NULL)
free(ed->size);
/* Don't free ed->fontfile */
if (ed->bdffile != NULL)
XtFree(ed->bdffile);
if (ed->udcrenge != NULL)
free(ed->udcrenge);
if (ed->gpf_code_list != NULL)
free(ed->gpf_code_list);
if (ed->bdf_code_list != NULL)
free(ed->bdf_code_list);
if (ed->comment_list != NULL)
free(ed->comment_list);
free(ed);
}
void Ecss(char * s1, char * s2)
{
fprintf(stderr,"%s is %s\n", s1, s2);
}
void Ecsd(char * s1, int i)
{
fprintf(stderr,"%s = %d\n", s1, i);
}
void checkdata(Exc_data *ed)
{
if (ed == NULL)
return;
/* Don't free ed->toplevel */
if (ed->locale != NULL)
Ecss("ed->locale", ed->locale);
Ecsd("ed->csnum", ed->csnum);
if (ed->xlfdname != NULL)
Ecss("ed->xlfdname",ed->xlfdname);
if (ed->fontfile != NULL)
Ecss("ed->fontfile",ed->fontfile);
if (ed->bdffile != NULL)
Ecss("ed->bdffile",ed->bdffile);
if (ed->udcrenge != NULL)
Ecss("ed->udcrenge",ed->udcrenge);
Ecsd("ed->code_num", ed->code_num);
}
void excterminate(Exc_data * ed)
{
freeExcdata(ed);
exit(0);
}
void excexit(Exc_data * ed)
{
excterminate(ed);
}
void freeld(ListData *ld)
{
int i;
char **cp;
if (ld != NULL) {
if (ld->allcode != NULL)
free(ld->allcode);
if (ld->existcode != NULL)
free(ld->existcode);
if (ld->existcode_c != NULL) {
cp = ld->existcode_c;
for (i = 0; i < ld->existcode_num; i++) {
if (*cp != NULL)
free(*cp);
cp++;
}
free(ld->existcode_c);
}
free(ld);
}
}
int bigger(int num1, int num2)
{
if (num1 >= num2)
return (num1);
else
return (num2);
}
int smaller(int num1, int num2)
{
if (num1 < num2)
return (num1);
else
return (num2);
}

View file

@ -0,0 +1,137 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: excutil.h /main/6 1996/12/23 08:48:26 barstow $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdio.h>
#include <stdlib.h>
#include <Xm/Xm.h>
#include <Xm/MessageB.h>
#include <Xm/PushB.h>
#define EXPORT 1
#define IMPORT 2
#define EXCERRMALLOC 101
#define EXCERRNOUDC 102
void Ecs();
void Ecd();
/*void getpcffn();*/
void getbdffn();
void selcharcd();
void getcharcd();
void createbdf();
int bigger();
int smaller();
int c2h();
char *renge2num();
void freeExcdata();
void checkdata();
void excexit();
void excterminate();
void freeld();
void getexistcode();
void AskUser();
void excerror();
Widget excCreatePushButton();
typedef struct {
char * charset;
char * udcrenge;
} UDCcsREC;
typedef struct {
int function;
XtAppContext app;
Widget toplevel;
char *locale;
int csnum;
UDCcsREC *cslist;
char *xlfdname;
char *style;
char *size;
char *fontfile;
char *bdffile;
char bdfmode[2];
char *udcrenge;
int code_num;
int *gpf_code_list;
int *bdf_code_list;
int comment_num;
char **comment_list;
} Exc_data;
typedef struct {
Widget list;
int allcode_num;
int *allcode;
int existcode_num;
int *existcode;
char **existcode_c;
Exc_data *ed;
} ListData;
#ifndef NO_MESSAGE_CATALOG
# ifdef __ultrix
# define _CLIENT_CAT_NAME "dtudcexch.cat"
# else /* __ultrix */
# define _CLIENT_CAT_NAME "dtudcexch"
# endif /* __ultrix */
# ifdef _NO_PROTO
extern char *_DtGetMessage();
# else /* _NO_PROTO */
extern char *_DtGetMessage(
char *filename,
int set,
int n,
char *s );
# endif /* _NO_PROTO */
#define GETMESSAGE(set, number, string) GetMessage(set, number, string)
static char *
GetMessage(set, number, string)
int set, number;
char *string;
{
char *tmp;
static char * point[100];
static int first = True;
if (first) {
memset(point, 0, sizeof(char *) * 100);
first = False;
}
if (point[number])
return(point[number]);
tmp = _DtGetMessage(_CLIENT_CAT_NAME, set, number, string);
point[number] = (char *) malloc(strlen(tmp) + 1);
strcpy(point[number], tmp);
return (point[number]);
}
#else /* NO_MESSAGE_CATALOG */
# define GETMESSAGE(set, number, string)\
string
#endif /* NO_MESSAGE_CATALOG */

View file

@ -0,0 +1,366 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: exportbdf.c /main/4 1996/04/10 13:49:20 ageorge $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*
* Authors: Seiya Miyazaki FUJITSU LIMITED
* Hiroyuki Chiba FUJITSU LIMITED
*/
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <stdlib.h>
#ifndef SVR4
#if !defined( SYSV )
#include <sys/resource.h>
#endif
#include <sys/wait.h>
#else
#include <wait.h>
#endif
#include <memory.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include "bdfgpf.h"
static int writeBdfHeader();
static int readBdfToMemory();
static void sigint_out();
static char buf[BUFSIZE];
static struct ptobhead w_bdf ;
static void
sigint_out()
{
fclose(w_bdf.output) ;
fclose(w_bdf.input) ; /* stream */
exit( 0 );
}
int
expCheckCode( code, code_num, code_list )
unsigned int code ;
int code_num ;
int *code_list ;
{
int i ;
if( code < MIN_CODE || code > MAX_CODE ) return -1 ;
for( i=0; i<code_num; i++ ){
if( code == code_list[i] ) return 0 ;
}
return -1 ;
}
int
ExpGpftoBDF( gpf_name, bdf_name, code_num, code_list, comment_num, comment_list, make_all )
char *gpf_name ; /* pointer to GPF file name area */
char *bdf_name ; /* pointer to BDF file name area */
int code_num ; /* number of GPF code */
int *code_list ; /* pointer to GPF code lists */
int comment_num ; /* number comments */
char **comment_list ;/* pointer to the list of comments */
int make_all ; /* convert whole GPF fomat file to BDF */
{
struct stat statbuf ;
struct btophead r_gpf ;
int rtn, i, num_chars ;
/*
* parameter check
*/
if( gpf_name == NULL || bdf_name == NULL ){
fprintf(stderr, "GPF or BDF file name is not specified.\n" ) ;
return -1 ;
}
/*
* initiation
*/
memset( &w_bdf, 0, sizeof(struct ptobhead) ) ;
memset( &r_gpf, 0, sizeof(struct btophead) ) ;
if ( stat( SNFTOBDF, &statbuf ) ) {
if (!( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ))) {
fprintf( stderr, "There is not %s command.\n", SNFTOBDF_CMD ) ;
return -1 ;
}
}else{
oakgtobdf = SNFTOBDF;
}
/*
* export glyphs in BDF format
*/
w_bdf.snf_file = gpf_name ;
if( (w_bdf.output = fopen( bdf_name, "w" )) == NULL ){
fprintf(stderr, "\"%s\" cannot open.\n", bdf_name ) ;
return -1 ;
}
signal( SIGHUP , (void(*)())sigint_out );
signal( SIGINT , (void(*)())sigint_out );
signal( SIGQUIT, (void(*)())sigint_out );
signal( SIGTERM, (void(*)())sigint_out );
if( (rtn = writeBdfHeader(&w_bdf, comment_num, comment_list)) ){
fprintf(stderr, "\"%s\" cannot write header.\n", bdf_name ) ;
fclose(w_bdf.output) ;
fclose(w_bdf.input) ; /* stream */
return rtn ;
}
r_gpf.bdf_width = w_bdf.bdf_width ;
r_gpf.bdf_height = w_bdf.bdf_height ;
r_gpf.input = w_bdf.input ;
num_chars = ((make_all) ? w_bdf.num_chars : code_num) ;
if( (r_gpf.code = (int *)malloc( sizeof(int) * num_chars)) == NULL ) {
fclose(w_bdf.output) ;
fclose(w_bdf.input) ;
return(MALLOC_ERROR);
}
if( (r_gpf.ptn = (char **)calloc( num_chars, sizeof(char *) )) == NULL ) {
fclose(w_bdf.output) ;
fclose(w_bdf.input) ;
return(MALLOC_ERROR);
}
if( (rtn = readBdfToMemory(&r_gpf, buf, code_num, code_list, make_all)) ){
fprintf(stderr, "\"%s\" cannot read glyph.\n", bdf_name ) ;
fclose(w_bdf.output) ;
fclose(w_bdf.input) ;
return rtn ;
}
fclose(w_bdf.input) ;
wait(0) ;
w_bdf.zoomf = 0 ;
w_bdf.num_chars = r_gpf.num_chars ;
w_bdf.code = r_gpf.code ;
w_bdf.ptn = r_gpf.ptn ;
if( (rtn = WritePtnToBdf( &w_bdf, buf )) ){
fprintf(stderr, "\"%s\" cannot write glyph.\n", bdf_name ) ;
fclose(w_bdf.output) ;
return rtn ;
}
fclose(w_bdf.output) ;
signal( SIGHUP , SIG_IGN );
signal( SIGINT , SIG_IGN );
signal( SIGQUIT, SIG_IGN );
signal( SIGTERM, SIG_IGN );
/*
* free memories
*/
free( r_gpf.code ) ;
for(i=0; i<r_gpf.num_chars; i++){
if(r_gpf.ptn[i]) free(r_gpf.ptn[i]) ;
}
free( r_gpf.ptn ) ;
return 0 ;
}
static int
writeBdfHeader(head, comment_num, comment_list)
struct ptobhead *head;
int comment_num ; /* number comments */
char **comment_list ;/* pointer to the list of comments */
{
FILE *fp;
int fd[2];
unsigned int getstat;
char buf[BUFSIZE], *p;
int cnt ;
int comflg ;
pid_t chld_pid = 0;
#if defined( SVR4 ) || defined( SYSV ) || defined(CSRG_BASED) || defined(__linux__)
int chld_stat ;
#else
union wait chld_stat ;
#endif
if (head->snf_file != NULL) {
if (pipe(fd) != 0) {
return PIPE_ERROR;
}
switch (chld_pid = fork()) {
case 0:
close(1);
if(dup(fd[1]) < 0) {
return(DUP_ERROR);
}
close(fd[0]);
close(fd[1]);
execl( oakgtobdf, oakgtobdf, head->snf_file, 0);
return EXEC_ERROR;
case -1:
return(FORK_ERROR);
default:
break;
}
close(fd[1]);
if((fp = (FILE *)fdopen(fd[0], "r")) == NULL) {
close( fd[0] );
kill( chld_pid, SIGKILL );
WaitID( chld_pid, chld_stat ) ;
return FDOPEN_ERROR;
}
} else {
return(BDF_OPEN_HEAD);
}
head->input = fp ;
getstat = 0;
comflg = 0 ;
while ( 1 ) {
if (fgets(buf, BUFSIZE, fp) == NULL) {
fclose( fp );
if (head->snf_file != NULL) {
close(fd[0]);
kill( chld_pid, SIGKILL );
WaitID( chld_pid, chld_stat ) ;
}
return(BDF_INVAL);
}
p = buf;
SCAN_TO_NONSP(p);
if (!strncmp(p, CHARS, CHARSsz)) {
if ((sscanf(p, "CHARS %d", &(head->num_chars))) != 1 ){
return(BDF_INVAL);
}
getstat |= 0x04;
break;
}
/*
* write user comments
*/
if ( !strncmp(p, "FONT", strlen("FONT"))
&& comment_list && !comflg
) {
int i ;
for( i=0; i<comment_num; i++ ){
char *ep ;
if( (ep = (char *)strchr( comment_list[i], '\n' )) != NULL )
*ep = '\0' ;
if( comment_list[i] == '\0' ) continue ;
fprintf(head->output, "COMMENT %s\n", comment_list[i]);
}
fprintf(head->output, "COMMENT\n");
comflg++ ;
}
fprintf(head->output, "%s", buf);
if (!strncmp(p, SIZE, SIZEsz)) {
if ((sscanf(p, "SIZE %f%d",
&(head->bdf_point), &(head->bdf_xdpi))) != 2) {
fclose(fp);
if (head->snf_file != NULL) {
close(fd[0]);
kill( chld_pid, SIGKILL );
WaitID( chld_pid, chld_stat ) ;
}
return(BDF_INVAL);
}
getstat |= 0x01;
continue;
}
if (!strncmp(p, FONTBOUNDINGBOX, FONTBOUNDINGBOXsz)) {
if (( cnt = sscanf( p, "FONTBOUNDINGBOX %d%d%d%d",
&(head->bdf_width), &(head->bdf_height),
&(head->bdf_x), &(head->bdf_y))) != 4
) {
fclose(fp);
if (head->snf_file != NULL) {
close(fd[0]);
kill( chld_pid, SIGKILL );
WaitID( chld_pid, chld_stat ) ;
}
return BDF_INVAL;
}
getstat |= 0x02;
continue;
}
get_charset_registry(head, p) ;
}
if (getstat != 0x07) {
return BDF_INVAL;
}
return 0;
}
static int
readBdfToMemory(head, buf, code_num, code_list, make_all)
struct btophead *head;
char *buf;
int code_num ; /* number of GPF code */
int *code_list ; /* pointer to GPF code lists */
int make_all ; /* convert whole GPF fomat file to BDF */
{
int code, mwidth, num_char, bsize, rtn;
char *ptn;
num_char = 0;
mwidth = (head->bdf_width + 7) / 8;
bsize = mwidth * head->bdf_height;
while(1) {
if ((rtn = GetBdfCode(head, buf, &code)) < 0) {
return(rtn); /* contain BDF_INVAL */
} else if (rtn == FILE_END) {
head->num_chars = num_char;
break;
}
if ( !make_all ) {
if ( expCheckCode(code, code_num, code_list) ) {
continue;
}
}
head->code[num_char] = code;
if ( ( ptn = head->ptn[num_char++] = (char *)malloc( bsize ) ) == NULL ) {
return(MALLOC_ERROR);
}
if ((rtn = GetBdfPtn(head, buf, ptn, mwidth, bsize)) != 0) {
return(rtn);
}
}
return(0);
}

View file

@ -0,0 +1,180 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: getbdffn.c /main/5 1996/10/14 14:44:32 barstow $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "excutil.h"
#include <Xm/FileSB.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
/*
* There is no public header file for this function (only an
* internal header XmStringI.h).
*/
extern XtPointer _XmStringUngenerate (XmString string,
XmStringTag tag,
XmTextType tag_type,
XmTextType output_type);
void filesbokCB();
void filesbcancelCB();
extern char *maintitle;
void getbdffn(Exc_data * ed)
{
Widget filesb;
Arg args[20];
Cardinal n;
char *selectlabel;
XmString xms;
selectlabel = GETMESSAGE(2, 2, "BDF file selection");
n = 0;
XtSetArg(args[n], XmNtitle, maintitle); n++;
xms = XmStringCreateLocalized(selectlabel);
XtSetArg(args[n], XmNselectionLabelString, xms); n++;
filesb = XmCreateFileSelectionDialog(ed->toplevel, "filesb", args, n);
XtAddCallback(filesb, XmNokCallback,
(XtCallbackProc) filesbokCB,
(XtPointer) ed);
XtAddCallback(filesb, XmNcancelCallback,
(XtCallbackProc) filesbcancelCB,
(XtPointer) ed);
XtUnmanageChild(XmFileSelectionBoxGetChild(filesb, XmDIALOG_HELP_BUTTON));
XtManageChild(filesb);
}
int fopencheck(char *file, char *dir, char *mode)
/*
* when mode = "r", if fopen can open the file with read only mode, return 0
* when mode = "w", if fopen can open the file with write mode, return 0
* but if the file exists, return 1
* otherwise return -1
*/
{
struct stat buf;
if (strcmp(mode, "r") == 0) {
if (stat(file, &buf) == 0)
if ((buf.st_mode & S_IFMT) == S_IFREG)
return 0; /* readable regular file */
} else if (strcmp(mode, "w") == 0) {
if (stat(file, &buf) == 0) {
if (((buf.st_mode & S_IFMT) == S_IFREG) &&
(access(file, W_OK) == 0))
return 1; /* writable existing file */
} else {
if (stat(dir, &buf) == 0) {
if (((buf.st_mode & S_IFMT) == S_IFDIR) &&
(access(dir, W_OK) == 0)) {
return 0; /* writable new file */
}
}
}
} else
fprintf(stderr, "Unanticipatable error occurred in fopencheck.\n");
return -1;
}
void filesbcancelCB(Widget widget, Exc_data * ed, XtPointer call_data)
{
excexit(ed);
}
void freeStrings(char * dir, char * file)
{
if (dir != NULL)
XtFree(dir);
if (file != NULL)
XtFree(file);
}
void filesbokCB(Widget widget, Exc_data * ed, XtPointer call_data)
{
XmFileSelectionBoxCallbackStruct *ptr;
char *file = NULL, *dir = NULL, *tmpfile;
int r, ans = 0;
char *msg1;
char *msg2;
msg1 = GETMESSAGE(2, 4, "The selected file exists. Overwrite?");
msg2 = GETMESSAGE(2, 6, "Failed to open the selected file.");
ptr = (XmFileSelectionBoxCallbackStruct *) call_data;
file = (char *) _XmStringUngenerate((XmString) ptr->value, NULL,
XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
if (!file) {
return;
}
dir = (char *) _XmStringUngenerate((XmString) ptr->dir, NULL,
XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
if (!dir) {
return;
} else {
if (*file != '/') {
if ((tmpfile = XtMalloc(strlen(dir) + 1 + strlen(file) + 1))
== NULL) {
excerror(ed, EXCERRMALLOC, "filesbokCB", "exit");
}
sprintf(tmpfile, "%s/%s", dir, file);
XtFree(file);
file = tmpfile;
}
}
r = fopencheck(file, dir, ed->bdfmode);
if (r == 0) {/* no problem */
/*fprintf(stderr, "%s will be opened\n", file);*/
} else if (r == 1) { /* file exist at export function */
AskUser(widget, ed, msg1, &ans, "warning");
if (ans != 1) { /* overwrite cancel */
freeStrings(dir, file);
return;
}
} else { /* file will not be opened */
AskUser(widget, ed, msg2, &ans, "error");
freeStrings(dir, file);
return;
}
ed->bdffile = (char *) malloc(strlen(file) + 1);
strcpy(ed->bdffile, file);
freeStrings(dir, file);
XtUnmanageChild(widget);
if (ed->function == EXPORT)
{
createbdf(ed);
} else if (ed->function == IMPORT)
{
PopupSelectXLFD(ed->toplevel);
}
}

View file

@ -0,0 +1,707 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: importbdf.c /main/5 1996/06/27 10:40:33 ageorge $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*
* Authors: Seiya Miyazaki FUJITSU LIMITED
* Hiroyuki Chiba FUJITSU LIMITED
*
*/
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifndef SVR4
#if !defined( SYSV )
#include <sys/resource.h>
#endif
#include <sys/wait.h>
#else
#include <wait.h>
#endif
#include <unistd.h>
#include <X11/Xmd.h>
#include <X11/Xproto.h>
#include "bdfgpf.h"
#include "FaLib.h"
#include <errno.h>
#define UNLINK_TMPFILE( file ){ \
if ( unlink( file ) != 0 ) { \
exit(-1) ; \
} \
}
static impFileConvInit();
static impGetGpfInf();
static impReadBdfHeaderAndPut();
static impMergePtn();
static impModifyPtn();
static impInsertPtn();
static impWriteSnf();
static int impWritePtnToBdf();
static int impPutDefaultChars();
static int impReadBdfToMemory();
extern int expCheckCode();
static struct ptobhead WriteGpf;
static char *targ_file = NULL; /* UDC_file_name */
static void
sigint_out()
{
if (WriteGpf.out_file) {
UNLINK_TMPFILE( WriteGpf.out_file );
}
exit( 0 );
}
int
ImpBDFCodeList( bdf_name, code_num, code_list )
char *bdf_name ;
int *code_num ;
int **code_list ;
{
int *glyph_list ;
FILE *bdfp ;
char *p ;
char buf[2048] ;
int cnt ;
/* open BDF file */
if( (bdfp = fopen( bdf_name, "r" )) == NULL ){
return(-1);
}
/* get number of characters in BDF file */
while ( 1 ) {
if( fgets( buf, BUFSIZE, bdfp ) == NULL) {
return (BDF_INVAL);
}
p = buf;
SCAN_TO_NONSP( p )
if ( !strncmp( p, CHARS, (unsigned int)strlen( CHARS ) ) ) {
if ( ( sscanf( p, "CHARS %d", code_num ) ) != 1 ) {
return BDF_INVAL;
}
break ;
}
}
/* alloc memory for codes */
if( (glyph_list = (int *)calloc( *code_num, (unsigned int)sizeof(int) )) == NULL ){
return(-1);
}
/* get codes of BDF file */
cnt = 0 ;
while( cnt < *code_num ) {
if (fgets(buf, BUFSIZE, bdfp ) == NULL) {
return (BDF_INVAL);
}
p = buf;
SCAN_TO_NONSP( p )
if (!strncmp(p, ENDFONT, (unsigned int)ENDFONTsz)) {
break;
}else if (!strncmp(p, ENCODING, (unsigned int)ENCODINGsz)) {
if ((sscanf(p, "ENCODING %d", &glyph_list[cnt] )) != 1) {
return(BDF_INVAL);
}
cnt ++ ;
}
}
if( cnt != *code_num ){
return(-1) ;
}
/* close BDF file */
if( fclose( bdfp ) ){
return(-1);
}
*code_list = glyph_list ;
return(0) ;
}
int
ImpBDFCodeListFree( code_list )
int **code_list ;
{
free( *code_list ) ;
return(0) ;
}
int
ImpBDFCheck( bdf_name, gpf_name )
char *bdf_name ; /* BDF file name */
char *gpf_name ; /* GPF file name */
{
/* parameter check */
if( bdf_name == NULL || gpf_name == NULL ){
return(-1) ;
}
return(0) ;
}
int
ImpBDFtoGpf( bdf_name, gpf_name, bdf_codenum, bdf_codelist)
char *bdf_name ;
char *gpf_name ;
int bdf_codenum ;
int *bdf_codelist ;
{
int rtn ;
int exit_stat;
struct btophead ReadGpf;
struct btophead ReadUdc;
struct stat statbuf;
char buf[BUFSIZE];
int chk_fd;
ReadGpf.in_file = ReadUdc.in_file = WriteGpf.out_file = NULL;
if (!( bdftopcf = get_cmd_path( getenv( "PATH" ), BDFTOPCF_CMD ))) {
bdftopcf = BDFTOPCF;
}
if (!( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ))) {
oakgtobdf = SNFTOBDF;
}
if (!( bdftosnf = get_cmd_path( getenv( "PATH" ), BDFTOSNF_CMD ))) {
bdftosnf = BDFTOSNF;
}
/*
* set input/output file name
*/
ReadUdc.in_file = bdf_name ;
ReadUdc.code_category = ALL_CODE ;
ReadUdc.start_code = MIN_CODE ;
ReadUdc.end_code = MAX_CODE ;
ReadGpf.in_file = gpf_name ;
ReadGpf.code_category = ALL_CODE ;
ReadGpf.start_code = MIN_CODE ;
ReadGpf.end_code = MAX_CODE ;
/*
* get real file name of GPF file
*/
if ((targ_file = GetRealFileName( ReadGpf.in_file )) == NULL){
return(-1);
}
/*
* WriteGpf.snf_file = ReadGpf.in_file
*/
WriteGpf.snf_file = targ_file;
signal( SIGHUP , (void(*)())sigint_out );
signal( SIGINT , (void(*)())sigint_out );
signal( SIGQUIT, (void(*)())sigint_out );
signal( SIGTERM, (void(*)())sigint_out );
/*
* impFileConvInit()
*
* SNFTOBDF, BDFTOSNF
*
* (ReadGpf.in_file) --> SNFTOBDF ==H
* H
* oakaddp <-- (ReadUdc.in_file)
* H
* (WriteGpf.out_file) <-- BDFTOSNF ==H
*
*/
/*
* make a temporary file by BDF format corresponded to target GPF file
*/
if ( rtn = impFileConvInit( &ReadUdc, &ReadGpf, &WriteGpf ) ) {
if ( WriteGpf.out_file ) {
UNLINK_TMPFILE( WriteGpf.out_file );
}
return(-1) ;
}
/*
* get informations from import file in BDF format
*/
if ( rtn = ReadBdfHeader( &ReadUdc, buf ) ) {
if ( WriteGpf.out_file ) {
UNLINK_TMPFILE( WriteGpf.out_file );
}
return(-1) ;
}
/*
* get informations from target file in BDF format
*/
if ( rtn = impGetGpfInf( &ReadGpf, &WriteGpf, buf, bdf_codenum ) ) {
if ( WriteGpf.out_file ) {
UNLINK_TMPFILE( WriteGpf.out_file );
}
return(-1) ;
}
/* wait for dtgpftobdf */
fclose( ReadGpf.input );
wait( 0 );
/*
* merge the UDC glyphs into GPF file (in BDF format)
*/
if ( ( rtn = impMergePtn( &ReadUdc, &ReadGpf, buf,
bdf_codenum, bdf_codelist ) ) ) {
if ( WriteGpf.out_file ) {
UNLINK_TMPFILE( WriteGpf.out_file );
}
return(-1) ;
}
/*
* write the UDC data into GPF output file (in BDF format)
*/
if ( ( rtn = impWriteSnf( &ReadGpf, &WriteGpf ) ) ) {
if ( WriteGpf.out_file ) {
UNLINK_TMPFILE( WriteGpf.out_file );
}
return(-1) ;
}
/*
* convert temporary file into GPF format
*/
fclose( ReadUdc.input );
fclose( WriteGpf.output );
wait( &exit_stat );
#if !defined( SVR4 ) && !defined( SYSV )
if ( !WIFEXITED(exit_stat) ) {
#else
if ( ! ( WIFEXITED(exit_stat) && !WEXITSTATUS(exit_stat) ) ) {
#endif
UNLINK_TMPFILE( WriteGpf.out_file );
return(-1) ;
}
signal( SIGHUP , SIG_IGN );
signal( SIGINT , SIG_IGN );
signal( SIGQUIT, SIG_IGN );
signal( SIGTERM, SIG_IGN );
sleep( 1 );
if ( ( stat( WriteGpf.out_file, &statbuf ) ) || ( statbuf.st_size == 0 )
) {
UNLINK_TMPFILE( WriteGpf.out_file );
return(-1) ;
}
if ( stat( WriteGpf.snf_file, &statbuf ) ) {
UNLINK_TMPFILE( WriteGpf.out_file );
return( -1 );
}
/*
* convert the temporary file to target file
*/
return( Make_NewFefFile( WriteGpf.snf_file, WriteGpf.out_file,
FONT_FILE_PARM, (uid_t)statbuf.st_uid, (gid_t)statbuf.st_gid, "ImpBDFtoGpf()" ));
}
/*
* sub functions
*/
static
impFileConvInit(r_udc, r_gpf, w_gpf )
struct btophead *r_udc;
struct btophead *r_gpf;
struct ptobhead *w_gpf;
{
int fd[2], snf_fd, permission;
char buf[BUFSIZE];
int pfd[2], ofd;
FontInfoRec *finf;
char *optlist[5] = {0,0,0,0,0};
char *ep ;
int i ;
struct stat statbuf ;
if ( ( r_udc->input = fopen(r_udc->in_file, "r")) == NULL ) {
return GPF_OPEN_IN;
}
/*
* case of SNF file
*/
if ( ChkPcfFontFile( w_gpf->snf_file ) ) {
/* snf */
if ( ( snf_fd = open( w_gpf->snf_file, O_RDONLY ) ) >= 0 ) {
COMM_SNF_FILEVERSION( snf_fd, finf, buf, permission ) ;
if( permission < 0 ) {
return BDF_INVAL;
}
} else {
return BDF_OPEN_IN;
}
}
if (pipe(fd) != 0) {
return PIPE_ERROR;
}
switch ( fork() ) {
case 0:
close( fd[0] );
close( 1 );
if ( dup( fd[1] ) < 0 ) {
return DUP_ERROR;
}
close( fd[1] );
/* gpf -> bdf */
execl( oakgtobdf, oakgtobdf, r_gpf->in_file, 0 );
return EXEC_ERROR;
case -1:
return FORK_ERROR;
default:
break;
}
close( fd[1] );
if ( ( r_gpf->input = (FILE *)fdopen( fd[0], "r" ) ) == NULL ) {
return FDOPEN_ERROR;
}
if ( !( w_gpf->out_file = GetTmpPath( targ_file ) ) ) {
return MKTMP_ERROR;
}
if ( pipe( pfd ) != 0 ) {
return PIPE_ERROR;
}
switch ( fork() ) {
case 0:
if ( ( ofd = open( w_gpf->out_file, O_WRONLY | O_CREAT, 0664 ) ) < 0 ) {
return BDF_OPEN_OUT;
}
close( 0 );
if ( dup(pfd[0]) < 0 ) {
return DUP_ERROR;
}
close( pfd[0] );
close( pfd[1] );
close( 1 );
if( dup( ofd ) < 0 ) {
return DUP_ERROR;
}
close( ofd );
/*
* case of PCF file format
*/
if ( ChkPcfFontFile( w_gpf->snf_file ) == 0 ) {
execl( bdftopcf, bdftopcf, 0 );
return EXEC_ERROR;
}
/*
* case of SNF file format
*/
COMM_SNF_EXECLBDFTOSNF( permission, buf, w_gpf->snf_file ) ;
return EXEC_ERROR;
case -1:
return FORK_ERROR;
default:
break;
}
close( pfd[0] );
if ( ( w_gpf->output = (FILE *)fdopen( pfd[1], "w" ) ) == NULL ) {
return FDOPEN_ERROR;
}
return 0;
}
static
impGetGpfInf( r_gpf, w_gpf, buf, bdf_codenum )
struct btophead *r_gpf;
struct ptobhead *w_gpf;
char *buf;
int bdf_codenum ;
{
int nchar, rtn;
if ( ( rtn = impReadBdfHeaderAndPut( r_gpf, w_gpf, buf ) ) ) {
return rtn;
}
nchar = r_gpf->num_chars + bdf_codenum ;
if ( ( r_gpf->code = (int *)malloc( sizeof(int) * nchar ) ) == NULL ) {
return MALLOC_ERROR;
}
if ( ( r_gpf->ptn = (char **)malloc( sizeof(char *) * nchar ) ) == NULL ) {
return MALLOC_ERROR;
}
return ReadBdfToMemory( r_gpf, buf ) ;
}
static
impReadBdfHeaderAndPut(r_gpf, w_gpf, buf)
struct btophead *r_gpf;
struct ptobhead *w_gpf;
char *buf;
{
char *p;
unsigned int getstat = 0;
while ( 1 ) {
if ( fgets( buf, BUFSIZE, r_gpf->input ) == NULL ) {
return BDF_INVAL;
}
p = buf;
SCAN_TO_NONSP( p )
if ( !strncmp( p, SIZE, (unsigned int)strlen( SIZE ) ) ) {
if ( ( sscanf( p, "SIZE %f%d",
&(r_gpf->bdf_point), &(r_gpf->bdf_xdpi))) != 2 ) {
return BDF_INVAL;
}
fprintf( w_gpf->output, "%s", buf );
getstat |= 0x01;
} else if ( !strncmp( p, FONTBOUNDINGBOX, (unsigned int)strlen( FONTBOUNDINGBOX ) ) ) {
if ( ( sscanf( p, "FONTBOUNDINGBOX %d %d %d %d",
&(r_gpf->bdf_width), &(r_gpf->bdf_height),
&(r_gpf->bdf_x), &(r_gpf->bdf_y) ) ) != 4 ) {
return BDF_INVAL;
}
fprintf( w_gpf->output, "%s", buf );
getstat |= 0x02;
} else if ( !strncmp( p, CHARS, (unsigned int)strlen( CHARS ) ) ) {
if ( ( sscanf( p, "CHARS %d", &( r_gpf->num_chars ) ) ) != 1 ) {
return BDF_INVAL;
}
getstat |= 0x04;
break;
} else {
fprintf( w_gpf->output, "%s", buf );
}
}
if ( getstat != 0x07 ) {
return BDF_INVAL;
}
return 0;
}
static
impMergePtn(r_udc, r_gpf, buf, bdf_codenum, bdf_codelist )
struct btophead *r_udc;
struct btophead *r_gpf;
char *buf;
int bdf_codenum ;
int *bdf_codelist ;
{
int code, rtn, msize, i, j;
char *ptn;
if ( ( r_udc->bdf_width != r_gpf->bdf_width )
|| ( r_udc->bdf_height != r_gpf->bdf_height )
) {
r_udc->zoomf = 1;
msize = ( r_udc->bdf_width + 7 ) / 8 * r_udc->bdf_height;
if ( ( ptn = (char *)malloc( msize ) ) == NULL ) {
return MALLOC_ERROR;
}
r_udc->ptn = &ptn;
} else {
r_udc->zoomf = 0;
}
for ( i = 0; i < r_udc->num_chars; i++ ) {
if ( ( rtn = GetBdfCode( r_udc, buf, &code ) ) < 0 ) {
return rtn;
} else if ( rtn == FILE_END ) {
break;
}
if( expCheckCode( code, bdf_codenum, bdf_codelist ) ) {
continue ;
}
for ( j = 0; j < r_gpf->num_chars; j++ ) {
if ( r_gpf->code[j] == code ) {
if ( ( rtn = impModifyPtn( r_udc, r_gpf, buf, j ) ) ) {
return rtn;
}
break;
} else if ( r_gpf->code[j] > code ) {
if ( ( rtn = impInsertPtn( r_udc, r_gpf, buf, code, j ) ) ) {
return rtn;
}
break;
}
}
if ( j == r_gpf->num_chars ) {
if ( ( rtn = impInsertPtn( r_udc, r_gpf, buf, code, j ) ) ) {
return rtn;
}
}
}
return 0;
}
static
impModifyPtn( r_udc, r_gpf, buf, ix )
struct btophead *r_udc;
struct btophead *r_gpf;
char *buf;
int ix;
{
int mwidth, msize, rtn;
mwidth = ( r_udc->bdf_width + 7 ) / 8;
msize = mwidth * r_udc->bdf_height;
if ( r_udc->zoomf ) {
if ( ( rtn = GetBdfPtn( r_udc, buf, r_udc->ptn[0], mwidth, msize ) ) ) {
return rtn;
}
if ( ( rtn = PtnZoom( r_gpf->ptn[ix], r_udc->ptn[0],
r_udc->bdf_width, r_udc->bdf_height,
r_gpf->bdf_width, r_gpf->bdf_height ) ) ) {
return rtn;
}
} else {
if ( ( rtn = GetBdfPtn( r_udc, buf, r_gpf->ptn[ix], mwidth, msize ) ) ) {
return rtn;
}
}
return 0;
}
static
impInsertPtn( r_udc, r_gpf, buf, code, ix )
struct btophead *r_udc;
struct btophead *r_gpf;
char *buf;
int code;
int ix;
{
int mwidth, msize, rtn, i;
for ( i = r_gpf->num_chars; i > ix; i-- ) {
r_gpf->code[i] = r_gpf->code[i-1];
r_gpf->ptn[i] = r_gpf->ptn[i-1];
}
r_gpf->code[ix] = code;
r_gpf->num_chars++;
mwidth = (r_gpf->bdf_width + 7) / 8;
msize = mwidth * r_gpf->bdf_height;
if ( ( r_gpf->ptn[ix] = (char *)malloc( msize ) ) == NULL ) {
return MALLOC_ERROR;
}
if ( r_udc->zoomf ) {
mwidth = (r_udc->bdf_width + 7) / 8;
msize = mwidth * r_udc->bdf_height;
if ( ( rtn = GetBdfPtn( r_udc, buf, r_udc->ptn[0], mwidth, msize ) ) ) {
return rtn;
}
if ( ( rtn = PtnZoom( r_gpf->ptn[ix], r_udc->ptn[0],
r_udc->bdf_width, r_udc->bdf_height,
r_gpf->bdf_width, r_gpf->bdf_height ) ) ) {
return rtn;
}
} else {
if ( ( rtn = GetBdfPtn( r_udc, buf, r_gpf->ptn[ix], mwidth, msize ) ) ) {
return rtn;
}
}
return(0);
}
static
impWriteSnf( r_gpf, w_gpf )
struct btophead *r_gpf;
struct ptobhead *w_gpf;
{
w_gpf->zoomf = 0;
w_gpf->num_chars = r_gpf->num_chars;
w_gpf->code = r_gpf->code;
w_gpf->ptn = r_gpf->ptn;
w_gpf->bdf_width = r_gpf->bdf_width;
w_gpf->bdf_height = r_gpf->bdf_height;
w_gpf->bdf_x = r_gpf->bdf_x;
w_gpf->bdf_y = r_gpf->bdf_y;
w_gpf->bdf_point = r_gpf->bdf_point;
w_gpf->bdf_xdpi = r_gpf->bdf_xdpi;
return WritePtnToBdf( w_gpf );
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,236 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: udcexc.c /main/4 1996/09/02 18:50:32 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "excutil.h"
#include "xoakufont.h"
#include "selectxlfd.h"
#include <locale.h>
#include <Xm/RowColumn.h>
#include <Xm/ToggleB.h>
#include <Xm/MessageB.h>
#include <Xm/MainW.h>
void callexpCB();
void callimpCB();
void exitCB();
void helpCB();
void udcexp();
void udcimp();
#define ERROR_1 errmsg_org[fal_utyerrno & 0xff]
/*#define ERROR_1 fal_errmsg_org[fal_utyerrno & 0xff]*/
/*#define ERROR_2 fal_errmsg_func[fal_utyerrno >>8]*/
Widget toplevel, mainw;
Exc_data *ed = NULL;
ListData *ld = NULL;
char *maintitle;
/*char *terminatemsg = "Do you want to terminate dtudcexch";*/
/*
* Error messages(by origin)
* fal_errmsg_org
*/
char *errmsg_org[0xff];
Rsrc resource ;
#define Rchar(name, class, member,def){ \
name, class, XtRString, sizeof(char *), \
XtOffsetOf(Rsrc, member), XtRString, (XtPointer)def }
Widget excCreateRadioButton(Widget parent, String name, String label,
XtCallbackProc callback_func,
XtPointer client_data)
{
Widget widget;
XmString xms;
widget = XtVaCreateManagedWidget(name,
xmToggleButtonWidgetClass, parent,
XmNindicatorType, XmONE_OF_MANY,
NULL);
XtAddCallback(widget, XmNvalueChangedCallback,
(XtCallbackProc) callback_func,
(XtPointer) client_data);
xms = XmStringCreateLocalized(label);
XtVaSetValues(widget,
XmNlabelString, xms,
NULL);
XmStringFree(xms);
return (widget);
}
int main(int argc, char * argv[])
{
XtAppContext app_context;
Widget row, expfunc, impfunc, exit/*, help*/;
Arg args[20];
Cardinal n;
static char *explabel;
static char *implabel;
static char *exitlabel;
/* static char helplabel[] = "Help";*/
/* char msg1[] = "Failed in the start of dtudcexch";*/
char err[128];
int ans;
int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
FalFontData key;
FalFontDataList *fontlist;
/* appinitialize */
XtSetLanguageProc(NULL,NULL,NULL);
_DtEnvControl(0);
n = 0;
toplevel = XtAppInitialize(&app_context, "UDCexchange",
(XrmOptionDescList) NULL,
0, (int *) &argc, argv, (String *) NULL,
args, n);
maintitle = GETMESSAGE(8, 2, "UDC data exchange utitlity");
errmsg_org[0] = GETMESSAGE(8, 4, "Fatal error occurred.");
errmsg_org[1] = GETMESSAGE(8, 6, "Cannot open the font file.");
errmsg_org[2] = GETMESSAGE(8, 8, "Cannot read the font file.");
errmsg_org[3] = GETMESSAGE(8, 10, "There is no more memory.");
errmsg_org[4] = GETMESSAGE(8, 12, "Fatal error occurred.");
errmsg_org[5] = GETMESSAGE(8, 14, "The specified font file does not exist.");
errmsg_org[6] = GETMESSAGE(8, 16, "This font is not a pcf or snf font.");
errmsg_org[7] = GETMESSAGE(8, 18, "Cannot open fonts.list file.");
errmsg_org[8] = GETMESSAGE(8, 20, "The format of fonts.list file is illegal.");
errmsg_org[9] = GETMESSAGE(8, 22, "The descriptions of the fonts.list file are incorrect.");
errmsg_org[10] = GETMESSAGE(8, 24, "The format of fonts.list file is illegal.");
errmsg_org[11] = GETMESSAGE(8, 26, "Cannot open fonts.dir file.");
errmsg_org[12] = GETMESSAGE(8, 28, "Cannot read fonts.dir file.");
errmsg_org[13] = GETMESSAGE(8, 30, "Cannot read font properties.");
errmsg_org[14] = GETMESSAGE(8, 32, "Cannot get FONT property.");
errmsg_org[15] = GETMESSAGE(8, 34, "Cannot get FAMILY_NAME property.");
errmsg_org[16] = GETMESSAGE(8, 36, "This font file is already opened by other application.");
errmsg_org[17] = GETMESSAGE(8, 38, "Cannot lock font file.");
errmsg_org[18] = GETMESSAGE(8, 40, "Cannot unlock font file.");
errmsg_org[19] = GETMESSAGE(8, 42, "Cannot get lock information from the font file.");
errmsg_org[20] = GETMESSAGE(8, 44, "Cannot find the specified font file.");
errmsg_org[21] = GETMESSAGE(8, 46, "Cannot read NLS database.");
errmsg_org[22] = GETMESSAGE(8, 48, "Cannot get charset names from NLS database.");
errmsg_org[23] = GETMESSAGE(8, 50, "Charset name not defined in NLS database.");
errmsg_org[24] = GETMESSAGE(8, 52, "The specified font has not been opened.");
errmsg_org[25] = GETMESSAGE(8, 54, "Fatal error occurred.");
resource.xlfd_label = GETMESSAGE(8, 56, "XLFD name :" ),
resource.copy_xlfd_label = GETMESSAGE(8, 58, "Original font (XLFD name) :");
resource.code_label = GETMESSAGE(8, 60, "UDC code area :");
resource.style_label = GETMESSAGE(8, 62, "Style :");
resource.size_label = GETMESSAGE(8, 64, "Size (letter size) :");
resource.exec_label = GETMESSAGE(8, 66, "Open");
resource.quit_label = GETMESSAGE(8, 68, "Cancel");
resource.ok_label = GETMESSAGE(8, 70, "OK");
resource.cancel_label = GETMESSAGE(8, 72, "cancel");
resource.copy_orgin = GETMESSAGE(8, 74, "Copy orgin code(hex) :");
resource.copy_target = GETMESSAGE(8, 76, "Copy target code(hex) :");
resource.copy_label = GETMESSAGE(8, 78, "Copy");
resource.overlay_label = GETMESSAGE(8, 80, "Overlay");
explabel = GETMESSAGE(8, 82, "export function");
implabel = GETMESSAGE(8, 84, "import function");
exitlabel = GETMESSAGE(8, 86, "Cancel");
/* initialize ed */
if ((ed = (Exc_data *) malloc(sizeof(Exc_data))) == NULL) {
excerror(ed, EXCERRMALLOC, "main", "exit");
}
memset(ed,0x00,sizeof(Exc_data));
ed->app = app_context;
ed->toplevel = toplevel;
if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
fprintf( stderr, "GetFontList Err\n" );
sprintf(err, "%s", ERROR_1);
AskUser(ed->toplevel, ed, err, &ans, "error");
/* AskUser(ed->toplevel, ed, msg1, &ans, "error");*/
excexit(ed);
}
FalFreeFontList(fontlist);
/* make main window */
n = 0;
XtSetArg( args[n], XmNautoUnmanage, False ) ; n++ ;
XtSetArg(args[n], XmNtitle, maintitle); n++;
mainw = XmCreateTemplateDialog(toplevel, "mainw", args, n);
row = XtVaCreateManagedWidget("row", xmRowColumnWidgetClass, mainw,
XmNradioBehavior, True,
XmNradioAlwaysOne, True,
NULL);
expfunc = excCreateRadioButton(row, "expfunc", explabel,
(XtCallbackProc) callexpCB, (XtPointer) ed);
impfunc = excCreateRadioButton(row, "impfunc", implabel,
(XtCallbackProc) callimpCB, (XtPointer) ed);
exit = excCreatePushButton(mainw, "exit", exitlabel,
(XtCallbackProc) exitCB, (XtPointer) ed);
/* help = excCreatePushButton(mainw, "help", helplabel,
(XtCallbackProc) helpCB, (XtPointer) ed);
*/
XtVaSetValues(mainw,
XmNmessageWindow, exit,
NULL);
XtManageChild(mainw);
/* XtRealizeWidget(toplevel);*/
XtAppMainLoop(app_context);
}
void callexpCB(Widget widget, Exc_data * ed, XtPointer call_data)
{
XtUnmanageChild(mainw);
udcexp(ed);
}
void callimpCB(Widget widget, Exc_data * ed, XtPointer call_data)
{
XtUnmanageChild(mainw);
udcimp(ed);
}
void exitCB(Widget widget, Exc_data * ed, XtPointer call_data)
{
excexit(ed);
}
/*void helpCB(Widget widget, Exc_data * ed, XtPointer call_data)
{
}*/

View file

@ -0,0 +1,214 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: udcexp.c /main/5 1996/10/14 14:45:34 barstow $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "excutil.h"
#include <Xm/MessageB.h>
#include <Xm/RowColumn.h>
#include <Xm/List.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
void setselectedcode();
extern char *maintitle;
void udcexp(Exc_data * ed)
{
ed->function = EXPORT;
strcpy(ed->bdfmode,"w");
PopupSelectXLFD(ed->toplevel);
}
void createbdf(Exc_data * ed)
{
int i = 0;
char *comment_list[] = {""};
int comment_num = 0;
char *msg;
int ans;
msg = GETMESSAGE(10, 2, "Failed to make the BDF file");
i = ExpGpftoBDF(ed->fontfile, ed->bdffile,
ed->code_num, ed->gpf_code_list,
comment_num, comment_list, 0);
if (i != 0) {
AskUser(ed->toplevel, ed, msg, &ans, "error");
}
excterminate(ed);
}
void selcharokCB(Widget widget, ListData * ld, XtPointer call_data)
{
int num;
Exc_data *ed;
int ans;
char *msg;
msg = GETMESSAGE(10, 4, "No indexes are selected");
XtVaGetValues(ld->list, XmNselectedItemCount, &num, NULL);
if (num == 0) {
/* AskUser(widget, ld->ed, msg, &ans, "error");*/
return;
} else {
setselectedcode(ld);
XtUnmanageChild(XtParent(widget));
ed = ld->ed;
freeld(ld);
getbdffn(ed);
}
}
void selcharcancelCB(Widget widget, ListData * ld, XtPointer call_data)
{
Exc_data *ed;
ed = ld->ed;
freeld(ld);
excterminate(ed);
}
XmString * setxmslist(ListData * ld)
{
char **cp;
XmString *xmslist, *xmsp;
int i;
if ((xmslist = (XmString *) calloc(ld->existcode_num, sizeof(XmString *)))
== NULL) {
excerror(ld->ed, EXCERRMALLOC, "setxmslist", "exit");
}
cp = ld->existcode_c;
xmsp = xmslist;
for (i = 0; i < ld->existcode_num; i++) {
*xmsp = XmStringCreateLocalized(*cp);
xmsp++;
cp++;
}
return (xmslist);
}
void freexmslist(ListData * ld, XmString * xmslist)
{
XmString *xmsp;
int i;
if (xmslist != NULL) {
xmsp = xmslist;
for (i = 0; i < ld->existcode_num; i++) {
XmStringFree(*xmsp);
xmsp++;
}
free(xmslist);
}
}
void selcharcd(Exc_data * ed)
{
Widget mainw, selcd, ok, cancel;
Widget slctLabel, form;
Arg args[20];
Cardinal n;
char *oklabel;
char *cancellabel;
XmString *xmslist;
extern ListData *ld;
char *p;
oklabel = GETMESSAGE(10, 6, "OK");
cancellabel = GETMESSAGE(10, 8, "Cancel");
n = 0;
XtSetArg(args[n], XmNautoUnmanage, False); n++;
XtSetArg(args[n], XmNtitle, maintitle); n++;
mainw = XmCreateTemplateDialog(ed->toplevel, "mainw", args, n);
n = 0;
form = XmCreateForm( mainw, "form", args, n);
XtManageChild(form);
p = GETMESSAGE(10, 10, "glyph indexes");
n = 0;
XtSetArg( args[n], XmNx, 20 ) ; n++;
XtSetArg( args[n], XmNheight, 20 ) ; n++ ;
XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ) ; n++ ;
XtSetArg( args[n], XmNtopOffset, 10 ) ; n++ ;
slctLabel = XmCreateLabel( form, p, args, n);
XtManageChild(slctLabel);
n = 0;
xmslist = setxmslist(ld);
XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
XtSetArg( args[n], XmNleftOffset, 20 ) ; n++ ;
XtSetArg( args[n], XmNtopAttachment, XmATTACH_WIDGET ); n++ ;
XtSetArg( args[n], XmNtopOffset, 5 ) ; n++ ;
XtSetArg( args[n], XmNwidth, 200 ) ; n++ ;
XtSetArg (args[n], XmNtopWidget, slctLabel ); n++;
XtSetArg(args[n], XmNitems, xmslist); n++;
XtSetArg(args[n], XmNitemCount, ld->existcode_num); n++;
XtSetArg(args[n], XmNvisibleItemCount, 10); n++;
XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); n++;
XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED); n++;
XtSetArg(args[n], XmNselectionPolicy, XmEXTENDED_SELECT); n++;
selcd = XmCreateScrolledList(form, "Select codes", args, n);
freexmslist(ld, xmslist);
XtManageChild(selcd);
ld->list = selcd;
ok = excCreatePushButton(mainw, "ok", oklabel,
(XtCallbackProc) selcharokCB, (XtPointer) ld);
cancel = excCreatePushButton(mainw, "cancel", cancellabel,
(XtCallbackProc) selcharcancelCB,
(XtPointer) ld);
XtManageChild(mainw);
}
void setselectedcode(ListData *ld)
{
int *position_list;
int position_count;
int i;
int *codep;
XmListGetSelectedPos(ld->list, &position_list, &position_count);
ld->ed->code_num = position_count;
ld->ed->gpf_code_list = (int *) calloc(position_count, sizeof(int));
codep = ld->ed->gpf_code_list;
for (i = 0; i < position_count; i++) {
*codep = *((ld->existcode)+(position_list[i]-1));
codep++;
}
}

View file

@ -0,0 +1,210 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: udcimp.c /main/4 1996/09/02 18:51:02 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "excutil.h"
#include "FaLib.h"
void addcharptn();
void setcodelists();
extern ListData *ld;
extern int num_gr;
extern FalGlyphRegion *gr;
extern FalFontData fullFontData;
void udcimp(Exc_data * ed)
{
ed->function = IMPORT;
strcpy(ed->bdfmode,"r");
getbdffn(ed);
}
int checkcode(int code)
{
int i, j;
int code1, code2;
for (i = 0; i < num_gr; i++) {
code1 = smaller(gr[i].start, gr[i].end);
code2 = bigger(gr[i].start, gr[i].end);
if ((code >= code1) && (code <= code2)) { /*in udc area */
for (j = 0; j < ld->existcode_num; j++) {
if (code == ld->existcode[j])
return (1); /* the font has same glyph index */
}
return (0);
}
}
return (-1); /* out of udc area */
}
int checkcodes(int code_num, int * code_list)
{
int *codep;
int i, ans;
int exist = 0;
codep = code_list;
for (i = 0; i < code_num; i++) {
ans = checkcode(*codep);
if (ans == -1) {
return (-1);
} else if (ans == 1) {
exist = 1;
}
codep++;
}
return (exist);
}
void getcharcd(Exc_data * ed)
{
int code_num;
int *code_list;
int i;
char *msg;
char *msg2;
char *msg3;
int ans, ans2;
msg = GETMESSAGE(12, 2, "Glyph images in this BDF file can't be added to the font.");
msg2 = GETMESSAGE(12, 4, "Failed to open the selected BDF font. You have no right to access for the font file, or the format of the file is not consistent.");
msg3 = GETMESSAGE(12, 6, "There are one or more glyph images being overwritten. Overwrite?");
i = ImpBDFCodeList(ed->bdffile, &code_num, &code_list);
if (i != 0) { /* bad BDF format */
AskUser(ed->toplevel, ed, msg2, &ans, "error");
freeld(ld);
excterminate(ed);
}
ans2 = checkcodes(code_num, code_list);
if (ans2 == -1) { /* out of UDC code exists */
AskUser(ed->toplevel, ed, msg, &ans, "error");
freeld(ld);
excterminate(ed);
} else if (ans2 == 1) { /* font file has same glyph index */
AskUser(ed->toplevel, ed, msg3, &ans, "warning");
if (ans != 1) {
freeld(ld);
excterminate(ed);
}
}
/* set twe codelists */
setcodelists(ld, code_num, code_list);
if (ImpBDFCodeListFree(&code_list) != 0) {
fprintf(stderr,"error in ImpBDFCodeListFree\n");
}
/* add gryph images to font */
addcharptn(ed);
}
void addcharptn(Exc_data * ed)
{
int i;
int ans;
char *msg;
char *msg2;
char *msg3;
int mask;
FalFontDataList *fulllist = NULL;
FalFontID fontid;
msg = GETMESSAGE(12, 8, "Failed to open the selected font. You have no right to access for the font file, or the format of the file is not consistent.");
msg2 = GETMESSAGE(12, 10, "Glyph images in this BDF file can't be added to the font.");
msg3 = GETMESSAGE(12, 12, "Failed in the registration of the font file.");
mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_GLYPH_INDEX |
FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UPDATE |
FAL_FONT_MASK_UNDEFINED | FAL_FONT_MASK_CODE_SET;
i = ImpBDFCheck(ed->bdffile, ed->fontfile);
if (i != 0) {
AskUser(ed->toplevel, ed, msg2, &ans, "error");
excterminate(ed);
}
fontid = FalOpenSysFont(&fullFontData, mask, &fulllist);
if (fontid == 0) {
AskUser(ld->ed->toplevel, ld->ed, msg, &ans, "error");
excterminate(ed);
}
i = 0;
i = ImpBDFtoGpf(ed->bdffile, ed->fontfile,
ed->code_num, ed->bdf_code_list);
FalCloseFont( fontid );
if (i != 0) {
AskUser(ed->toplevel, ed, msg3, &ans, "error");
}
excterminate(ed);
}
void setcodelists(ListData *ld, int code_num, int *code_list)
{
int *c1, *c2;
int i;
Exc_data *ed;
ld->ed->code_num = code_num;
if ((c1 = (int *) calloc(code_num, sizeof(int))) == NULL) {
ed = ld->ed;
freeld(ld);
excerror(ed, EXCERRMALLOC, "setcodelists", "exit");
}
ld->ed->bdf_code_list = c1;
c2 = code_list;
for (i = 0; i < code_num; i++)
{
*c1 = *c2;
c1++;
c2++;
}
if ((c1 = (int *) calloc(code_num, sizeof(int))) == NULL) {
ed = ld->ed;
freeld(ld);
excerror(ed, EXCERRMALLOC, "setcodelists", "exit");
}
ld->ed->gpf_code_list = c1;
c2 = code_list;
for (i = 0; i < code_num; i++)
{
*c1 = *c2;
c1++;
c2++;
}
}

View file

@ -0,0 +1,339 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: xlfdutil.c /main/2 1996/10/14 14:45:50 barstow $ */
/*
* All Rights Reserved, Copyright (c) FUJITSU LIMITED 1995
*
* This is unpublished proprietary source code of FUJITSU LIMITED
*
* Authors: Seiya Miyazaki FUJITSU LIMITED
* Hiroyuki Chiba Fujitsu Basic Software Corporation
*
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <nl_types.h>
#include <Xm/Xm.h>
#include <Xm/Form.h>
#include <Xm/PushB.h>
#include <Xm/Text.h>
#include <Xm/TextF.h>
#include <Xm/Label.h>
#include <Xm/SeparatoG.h>
#include <Xm/List.h>
#include <Xm/ToggleB.h>
#include <Xm/MessageB.h>
#include "FaLib.h"
#include "falxlfd.h"
#include "selectxlfd.h"
#ifdef DEBUG
#undef Dprintf
#define Dprintf fprintf
#else
#define Dprintf
#endif /* DEBUG */
/*
* parameters
*/
static char* skipSpace() ;
extern FalFontDataList *font_L ;
extern FalxFontDataBuff KeyBuff ;
extern FalxCodeList *CodeList ;
extern FalxStyleList *StyleList ;
extern FalxSizeList *SizeList ;
extern int SelectedOffset ;
extern int getmask ;
extern char *fullPathName ;
extern Widget toplevel ;
extern Widget
xlfdWform, cpyWform,
slctBLabel[BUTTONITEMS],slctBText[BUTTONITEMS], slctButton[BUTTONITEMS],
listPop[BUTTONITEMS], listW[BUTTONITEMS],
errorMD, msgBox ;
/****************************************************************
* functions for get font infomation
****************************************************************/
int
GetXLFDInfomations()
{
Dprintf( stdout, "GetXLFDInfomations()\n" ) ;
/* initialize */
getmask = 0 ;
SelectedOffset = 0 ;
fullPathName = NULL ;
FalxInitDataBuff( &KeyBuff ) ;
/* get UDC informations */
if( FalxGetFontList( &font_L, XtDisplayOfObject( toplevel ) ) ){
Dprintf( stderr, "GetXLFDInfomations() : FalxGetFontList() error.\n" ) ;
return(-1);
}
/* create code area list */
if( FalxCreateCodeList( &CodeList, font_L ) ){
Dprintf( stderr, "\nGetXLFDInfomations() : FalxCreateCodeList() error.\n" ) ;
return(-1);
}
/* create style list */
if( FalxCreateStyleList( &StyleList, font_L ) ){
Dprintf( stderr, "\nGetXLFDInfomations() : FalxCreateStyleList() error.\n" ) ;
return(-1);
}
/* create size list */
if( FalxCreateSizeList( &SizeList, font_L ) ){
Dprintf( stderr, "\nGetXLFDInfomations() : FalxCreateSizeList() error.\n" ) ;
return(-1);
}
return(0) ;
}
int
GetItemsToDisplay( num, itemcnt, xms_list )
int num ;
int *itemcnt ;
XmString **xms_list ;
{
int i, j, cnt ;
char *sp ,string[256], buf[256] ;
Arg args[1];
int length, maxlength ;
FalxXlfdList *xlist ;
int tmp_cnt ;
char **tmp_dlist, *str ;
XmString *xms ;
int rlen ;
int rtn ;
switch( num ){
case 0 : /* XLFD */
/* set key data */
for( i=1; i<BUTTONITEMS; i++ ){
if( (str = XmTextGetString( slctBText[i] )) == NULL ){
exit(-1) ;
}
if( *str == ' ' || *str == NULL ) continue ;
if( SetKeyBuff( i, str ) ){
exit(-1) ;
}
}
rtn = FalxGetXlfdList( &xlist, font_L, &KeyBuff, getmask ) ;
if( rtn ) return( rtn ) ;
tmp_cnt = xlist->num ;
tmp_dlist = xlist->list ;
break ;
case 1 : /* code area */
tmp_cnt = CodeList->num ;
tmp_dlist = (char **)malloc( sizeof(char *) * tmp_cnt ) ;
if( tmp_dlist == NULL ) return(-1) ;
for( i=0; i<tmp_cnt; i++ ){
sp = string ;
rlen = sprintf( sp, "CS:%d ", (CodeList->dlist[i]->fontset) ) ;
sp += rlen ;
for( j=0; j<CodeList->dlist[i]->code_area_num; j++ ){
rlen = sprintf( sp, "%x - %x ",
CodeList->dlist[i]->alist[j]->udc_start,
CodeList->dlist[i]->alist[j]->udc_end ) ;
sp += rlen ;
}
if( (tmp_dlist[i] = strdup( string )) == NULL ){
return(-1) ;
}
}
break ;
case 2 : /* style */
tmp_cnt = StyleList->num ;
tmp_dlist = (char **)malloc( sizeof(char *) * tmp_cnt ) ;
for( i=0; i<tmp_cnt; i++ ){
if( (tmp_dlist[i] = strdup( StyleList->list[i] )) == NULL ){
return(-1) ;
}
}
break ;
case 3 : /* size */
tmp_cnt = SizeList->num ;
tmp_dlist = (char **)malloc( sizeof(char *) * tmp_cnt ) ;
for( i=0; i<tmp_cnt; i++ ){
sprintf( string, "%d ", SizeList->list[i] ) ;
if( (tmp_dlist[i] = strdup( string )) == NULL ){
return(-1) ;
}
}
break ;
default : /* error */
return(-1) ;
}
if( (xms = (XmString *)calloc( tmp_cnt, sizeof(XmString) )) == NULL ){
return( -1 ) ;
}
/*
* set list for display
*/
maxlength = 0 ;
for ( i=0; i<tmp_cnt; i++ ){
xms[i] = XmStringCreateLocalized( tmp_dlist[i] );
}
/*
* free allocated memory
*/
switch( num ){
case 0 : /* XLFD */
FalxFreeXlfdList( xlist ) ;
break ;
case 1 : /* code area */
case 2 : /* style */
case 3 : /* size */
for( i=0; i<tmp_cnt; i++ ){
free( tmp_dlist[i] ) ;
}
free( tmp_dlist ) ;
break ;
default : /* error */
return(-1) ;
}
*itemcnt = tmp_cnt ;
*xms_list = xms ;
return(0) ;
}
static char*
skipSpace( str, skipcnt )
char *str ;
int skipcnt ;
{
int i, spacecnt ;
char *sp ;
int len ;
if( *str == NULL ) return( NULL ) ;
len = strlen( str ) ;
sp = str ;
for( i=0,spacecnt=0; i<len-1; i++, sp++ ) {
if( *sp == NULL ) return( NULL ) ;
if( *sp == ' ' ) spacecnt++ ;
if( spacecnt == skipcnt ) break ;
}
sp++ ;
return( sp ) ;
}
int
SetKeyBuff( num, str )
int num ;
char *str ;
{
int i, j ;
int cdset, start, end ;
FalxUdcArea *tmp_list ;
char hyp, *sp ;
switch( num ){
case 0 : /* XLFD */
KeyBuff.FontData.xlfdname = str ;
break ;
case 1 : /* code area */
getmask |= FAL_FONT_MASK_CODE_SET ;
if( KeyBuff.FileData.list != NULL ){
free( KeyBuff.FileData.list ) ;
}
KeyBuff.FileData.list = NULL ;
tmp_list = NULL ;
sp = str ;
if( sscanf( sp, "CS:%d ", &cdset ) != 1 ){
return(-1) ;
}
if( (sp = skipSpace( sp, 1 )) == NULL ) return( -1 ) ;
num = 0 ;
KeyBuff.FontData.cd_set = cdset ;
while( sscanf( sp, "%x %c %x ", &start, &hyp, &end ) == 3 ){
if( hyp != '-' ) break ;
if( tmp_list == NULL ){
tmp_list = (FalxUdcArea *)malloc( sizeof(FalxUdcArea) ) ;
}else{
tmp_list = (FalxUdcArea *)realloc( KeyBuff.FileData.list,
sizeof(FalxUdcArea) * (num+1) ) ;
}
if( tmp_list == NULL ) return(-1) ;
tmp_list[num].udc_start = (int)start ;
tmp_list[num].udc_end = (int)end ;
num ++ ;
if( (sp = skipSpace( sp, 3 )) == NULL ) break ;
}
if( num == 0 ) return(-1) ;
KeyBuff.FileData.code_area_num = num ;
KeyBuff.FileData.list = tmp_list ;
break ;
case 2 : /* style */
getmask |= FAL_FONT_MASK_STYLE_NAME ;
KeyBuff.FontData.style.name = str ;
break ;
case 3 : /* size */
getmask |= FAL_FONT_MASK_LETTER_W ;
getmask |= FAL_FONT_MASK_LETTER_H ;
KeyBuff.FontData.letter.w = atoi( str ) ;
KeyBuff.FontData.letter.h = atoi( str ) ;
break ;
default :
return(-1) ;
}
return(0);
}

View file

@ -0,0 +1,81 @@
/* Imakefile 1.8 - Fujitsu source for CDEnext 96/06/10 13:34:37 */
/* $TOG: Imakefile /main/20 1997/04/30 15:51:07 samborn $ */
LOCAL_XLIBPATH =
DESTDIR = $(CDE_INSTALLATION_TOP)
BINDIR = /bin
UDC_INC_PATH1 = -I./
UDC_INC_PATH2 = -I./include
UDC_INC_PATH3 = -I./libfal
UDC_INC_PATH4 = -I./libfal/include
UDC_INC_PATH5 = -I$(DTSVCSRC)/DtXpm
UDC_INC_PATH6 = -I$(TOP)/../x11/xc
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
DEFINES = $(OPT2)
INCLUDES = $(UDC_INC_PATH1)\
$(UDC_INC_PATH2)\
$(UDC_INC_PATH3)\
$(UDC_INC_PATH4)\
$(UDC_INC_PATH5)\
$(UDC_INC_PATH6)
DEPLIBS = $(DEPDTSVCLIB) $(DEPTTLIB) $(DEPXMLIB) $(DEPXTOOLLIB) $(DEPXLIB)
LOCAL_LIBRARIES = $(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XLIB) ./libfuty/liboakfuty.a ./libfal/libfal.a
SRCS = comsub.c cpyw.c mtfgui.c ufont.c util.c\
selectx.c cpyx.c xutil.c code.c
OBJS = comsub.o ufont.o cpyw.o mtfgui.o util.o\
cpyx.o xutil.o selectx.o code.o
/* Sun needs the widechar library */
#ifdef SunArchitecture
SYS_LIBRARIES = DtClientSysLibs -lw
#else
SYS_LIBRARIES = DtClientSysLibs
#endif
#define IHaveSubdirs
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
SUBDIRS = \
libfal \
libfuty \
dtaddcpf \
dtbdftocpf \
dtcpftobdf \
dtcpftogpf \
dtcpgpf \
dtgpftobdf \
dtgpftocpf \
dtlsgpf
MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
ComplexProgramTarget(dtudcfonted)
install::
@if [ -d $(DESTDIR)/app-defaults/C ]; then set +x; \
else (set -x; $(MKDIRHIER) $(DESTDIR)/app-defaults/C); fi ; \
if [ -d $(DESTDIR)/app-defaults/ja_JP ]; then set +x; \
else (set -x; $(MKDIRHIER) $(DESTDIR)/app-defaults/ja_JP); fi ; \
if [ -f $(DESTDIR)/app-defaults/C/Dtudcfonted ]; then set +x; \
else (set +x ; echo "installing" "in $(DESTDIR)/app-defaults/C" ; \
$(CP) ./resource/Dtudcfonted $(DESTDIR)/app-defaults/C; \
chmod 0444 $(DESTDIR)/app-defaults/C/Dtudcfonted); fi ; \
if [ -f $(DESTDIR)/app-defaults/ja_JP/Dtudcfonted ]; then set +x; \
else (set +x ; echo "installing" "in $(DESTDIR)/app-defaults/ja_JP" ; \
$(CP) ./resource/Dtudcfonted.ja_JP $(DESTDIR)/app-defaults/ja_JP/Dtudcfonted; \
chmod 0444 $(DESTDIR)/app-defaults/ja_JP/Dtudcfonted); fi

View file

@ -0,0 +1,30 @@
$XConsortium: README /main/3 1996/07/04 02:23:02 cde-fuj $
UDC font editor and UDC data exchange utility README
1) Environment
1.1) XLOCALEDIR environment variable
- If the NLS database ("XLC_LOCALE" files) locates
in different directory from where specified at building
time, set the full path name of the correct directory to
the XLOCALEDIR environment variable.
1.2) Editable Fonts
- Currently, only jisx0208 fonts in Japanese locale is
defined in NLS database to have UDC. So the dtudcfonted
will not show the edit view in other locales than Japanese.
- If the "fonts.list" file exists in the directories showed
below, dtudcfonted and dtudcexch read and get directories
from this file to search fonts.
/usr/dt/config/
/usr/dt/config/$LANG
$DTUDCFONTS/
$DTUDCFONTS/$LANG
- If the system place fonts in different directories other
than listed in this file, you need to add them in it.

View file

@ -0,0 +1,504 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* code.c 1.37 - Fujitsu source for CDEnext 96/10/30 13:13:47 */
/* $XConsortium: code.c /main/6 1996/11/08 01:57:21 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdio.h>
#include <string.h>
#include <X11/keysym.h>
#include <Xm/Xm.h>
#include <Xm/Label.h>
#include <Xm/List.h>
#include <Xm/RowColumn.h>
#include <Xm/SeparatoG.h>
#include <Xm/Text.h>
#include <Xm/PushB.h>
#include <Xm/Frame.h>
#include <Xm/Form.h>
#include <Xm/MwmUtil.h>
#include <X11/Intrinsic.h>
#include "falfont.h"
#include "xoakufont.h"
#define NUM 0x80
static Display *display=NULL;
static int screen;
static Boolean open_font;
static Widget toggle[NUM];
static Widget text;
static Window BaseW;
static Widget set_widget;
static Widget code_w=0;
static int font_w, font_h;
static unsigned long fg, bg;
static unsigned char *ptn, *clr;
static Pixmap no_pix;
static int len, code1;
static char *FontName=NULL;
static FalFontID fid;
extern FalFontID font_id;
extern int CodePoint;
extern Resource resource;
static void
OpenFont()
{
int mask;
FalFontData font_data;
static FalFontDataList *copylist;
extern FalFontData fullFontData;
if(strcmp(FontName, fullFontData.xlfdname) == 0) {
fid = font_id;
return;
}
mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_DEFINED |
FAL_FONT_MASK_UNDEFINED;
font_data.xlfdname = FontName;
if (! CodePoint) {
mask |= FAL_FONT_MASK_GLYPH_INDEX;
}
fid = FalOpenSysFont(&font_data, mask, &copylist);
}
static void
CloseFont()
{
if (fid != font_id) {
FalCloseFont(fid);
fid = 0;
}
}
static void
DrawCode(w, low_code)
Widget w;
int low_code;
{
int hi_code;
char *f = NULL;
XImage image;
GC gc = XDefaultGC(display, 0);
hi_code = (code1 & 0xff) << 8;
image.width = font_w;
image.height = font_h;
image.xoffset = 0;
image.format = XYBitmap;
image.byte_order = LSBFirst;
image.bitmap_unit = 8;
image.bitmap_bit_order = MSBFirst;
image.bitmap_pad = 8;
image.depth = 1;
image.bytes_per_line = (font_w - 1) / 8 + 1;
XSetForeground(display, gc, fg);
XSetBackground(display, gc, bg);
if (open_font) {
f = (char *)FalReadFont(fid, hi_code | low_code, font_w, font_h);
if(f == NULL || f == (char *)FAL_ERROR) {
return;
}
if( EXISTS_FLAG == 0 ) {
memcpy(ptn, f, len);
image.data = (char *)ptn;
} else {
image.data = (char *)clr;
}
XPutImage(display, XtWindow(toggle[low_code]), gc, &image, 0, 0, 6, 6, font_w, font_h);
} else {
if (ptnGet(hi_code | low_code, ptn) == 0) {
image.data = (char *)ptn;
} else {
image.data = (char *)clr;
}
XPutImage(display, XtWindow(toggle[low_code]), gc, &image, 0, 0, 6, 6, font_w, font_h);
}
}
static void
SetPixmap(start_code)
{
int hi_code, low_code;
char *f = NULL;
XImage image;
GC gc = XDefaultGC(display, 0);
hi_code = (start_code & 0xff) << 8;
image.width = font_w;
image.height = font_h;
image.xoffset = 0;
image.format = XYBitmap;
image.byte_order = LSBFirst;
image.bitmap_unit = 8;
image.bitmap_bit_order = MSBFirst;
image.bitmap_pad = 8;
image.depth = 1;
image.bytes_per_line = (font_w - 1) / 8 + 1;
XSetForeground(display, gc, fg);
XSetBackground(display, gc, bg);
if (open_font) {
for (low_code=0; low_code < NUM; low_code++) {
f = (char *)FalReadFont(fid, hi_code | low_code, font_w, font_h);
if(f == NULL || f == (char *)FAL_ERROR) {
return;
}
if( EXISTS_FLAG == 0 ) {
memcpy(ptn, f, len);
image.data = (char *)ptn;
} else {
image.data = (char *)clr;
}
XPutImage(display, XtWindow(toggle[low_code]), gc, &image, 0, 0, 6, 6, font_w, font_h);
}
} else {
for (low_code=0; low_code < NUM; low_code++) {
if (ptnGet(hi_code | low_code, ptn) == 0) {
image.data = (char *)ptn;
} else {
image.data = (char *)clr;
}
XPutImage(display, XtWindow(toggle[low_code]), gc, &image, 0, 0, 6, 6, font_w, font_h);
}
}
}
static void
Code1Call(w, start_code, data)
Widget w;
int start_code;
XmListCallbackStruct *data;
{
code1 = start_code + data->item_position -1;
SetPixmap(code1);
}
static void
Code2Call(w, code2, data)
Widget w;
int code2;
XmPushButtonCallbackStruct *data;
{
char asc[16];
sprintf(asc, "%2.2X%2.2X", code1, code2);
XtVaSetValues(text, XmNvalue, asc, NULL);
DrawCode(w, code2);
}
static void
PrevPage(w, scroll)
Widget w, scroll;
{
int *list;
int num;
if (XmListGetSelectedPos(scroll, &list, &num)) {
if(list[0] > 1) {
XmListSelectPos(scroll, list[0] - 1, True);
XmListSetPos(scroll, list[0] - 1);
}
}
}
static void
NextPage(w, scroll)
Widget w, scroll;
{
int *list;
int num, item;
XtVaGetValues(scroll, XmNitemCount, &item, NULL);
if (XmListGetSelectedPos(scroll, &list, &num)) {
if(list[0] < item) {
XmListSelectPos(scroll, list[0] + 1, True);
XmListSetBottomPos(scroll, list[0] + 1);
}
}
}
static void
Cancel()
{
XtUnmapWidget(XtParent(code_w));
}
static void
Apply()
{
char *asc;
XtVaGetValues(text, XmNvalue, &asc, NULL);
XtVaSetValues(set_widget, XmNvalue, asc, NULL);
XtFree(asc);
Cancel();
}
static void
CreateItem(item, item_count, start_code)
XmString *item;
int *item_count;
int *start_code;
{
int count;
int start, end;
char str[5];
FalFontinfo finfo;
extern int begin_code, last_code;
if (open_font) {
if (FalQueryFont(fid, &finfo) == FAL_ERROR) {
*item_count = 0;
CloseFont();
return;
}
font_w = finfo.width;
font_h = finfo.height;
start = (finfo.top & 0xff00) >> 8;
end = (finfo.bottom & 0xff00) >> 8;
} else {
font_w = edg.width;
font_h = edg.height;
start = (begin_code & 0xff00) >> 8;
end = (last_code & 0xff00) >> 8;
}
if (CodePoint) {
if (start < 0x80)
start = 80;
if (end < 0x80)
start = 80;
} else {
if (start > 0x7f)
start = 0x7f;
if (end > 0x7f)
end = 0x7f;
}
*start_code = start;
for (count=0;start <= end; start++, count++) {
sprintf(str, "%X", start);
item[count] = XmStringCreateLocalized(str);
}
*item_count = count;
}
static Widget
CreateCodeWindow(w)
Widget w;
{
Widget top, base1, base2, base3, base4;
Widget frame, scroll, label, sep, form;
Widget push1, push2, push3, push4;
Arg args[16];
int n, i;
XmString item[128];
XmString xcs;
int item_count, start_code, add_c;
char add[9];
n = 0;
XtSetArg(args[n], XmNmwmFunctions, MWM_FUNC_ALL | MWM_FUNC_CLOSE |
MWM_FUNC_RESIZE); n++;
XtSetArg(args[n], XmNmwmDecorations, MWM_DECOR_ALL); n++;
top = XmCreateFormDialog(w, "code", args, n);
base1 = XtVaCreateManagedWidget("base1", xmRowColumnWidgetClass, top,
XmNorientation, XmVERTICAL, NULL);
frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, base1,
NULL);
base2 = XtVaCreateManagedWidget("base2", xmRowColumnWidgetClass, frame,
XmNorientation, XmHORIZONTAL, NULL);
CreateItem(item, &item_count, &start_code);
code1 = start_code;
n = 0 ;
XtSetArg(args[n], XmNitems, item); n++;
XtSetArg(args[n], XmNitemCount, item_count); n++;
XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); n++;
scroll = XmCreateScrolledList(base2, "scroll", args, n);
XtManageChild(scroll);
XtAddCallback(scroll, XmNbrowseSelectionCallback,
(XtCallbackProc)Code1Call, (XtPointer) (intptr_t) start_code);
XtAddCallback(scroll, XmNdefaultActionCallback,
(XtCallbackProc)Code1Call, (XtPointer) (intptr_t) start_code);
XmListSelectPos(scroll, 1, False);
base3 = XtVaCreateManagedWidget("base3", xmRowColumnWidgetClass, base2,
XmNorientation, XmHORIZONTAL,
XmNpacking, XmPACK_COLUMN,
XmNradioAlwaysOne, True,
XmNradioBehavior , True,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
XmNspacing, 0,
XmNnumColumns, 9, NULL);
len = (font_w / 8 + 1) * font_h;
ptn = (unsigned char *) malloc(len);
clr = (unsigned char *) malloc(len);
memset(clr, 0, len);
XtVaGetValues(w, XmNforeground, &fg, XmNbackground, &bg, NULL);
no_pix = XCreatePixmapFromBitmapData(display, BaseW, (char *)clr,
font_w, font_h, fg, bg, DefaultDepth(display, screen));
XtVaCreateManagedWidget("", xmLabelWidgetClass, base3, NULL);
for (i=0; i < 16; i++) {
sprintf(add, "%2.1X", i);
XtVaCreateManagedWidget(add, xmLabelWidgetClass, base3, NULL);
}
if (CodePoint)
add_c = 8;
else
add_c = 0;
for (i=0; i < NUM; i++) {
if ((i % 16) == 0) {
snprintf(add, sizeof(add), "%2.1X", add_c++);
XtVaCreateManagedWidget(add, xmLabelWidgetClass, base3, NULL);
}
toggle[i] = XtVaCreateWidget("toggle",
xmPushButtonWidgetClass, base3,
XmNwidth, font_w,
XmNheight, font_h,
XmNlabelType, XmPIXMAP,
XmNlabelPixmap, no_pix, NULL);
XtAddCallback(toggle[i], XmNactivateCallback,
(XtCallbackProc)Code2Call, (XtPointer) (intptr_t) i);
XtAddCallback(toggle[i], XmNarmCallback,
(XtCallbackProc)DrawCode, (XtPointer) (intptr_t) i);
XtAddCallback(toggle[i], XmNdisarmCallback,
(XtCallbackProc)DrawCode, (XtPointer) (intptr_t) i);
XtAddEventHandler(toggle[i], ExposureMask, False,
(XtEventHandler)DrawCode, (XtPointer) (intptr_t) i);
}
XtManageChildren(toggle, NUM);
base4 = XtVaCreateManagedWidget("base4", xmFormWidgetClass, base1, NULL);
xcs = XmStringCreateLocalized(resource.l_code);
label = XtVaCreateManagedWidget("code", xmLabelWidgetClass, base4,
XmNlabelString, xcs,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 30, NULL);
text = XtVaCreateManagedWidget("text", xmTextWidgetClass, base4,
XmNeditable, False,
XmNcursorPositionVisible, False,
XmNcolumns, 4,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, label, NULL);
sep = XtVaCreateManagedWidget("sep", xmSeparatorGadgetClass, base1,
XmNorientation, XmHORIZONTAL, NULL);
form = XtVaCreateManagedWidget("sep", xmFormWidgetClass, base1, NULL);
xcs = XmStringCreateLocalized(resource.previous);
push1 = XtVaCreateManagedWidget("PreviousPage", xmPushButtonWidgetClass, form,
XmNleftAttachment, XmATTACH_POSITION,
XmNlabelString, xcs,
XmNleftPosition, 10, NULL);
XtAddCallback(push1, XmNactivateCallback,
(XtCallbackProc)PrevPage, (XtPointer)scroll);
XmStringFree(xcs);
xcs = XmStringCreateLocalized(resource.next);
push2 = XtVaCreateManagedWidget("NextPage", xmPushButtonWidgetClass, form,
XmNleftAttachment, XmATTACH_POSITION,
XmNlabelString, xcs,
XmNleftPosition, 35, NULL);
XtAddCallback(push2, XmNactivateCallback,
(XtCallbackProc)NextPage, (XtPointer)scroll);
XmStringFree(xcs);
xcs = XmStringCreateLocalized(resource.apply);
push3 = XtVaCreateManagedWidget("Apply", xmPushButtonWidgetClass, form,
XmNleftAttachment, XmATTACH_POSITION,
XmNlabelString, xcs,
XmNleftPosition, 60, NULL);
XtAddCallback(push3, XmNactivateCallback, (XtCallbackProc)Apply, NULL);
XmStringFree(xcs);
xcs = XmStringCreateLocalized(resource.l_cancel);
push4 = XtVaCreateManagedWidget("Cancel", xmPushButtonWidgetClass, form,
XmNleftAttachment, XmATTACH_POSITION,
XmNlabelString, xcs,
XmNleftPosition, 80, NULL);
XtAddCallback(push4, XmNactivateCallback, (XtCallbackProc)Cancel, NULL);
XmStringFree(xcs);
return(top);
}
void
CodeWindow(widget, font_name, load_font)
Widget widget;
char * font_name;
Boolean load_font;
{
static Boolean old_load_font;
extern int CodePoint;
set_widget = widget;
BaseW = XtWindow(widget);
display = XtDisplay(widget);
screen = DefaultScreen(display);
if (FontName == NULL || strcmp(font_name, FontName) ||
load_font != old_load_font) {
old_load_font = load_font;
if (code_w) {
XtDestroyWidget(code_w);
code_w = 0;
free(ptn);
free(clr);
if (fid != 0) {
CloseFont();
}
}
if (FontName)
free(FontName);
FontName = (char *)malloc(strlen(font_name)+1);
strcpy(FontName, font_name);
if (load_font) {
OpenFont();
if (fid == 0)
return;
open_font = True;
} else {
open_font = False;
}
code_w = CreateCodeWindow(widget);
XtManageChild(code_w);
} else {
XtMapWidget(XtParent(code_w));
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,619 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* cpyw.c 1.9 - Fujitsu source for CDEnext 96/10/30 13:31:40 */
/* $XConsortium: cpyw.c /main/7 1996/11/08 01:53:38 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdio.h>
#include <X11/Intrinsic.h>
#include "xoakufont.h"
#include "util.h"
extern Resource resource ;
extern Widget cpyDialog;
/**
** create and display the "User defined character ecitor :Copy" window
** ==================================================================
**/
void PopdownCpyPtn();
void DoCpyProc();
void CpyPtnCB();
void CpyCB();
/* static */ TextField SrcTf;
/* static */ TextField DestTf;
/**
** contents : initialize the "Copy" window
** --------------------
**
**
**/
void
InitCpyPtn()
{
/* initialize font infomation */
}
/**
** contents : create and pop up the "Copy" window
** ----------------------------------
**
**/
void
CpyPtnCB()
{
extern void CpyPtnXLFD();
CpyPtnXLFD();
}
/**
** contents : pop down the "Copy" window
** ----------------------
**/
void
PopdownCpyPtn()
{
ForcePopdownDialog(cpyDialog);
}
/** contents :
** get the character strings of source code area from the input field
** --------------------------------------
**/
String
CpySrcCodeTfValue()
{
return(GetTextFieldValue(&SrcTf));
}
/** contents :
** get the character strings of destination code area from input field
** --------------------------------------
**/
String
CpyDestCodeTfValue()
{
return(GetTextFieldValue(&DestTf));
}
/**
** contents : pop up the copy confirmation window
** --------------------------------
**/
void
PopupCpyNotice( message )
String message;
{
char bmsg[512] = "";
static NoticeButton buttons[] = {
NBTNARGS( DoCpyProc, NULL, NULL, True, False ),
NBTNARGS( NULL, NULL, NULL, True, False ),
};
static NButton BTN = NBUTTONS( buttons );
snprintf(bmsg, sizeof(bmsg), "%s%s", resource.mn_cpy_lost, message);
SetItemLabel(&BTN, 0, resource.l_ok);
SetItemLabel(&BTN, 1, resource.l_cancel);
PopupNotice( cpyPtnW, bmsg, D_WARNING, &BTN, False, resource.l_warning_title);
}
/**
** contents : "Copy" button callback
** ------------------------
** execute the copy processing
**/
/*ARGSUSED*/
void
CpyCB(w, cdata)
Widget w;
XtPointer cdata;
{
extern Boolean BeforeCpyCheck();
if (BeforeCpyCheck(cdata)){
PopdownCpyPtn();
DoCpyProc();
}
}
/**
** "Add/Delete" window
** ===================================================================
**/
/**
** contents : pop down the "Add/Delete" window
** ------------------------------
**/
static void
PopdownMngPtn()
{
PopdownDialog(mngPtnW);
}
/**
** contents : "Add" button callback
** ------------------------
**/
static void
AddCB()
{
int s_code, e_code;
extern Boolean BeforeMngCheck();
extern void DoAddProc();
if (BeforeMngCheck(&s_code, &e_code)){
DoAddProc(s_code, e_code);
PopdownMngPtn();
}
}
/**
** contents : "Delete" button callback
** ------------------------
**/
static void
DelCB()
{
int s_code, e_code;
extern void DoDelProc();
extern Boolean BeforeMngCheck();
if (BeforeMngCheck(&s_code, &e_code)){
DoDelProc(s_code, e_code);
}
}
static ButtonItems add_btn[] = {
BTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) AddCB, NULL, NULL, True, True ),
BTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) DelCB, NULL, NULL, True, False ),
BTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) PopdownMngPtn, NULL, NULL, True, False ),
};
static Button AddBTN = BUTTONS( add_btn );
static TextField MngCodeTf;
/**
** contents : create and pop up the "Add/Delete" window
** ------------------------------------
**/
void
MngPtnCB()
{
if (! mngPtnW){
Widget rowcol;
SetItemLabel(&AddBTN, 0, resource.l_add);
SetItemLabel(&AddBTN, 1, resource.l_delete);
SetItemLabel(&AddBTN, 2, resource.l_cancel);
rowcol =
CreateDialogAndButtons( toplevel, resource.l_add_title,
NULL, &AddBTN, XtNumber(add_btn), &mngPtnW);
CreateTextField(rowcol, "wgkTxtF",
resource.l_manage_code, &MngCodeTf, 4);
}
PopupDialog(mngPtnW);
}
/**
** contents : get the character strings of code for add or delete from the input field
** --------------------------------------------
**/
String
MngCodeTfValue()
{
return(GetTextFieldValue(&MngCodeTf));
}
/**
** the delete confirmation window
** ===================================================================
**/
static Widget CreateDelNotice();
static void drawDelPtn();
static void drawDelCode();
static void CBdnOblB_del();
static void EHdnBulB_disp();
void EHStaT_disp(); /* add 1995.09.20 */
static Widget dnStaT_code[D_MAX], dnBulB_disp[D_MAX], dnPopW;
/**
** contents : pop up the delete confirmation window
** --------------------------
**/
void
PopupDelNotice( owner )
Widget owner;
{
int i;
Widget delNoticeW = NULL;
delNoticeW = CreateDelNotice(owner);
XtVaSetValues(XtParent(delNoticeW), XmNmappedWhenManaged, False, NULL);
XtManageChild(delNoticeW);
for ( i=0 ; i < dn.disp_num ; i++ ) {
/* moved from paneDelNotice body */
dl[i].disp_winID = XtWindow( dnBulB_disp[i] );
drawDelCode(i);
drawDelPtn(i);
}
XtVaSetValues(XtParent(delNoticeW), XmNmappedWhenManaged, True, NULL);
XBell(XtDisplayOfObject(delNoticeW), 0);
}
/**
** contents : clear the image of deleted character
** ----------------------------------------------
**/
static void
dstrypaneDelNotice()
{
int i;
for ( i=0; i<dn.disp_num; i++ ){
XFree((char *) dl[i].dispImage);
}
}
/**
** contents : "OK" button callback
** ----------------------------
**/
static void
DelOkCB()
{
CBdnOblB_del();
PopdownMngPtn();
}
/**
** contents : callback of the delete list
** ------------------------------------
**/
static void
delScProc( value )
int value;
{
int i;
extern int RelToAbsSq();
dn.sq_top = RelToAbsSq( dn.sq_start, value - dn.sq_start);
for ( i=0 ; i < dn.disp_num ; i++ ) {
drawDelCode(i);
drawDelPtn(i);
}
}
/**
** contents : create the delete confirmation window
** --------------------------
**/
static Widget
CreateDelNotice(owner)
Widget owner;
{
Widget form, listBase, itemform[D_MAX];
char buf[64];
int i, val, min, max;
int c ;
extern int AbsSqToRel();
extern void AddDestroyProc();
static NoticeButton buttons[] = {
NBTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) DelOkCB, NULL, NULL, True, False ),
NBTNARGS( NULL, NULL, NULL, True, False ),
};
static NButton BTN = NBUTTONS( buttons );
c = AbsSqToRel( dn.sq_start, dn.sq_end) + 1;
if (c == 1) {
sprintf(buf, "%s(%d %s)", resource.mg_start_del_s,
c, resource.mg_start_del_cs );
} else {
sprintf(buf, "%s(%d %s)", resource.mg_start_del_m,
c, resource.mg_start_del_cm );
}
SetItemLabel(&BTN, 0, resource.l_ok);
SetItemLabel(&BTN, 1, resource.l_cancel);
form = CreateTemplateDialog( owner, buf, D_QUESTION, &BTN,
resource.l_question_title, &dnPopW);
AddDestroyProc(dnPopW, dstrypaneDelNotice);
if ( dn.disp_num < (AbsSqToRel( dn.sq_start, dn.sq_end) + 1)) {
val = AbsSqToRel( dn.sq_start, dn.sq_top) + dn.sq_start;
min = dn.sq_start;
max = AbsSqToRel( dn.sq_start, dn.sq_end) + dn.sq_start +1;
listBase = CreateScrollBase( form, "listBase",
min, max, val, dn.disp_num, delScProc );
}
else{
listBase =
CreateRowColumn( form, "listBase", L_VERTICAL, 4,2,2 );
}
for(i=0; i<dn.disp_num; i++) {
/* create form for the codes and fonts to be deleted */
itemform[i] = CreateForm( listBase, "listBase" );
/* create widgets for the codes to be deleted in the list */
dnStaT_code[i] = CreateLabel( itemform[i], "label", " " );
AddTopAttachForm( dnStaT_code[i], 0 );
AddLeftAttachForm( dnStaT_code[i], 0 );
AddBottomAttachForm( dnStaT_code[i], 0 );
/* create widgets for the image of the codes to be deleted in the list */
dnBulB_disp[i] = CreateDrawingArea( itemform[i], "image",
edg.width, edg.height, EHdnBulB_disp, i);
AddLeftAttachWidget( dnBulB_disp[i], dnStaT_code[i], 0 );
/* */
dl[i].dispImage = XCreateImage( xl.display,
DefaultVisual( xl.display, DefaultScreen(xl.display) ),
1, XYBitmap, 0, dl[i].ptn, dn.ptn_w, dn.ptn_h, 8, 0);
dl[i].dispImage->bitmap_bit_order = MSBFirst;
dl[i].dispImage->byte_order = MSBFirst;
}
XtManageChildren( itemform, dn.disp_num );
return(dnPopW);
}
/**
** contents : delete characters from editor
** -----------------------------------------
**
**/
static void
CBdnOblB_del()
{
int code; /* code number for check */
int ncode; /* sequential number in the codeset system area */
int sq_now; /* sequential number in the editor */
char mode; /* notify the modification of the edit list */
extern void chgEdCode();
XtSetSensitive( dnPopW, FALSE );
mode = OFF;
for( sq_now=dn.sq_end ; sq_now >= dn.sq_start ; sq_now-- ) {
ncode = ptnSqToNo(sq_now);
if ( codeCheck( noToCode(ncode)))
continue;
if (ptnSense( noToCode(ncode) ) == 1) {
ptnDel( noToCode(ncode) );
edlist.nptn--;
edg.flag = ON;
mode = ON;
}
}
/* update the current character */
sq_now++;
for ( ; sq_now < (edlist.sqstart + edlist.nptn); sq_now++) {
ncode = ptnSqToNo(sq_now);
if (( ncode >= 0) && ( codeCheck( noToCode( ncode)) == 0))
break;
}
if(sq_now > (edlist.sqstart + edlist.nptn -1)) {
sq_now--;
for ( ; sq_now >= edlist.sqstart; sq_now--) {
ncode = ptnSqToNo(sq_now);
if (( ncode >= 0) && ( codeCheck( noToCode( ncode)) == 0))
break;
}
}
/* check the existence of the current character */
if( (sq_now != -1) && ((ncode = ptnSqToNo(sq_now)) != -1) ){
code = noToCode( ncode );
} else {
/* There is no characters on the editor, dtudcfonted does not
* display any character on the editing pane and forbid users
* to input.
* It can realize to put 0 to the first parameter of chgEdCode().
*/
code = 0;
}
if(codeCheck( code )) {
code = 0;
}
/* */
if( ptnSense( edg.code ) == 1 ) {
ptnAdd( edg.code, edg.ptn );
}
/* renew the current character */
if (mode == ON) {
chgEdCode( code, mode );
}
XtSetSensitive( dnPopW, TRUE );
}
/**
** contents : display the image of the character to be deleted
** ------------------------
**
**/
static void
drawDelPtn( i )
int i; /* window number */
{
if ( RelToAbsSq( dn.sq_top, i) <= dn.sq_end) {
ptnGet( noToCode(ptnSqToNo(RelToAbsSq( dn.sq_top, i))),
dl[i].ptn );
XPutImage(xl.display, dl[i].disp_winID, xl.borderGC,
dl[i].dispImage, 0,0,0,0, dn.ptn_w, dn.ptn_h );
} else {
return;
}
}
/**
** contents : display the code of the character to be deleted
** ----------------------
**
**/
static void
drawDelCode( i )
int i; /* window number */
{
char str[20];
if ( RelToAbsSq( dn.sq_top, i) <= dn.sq_end) {
sprintf(str, "%4x ", noToCode(ptnSqToNo(RelToAbsSq( dn.sq_top, i))));
SetLabelString(dnStaT_code[i], str);
} else {
return;
}
}
/**
** contents : re-display the code of the character to be deleted
** --------------------------------------------------------------
**/
/*ARGSUSED*/
static void
EHdnBulB_disp( widget, i )
Widget widget;
int i; /* widget that have some ivent */
{
drawDelPtn( i );
}
/**
** notify error message
** ===================================================================
**
**/
/**
** contents : inner functions of DispMngErrorMessage()
** ----------------------------------
**/
static void
DispErrorMessage( owner, title, msg )
Widget owner;
String title;
String msg;
{
static NoticeButton buttons[] = {
NBTNARGS( NULL, NULL, NULL, True, False ),
};
static NButton BTN = NBUTTONS( buttons );
SetItemLabel(&BTN, 0, resource.l_ok);
PopupNotice( owner, msg, D_ERROR, &BTN, False, title );
}
/**
** contents : display "Add" or "Delete" error
** --------------------------------
**/
void
DispMngErrorMessage( msg )
String msg;
{
DispErrorMessage( mngPtnW, resource.l_error_title, msg );
}
/**
** contents : display "Copy" error
** --------------------------
**/
void
DispCpyErrorMessage( msg )
String msg;
{
DispErrorMessage( cpyPtnW, resource.l_error_title, msg );
}

View file

@ -0,0 +1,944 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* cpyx.c 1.29 - Fujitsu source for CDEnext 96/10/30 13:13:45 */
/* $XConsortium: cpyx.c /main/8 1996/11/08 01:52:55 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <nl_types.h>
#include<X11/Xlib.h>
#include<X11/Xutil.h>
#include<X11/Xatom.h>
#include <Xm/XmAll.h>
/*
* There is no public header file for this function (only an
* internal header XmStringI.h).
*/
extern XtPointer _XmStringUngenerate (XmString string,
XmStringTag tag,
XmTextType tag_type,
XmTextType output_type);
#include "util.h"
#include "selectxlfd.h"
#include "xoakufont.h"
#include "xpm.h"
#ifdef XPM
#define ReadXpm XpmCreatePixmapFromData
#else
#define ReadXpm _DtXpmCreatePixmapFromData
#endif
#include "pixmaps/arrow.pm"
static Widget CreateCopyXLFD() ;
static void CpyXLFDCB() ;
extern int CreateOtherLabelAndText();
extern Widget xlfdCreateScrolledList();
extern int GetItemsToDisplay();
extern void xlfdPopupDialog();
extern void InitCpyPtn() ;
extern void _unmap();
extern void CpyCB() ;
extern void PopdownCpyPtn() ;
extern void AddPopupProc() ;
extern FalFontData fullFontData;
/*
* parameters
*/
FalFontData copyFontData;
extern Widget toplevel ;
Widget cpyDialog=NULL;
static Widget codeLabel[COPYLABELS];
static Widget codeText[COPYLABELS+1];
extern TextField SrcTf;
extern TextField DestTf;
extern char AreaStr[160];
/*
* resource database
*/
extern Resource resource ;
#define CS0 "Codeset 0"
#define CS1 "Codeset 1"
#define CS2 "Codeset 2"
#define CS3 "Codeset 3"
#define FAL_ERROR_STR resource.falerrmsg[((fal_utyerrno & 0xff) > 25) ? 0 : (fal_utyerrno & 0xff)]
static Widget pull1, pull2, pull3, pull4, scrolllist;
static int xlf_count = 0;
static XmString *xlf=NULL;
static int udc_count = 0;
static Boolean udc_flag = False;
static int *udc=NULL;
static int udc_val;
static int sty_count = 0;
static Boolean sty_flag = False;
static char **sty=NULL;
static char *sty_val=NULL;
static int wls_count = 0;
static Boolean wls_flag = False;
static int *wls=NULL;
static int wls_val;
static int hls_count = 0;
static Boolean hls_flag = False;
static int *hls=NULL;
static int hls_val;
static Widget *button1=NULL;
static Widget *button2=NULL;
static Widget *button3=NULL;
static Widget *button4=NULL;
static Widget focus_widget=NULL;
/****************************************************************
* callbacks *
***************************************************************/
/*ARGSUSED*/
static void
CpyXLFDCB(w, client_data, call_data)
Widget w;
caddr_t client_data, *call_data;
{
char *str;
XmStringTable st;
/* get font file name (str: XLFD name) */
/* get font file name (str: XLFD name) */
XtVaGetValues(scrolllist, XmNselectedItems, &st, NULL);
if( st == NULL ){
copyFontData.xlfdname = NULL;
return ;
}
str = _XmStringUngenerate(st[0], NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
copyFontData.xlfdname = str;
if(udc_flag == True)
copyFontData.cd_set = udc_val;
else
copyFontData.cd_set = -1;
}
void
CpyPtnXLFD()
{
if( cpyDialog == NULL )
{
CreateCopyXLFD( toplevel ) ;
/*
* add callbacks
*/
XtAddCallback(cpyDialog, XmNokCallback, (XtCallbackProc)_unmap, NULL);
XtAddCallback(cpyDialog, XmNokCallback,
(XtCallbackProc)CpyXLFDCB, NULL);
XtAddCallback(cpyDialog, XmNokCallback, (XtCallbackProc)CpyCB, NULL);
XtAddCallback(cpyDialog, XmNcancelCallback,
(XtCallbackProc)_unmap, (XtPointer)1);
XtAddCallback(cpyDialog, XmNcancelCallback,
(XtCallbackProc)CpyXLFDCB, (XtPointer)1);
XtAddCallback(cpyDialog, XmNcancelCallback,
(XtCallbackProc)CpyCB, (XtPointer)1);
XtAddCallback(cpyDialog, XmNhelpCallback, (XtCallbackProc)_unmap, NULL);
XtAddCallback(cpyDialog, XmNhelpCallback,
(XtCallbackProc)PopdownCpyPtn, NULL);
AddPopupProc( cpyDialog, InitCpyPtn ) ;
SrcTf.w1 = codeText[0] ;
SrcTf.w2 = codeText[1] ;
DestTf.w1 = codeText[2] ;
DestTf.w2 = NULL;
}
xlfdPopupDialog( cpyDialog );
}
static void
create_xlfd()
{
int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
FalFontData key;
FalFontDataList *fontlist;
FalFontData *f;
int i;
if (udc_flag == True) {
key.cd_set = udc_val;
mask |= FAL_FONT_MASK_CODE_SET;
}
if (sty_flag == True) {
key.style.name = sty_val;
mask |= FAL_FONT_MASK_STYLE_NAME;
}
if (wls_flag == True) {
key.size.w = wls_val;
mask |= FAL_FONT_MASK_SIZE_W;
}
if (hls_flag == True) {
key.size.h = hls_val;
mask |= FAL_FONT_MASK_SIZE_H;
}
xlf_count = 0;
if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
return;
}
if(fontlist->num == 0) {
FalFreeFontList(fontlist);
return;
}
xlf = (XmString *)XtMalloc(sizeof(XmString) * fontlist->num);
for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) {
xlf[xlf_count++] = XmStringCreateLocalized(f->xlfdname);
}
FalFreeFontList(fontlist);
}
static void
udc_call(w)
Widget w;
{
XmString label;
char *moji;
XtVaGetValues(w, XmNlabelString, &label, NULL);
moji = _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
if(strncmp(moji, "*", 1) == 0) {
udc_flag = False;
} else if(strcmp(moji, CS0) == 0) {
udc_val = FAL_FONT_CS0;
udc_flag = True;
} else if(strcmp(moji, CS1) == 0) {
udc_val = FAL_FONT_CS1;
udc_flag = True;
} else if(strcmp(moji, CS2) == 0) {
udc_val = FAL_FONT_CS2;
udc_flag = True;
} else if(strcmp(moji, CS3) == 0) {
udc_val = FAL_FONT_CS3;
udc_flag = True;
} else {
udc_flag = False;
}
XtFree(moji);
create_xlfd();
XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
}
static void
sty_call(w)
Widget w;
{
XmString label;
char *moji;
if (sty_val) {
XtFree(sty_val);
sty_val = NULL;
}
XtVaGetValues(w, XmNlabelString, &label, NULL);
moji = _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
if(strncmp(moji, "*", 1) == 0) {
sty_flag = False;
}
else {
sty_val = XtMalloc(sizeof(char) * (strlen(moji) + 1));
strcpy(sty_val, moji);
sty_flag = True;
}
XtFree(moji);
create_xlfd();
XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
}
static void
wls_call(w)
Widget w;
{
XmString label;
char *moji;
XtVaGetValues(w, XmNlabelString, &label, NULL);
moji = _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
if(strncmp(moji, "*", 1) == 0) {
wls_flag = False;
}
else {
wls_val = atoi(moji);
wls_flag = True;
}
XmStringFree(label);
XtFree(moji);
create_xlfd();
XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
}
static void
hls_call(w)
Widget w;
{
XmString label;
char *moji;
XtVaGetValues(w, XmNlabelString, &label, NULL);
moji = _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
if(strncmp(moji, "*", 1) == 0) {
hls_flag = False;
}
else {
hls_val = atoi(moji);
hls_flag = True;
}
XmStringFree(label);
XtFree(moji);
create_xlfd();
XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL);
}
static void
button_set1()
{
int i, j;
int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
FalFontData key;
FalFontDataList *fontlist;
FalFontData *f;
Boolean found;
if (sty_flag == True) {
key.style.name = sty_val;
mask |= FAL_FONT_MASK_STYLE_NAME;
}
if (wls_flag == True) {
key.size.w = wls_val;
mask |= FAL_FONT_MASK_SIZE_W;
}
if (hls_flag == True) {
key.size.h = hls_val;
mask |= FAL_FONT_MASK_SIZE_H;
}
if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
for (j=0; j<udc_count; j++)
XtSetSensitive(button1[j], False);
return;
}
if(fontlist->num == 0) {
FalFreeFontList(fontlist);
for (j=0; j<udc_count; j++)
XtSetSensitive(button1[j], False);
return;
}
for (j=0; j<udc_count; j++) {
for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
if(udc[j] == f->cd_set) {
found = True;
break;
}
}
if(found == False)
XtSetSensitive(button1[j], False);
else
XtSetSensitive(button1[j], True);
}
FalFreeFontList(fontlist);
}
static void
button_set2()
{
int i, j;
int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
FalFontData key;
FalFontDataList *fontlist;
FalFontData *f;
Boolean found;
if (udc_flag == True) {
key.cd_set = udc_val;
mask |= FAL_FONT_MASK_CODE_SET;
}
if (wls_flag == True) {
key.size.w = wls_val;
mask |= FAL_FONT_MASK_SIZE_W;
}
if (hls_flag == True) {
key.size.h = hls_val;
mask |= FAL_FONT_MASK_SIZE_H;
}
if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
for (j=0; j<sty_count; j++)
XtSetSensitive(button2[j], False);
return;
}
if(fontlist->num == 0) {
for (j=0; j<sty_count; j++)
XtSetSensitive(button2[j], False);
FalFreeFontList(fontlist);
return;
}
for (j=0; j<sty_count; j++) {
for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
if(strcmp(sty[j], f->style.name) == 0) {
found = True;
break;
}
}
if(found == False)
XtSetSensitive(button2[j], False);
else
XtSetSensitive(button2[j], True);
}
FalFreeFontList(fontlist);
}
static void
button_set3()
{
int i, j;
int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
FalFontData key;
FalFontDataList *fontlist;
FalFontData *f;
Boolean found;
if (udc_flag == True) {
key.cd_set = udc_val;
mask |= FAL_FONT_MASK_CODE_SET;
}
if (sty_flag == True) {
key.style.name = sty_val;
mask |= FAL_FONT_MASK_STYLE_NAME;
}
if (hls_flag == True) {
key.size.h = hls_val;
mask |= FAL_FONT_MASK_SIZE_H;
}
if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
for (j=0; j<wls_count; j++)
XtSetSensitive(button3[j], False);
return;
}
if(fontlist->num == 0) {
for (j=0; j<wls_count; j++)
XtSetSensitive(button3[j], False);
FalFreeFontList(fontlist);
return;
}
for (j=0; j<wls_count; j++) {
for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
if(wls[j] == f->size.w) {
found = True;
break;
}
}
if(found == False)
XtSetSensitive(button3[j], False);
else
XtSetSensitive(button3[j], True);
}
FalFreeFontList(fontlist);
}
static void
button_set4()
{
int i, j;
int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
FalFontData key;
FalFontDataList *fontlist;
FalFontData *f;
Boolean found;
if (udc_flag == True) {
key.cd_set = udc_val;
mask |= FAL_FONT_MASK_CODE_SET;
}
if (sty_flag == True) {
key.style.name = sty_val;
mask |= FAL_FONT_MASK_STYLE_NAME;
}
if (wls_flag == True) {
key.size.w = wls_val;
mask |= FAL_FONT_MASK_SIZE_W;
}
if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
for (j=0; j<hls_count; j++)
XtSetSensitive(button4[j], False);
return;
}
if(fontlist->num == 0) {
for (j=0; j<hls_count; j++)
XtSetSensitive(button4[j], False);
FalFreeFontList(fontlist);
return;
}
for (j=0; j<hls_count; j++) {
for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) {
if(hls[j] == f->size.h) {
found = True;
break;
}
}
if (found == False)
XtSetSensitive(button4[j], False);
else
XtSetSensitive(button4[j], True);
}
FalFreeFontList(fontlist);
}
static void
font_init()
{
FalFontDataList *fontlist;
FalFontData *f;
Boolean found;
int i, j;
char tmp[16];
char err[128];
Widget button;
extern void data_sort();
extern void Error_message();
xlf_count = udc_count = sty_count = wls_count = hls_count = 0;
if (FalGetFontList(NULL, FAL_FONT_MASK_DEFINED |
FAL_FONT_MASK_UNDEFINED, &fontlist) == FAL_ERROR) {
snprintf(err, sizeof(err), "%s", FAL_ERROR_STR);
Error_message((Widget)NULL, err);
return;
}
if(fontlist->num == 0) {
FalFreeFontList(fontlist);
snprintf(err, sizeof(err), "%s", resource.mn_no_font);
Error_message((Widget)NULL, err);
return;
}
xlf = (XmString *)XtMalloc(sizeof(XmString) * fontlist->num);
udc = (int *)XtMalloc(sizeof(int) * fontlist->num);
sty = (char **)XtMalloc(sizeof(char *) * fontlist->num);
wls = (int *)XtMalloc(sizeof(int) * fontlist->num);
hls = (int *)XtMalloc(sizeof(int) * fontlist->num);
for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) {
xlf[xlf_count++] = XmStringCreateLocalized(f->xlfdname);
for (j=0,found=False; j<udc_count; j++) {
if(udc[j] == f->cd_set) {
found=True;
break;
}
}
if (found == False) {
udc[udc_count++] = f->cd_set;
}
for (j=0,found=False; j<sty_count; j++) {
if(strcmp(sty[j], f->style.name) == 0) {
found=True;
break;
}
}
if (found == False) {
sty[sty_count] = XtMalloc(sizeof(char) * (strlen(f->style.name) + 1));
strcpy(sty[sty_count++], f->style.name);
}
if (f->size.w != -1) {
for (j=0,found=False; j<wls_count; j++) {
if(wls[j] == f->size.w) {
found=True;
break;
}
}
if (found == False) {
wls[wls_count++] = f->size.w;
}
}
for (j=0,found=False; j<hls_count; j++) {
if(hls[j] == f->size.h) {
found=True;
break;
}
}
if (found == False) {
hls[hls_count++] = f->size.h;
}
}
FalFreeFontList(fontlist);
data_sort(udc, udc_count);
data_sort(wls, wls_count);
data_sort(hls, hls_count);
button1 = (Widget *) XtMalloc(sizeof(Widget) * udc_count);
button2 = (Widget *) XtMalloc(sizeof(Widget) * sty_count);
button3 = (Widget *) XtMalloc(sizeof(Widget) * wls_count);
button4 = (Widget *) XtMalloc(sizeof(Widget) * hls_count);
button = XmCreatePushButton(pull1, "*", NULL, 0);
XtManageChild(button);
XtAddCallback(button, XmNactivateCallback,
(XtCallbackProc)udc_call, NULL);
for (i=0; i < udc_count; i++) {
if(udc[i] == FAL_FONT_CS0)
snprintf(tmp, sizeof(tmp), "%s", CS0);
else if(udc[i] == FAL_FONT_CS1)
snprintf(tmp, sizeof(tmp), "%s", CS1);
else if(udc[i] == FAL_FONT_CS2)
snprintf(tmp, sizeof(tmp), "%s", CS2);
else if(udc[i] == FAL_FONT_CS3)
snprintf(tmp, sizeof(tmp), "%s", CS3);
else
snprintf(tmp, sizeof(tmp), "Codeset %x?", udc[i]);
button1[i] = XmCreatePushButton(pull1, tmp, NULL, 0);
XtManageChild(button1[i]);
XtAddCallback(button1[i], XmNactivateCallback,
(XtCallbackProc)udc_call, NULL);
}
button = XmCreatePushButton(pull2, "*", NULL, 0);
XtManageChild(button);
XtAddCallback(button, XmNactivateCallback,
(XtCallbackProc)sty_call, NULL);
for (i=0; i < sty_count; i++) {
button2[i] = XmCreatePushButton(pull2, sty[i], NULL, 0);
XtManageChild(button2[i]);
XtAddCallback(button2[i], XmNactivateCallback,
(XtCallbackProc)sty_call, NULL);
}
button = XmCreatePushButton(pull3, "*", NULL, 0);
XtManageChild(button);
XtAddCallback(button, XmNactivateCallback,
(XtCallbackProc)wls_call, NULL);
for (i=0; i < wls_count; i++) {
snprintf(tmp, sizeof(tmp), "%d", wls[i]);
button3[i] = XmCreatePushButton(pull3, tmp, NULL, 0);
XtManageChild(button3[i]);
XtAddCallback(button3[i], XmNactivateCallback,
(XtCallbackProc)wls_call, NULL);
}
button = XmCreatePushButton(pull4, "*", NULL, 0);
XtManageChild(button);
XtAddCallback(button, XmNactivateCallback,
(XtCallbackProc)hls_call, NULL);
for (i=0; i < hls_count; i++) {
snprintf(tmp, sizeof(tmp), "%d", hls[i]);
button4[i] = XmCreatePushButton(pull4, tmp, NULL, 0);
XtManageChild(button4[i]);
XtAddCallback(button4[i], XmNactivateCallback,
(XtCallbackProc)hls_call, NULL);
}
}
/*ARGSUSED*/
static void
arrow_change(w, wid)
Widget w;
Widget wid;
{
if (XtIsSensitive(wid)) {
XtSetSensitive(wid, False);
} else {
XtSetSensitive(wid, True);
}
}
static void
focus(w)
Widget w;
{
focus_widget = w;
}
static void
code_input()
{
char *str;
XmStringTable st;
extern void CodeWindow();
XtVaGetValues(scrolllist, XmNselectedItems, &st, NULL);
if( st == NULL ){
return ;
}
str = _XmStringUngenerate(st[0], NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
CodeWindow(focus_widget, str, True);
}
static void
code_input2()
{
extern void CodeWindow();
CodeWindow(codeText[2], fullFontData.xlfdname, False);
}
static Widget
CreateCopyXLFD( top )
Widget top ;
{
int n;
Arg args[16];
XmString xms, xms1, xms2 ;
Widget frame, row, label1, row1, row2, row3, row4, row5;
Widget sep, cas1, cas2, cas3, cas4;
Widget arrow, code;
XmString str;
extern Pixmap arrow_pix;
Display *disp;
Window root;
Pixmap mask;
XpmAttributes attr;
udc_flag = sty_flag = wls_flag = hls_flag = False;
/*
* create base window
*/
n = 0 ;
XtSetArg( args[n], XmNautoUnmanage, False ) ; n++ ;
xms = XmStringCreateLocalized( resource.l_copy ) ;
XtSetArg( args[n], XmNokLabelString, xms ) ; n++ ;
xms1 = XmStringCreateLocalized( resource.l_overlay ) ;
XtSetArg( args[n], XmNcancelLabelString, xms1 ) ; n++ ;
xms2 = XmStringCreateLocalized( resource.quit_label) ;
XtSetArg( args[n], XmNhelpLabelString, xms2 ) ; n++ ;
XtSetArg( args[n], XmNnoResize, True ) ; n++ ;
XtSetArg( args[n], XmNminimizeButtons, True ) ; n++ ;
XtSetArg( args[n], XmNtitle, resource.l_copy_title) ; n++ ;
cpyDialog = XmCreateTemplateDialog( top, "copy_dialog", args, n );
XmStringFree( xms ) ;
XmStringFree( xms1 ) ;
XmStringFree( xms2 ) ;
n = 0;
pull1 = XmCreatePulldownMenu(top, "pull", args, n);
pull2 = XmCreatePulldownMenu(top, "pull", args, n);
pull3 = XmCreatePulldownMenu(top, "pull", args, n);
pull4 = XmCreatePulldownMenu(top, "pull", args, n);
n = 0 ;
row = XmCreateRowColumn( cpyDialog, "BaseForm", args, n );
XtManageChild( row );
n = 0;
frame = XmCreateFrame( row, "frame", args, n);
XtManageChild( frame );
n = 0 ;
row1 = XmCreateRowColumn( frame, "row", args, n );
XtManageChild( row1 );
n = 0;
str = XmStringCreateLocalized(resource.l_selectitem) ;
XtSetArg(args[n], XmNlabelString, str); n++;
label1 = XmCreateLabel( row1, "SelectItems", args, n);
XtManageChild( label1 );
XmStringFree(str);
n = 0 ;
row2 = XmCreateRowColumn( row1, "row", args, n );
XtManageChild( row2 );
n = 0 ;
str = XmStringCreateLocalized(resource.l_codeset) ;
XtSetArg(args[n], XmNlabelString, str); n++;
XtSetArg(args[n], XmNsubMenuId, pull1); n++;
cas1 = XmCreateOptionMenu( row2, "CodeSet", args, n );
XtManageChild( cas1 );
XtAddCallback(XmOptionButtonGadget(cas1), XmNcascadingCallback,
(XtCallbackProc)button_set1, NULL);
XmStringFree(str);
n = 0 ;
str = XmStringCreateLocalized(resource.l_style) ;
XtSetArg(args[n], XmNlabelString, str); n++;
XtSetArg(args[n], XmNsubMenuId, pull2); n++;
cas2 = XmCreateOptionMenu( row2, "Style", args, n );
XtAddCallback(XmOptionButtonGadget(cas2), XmNcascadingCallback,
(XtCallbackProc)button_set2, NULL);
XtManageChild( cas2 );
XmStringFree(str);
n = 0 ;
str = XmStringCreateLocalized(resource.l_width) ;
XtSetArg(args[n], XmNlabelString, str); n++;
XtSetArg(args[n], XmNsubMenuId, pull3); n++;
cas3 = XmCreateOptionMenu( row2, "Width", args, n );
XtManageChild( cas3 );
XtAddCallback(XmOptionButtonGadget(cas3), XmNcascadingCallback,
(XtCallbackProc)button_set3, NULL);
XmStringFree(str);
n = 0 ;
str = XmStringCreateLocalized(resource.l_height) ;
XtSetArg(args[n], XmNlabelString, str); n++;
XtSetArg(args[n], XmNsubMenuId, pull4); n++;
cas4 = XmCreateOptionMenu( row2, "Height", args, n );
XtManageChild( cas4 );
XtAddCallback(XmOptionButtonGadget(cas4), XmNcascadingCallback,
(XtCallbackProc)button_set4, NULL);
XmStringFree(str);
font_init();
n = 0;
XtSetArg(args[n], XmNvisibleItemCount, 10) ; n++ ;
XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT) ; n++ ;
XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC) ; n++ ;
XtSetArg(args[n], XmNselectionPolicy, XmSINGLE_SELECT) ; n++ ;
XtSetArg(args[n], XmNitems, xlf) ; n++ ;
XtSetArg(args[n], XmNitemCount, xlf_count) ; n++ ;
scrolllist = XmCreateScrolledList(row, "scrolllist", args, n);
XtManageChild(scrolllist);
n = 0;
sep = XmCreateSeparator(row, "sep", args, n);
XtManageChild(sep);
n = 0 ;
row3 = XmCreateRowColumn( row, "row", args, n );
XtManageChild( row3 );
if (! arrow_pix) {
disp = XtDisplay(row);
root = DefaultRootWindow(disp);
attr.valuemask = 0;
ReadXpm(disp, root, arrow_pm, &arrow_pix, &mask, &attr);
}
n = 0 ;
XtSetArg(args[n], XmNorientation, XmHORIZONTAL) ; n++ ;
row4 = XmCreateRowColumn( row3, "row", args, n );
XtManageChild( row4 );
xms = XmStringCreateLocalized(resource.l_copy_src_code);
n = 0;
XtSetArg(args[n], XmNlabelString, xms); n++ ;
codeLabel[0] = XmCreateLabel(row4 , "copylabel", args, n);
XtManageChild(codeLabel[0]);
XmStringFree( xms ) ;
n = 0;
XtSetArg(args[n], XmNcolumns, 4); n++;
XtSetArg(args[n], XmNmaxLength, 4); n++;
XtSetArg(args[n], XmNeditable, True); n++;
XtSetArg(args[n], XmNcursorPositionVisible, True); n++;
focus_widget = codeText[0] = XmCreateText(row4 , "copytext",
args, n);
XtManageChild(codeText[0]);
XtAddCallback(codeText[0], XmNfocusCallback, (XtCallbackProc)focus, NULL);
n = 0;
XtSetArg(args[n], XmNlabelPixmap, arrow_pix); n++;
XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++;
XtSetArg(args[n], XmNindicatorOn, False); n++;
XtSetArg(args[n], XmNshadowThickness, 2); n++;
XtSetArg(args[n], XmNfillOnSelect, False); n++;
XtSetArg(args[n], XmNhighlightThickness, 0); n++;
arrow = XmCreateToggleButton(row4, "arrow", args, n);
XtManageChild(arrow);
n = 0;
XtSetArg(args[n], XmNcolumns, 4); n++;
XtSetArg(args[n], XmNmaxLength, 4); n++;
XtSetArg(args[n], XmNeditable, True); n++;
XtSetArg(args[n], XmNcursorPositionVisible, True); n++;
codeText[1] = XmCreateText(row4 , "copytext", args, n);
XtManageChild(codeText[1]);
XtSetSensitive(codeText[1], False);
XtAddCallback(codeText[1], XmNfocusCallback, (XtCallbackProc)focus, NULL);
XtAddCallback(arrow, XmNvalueChangedCallback,
(XtCallbackProc)arrow_change, (XtPointer)codeText[1]);
n = 0;
xms = XmStringCreateLocalized(resource.code) ;
XtSetArg(args[n], XmNlabelString, xms); n++;
XtSetArg(args[n], XmNhighlightThickness, 0); n++;
code = XmCreatePushButton(row4, "Code", args, n);
XtManageChild(code);
XmStringFree(xms);
XtAddCallback(code, XmNactivateCallback,
(XtCallbackProc)code_input, (XtPointer)NULL);
n = 0 ;
XtSetArg(args[n], XmNorientation, XmHORIZONTAL) ; n++ ;
row5 = XmCreateRowColumn( row3, "row", args, n );
XtManageChild( row5 );
xms = XmStringCreateLocalized(resource.l_copy_dest_code);
n = 0;
XtSetArg(args[n], XmNlabelString, xms); n++ ;
codeLabel[1] = XmCreateLabel(row5 , "copylabel", args, n);
XtManageChild(codeLabel[1]);
XmStringFree( xms ) ;
n = 0;
XtSetArg(args[n], XmNcolumns, 4); n++;
XtSetArg(args[n], XmNmaxLength, 4); n++;
XtSetArg(args[n], XmNeditable, True); n++;
XtSetArg(args[n], XmNcursorPositionVisible, True); n++;
codeText[2] = XmCreateText(row5 , "copytext", args, n);
XtManageChild(codeText[2]);
n = 0;
xms = XmStringCreateLocalized(resource.code) ;
XtSetArg(args[n], XmNlabelString, xms); n++;
XtSetArg(args[n], XmNhighlightThickness, 0); n++;
code = XmCreatePushButton(row5, "Code", args, n);
XtManageChild(code);
XmStringFree(xms);
XtAddCallback(code, XmNactivateCallback,
(XtCallbackProc)code_input2, (XtPointer)NULL);
return( cpyDialog ) ;
}

View file

@ -0,0 +1,27 @@
XCOMM $XConsortium: Imakefile /main/8 1996/09/09 11:19:28 drk $
DESTDIR = $(CDE_INSTALLATION_TOP)
BINDIR = /bin
OPT1 = -DDEFAULT_CODESET='"'3'"'
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"'
DEFINES = $(OPT1) $(OPT2) $(OPT3)
INCLUDES = -I../include -I../libfal/include
LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) -lc
SRCS = addcpf.c
OBJS = addcpf.o
SHLIBDIR = ../../../usr/bin
ComplexProgramTarget(dtaddcpf)

View file

@ -0,0 +1,957 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: addcpf.c /main/9 1996/11/08 02:00:29 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdio.h>
#include <locale.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifndef SVR4
#if !defined( SYSV )
#include <sys/resource.h>
#endif
#include <sys/wait.h>
#else
#include <wait.h>
#endif
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include "bdfgpf.h"
#include <X11/Xmd.h>
#include <X11/Xproto.h>
#include "fontstruct.h"
#include "FaLib.h"
#include "snfstruct.h"
#include "udcutil.h"
#include <errno.h>
static int rw_init() ;
static int readSnf() ;
static int readSnf_with_init() ;
static int readSnfHeader() ;
static int readBdfHeaderAndPut() ;
static int mergePtn() ;
static int ModifyPtn() ;
static int InsertPtn() ;
static int writeSnf() ;
static void put_error_and_exit();
static void put_help();
static int readBdfToMemory_with_init() ;
extern int fal_glyph_to_code() ;
static struct ptobhead WriteSnf;
static char *targ_file = NULL; /* UDC_file_name */
static char *com = NULL; /* command_name */
static char *spacing ;
static char *char_set ;
static char *util_locale ;
static pid_t gtob_pid = 0;
static pid_t btop_pid = 0;
#if defined( SVR4 ) || defined( SYSV ) || defined(CSRG_BASED) || defined(__linux__)
static int chld_stat ;
#else
static union wait chld_stat ;
#endif
static void
sigint_out()
{
if (WriteSnf.out_file) {
Unlink_Tmpfile( WriteSnf.out_file, com );
}
exit( 0 );
}
main( argc, argv )
int argc;
char *argv[];
{
int code_area , init, modify, help, no_infile, no_style;
int fupd = 0 ;
int init_all, rtn, i;
#ifndef ROOT_ONLY
int exit_stat;
#endif
struct btophead ReadSnf; /* output file (GPF) */
struct ptobhead ReadGpf; /* input file (CPF) */
struct stat statbuf;
char snf_file[BUFSIZE] ;
char buf[BUFSIZE];
char *style ;
char *xlfdname, *cbuf ;
int chk_fd;
FalGlyphRegion *gr ;
int num_gr ;
char *ep ;
int code_no;
char *codeset = DEFAULT_CODESET;
if( (util_locale = (char *)getenv( "LANG" )) == NULL ){
util_locale = "C" ;
}
ReadSnf.in_file = ReadGpf.in_file = WriteSnf.out_file = NULL;
com = argv[0];
COMM_SETDEFAULTSTYLE( style ) ;
cbuf = xlfdname = ep = '\0' ;
gr = NULL ;
num_gr = 0 ;
spacing = char_set = NULL ;
if (!( bdftopcf = get_cmd_path( getenv( "PATH" ), BDFTOPCF_CMD ))) {
bdftopcf = BDFTOPCF;
}
if (!( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ))) {
oakgtobdf = SNFTOBDF;
}
if (!( bdftosnf = get_cmd_path( getenv( "PATH" ), BDFTOSNF_CMD ))) {
bdftosnf = BDFTOSNF;
}
code_area = NORMAL;
init = modify = help = no_infile = no_style = init_all = 0;
for ( i = 1; i < argc; i++ ) {
if ( !strcmp( argv[i], "-g" ) ) {
if ( ( i < argc-1) && (*argv[i+1] != '-' ) ) {
ReadSnf.in_file = argv[++i];
}
} else if ( !strcmp( argv[i], "-p" ) ) {
if ( (i < argc-1) && (*argv[i+1] != '-') ){
ReadGpf.in_file = argv[++i];
} else {
no_infile = 1;
}
} else if ( !strcmp( argv[i], "-init" ) ) {
init = 1;
} else if ( !strcmp( argv[i], "-modify" ) ) {
modify = 1;
} else if ( !strcmp( argv[i], "-system" ) ) {
code_area |= SYSTM;
} else if ( !strcmp( argv[i], "-help" ) ) {
help = 1;
} else if ( !strcmp( argv[i], "-style" ) ) {
if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ){
style = argv[++i];
} else {
no_style = 1;
}
} else if ( !strcmp( argv[i], "-codeset" ) ) {
if ( ( i < argc - 1 ) && ( *argv[i+1] != '-' )){
codeset = argv[++i];
COMM_SET_CODESET( codeset, code_area ) ;
}
} else if ( !strcmp( argv[i], "-xlfd" ) ) {
if ( i < argc - 1 ){
xlfdname = argv[++i];
}
} else if ( COMM_SBOPT_STRCMP( argv, i ) ) {
COMM_SBOPT_SETSBOPT( code_area ) ;
} else if ( !strcmp( argv[i], "-f" ) ) {
fupd = 1;
} else {
put_help(argv[0]);
exit( 1 );
}
}
/* help_message */
if ( help == 1 ) {
put_help( argv[0] );
exit( 0 );
}
COMM_SBOPT_CHECKSBOPT( argv[0], code_area ) ;
if ( no_infile ) {
USAGE1("%s : The input file name following -p option cannot be omitted.\n", argv[0] );
exit( 1 );
}
ep = (char *)strchr( codeset, '\0' ) ;
code_no = (int)strtol( codeset, &cbuf, 10 ) ;
if ( cbuf == codeset || cbuf != ep ) {
USAGE2("%s : The codeset number is not right.¡Ê %s ¡Ë\n",
argv[0], codeset );
exit( 1 );
}
if ( no_style ) {
USAGE1("%s : The style is not specified.\n", argv[0] ) ;
exit( 1 );
}
if ( ReadSnf.in_file == NULL && xlfdname == NULL ) {
if ( code_area & SYSTM ) {
USAGE1("%s : The GPF output file name cannot be omitted.\n", argv[0] );
} else { /* string of charcter size */
USAGE1("%s : The character size specification cannot be omitted.\n", argv[0] );
}
exit( 1 );
}
/* open GPF file */
if ( !(code_area & SYSTM) ) {
if( xlfdname ) {
if ( GetUdcFileName( argv[0], code_no, xlfdname, snf_file ) ) {
USAGE1("%s : Failed to get font file. Terminates abnormally.\n", argv[0]);
exit( 1 );
}
ReadSnf.in_file = snf_file ;
} else {
switch ( GetFileName( argv[0], ReadSnf.in_file, style, code_no, snf_file ) ) {
case 0:
ReadSnf.in_file = snf_file;
break;
case -1:
exit(1);
default:
USAGE1("%s : The font file name cannot be obtained. Terminates abnormally.\n", argv[0]);
exit(1);
}
}
if ( GetUdcRegion( argv[0], code_no, ReadSnf.in_file, &num_gr, &gr ) ) {
USAGE1("%s : This font cannot get UDC code region. Terminates abnormally.\n", argv[0]);
exit( 1 );
}
} else {
num_gr = 1 ;
if( (gr = (FalGlyphRegion *)malloc( sizeof(FalGlyphRegion) * num_gr )) == NULL ) {
USAGE1("%s : malloc error. Terminates abnormally.\n", argv[0]);
exit( 1 );
}
gr[0].start = MIN_CODE ;
gr[0].end = MAX_CODE ;
}
/*
* refuse proportional fonts
*/
if ( GetUdcFontName( ReadSnf.in_file, NULL, &xlfdname ) ) {
USAGE1("%s : This font cannot get XLFD. Terminates abnormally.\n", argv[0]);
exit( 1 );
}
GETSPACINGSTR( spacing, xlfdname ) ;
if ( !strcmp( "p", spacing ) || !strcmp( "P", spacing ) ) {
USAGE2("%s cannot edit proportional fonts.(SPACING \"%s\")\n", argv[0], spacing );
exit( 1 );
}
GETCHARSETSTR( char_set, xlfdname ) ;
/* get ReadSnf.in_file */
if ((targ_file = GetRealFileName( ReadSnf.in_file )) == NULL){
USAGE2("%s : It was not possible to refer to the substance of the font file. \"%s\"\n", argv[0], ReadSnf.in_file);
exit(1);
}
WriteSnf.snf_file = targ_file;
if ( ( chk_fd = open( targ_file, O_RDWR ) ) < 0 ) {
USAGE2("%s : The font file of substance \"%s\" cannot be opened.\n", argv[0] , targ_file );
exit( 1 );
}
if( !fupd ){
if ( isLock( chk_fd ) == 1 ) {
USAGE1("%s : Editing by other application. \n", argv[0] );
close( chk_fd );
exit( 1 );
}
}
close( chk_fd );
/* We read whole characters from gpf file. */
ReadSnf.start_code = MIN_CODE;
ReadSnf.end_code = MAX_CODE;
ReadSnf.code_category = ALL_CODE;
switch ( code_area ) {
case SYSTM:
ReadGpf.start_code = MIN_CODE;
ReadGpf.end_code = MAX_CODE;
ReadGpf.code_category = ALL_CODE;
break;
case SYSTM | CDSET1 :
ReadGpf.start_code = MIN_CODE;
ReadGpf.end_code = MAX_CODE;
ReadGpf.code_category = ALL_CODE;
break;
default:
COMM_SBFNT_SETUDCAREA( argv[0], ReadGpf, char_set, code_area, num_gr, gr ) ;
}
COMM_SBFNT_CONVCODETOGI( char_set, ReadSnf ) ;
COMM_SBFNT_CONVCODETOGI( char_set, ReadGpf ) ;
signal( SIGHUP , (void(*)())sigint_out );
signal( SIGINT , (void(*)())sigint_out );
signal( SIGQUIT, (void(*)())sigint_out );
signal( SIGTERM, (void(*)())sigint_out );
/*
* rw_init()
*
* GPFTOBDF, BDFTOGPF
*
* (ReadSnf.in_file) --> GPFTOBDF ==H
* H
* dtaddcpf <-- (ReadGpf.in_file)
* H
* (WriteSnf.out_file) <-- BDFTOGPF ==H
*
*/
if ( rtn = rw_init( &ReadGpf, &ReadSnf, &WriteSnf, init_all ) ) {
if ( WriteSnf.out_file ) {
Unlink_Tmpfile( WriteSnf.out_file, argv[0] );
}
put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, rtn, argv[0] );
}
if ( rtn = ReadGpfHeader( &ReadGpf, buf ) ) {
if ( WriteSnf.out_file ) {
Unlink_Tmpfile( WriteSnf.out_file, argv[0] );
}
put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, rtn, argv[0] );
}
if ( init_all ) {
/* We read only header of gpf file. */
rtn = readSnfHeader( &ReadGpf, &ReadSnf, &WriteSnf, buf );
} else if ( init ) {
/* We read characters in UDC area from gpf file. */
rtn = readSnf_with_init( &ReadGpf, &ReadSnf, &WriteSnf,
init, buf, num_gr, gr );
} else {
/* We read whole characters from gpf file. */
rtn = readSnf( &ReadGpf, &ReadSnf, &WriteSnf, buf );
}
if ( rtn ) {
if ( WriteSnf.out_file ) {
Unlink_Tmpfile( WriteSnf.out_file, argv[0] );
}
put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, rtn, argv[0] );
}
fclose( ReadSnf.input );
WaitID( gtob_pid, chld_stat ) ;
if ( ( rtn = mergePtn( argv[0], &ReadGpf, &ReadSnf, buf, code_area, modify, argv[0], num_gr, gr, code_no ) ) ) {
if ( WriteSnf.out_file ) {
Unlink_Tmpfile( WriteSnf.out_file, argv[0] );
}
put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, rtn, argv[0] );
}
/* write SNF output file */
if ( ( rtn = writeSnf( &ReadSnf, &WriteSnf ) ) ) {
if ( WriteSnf.out_file ) {
Unlink_Tmpfile( WriteSnf.out_file, argv[0] );
}
put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, rtn, argv[0] );
}
#ifdef ROOT_ONLY
if ( pclose( WriteSnf.output ) ) {
Unlink_Tmpfile( WriteSnf.out_file, argv[0] );
put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, PCLOSE_ERROR, argv[0] );
}
#else
fclose( WriteSnf.output );
WaitID( btop_pid, chld_stat ) ;
#if !defined( SVR4 ) && !defined( SYSV ) && !defined(__FreeBSD__)
if ( !WIFEXITED(chld_stat) ) {
#else
if ( ! ( WIFEXITED(chld_stat) && !WEXITSTATUS(chld_stat) ) ) {
#endif
USAGE4("%s: The error occurred by %s (%08x). Cannot write %s\n",
argv[0], bdftopcf, chld_stat, WriteSnf.out_file);
Unlink_Tmpfile( WriteSnf.out_file, argv[0] );
put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf,
FATAL_ERROR, argv[0] );
}
#endif
signal( SIGHUP , SIG_IGN );
signal( SIGINT , SIG_IGN );
signal( SIGQUIT, SIG_IGN );
signal( SIGTERM, SIG_IGN );
if ( ( stat( WriteSnf.out_file, &statbuf ) ) ||
( statbuf.st_size == 0 )
) {
Unlink_Tmpfile( WriteSnf.out_file, argv[0] );
put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf,
BDF_WRITE, argv[0] );
}
if ( stat( WriteSnf.snf_file, &statbuf ) ) {
Unlink_Tmpfile( WriteSnf.out_file, argv[0] );
exit( 1 );
}
exit( Make_NewFefFile(
WriteSnf.snf_file, WriteSnf.out_file,
FONT_FILE_PARM,
(uid_t)statbuf.st_uid, (gid_t)statbuf.st_gid,
argv[0] ));
}
static
rw_init(r_gpf, r_snf, w_snf, init_all )
struct ptobhead *r_gpf;
struct btophead *r_snf;
struct ptobhead *w_snf;
int init_all;
{
FontInfoRec *finf;
int fd[2], snf_fd, permission;
char buf[BUFSIZE];
#ifdef ROOT_ONLY
char command[BUFSIZE], *ep ;
#else
int pfd[2], ofd;
#endif
if ( r_gpf->in_file == NULL ) {
r_gpf->input = stdin;
} else {
if ( ( r_gpf->input = fopen(r_gpf->in_file, "r")) == NULL ) {
return GPF_OPEN_IN;
}
}
/* SNF format */
if ( ChkPcfFontFile( w_snf->snf_file ) ) {
permission = 0 ;
if( (snf_fd = open( w_snf->snf_file, O_RDONLY ) ) >= 0 ) {
COMM_SNF_FILEVERSION( snf_fd, finf, buf, permission ) ;
if ( permission < 0 ) {
return BDF_INVAL;
}
} else {
return BDF_OPEN_IN;
}
}
if (pipe(fd) != 0) {
return PIPE_ERROR;
}
switch (gtob_pid = fork()) {
case 0:
close( fd[0] );
close( 1 );
if ( dup( fd[1] ) < 0 ) {
return DUP_ERROR;
}
close( fd[1] );
/* SNFTOBDF */
execl( oakgtobdf, oakgtobdf, r_snf->in_file, 0 );
return EXEC_ERROR;
case -1:
return FORK_ERROR;
default:
break;
}
close( fd[1] );
if ( ( r_snf->input = fdopen( fd[0], "r" ) ) == NULL ) {
return FDOPEN_ERROR;
}
if ( !( w_snf->out_file = GetTmpPath( targ_file ) ) ) {
return MKTMP_ERROR;
}
#ifdef ROOT_ONLY
if( ChkPcfFontFile( w_snf->snf_file ) == 0 ) {
sprintf(command, "%s > %s", bdftopcf, w_snf->out_file) ;
} else {
COMM_SNF_POPEN( permission, w_snf->snf_file, w_snf->out_file, ep, buf, command ) ;
}
if ((w_snf->output = popen(command, "w")) == NULL) {
return(POPEN_ERROR);
}
#else /* ROOT_ONLY */
if ( pipe( pfd ) != 0 ) {
return PIPE_ERROR;
}
switch (btop_pid = fork()) {
case 0:
if ( ( ofd = open( w_snf->out_file, O_WRONLY | O_CREAT, 0664 ) ) < 0 ) {
return BDF_OPEN_OUT;
}
close( 0 );
if ( dup(pfd[0]) < 0 ) {
return DUP_ERROR;
}
close( pfd[0] );
close( pfd[1] );
close( 1 );
if( dup( ofd ) < 0 ) {
close( ofd );
return DUP_ERROR;
}
close( ofd );
if ( ChkPcfFontFile( w_snf->snf_file ) == 0 ) {
execl( bdftopcf, bdftopcf, 0 );
return PCFFONTC_ERROR;
}
COMM_SNF_EXECLBDFTOSNF( permission, buf, w_snf->snf_file ) ;
return SNFFONTC_ERROR;
case -1:
return FORK_ERROR;
default:
break;
}
close( pfd[0] );
if ( ( w_snf->output = fdopen( pfd[1], "w" ) ) == NULL ) {
return FDOPEN_ERROR;
}
#endif /* ROOT_ONLY */
return 0;
}
static
readSnf(r_gpf, r_snf, w_snf, buf)
struct ptobhead *r_gpf;
struct btophead *r_snf;
struct ptobhead *w_snf;
char *buf;
{
int nchar, rtn;
if ( ( rtn = readBdfHeaderAndPut( r_snf, w_snf, buf ) ) ) {
return rtn;
}
nchar = r_snf->num_chars + r_gpf->num_chars;
if ( ( r_snf->code = (int *)malloc( sizeof(int) * nchar ) ) == NULL ) {
return MALLOC_ERROR;
}
if ( ( r_snf->ptn = (char **)malloc( sizeof(char *) * nchar ) ) == NULL ) {
return MALLOC_ERROR;
}
return ReadBdfToMemory( r_snf, buf ) ;
}
static
readSnf_with_init(r_gpf, r_snf, w_snf, init, buf, num_gr, gr )
struct ptobhead *r_gpf;
struct btophead *r_snf;
struct ptobhead *w_snf;
int init;
char *buf;
int num_gr ;
FalGlyphRegion *gr ;
{
int nchar, rtn;
if ( ( rtn = readBdfHeaderAndPut( r_snf, w_snf, buf ) ) ) {
return rtn;
}
nchar = r_snf->num_chars + r_gpf->num_chars;
if ( ( r_snf->code = (int *)malloc( sizeof(int) * nchar ) ) == NULL ) {
return MALLOC_ERROR;
}
if ( ( r_snf->ptn = (char **)malloc( sizeof(char *) * nchar ) ) == NULL ) {
return MALLOC_ERROR;
}
return readBdfToMemory_with_init( r_snf, init, buf, num_gr, gr ) ;
}
static
readSnfHeader(r_gpf, r_snf, w_snf, buf)
struct ptobhead *r_gpf;
struct btophead *r_snf;
struct ptobhead *w_snf;
char *buf;
{
int rtn;
if ( ( rtn = readBdfHeaderAndPut( r_snf, w_snf, buf ) ) ) {
return rtn;
}
r_snf->num_chars = 0;
if ( ( r_snf->code = (int *)malloc( sizeof(int) * r_gpf->num_chars ) ) == NULL ) {
return MALLOC_ERROR;
}
if ( ( r_snf->ptn = (char **)malloc( sizeof(char *) * r_gpf->num_chars ) ) == NULL ) {
return MALLOC_ERROR;
}
return 0;
}
static
readBdfHeaderAndPut(r_snf, w_snf, buf)
struct btophead *r_snf;
struct ptobhead *w_snf;
char *buf;
{
char *p;
int getstat = 0;
while ( 1 ) {
if ( fgets( buf, BUFSIZE, r_snf->input ) == NULL ) {
return BDF_INVAL;
}
p = buf;
SCAN_TO_NONSP( p )
if ( !strncmp( p, SIZE, strlen( SIZE ) ) ) {
if ( ( sscanf( p, "SIZE %f%d",
&(r_snf->bdf_point), &(r_snf->bdf_xdpi))) != 2 ) {
return BDF_INVAL;
}
fprintf( w_snf->output, "%s", buf );
getstat |= 0x01;
} else if ( !strncmp( p, FONTBOUNDINGBOX, strlen( FONTBOUNDINGBOX ) ) ) {
if ( ( sscanf( p, "FONTBOUNDINGBOX %d%d%d%d",
&(r_snf->bdf_width), &(r_snf->bdf_height),
&(r_snf->bdf_x), &(r_snf->bdf_y) )) != 4) {
return BDF_INVAL;
}
fprintf( w_snf->output, "%s", buf );
getstat |= 0x02;
} else if ( !strncmp( p, CHARS, strlen( CHARS ) ) ) {
if ( ( sscanf( p, "CHARS %d", &( r_snf->num_chars ) ) ) != 1 ) {
return BDF_INVAL;
}
getstat |= 0x04;
break;
} else {
fprintf( w_snf->output, "%s", buf );
}
}
if ( getstat != 0x07 ) {
return BDF_INVAL;
}
return 0;
}
#define DispCodePoint( command, char_set, gidx, dspcode, code_no, locale ){\
if( COMM_SBFNT_ISSBFNT( (char_set) ) ){\
dspcode = DISPCODEPOINT( (char_set), (gidx) ) ;\
}else{\
if( fal_glyph_to_code( (locale), (char_set), FALGETFALCODESET((code_no)), (gidx), &(dspcode) ) ){\
USAGE3("%s : Failed to convert glyph index into code point.(0x%x charset: %s)\n", (command), (gidx), (char_set) ) ;\
return -1 ;\
}\
}\
}
static
mergePtn(com, r_gpf, r_snf, buf, code_area, modify, prog_name, num_gr, gr, code_no)
char *com ;
struct ptobhead *r_gpf;
struct btophead *r_snf;
char *buf;
int code_area;
int modify;
char *prog_name;
int num_gr ;
FalGlyphRegion *gr ;
int code_no ;
{
int code, rtn, msize, i, j, dspcode;
char *ptn;
if ( ( r_gpf->p_width != r_snf->bdf_width )
|| ( r_gpf->p_height != r_snf->bdf_height )
) {
r_gpf->zoomf = 1;
msize = ( r_gpf->p_width + 7 ) / 8 * r_gpf->p_height;
if ( ( ptn = (char *)malloc( msize ) ) == NULL ) {
return MALLOC_ERROR;
}
r_gpf->ptn = &ptn;
} else {
r_gpf->zoomf = 0;
}
for ( i = 0; i < r_gpf->num_chars; i++ ) {
if ( ( rtn = GetGpfCode( r_gpf, buf, &code ) ) < 0 ) {
return rtn;
} else if ( rtn == FILE_END ) {
break;
}
if( COMM_SBFNT_ISSBFNT( char_set ) ) CONVGLYPHINDEX( code ) ;
if (
( code < r_gpf->start_code) || ( code > r_gpf->end_code )
||( !IN_CODE( r_gpf->code_category, SHIFT_ON( code ) ) )
||(
(r_gpf->code_category == ALL_CODE) &&
!( code_area & SYSTM ) &&
IsInRegion( code, num_gr, gr )
)
) {
DispCodePoint( com, char_set, code, dspcode, code_no, util_locale ) ;
USAGE2("%s : The font of a specified code cannot be added/changed \"0x%x\".\n", prog_name, dspcode );
fgets(buf, BUFSIZE, r_gpf->input);
continue;
}
for ( j = 0; j < r_snf->num_chars; j++ ) {
if ( r_snf->code[j] == code ) {
if ( !modify ) {
DispCodePoint( com, char_set, code, dspcode, code_no, util_locale ) ;
USAGE2("%s : The font has already been registered in a specified code. \"0x%x\"\n", prog_name, dspcode );
fgets( buf, BUFSIZE, r_gpf->input );
break;
}
if ( ( rtn = ModifyPtn( r_gpf, r_snf, buf, j ) ) ) {
return rtn;
}
break;
} else if ( r_snf->code[j] > code ) {
if ( ( rtn = InsertPtn( r_gpf, r_snf, buf, code, j ) ) ) {
return rtn;
}
break;
}
}
if ( j == r_snf->num_chars ) {
if ( ( rtn = InsertPtn( r_gpf, r_snf, buf, code, j ) ) ) {
return rtn;
}
}
}
return 0;
}
static
ModifyPtn( r_gpf, r_snf, buf, ix )
struct ptobhead *r_gpf;
struct btophead *r_snf;
char *buf;
int ix;
{
int mwidth, msize, rtn;
mwidth = ( r_gpf->p_width + 7 ) / 8;
msize = mwidth * r_gpf->p_height;
if ( r_gpf->zoomf ) {
if ( ( rtn = GetGpfPtn( r_gpf, buf, r_gpf->ptn[0], mwidth, msize ) ) ) {
return rtn;
}
if ( ( rtn = PtnZoom( r_snf->ptn[ix], r_gpf->ptn[0],
r_gpf->p_width, r_gpf->p_height,
r_snf->bdf_width, r_snf->bdf_height ) ) ) {
return rtn;
}
} else {
if ( ( rtn = GetGpfPtn( r_gpf, buf, r_snf->ptn[ix], mwidth, msize ) ) ) {
return rtn;
}
}
return 0;
}
static
InsertPtn( r_gpf, r_snf, buf, code, ix )
struct ptobhead *r_gpf;
struct btophead *r_snf;
char *buf;
int code;
int ix;
{
int mwidth, msize, rtn, i;
for ( i = r_snf->num_chars; i > ix; i-- ) {
r_snf->code[i] = r_snf->code[i-1];
r_snf->ptn[i] = r_snf->ptn[i-1];
}
r_snf->code[ix] = code;
r_snf->num_chars++;
mwidth = (r_snf->bdf_width + 7) / 8;
msize = mwidth * r_snf->bdf_height;
if ( ( r_snf->ptn[ix] = (char *)malloc( msize ) ) == NULL ) {
return MALLOC_ERROR;
}
if ( r_gpf->zoomf ) {
mwidth = (r_gpf->p_width + 7) / 8;
msize = mwidth * r_gpf->p_height;
if ( ( rtn = GetGpfPtn( r_gpf, buf, r_gpf->ptn[0], mwidth, msize ) ) ) {
return rtn;
}
if ( ( rtn = PtnZoom( r_snf->ptn[ix], r_gpf->ptn[0],
r_gpf->p_width, r_gpf->p_height,
r_snf->bdf_width, r_snf->bdf_height ) ) ) {
return rtn;
}
} else {
if ( ( rtn = GetGpfPtn( r_gpf, buf, r_snf->ptn[ix], mwidth, msize ) ) ) {
return rtn;
}
}
return(0);
}
static
writeSnf( r_snf, w_snf )
struct btophead *r_snf;
struct ptobhead *w_snf;
{
w_snf->zoomf = 0;
w_snf->num_chars = r_snf->num_chars;
w_snf->code = r_snf->code;
w_snf->ptn = r_snf->ptn;
w_snf->bdf_width = r_snf->bdf_width;
w_snf->bdf_height = r_snf->bdf_height;
w_snf->bdf_x = r_snf->bdf_x;
w_snf->bdf_y = r_snf->bdf_y;
w_snf->bdf_point = r_snf->bdf_point;
w_snf->bdf_xdpi = r_snf->bdf_xdpi;
return WritePtnToBdf( w_snf );
}
static void
put_error_and_exit(ptob_in, btop, ptob_out, er_no, prog_name)
struct ptobhead *ptob_in;
struct btophead *btop;
struct ptobhead *ptob_out;
int er_no;
char *prog_name;
{
ErrMsgTable_AndExit( er_no, ptob_in->in_file, ptob_out->out_file,
btop->in_file, NULL,
ptob_in->bdf_file,
prog_name
);
return;
}
static void
put_help( prog_name )
char *prog_name;
{
USAGE1("Usage: %s -xlfd xlfd_name \n", prog_name);
USAGE("\t\t[-g character_size][-p character_pattern_file_name]\n");
USAGE("\t\t[-style style]");
USAGE("\t\t[-init]\t(clear whole glyphs of gpf file that used for user defined characters)\n" ) ;
USAGE("\t\t[-modify]\t(permits the change of font)\n");
COMM_HELP_MSG ;
USAGE1("%s can insert or modify glyphs in the following code area.\n", prog_name);
USAGE("codeset \t\tcode area\n");
USAGE("----------------------------------------\n");
DispUdcCpArea() ;
USAGE("The xlfd name and character size may be obtained using dtlsgpf command.\n");
return;
}
static int
readBdfToMemory_with_init(head, init, buf, num_gr, gr )
struct btophead *head;
int init;
char *buf;
int num_gr ;
FalGlyphRegion *gr ;
{
int code, mwidth, num_char, bsize, rtn ;
char *ptn;
num_char = 0;
mwidth = (head->bdf_width + 7) / 8;
bsize = mwidth * head->bdf_height;
while(1) {
if ((rtn = GetBdfCode(head, buf, &code)) < 0) {
return(rtn); /* contain BDF_INVAL */
} else if (rtn == FILE_END) {
head->num_chars = num_char;
break;
}
rtn = IsInRegion( code, num_gr, gr ) ;
if (
( code < head->start_code) || ( code > head->end_code )
||( !IN_CODE( head->code_category, SHIFT_ON( code ) ) )
||(
(head->code_category == ALL_CODE)
&& ( (init)? ((rtn)?0:1) : ((rtn)?1:0) )
||( COMM_ISDEFAULTCHAR( code ) )
)
) {
continue;
}
head->code[num_char] = code;
if ((ptn = head->ptn[num_char++] =
(char *)malloc(bsize)) == NULL) {
return(MALLOC_ERROR);
}
if ((rtn = GetBdfPtn(head, buf, ptn, mwidth, bsize)) != 0) {
return(rtn);
}
}
return(0);
}

View file

@ -0,0 +1,24 @@
XCOMM $XConsortium: Imakefile /main/8 1996/09/09 11:19:34 drk $
DESTDIR = $(CDE_INSTALLATION_TOP)
BINDIR = /bin
OPT1 = -DDEFAULT_CODESET='"'3'"'
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"'
DEFINES = $(OPT1) $(OPT2) $(OPT3)
INCLUDES = -I../include -I../libfal/include
LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) -lc
SRCS = bdftocpf.c
OBJS = bdftocpf.o
ComplexProgramTarget(dtbdftocpf)

View file

@ -0,0 +1,292 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: bdftocpf.c /main/6 1996/11/08 02:01:17 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "bdfgpf.h"
#include "udcutil.h"
static void put_error();
static void put_help() ;
static void Usage() ;
static void sigint_out() ;
static int CnvBDFtoGPF() ;
static struct btophead Head;
static void
sigint_out()
{
if (Head.out_file) {
unlink(Head.out_file);
}
exit(0);
}
main(argc, argv)
int argc;
char *argv[];
{
int rtn, i;
char *GetTmpPath();
struct stat st;
for (i=1; i<argc; i++) {
if (!strcmp(argv[i], "-help")) {
put_help(argv[0]);
exit(0);
}
}
if (!(argc % 2)) {
Usage(argv[0]);
}
Head.in_file = Head.out_file = Head.text_file = NULL;
Head.p_width = Head.p_height = USE_ORG_SIZE;
Head.start_code = MIN_CODE ;
Head.end_code = MAX_CODE ;
Head.code_category = ALL_CODE;
for (i=1; i<argc; i+=2) {
if (!strcmp(argv[i], "-p")) {
Head.out_file = argv[i+1];
} else if (!strcmp(argv[i], "-bdf")) {
Head.in_file = argv[i+1];
} else if (!strcmp(argv[i], "-width")) {
Head.p_width = atoi(argv[i+1]);
if ((Head.p_width > MAX_FONT_WIDTH) ||
(Head.p_width < MIN_FONT_WIDTH)) {
USAGE2("%s: The specification of the character width is improper.\"%s\"\n",
argv[0], argv[i+1]);
exit(PARAM_ERROR * (-1));
}
} else if (!strcmp(argv[i], "-height")) {
Head.p_height = atoi(argv[i+1]);
if ((Head.p_height > MAX_FONT_HEIGHT) ||
(Head.p_height < MIN_FONT_HEIGHT)) {
USAGE2("%s: The specification of the character height is improper.\"%s\"\n",
argv[0], argv[i+1]);
exit(PARAM_ERROR * (-1));
}
} else {
Usage(argv[0]);
}
}
if (Head.in_file == NULL) {
Head.input = stdin;
} else {
char *spacing ;
char *xlfdname ;
spacing = xlfdname = NULL ;
/* refuse proportional fonts */
if ( GetUdcFontName( NULL, Head.in_file, &xlfdname ) ) {
USAGE1("%s : This font cannot get XLFD. Terminates abnormally.\n", argv[0]);
exit( 1 );
}
GETSPACINGSTR( spacing, xlfdname ) ;
if ( !strcmp( "p", spacing ) || !strcmp( "P", spacing ) ) {
USAGE2("%s cannot edit proportional fonts.(SPACING \"%s\")\n", argv[0], spacing );
exit( 1 );
}
if ((Head.input = fopen(Head.in_file, "r")) == NULL) {
USAGE2("%s: The BDF file cannot be opened.\"%s\"\n",
argv[0], Head.in_file);
exit(BDF_OPEN * (-1));
}
}
signal(SIGHUP, (void(*)())sigint_out);
signal(SIGINT, (void(*)())sigint_out);
signal(SIGQUIT, (void(*)())sigint_out);
signal(SIGTERM, (void(*)())sigint_out);
if (Head.out_file == NULL) {
Head.output = stdout;
} else {
if (stat(Head.out_file, &st) != 0) {
if ((Head.output = fopen(Head.out_file, "w")) == NULL) {
USAGE2("%s: The character pattern file cannot be opened. \"%s\"\n",
argv[0], Head.out_file);
exit(GPF_OPEN *(-1));
}
} else {
Head.text_file = Head.out_file;
if ((Head.out_file = GetTmpPath( Head.out_file )) == NULL) {
USAGE1("%s: Failed convert.\n", argv[0]);
exit(FATAL_ERROR * (-1));
}
if ((Head.output = fopen(Head.out_file, "w")) == NULL) {
USAGE2("%s: The character pattern file cannot be opened. \"%s\"\n",
argv[0], Head.out_file);
exit(GPF_OPEN * (-1));
}
}
}
if ((rtn = CnvBDFtoGPF(&Head))) {
if (Head.in_file != NULL) {
fclose(Head.input);
}
if (Head.out_file != NULL) {
fclose(Head.output);
unlink(Head.out_file);
}
put_error(&Head, rtn, argv[0]);
exit(rtn * (-1));
}
if (Head.in_file != NULL) {
fclose(Head.input);
}
if (Head.out_file != NULL) {
fclose(Head.output);
signal(SIGHUP, SIG_IGN);
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGTERM, SIG_IGN);
if (Head.text_file != NULL) {
Link_NewFile(Head.out_file, Head.text_file);
unlink(Head.out_file);
}
}
exit(0);
}
static
CnvBDFtoGPF(head)
struct btophead *head;
{
char bdfbuf[BUFSIZE];
int rtn;
if ((rtn = ReadBdfHeader(head, bdfbuf)) < 0) {
return(rtn);
}
if (head->p_width == USE_ORG_SIZE) {
head->p_width = head->bdf_width;
}
if (head->p_height == USE_ORG_SIZE) {
head->p_height = head->bdf_height;
}
if ((head->p_width != head->bdf_width) ||
(head->p_height != head->bdf_height)) {
head->zoomf = 1;
} else {
head->zoomf = 0;
}
if ((head->code = (int *)malloc(sizeof(int)*head->num_chars)) == NULL) {
return(FATAL_ERROR);
}
if ((head->ptn = (char **)malloc(sizeof(char *)*head->num_chars)) == NULL) {
return(FATAL_ERROR);
}
if ((rtn = ReadBdfToMemory(head, bdfbuf))) {
return(rtn);
}
WriteGpfHeader(head);
if ((rtn = WritePtnToGpf(head))) {
return(rtn);
}
return(0);
}
static void
put_error(head, er_no, prog_name)
struct btophead *head;
int er_no;
char *prog_name;
{
switch(er_no) {
case FATAL_ERROR :
USAGE1("%s: Failed convert.\n", prog_name);
break;
case BDF_OPEN :
USAGE2("%s: The BDF file cannot be opened. \"%s\"\n",
prog_name, head->in_file);
break;
case BDF_READ :
USAGE2("%s: The BDF file cannot be read. \"%s\"\n",
prog_name, head->in_file);
break;
case BDF_INVAL :
USAGE2("%s: The format of the BDF file is illegal. \"%s\"\n",
prog_name, head->in_file);
break;
case GPF_OPEN :
USAGE2("%s: The character pattern file cannot be opened. \"%s\"\n",
prog_name, head->out_file);
break;
case GPF_WRITE :
USAGE2("%s: It is not possible to write to the character pattern file. \"%s\"\n",
prog_name, head->out_file);
break;
default :
break;
}
}
static void
put_help(prog_name)
char *prog_name;
{
USAGE1("Usage: %s [-p character_pattern_file_name] [-bdf BDF_file_name]\n", prog_name);
USAGE("\t\t[-width character_width] [-height character_height] [-help]\n\n");
}
static void
Usage(prog_name)
char *prog_name;
{
put_help(prog_name);
exit(PARAM_ERROR * (-1));
}

View file

@ -0,0 +1,24 @@
XCOMM $XConsortium: Imakefile /main/8 1996/09/09 11:19:37 drk $
DESTDIR = $(CDE_INSTALLATION_TOP)
BINDIR = /bin
OPT1 = -DDEFAULT_CODESET='"'3'"'
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"'
DEFINES = $(OPT1) $(OPT2) $(OPT3)
INCLUDES = -I../include -I../libfal/include
LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) -lc
SRCS = cpftobdf.c
OBJS = cpftobdf.o
ComplexProgramTarget(dtcpftobdf)

View file

@ -0,0 +1,290 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: cpftobdf.c /main/6 1996/11/08 02:02:03 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "bdfgpf.h"
#include "udcutil.h"
static void put_error();
static void put_help() ;
static void Usage() ;
static int CnvGPFtoBDF() ;
static void sigint_out() ;
static struct ptobhead Head;
static void
sigint_out()
{
if ( Head.out_file ) {
unlink( Head.out_file );
}
exit( 0 );
}
main( argc, argv )
int argc;
char *argv[];
{
int rtn, i;
char *GetTmpPath();
char *spacing ;
char *xlfdname ;
for ( i = 1; i < argc; i++ ) {
if ( !strcmp( argv[i], "-help" ) ) {
put_help( argv[0] );
exit( 0 );
}
}
if ( !( argc % 2 ) ) {
Usage(argv[0]);
}
spacing = xlfdname = NULL ;
Head.in_file = Head.bdf_file = Head.snf_file = Head.out_file = NULL;
Head.start_code = MIN_CODE ;
Head.end_code = MAX_CODE ;
Head.code_category = ALL_CODE;
if (!( bdftopcf = get_cmd_path( getenv( "PATH"), BDFTOPCF_CMD ))){
bdftopcf = BDFTOPCF;
}
if (!( oakgtobdf = get_cmd_path( getenv( "PATH"), SNFTOBDF_CMD ))) {
oakgtobdf = SNFTOBDF;
}
for ( i = 1; i < argc; i+=2 ) {
if ( !strcmp( argv[i], "-bdf" ) ) {
Head.bdf_file = argv[ i+1 ];
} else if ( !strcmp( argv[i], "-p" ) ) {
Head.in_file = argv[i+1];
} else if ( !strcmp( argv[i], "-g" ) ) {
Head.snf_file = argv[i+1];
} else {
Usage( argv[0] );
}
}
if ( Head.in_file == NULL ) {
Head.input = stdin;
} else {
if ( ( Head.input = fopen( Head.in_file, "r" ) ) == NULL ) {
USAGE2("%s: The character pattern file cannot be opened. \"%s\"\n", argv[0], Head.in_file );
exit( GPF_OPEN * (-1) );
}
}
signal( SIGHUP, (void(*)())sigint_out );
signal( SIGINT, (void(*)())sigint_out );
signal( SIGQUIT, (void(*)())sigint_out );
signal( SIGTERM, (void(*)())sigint_out );
if ( Head.bdf_file == NULL ) {
if ( Head.snf_file == NULL ) {
USAGE1("%s: If the output is stdout, the user defined font file name cannot be omitted.\n", argv[0]);
exit(PARAM_ERROR * (-1));
}
Head.output = stdout;
} else {
if ( ! ( Head.out_file = GetTmpPath( Head.bdf_file ) ) ) {
exit( FATAL_ERROR * ( -1 ) );
}
if ( ( Head.output = fopen( Head.out_file, "w" ) ) == NULL ) {
USAGE2("%s: The work file for the output cannot be opened. \"%s\"\n", argv[0], Head.out_file );
exit( BDF_OPEN * (-1) );
}
}
/* refuse proportional fonts */
if ( GetUdcFontName( Head.snf_file, Head.bdf_file, &xlfdname ) ) {
USAGE1("%s : This font cannot get XLFD. Terminates abnormally.\n", argv[0]);
if ( Head.in_file != NULL ) {
fclose( Head.input );
}
if ( Head.out_file != NULL ) {
fclose( Head.output );
unlink( Head.out_file );
}
exit( 1 );
}
GETSPACINGSTR( spacing, xlfdname ) ;
if ( !strcmp( "p", spacing ) || !strcmp( "P", spacing ) ) {
USAGE2("%s cannot edit proportional fonts.(SPACING \"%s\")\n", argv[0], spacing );
if ( Head.in_file != NULL ) {
fclose( Head.input );
}
if ( Head.out_file != NULL ) {
fclose( Head.output );
unlink( Head.out_file );
}
exit( 1 );
}
if ( ( rtn = CnvGPFtoBDF( &Head ) ) ) {
if ( Head.in_file != NULL ) {
fclose( Head.input );
}
if ( Head.out_file != NULL ) {
fclose( Head.output );
unlink( Head.out_file );
}
put_error( &Head, rtn, argv[0] );
exit( rtn * (-1) );
}
if ( Head.in_file != NULL ) {
fclose( Head.input );
}
if ( Head.out_file != NULL ) {
fclose( Head.output );
signal( SIGHUP, SIG_IGN );
signal( SIGINT, SIG_IGN );
signal( SIGQUIT, SIG_IGN );
signal( SIGTERM, SIG_IGN );
if ( Head.bdf_file != NULL ) {
Link_NewFile( Head.out_file, Head.bdf_file );
unlink( Head.out_file );
}
}
exit( 0 );
}
static
CnvGPFtoBDF( head )
struct ptobhead *head;
{
char textbuf[BUFSIZE] ;
int rtn ;
if ( ( rtn = ReadGpfHeader( head, textbuf ) ) ) {
return rtn;
}
if ( ( rtn = WriteBdfHeader( head ) ) ) {
return rtn;
}
if ( ( head->p_width != head->bdf_width )
|| ( head->p_height != head->bdf_height )
) {
head->zoomf = 1;
} else {
head->zoomf = 0;
}
if ( ( head->code = (int *)malloc( sizeof(int) * head->num_chars ) ) == NULL ) {
return FATAL_ERROR;
}
if ( ( head->ptn = (char **)malloc( sizeof( char * ) * head->num_chars ) ) == NULL ) {
return FATAL_ERROR;
}
if ( ( rtn = ReadGpfToMemory( head, textbuf ) ) ) {
return rtn;
}
if ( ( rtn = WritePtnToBdf( head ) ) ) {
return rtn;
}
return 0;
}
static void
put_error( head, er_no, prog_name )
struct ptobhead *head;
int er_no;
char *prog_name;
{
switch( er_no ) {
case FATAL_ERROR:
USAGE1("%s: Failed convert.\n", prog_name );
break;
case BDF_OPEN:
USAGE2("%s: The BDF file cannot be opened. \"%s\"\n", prog_name, head->bdf_file );
break;
case BDF_READ:
USAGE2("%s: The BDF file cannot be read. \"%s\"\n", prog_name, head->bdf_file );
break;
case BDF_WRITE:
USAGE2("%s: It is not possible to write to the BDF file. \"%s\"\n", prog_name, head->out_file );
break;
case BDF_INVAL:
if ( head->snf_file ) {
USAGE2("%s: The information from the font file cannot be obtained.\"%s\"\n", prog_name, head->snf_file );
} else {
USAGE2("%s: The format of the BDF file is illegal. \"%s\"\n", prog_name, head->bdf_file );
}
break;
case GPF_OPEN:
USAGE2("%s: The character pattern file cannot be opened. \"%s\"\n", prog_name, head->in_file );
break;
case GPF_READ:
USAGE2("%s: The character pattern file cannot be read. \"%s\"\n", prog_name, head->in_file );
break;
case GPF_INVAL:
USAGE2("%s: The format of the character pattern file is illegal. \"%s\"\n", prog_name, head->in_file );
break;
default:
break;
}
}
static void
put_help( prog_name )
char *prog_name;
{
USAGE1("Usage: %s [-bdf BDF_file_name] [-p chracter_pattern_file_name]\n", prog_name);
USAGE("\t\t[-g user_defined_character_file_name] [-help]\n");
}
static void
Usage( prog_name )
char *prog_name;
{
put_help( prog_name );
exit( PARAM_ERROR * (-1) );
}

View file

@ -0,0 +1,24 @@
XCOMM $XConsortium: Imakefile /main/8 1996/09/09 11:19:41 drk $
DESTDIR = $(CDE_INSTALLATION_TOP)
BINDIR = /bin
OPT1 = -DDEFAULT_CODESET='"'3'"'
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"'
DEFINES = $(OPT1) $(OPT2) $(OPT3)
INCLUDES = -I../include -I../libfal/include
LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) -lc
SRCS = cpftogpf.c
OBJS = cpftogpf.o
ComplexProgramTarget(dtcpftogpf)

View file

@ -0,0 +1,466 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: cpftogpf.c /main/7 1996/11/08 02:02:48 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#ifndef SVR4
#if !defined( SYSV )
#include <sys/resource.h>
#endif
#include <sys/wait.h>
#else
#include <wait.h>
#endif
#include <sys/stat.h>
#include <string.h>
#include <unistd.h>
#include <X11/Xmd.h>
#include <X11/Xproto.h>
#include "bdfgpf.h"
#include "snfstruct.h"
#include "fontstruct.h"
#include "FaLib.h"
#include "udcutil.h"
#include <errno.h>
static void sigint_out() ;
static void put_error_and_exit();
static void put_help();
static int CnvGPFtoBDF() ;
static struct ptobhead Head;
static char *targ_file = NULL; /* UDC character filename */
static char *com = NULL; /* command name */
static char *spacing ;
static char *char_set ;
static void
sigint_out()
{
if (Head.out_file) {
Unlink_Tmpfile(Head.out_file, com);
}
exit(0);
}
main( argc, argv )
int argc;
char *argv[];
{
FontInfoRec *finf;
int help, no_infile, style_err, rtn, i;
struct stat statbuf;
char snf_file[BUFSIZE], buf[BUFSIZE];
int pfd[2], fd, snf_fd, permission;
int exit_stat;
char *style ; /* style */
int chk_fd;
pid_t chld_pid = 0;
#if defined( SVR4 ) || defined( SYSV ) || defined(CSRG_BASED) || defined(__linux__)
int chld_stat ;
#else
union wait chld_stat ;
#endif
int code_no, code_area ;
FalFontData key ;
char *xlfdname, *cbuf, *ep ;
char *codeset = DEFAULT_CODESET ;
/* format */
Head.in_file = Head.bdf_file = Head.snf_file = Head.out_file = NULL;
help = no_infile = style_err = 0;
com = argv[0];
COMM_SETDEFAULTSTYLE( style ) ;
memset( &key, '\0', sizeof(FalFontData) ) ;
xlfdname = cbuf = ep = '\0' ;
spacing = char_set = NULL ;
code_no = code_area = 0 ;
if (!( bdftopcf = get_cmd_path( getenv( "PATH" ), BDFTOPCF_CMD ))) {
bdftopcf = BDFTOPCF;
}
if (!( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ))) {
oakgtobdf = SNFTOBDF;
}
if (!( bdftosnf = get_cmd_path( getenv( "PATH" ), BDFTOSNF_CMD ))) {
bdftosnf = BDFTOSNF;
}
Head.code_category = ALL_CODE;
Head.start_code = MIN_CODE;
Head.end_code = MAX_CODE;
for (i=1; i<argc; i++) {
if ( !strcmp( argv[i], "-system" ) ) {
code_area |= SYSTM ;
} else if ( !strcmp( argv[i], "-help" ) ) {
help = 1;
} else if ( !strcmp( argv[i], "-g" ) ) {
if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ) {
Head.snf_file = argv[++i];
}
} else if (!strcmp(argv[i], "-p")) {
if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ) {
Head.in_file = argv[++i];
} else {
no_infile = 1;
}
} else if ( !strcmp(argv[i], "-style" ) ) {
if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ){
style = argv[++i];
} else {
style_err = 1;
}
} else if ( !strcmp( argv[i], "-codeset" ) ) {
if (
( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ) &&
( strlen( argv[i + 1] ) == 1 )
) {
if ( *argv[i+1] == '1' ) code_area |= CDSET1 ;
codeset = argv[++i] ;
} else {
put_help( argv[0] );
exit( 1 );
}
} else if ( !strcmp( argv[i], "-xlfd" ) ) {
if ( i < argc-1 ) {
xlfdname = argv[++i] ;
} else {
put_help( argv[0] );
exit( 1 );
}
} else {
put_help( argv[0] );
exit( 1 );
}
}
ep = (char *)strchr( codeset, '\0' ) ;
code_no = (int)strtol( codeset, &cbuf, 10 ) ;
if( cbuf == codeset || cbuf != ep ) {
USAGE1("%s : The code set number is not right.\n", argv[0] ) ;
exit(1) ;
}
if ( help ) {
put_help( argv[0] );
exit( 0 );
}
if ( no_infile ) {
USAGE1("%s : The input file name following -p option cannot be omitted.\n", argv[0] );
exit( 1 );
}
if ( style_err ) {
USAGE1("%s : The style is not specified.\n", argv[0] );
exit( 1 );
}
if ( Head.snf_file == NULL && xlfdname == NULL ) {
if ( code_area & SYSTM ) {
USAGE1("%s : The SNF output file name cannot be omitted.\n", argv[0] );
} else {
USAGE1("%s : The character size specification cannot be omitted.\n", argv[0] );
}
exit( 1 );
}
if ( !( code_area & SYSTM ) ) {
if( xlfdname ) {
if( GetUdcFileName( com, code_no, xlfdname, snf_file ) ) {
USAGE1("%s : The font file name cannot be obtained. Terminates abnormally.\n", com );
exit( 1 );
}
Head.snf_file = snf_file;
} else {
switch ( GetFileName( argv[0], Head.snf_file, style, code_no, snf_file ) ) {
case 0:
Head.snf_file = snf_file;
break;
case -1:
/* output GetFileName() */
exit( 1 );
default:
USAGE1("%s : The font file name cannot be obtained. Terminates abnormally.\n", argv[0] );
exit( 1 );
}
}
}
/*
* refuse proportional fonts
*/
if ( GetUdcFontName( Head.snf_file, NULL, &xlfdname ) ) {
USAGE1("%s : This font cannot get XLFD. Terminates abnormally.\n", argv[0]);
exit( 1 );
}
GETSPACINGSTR( spacing, xlfdname ) ;
if ( !strcmp( "p", spacing ) || !strcmp( "P", spacing ) ) {
USAGE2("%s cannot edit proportional fonts.(SPACING \"%s\")\n", argv[0], spacing );
exit( 1 );
}
GETCHARSETSTR( char_set, xlfdname ) ;
COMM_SET_CODECATEGORY( char_set, code_area, Head) ;
if ( ( targ_file = GetRealFileName( Head.snf_file ) ) == NULL ){
USAGE2("%s : It was not possible to refer to the substance of the font file. \"%s\"\n", argv[0], Head.snf_file );
exit( 1 );
}
if ( ( chk_fd = open( targ_file, O_RDWR ) ) < 0 ) {
USAGE2("%s : The font file of substance \"%s\" cannot be opened.\n", argv[0] , targ_file );
exit( 1 );
}
if ( isLock( chk_fd ) == 1 ) {
USAGE1("%s : Editing by other application.\n", argv[0] );
close( chk_fd );
exit( 1 );
}
close( chk_fd );
/*
* open input file(CPF)
*/
if ( Head.in_file == NULL ) {
Head.input = stdin;
} else {
if ( ( Head.input = fopen( Head.in_file, "r" ) ) == NULL ) {
put_error_and_exit( &Head, GPF_OPEN_IN, argv[0] );
}
}
/*
* get GPF filename
*/
if ( !( Head.out_file = GetTmpPath( targ_file ) ) ) {
put_error_and_exit( &Head, MKTMP_ERROR, argv[0] );
}
permission = 0;
if ( ( snf_fd = open( Head.snf_file, O_RDONLY ) ) >= 0 ) {
if ( ChkPcfFontFile( Head.snf_file) ) {
/* snf file */
COMM_SNF_FILEVERSION( snf_fd, finf, buf, permission ) ;
if( permission < 0 ) {
put_error_and_exit( &Head, BDF_INVAL, argv[0] );
}
} else {
/* pcf */
close( snf_fd );
}
} else {
put_error_and_exit( &Head, BDF_OPEN_IN, argv[0] );
}
if ( pipe( pfd ) != 0 ) {
put_error_and_exit( &Head, PIPE_ERROR, argv[0] );
}
signal( SIGHUP , (void(*)())sigint_out );
signal( SIGINT , (void(*)())sigint_out );
signal( SIGQUIT, (void(*)())sigint_out );
signal( SIGTERM, (void(*)())sigint_out );
switch ( chld_pid = fork() ) {
case 0:
if ( ( fd = open( Head.out_file, O_WRONLY | O_CREAT, 0664 ) ) < 0 ) {
put_error_and_exit( &Head, BDF_OPEN_OUT, argv[0] );
}
close(0);
if ( dup( pfd[0] ) < 0 ) {
put_error_and_exit( &Head, DUP_ERROR, argv[0] );
}
close( pfd[0] );
close( pfd[1] );
close( 1 );
if ( dup( fd ) < 0 ) {
put_error_and_exit( &Head, DUP_ERROR, argv[0] );
}
if ( ChkPcfFontFile( Head.snf_file ) == 0 ) {
execl( bdftopcf, bdftopcf, 0 );
/* exec error */
put_error_and_exit( &Head, PCFFONTC_ERROR, argv[0] );
}
COMM_SNF_EXECLBDFTOSNF( permission, buf, Head.snf_file ) ;
/* exec error */
put_error_and_exit( &Head, SNFFONTC_ERROR, argv[0] );
case -1:
/* fork() error */
put_error_and_exit( &Head, FORK_ERROR, argv[0] );
default:
break;
}
close( pfd[0] );
if ( ( Head.output = fdopen( pfd[1], "w" ) ) == NULL ) {
close( pfd[1] );
kill( chld_pid, SIGKILL );
WaitID( chld_pid, chld_stat ) ;
put_error_and_exit( &Head, FDOPEN_ERROR, argv[0] );
}
if ( ( rtn = CnvGPFtoBDF( &Head ) ) ) {
fclose( Head.input );
fclose( Head.output );
close( pfd[1] );
kill( chld_pid, SIGKILL );
WaitID( chld_pid, chld_stat ) ;
Unlink_Tmpfile( Head.out_file, argv[0] );
put_error_and_exit( &Head, rtn, argv[0] );
}
fclose( Head.output );
close( pfd[1] );
wait( &exit_stat );
#if !defined( SVR4 ) && !defined( SYSV ) && !defined(__FreeBSD__)
if ( !WIFEXITED(exit_stat) ) {
#else
if (! ( WIFEXITED(exit_stat) && !WEXITSTATUS(exit_stat) ) ) {
#endif
USAGE3("%s: The error occurred by %s (%08x).\n", argv[0], bdftopcf, exit_stat );
Unlink_Tmpfile( Head.out_file, argv[0] );
exit( 1 );
}
fclose( Head.input );
signal( SIGHUP , SIG_IGN );
signal( SIGINT , SIG_IGN );
signal( SIGQUIT, SIG_IGN );
signal( SIGTERM, SIG_IGN );
sleep(1) ;
if ( (stat( Head.out_file,&statbuf ) ) ||
( statbuf.st_size == 0 ) ) {
Unlink_Tmpfile( Head.out_file, argv[0] );
put_error_and_exit( &Head, BDF_WRITE, argv[0] );
}
if ( stat( targ_file, &statbuf ) ) {
Unlink_Tmpfile( Head.out_file, argv[0] );
put_error_and_exit( &Head, BDF_WRITE, argv[0] );
}
exit ( Make_NewFefFile( targ_file, Head.out_file,
FONT_FILE_PARM, (uid_t)statbuf.st_uid, (gid_t)statbuf.st_gid, argv[0]) );
}
static
CnvGPFtoBDF( head )
struct ptobhead *head;
{
int rtn;
char textbuf[BUFSIZE];
if ( ( rtn = ReadGpfHeader( head, textbuf ) ) ) {
return rtn;
}
if ( ( rtn = WriteBdfHeader( head ) ) ) {
return rtn;
}
if ( ( head->p_width != head->bdf_width ) ||
( head->p_height != head->bdf_height )
) {
head->zoomf = 1;
} else {
head->zoomf = 0;
}
if ( ( head->code = (int *)malloc( sizeof(int) * head->num_chars ) ) == NULL ) {
return MALLOC_ERROR;
}
if ( ( head->ptn = (char **)malloc( sizeof(char *)*head->num_chars ) ) == NULL ) {
return MALLOC_ERROR;
}
if ( ( rtn = ReadGpfToMemory(head, textbuf ) ) ) {
return rtn;
}
if ( ( rtn = WritePtnToBdf( head ) ) ) {
return rtn;
}
return 0;
}
static void
put_error_and_exit( ptob, er_no, prog_name )
struct ptobhead *ptob;
int er_no;
char *prog_name;
{
ErrMsgTable_AndExit( er_no, ptob->snf_file, ptob->out_file,
ptob->in_file, NULL,
ptob->bdf_file,
prog_name
);
return;
}
static void
put_help( prog_name )
char *prog_name;
{
USAGE1("Usage: %s -xlfd xlfd_name\n", prog_name);
USAGE("\t\t[-g character_size][-p character_pattern_file_name]\n" );
USAGE("\t\t [-style style] \n");
COMM_HELP_MSG ;
USAGE("The character size may be obtained using the dtlsgpf command.\n");
USAGE("\n");
}

View file

@ -0,0 +1,28 @@
XCOMM $XConsortium: Imakefile /main/8 1996/09/09 11:19:44 drk $
DESTDIR = $(CDE_INSTALLATION_TOP)
BINDIR = /bin
OPT1 = -DDEFAULT_CODESET='"'3'"'
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"'
DEFINES = $(OPT1) $(OPT2) $(OPT3)
UDC_INC_PATH1 = -I../libfal/include
UDC_INC_PATH2 = -I../include
UDC_INC_PATH3 = -I./
INCLUDES = $(UDC_INC_PATH1) $(UDC_INC_PATH2) $(UDC_INC_PATH3)
LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) -lc
SRCS = cpgpf.c
OBJS = cpgpf.o
ComplexProgramTarget(dtcpgpf)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,25 @@
XCOMM $XConsortium: Imakefile /main/8 1996/09/09 11:19:48 drk $
DESTDIR = $(CDE_INSTALLATION_TOP)
BINDIR = /bin
OPT1 = -DDEFAULT_CODESET='"'3'"'
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"'
DEFINES = $(OPT1) $(OPT2) $(OPT3)
INCLUDES = -I../libfal/include\
-I../include
LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) -lc
SRCS = gpftobdf.c
OBJS = gpftobdf.o
ComplexProgramTarget(dtgpftobdf)

View file

@ -0,0 +1,131 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: bdftosnf.h /main/4 1996/06/25 20:13:29 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include<X11/Xfuncs.h>
#ifndef MIN
#define MIN(a,b) ((a)>(b)?(b):(a))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
typedef struct _GlyphMap {
char *bits;
int h;
int w;
int widthBytes;
} GlyphMap;
/*
* a structure to hold all the pointers to make it easy to pass them all
* around. Much like the FONT structure in the server.
*/
typedef struct _TempFont {
FontInfoPtr pFI;
CharInfoPtr pCI;
unsigned char *pGlyphs;
FontPropPtr pFP;
CharInfoPtr pInkCI;
CharInfoPtr pInkMin;
CharInfoPtr pInkMax;
} TempFont; /* not called font since collides with type in X.h */
#ifdef vax
# define DEFAULTGLPAD 1 /* default padding for glyphs */
# define DEFAULTBITORDER LSBFirst /* default bitmap bit order */
# define DEFAULTBYTEORDER LSBFirst /* default bitmap byte order */
# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */
#elif defined(sun)
# if (sun386 || sun5)
# define DEFAULTGLPAD 4 /* default padding for glyphs */
# define DEFAULTBITORDER LSBFirst /* default bitmap bit order */
# define DEFAULTBYTEORDER LSBFirst /* default bitmap byte order */
# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */
# else
# define DEFAULTGLPAD 4 /* default padding for glyphs */
# define DEFAULTBITORDER MSBFirst /* default bitmap bit order */
# define DEFAULTBYTEORDER MSBFirst /* default bitmap byte order */
# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */
# endif
#elif defined(ibm032)
# define DEFAULTGLPAD 1 /* default padding for glyphs */
# define DEFAULTBITORDER MSBFirst /* default bitmap bit order */
# define DEFAULTBYTEORDER MSBFirst /* default bitmap byte order */
# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */
#elif defined(hpux)
# define DEFAULTGLPAD 2 /* default padding for glyphs */
# define DEFAULTBITORDER MSBFirst /* default bitmap bit order */
# define DEFAULTBYTEORDER MSBFirst /* default bitmap byte order */
# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */
#elif defined(pegasus)
# define DEFAULTGLPAD 4 /* default padding for glyphs */
# define DEFAULTBITORDER MSBFirst /* default bitmap bit order */
# define DEFAULTBYTEORDER MSBFirst /* default bitmap byte order */
# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */
#elif defined(mips)
# ifdef MIPSEL
# define DEFAULTGLPAD 4 /* default padding for glyphs */
# define DEFAULTBITORDER LSBFirst /* default bitmap bit order */
# define DEFAULTBYTEORDER LSBFirst /* default bitmap byte order */
# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */
# else
# define DEFAULTGLPAD 4 /* default padding for glyphs */
# define DEFAULTBITORDER MSBFirst /* default bitmap bit order */
# define DEFAULTBYTEORDER MSBFirst /* default bitmap byte order */
# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */
# endif
#else
# define DEFAULTGLPAD 1 /* default padding for glyphs */
# define DEFAULTBITORDER MSBFirst /* default bitmap bit order */
# define DEFAULTBYTEORDER MSBFirst /* default bitmap byte order */
# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */
#endif
#define GLWIDTHBYTESPADDED(bits,nbytes) \
((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
:(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
:(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
:(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
: 0)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,84 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: gtobdf.h /main/3 1996/06/25 20:13:05 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
static
unsigned int
cvt[256]=
{0x30300a00,0x30310a00,0x30320a00,0x30330a00,0x30340a00,0x30350a00,0x30360a00,
0x30370a00,0x30380a00,0x30390a00,0x30610a00,0x30620a00,0x30630a00,0x30640a00,
0x30650a00,0x30660a00,
0x31300a00,0x31310a00,0x31320a00,0x31330a00,0x31340a00,0x31350a00,
0x31360a00,0x31370a00,0x31380a00,0x31390a00,0x31610a00,0x31620a00,0x31630a00,
0x31640a00,0x31650a00,0x31660a00,
0x32300a00,0x32310a00,0x32320a00,0x32330a00,0x32340a00,0x32350a00,
0x32360a00,0x32370a00,0x32380a00,0x32390a00,0x32610a00,0x32620a00,0x32630a00,
0x31640a00,0x32650a00,0x32660a00,
0x33300a00,0x33310a00,0x33320a00,0x33330a00,0x33340a00,0x33350a00,
0x33360a00,0x33370a00,0x33380a00,0x33390a00,0x33610a00,0x33620a00,0x33630a00,
0x33640a00,0x33650a00,0x33660a00,
0x34300a00,0x34310a00,0x34320a00,0x34330a00,0x34340a00,0x34350a00,
0x34360a00,0x34370a00,0x34380a00,0x34390a00,0x34610a00,0x34620a00,0x34630a00,
0x34640a00,0x34650a00,0x34660a00,
0x35300a00,0x35310a00,0x35320a00,0x35330a00,0x35340a00,0x35350a00,
0x35360a00,0x35370a00,0x35380a00,0x35390a00,0x35610a00,0x35620a00,0x35630a00,
0x35640a00,0x35650a00,0x35660a00,
0x36300a00,0x36310a00,0x36320a00,0x36330a00,0x36340a00,0x36350a00,
0x36360a00,0x36370a00,0x36380a00,0x36390a00,0x36610a00,0x36620a00,0x36630a00,
0x36640a00,0x36650a00,0x36660a00,
0x37300a00,0x37310a00,0x37320a00,0x37330a00,0x37340a00,0x37350a00,
0x37360a00,0x37370a00,0x37380a00,0x37390a00,0x37610a00,0x37620a00,0x37630a00,
0x37640a00,0x37650a00,0x37660a00,
0x38300a00,0x38310a00,0x38320a00,0x38330a00,0x38340a00,0x38350a00,
0x38360a00,0x38370a00,0x38380a00,0x38390a00,0x38610a00,0x38620a00,0x38630a00,
0x38640a00,0x38650a00,0x38660a00,
0x39300a00,0x39310a00,0x39320a00,0x39330a00,0x39340a00,0x39350a00,
0x39360a00,0x39370a00,0x39380a00,0x39390a00,0x39610a00,0x39620a00,0x39630a00,
0x39640a00,0x39650a00,0x39660a00,
0x61300a00,0x61310a00,0x61320a00,0x61330a00,0x61340a00,0x61350a00,
0x61360a00,0x61370a00,0x61380a00,0x61390a00,0x61610a00,0x61620a00,0x61630a00,
0x61640a00,0x61650a00,0x61660a00,
0x62300a00,0x62310a00,0x62320a00,0x62330a00,0x62340a00,0x62350a00,
0x62360a00,0x62370a00,0x62380a00,0x62390a00,0x62610a00,0x62620a00,0x62630a00,
0x62640a00,0x62650a00,0x62660a00,
0x63300a00,0x63310a00,0x63320a00,0x63330a00,0x63340a00,0x63350a00,
0x63360a00,0x63370a00,0x63380a00,0x63390a00,0x63610a00,0x63620a00,0x63630a00,
0x63640a00,0x63650a00,0x63660a00,
0x64300a00,0x64310a00,0x64320a00,0x64330a00,0x64340a00,0x64350a00,
0x64360a00,0x64370a00,0x64380a00,0x64390a00,0x64610a00,0x64620a00,0x64630a00,
0x64640a00,0x64650a00,0x64660a00,
0x65300a00,0x65310a00,0x65320a00,0x65330a00,0x65340a00,0x65350a00,
0x65360a00,0x65370a00,0x65380a00,0x65390a00,0x65610a00,0x65620a00,0x65630a00,
0x65640a00,0x65650a00,0x65660a00,
0x66300a00,0x66310a00,0x66320a00,0x66330a00,0x66340a00,0x66350a00,
0x66360a00,0x66370a00,0x66380a00,0x66390a00,0x66610a00,0x66620a00,0x66630a00,
0x66640a00,0x66650a00,0x66660a00 };
static
unsigned int *cvtp[256];

View file

@ -0,0 +1,26 @@
XCOMM $XConsortium: Imakefile /main/6 1996/09/09 11:19:51 drk $
DESTDIR = $(CDE_INSTALLATION_TOP)
BINDIR = /bin
OPT1 = -DDEFAULT_CODESET='"'3'"'
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"'
DEFINES = $(OPT1) $(OPT2) $(OPT3)
INCLUDES = -I../include -I../libfal/include
DEPLIBS = ../libfuty/liboakfuty.a ../libfal/libfal.a $(DEPXLIB)
LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB)
SYS_LIBRARIES = -lc
SRCS = gpftocpf.c
OBJS = gpftocpf.o
ComplexProgramTarget(dtgpftocpf)

View file

@ -0,0 +1,672 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: gpftocpf.c /main/6 1996/11/08 02:05:11 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifndef SVR4
#if !defined ( SYSV )
#include <sys/resource.h>
#endif
#include <sys/wait.h>
#else
#include <wait.h>
#endif
#include <errno.h>
#include <locale.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include "bdfgpf.h"
#include <X11/Xmd.h>
#include <X11/Xproto.h>
#include "snfstruct.h"
#include "FaLib.h"
#include "udcutil.h"
#define START_CODE 0
#define END_CODE 1
static int CnvBDFtoGPF() ;
static int check_width() ;
static int check_height() ;
static int check_width_height() ;
static int check_code() ;
static int readBdfToMemory() ;
static void sigint_out() ;
static void put_error_and_exit();
static void put_help();
static void Usage();
extern int fal_code_to_glyph() ;
static struct btophead Head;
static char *locale ;
static char *spacing ;
static char *char_set ;
static void
sigint_out()
{
if ( Head.out_file ) {
unlink( Head.out_file );
}
exit( 0 );
}
main( argc, argv )
int argc;
char *argv[];
{
int help, code_area, fd[2], rtn, i;
struct stat st;
char snf_file[BUFSIZE];
char *style ;
int code_no ;
int num_gr ;
FalGlyphRegion *gr ;
char *xlfdname, *cbuf, *ep ;
char *codeset = DEFAULT_CODESET ;
char *start_code, *end_code ;
/* format */
if( (locale = (char *)getenv( "LANG" )) == NULL ){
locale = "C" ;
}
Head.in_file = Head.out_file = Head.text_file = NULL;
Head.p_width = Head.p_height = USE_ORG_SIZE;
Head.code_category = ALL_CODE ;
Head.start_code = MIN_CODE;
Head.end_code = MAX_CODE;
help = code_area = 0;
COMM_SETDEFAULTSTYLE( style ) ;
xlfdname = cbuf = start_code = end_code = ep = '\0' ;
spacing = char_set = NULL ;
gr = '\0' ;
num_gr = 0 ;
if ( ! ( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ) ) ) {
oakgtobdf = SNFTOBDF;
}
/*
* check options
*/
for ( i = 1; i < argc; i++ ) {
if ( !strcmp(argv[i], "-help" ) ) {
help = 1;
} else if ( !strcmp(argv[i], "-system" ) ) {
code_area |= SYSTM;
} else if ( !strcmp( argv[i], "-codeset" ) ) {
if (
( (i+1) < argc ) &&
( strlen( argv[i+1] ) == 1 )
) {
if ( *argv[i+1] == '1' ) code_area |= CDSET1;
codeset = argv[++i] ;
} else {
put_help( argv[0] );
exit( 1 );
}
} else if ( COMM_SBOPT_STRCMP( argv, i ) ) {
COMM_SBOPT_SETSBOPT( code_area ) ;
} else {
continue ;
}
}
if ( help ) {
put_help( argv[0] );
exit( 0 );
}
ep = (char *)strchr( codeset, '\0' ) ;
code_no = (int)strtol( codeset, &cbuf, 10 ) ;
if( cbuf == codeset || cbuf != ep ) {
USAGE1("%s : The code set number is not right.\n", argv[0] ) ;
exit(1) ;
}
COMM_SBOPT_CHECKSBOPT( argv[0], code_area ) ;
/*
* get parameters
*/
for (i=1; i<argc; i++) {
if ( !strcmp(argv[i], "-g") ) {
if((i < argc-1) && (*argv[i+1] != '-')){
Head.in_file = argv[++i];
}
} else if ( !strcmp(argv[i], "-p") ) {
if ((i < argc-1) && (*argv[i+1] != '-')){
Head.out_file = argv[++i];
} else {
USAGE1("%s : The output file name following -p option cannot be omitted.\n",
argv[0]);
exit(1);
}
} else if ( !strcmp(argv[i], "-width") ) {
if ((i < argc-1) && (*argv[i+1] != '-')) {
Head.p_width = check_width( argv[0], argv[++i]);
if (Head.p_width == 0) {
exit(1);
}
}
else {
USAGE1("%s : The character width is not specified.\n", argv[0]);
exit( 1 );
}
} else if ( !strcmp(argv[i], "-height") ) {
if ((i < argc-1) && (*argv[i+1] != '-')) {
Head.p_height = check_height( argv[0], argv[++i]);
if (Head.p_height == 0) {
exit(1);
}
}
else {
USAGE1("%s : The character height is not specified.\n", argv[0]);
exit(1);
}
} else if ( !strcmp(argv[i], "-start") ) {
if ((i < argc-1) && (*argv[i+1] != '-')) {
start_code = argv[++i] ;
} else {
USAGE1("%s : The extract start code is not specified.\n",
argv[0]);
exit( 1 );
}
} else if ( !strcmp(argv[i], "-end" ) ) {
if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ) {
end_code = argv[++i] ;
} else {
USAGE1("%s : The extract end code is not specified.\n",
argv[0]);
exit( 1 );
}
} else if ( !strcmp(argv[i], "-style" ) ) {
if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ){
style = argv[++i];
} else {
USAGE1("%s : The style is not specified.\n", argv[0]);
exit( 1 );
}
} else if ( !strcmp(argv[i], "-xlfd" ) ) {
if ( i < argc-1 ){
xlfdname = argv[++i];
} else {
USAGE1("%s : The XLFD name is not specified.\n", argv[0]);
exit( 1 );
}
} else if ( !strcmp(argv[i], "-help" )
|| !strcmp(argv[i], "-system")
|| COMM_SBOPT_STRCMP( argv, i )
) {
continue;
} else if ( !strcmp( argv[i], "-codeset" ) ) {
i++;
continue;
} else {
Usage(argv[0]);
}
}
if ( Head.in_file == NULL && xlfdname == NULL ) {
if ( code_area & SYSTM ) {
USAGE1("%s : The GPF output file name cannot be omitted.\n", argv[0] );
} else {
USAGE1("%s : The specification of the character size cannot be omitted.\n", argv[0] );
}
exit( 1 );
}
signal( SIGHUP , (void(*)())sigint_out );
signal( SIGINT , (void(*)())sigint_out );
signal( SIGQUIT, (void(*)())sigint_out );
signal( SIGTERM, (void(*)())sigint_out );
if ( !(code_area & SYSTM ) ) {
if( xlfdname ) {
if( GetUdcFileName( argv[0], code_no, xlfdname, snf_file ) ) {
USAGE1("%s : The font file name cannot be obtained. Terminates abnormally.\n", argv[0]);
exit(1) ;
}
Head.in_file = snf_file;
} else {
switch (GetFileName(argv[0], Head.in_file, style, code_no, snf_file)) {
case 0:
Head.in_file = snf_file;
break;
case -1:
exit(1);
default:
USAGE1("%s : The font file name cannot be obtained. Terminates abnormally.\n", argv[0]);
exit(1);
}
}
if( GetUdcRegion( argv[0], code_no, Head.in_file, &num_gr, &gr ) ) {
USAGE1("%s : The font file cannot get UDC code area.\n", argv[0]);
exit(1) ;
}
} else {
num_gr = 1 ;
if( (gr = (FalGlyphRegion *)malloc( sizeof(FalGlyphRegion) * num_gr )) == NULL ) {
USAGE1("%s : malloc error occurred. Terminates abnormally.\n", argv[0]);
exit(1) ;
}
gr[0].start = MIN_CODE ;
gr[0].end = MAX_CODE ;
}
/*
* refuse proportional fonts
*/
if ( GetUdcFontName( Head.in_file, NULL, &xlfdname ) ) {
USAGE1("%s : This font cannot get XLFD. Terminates abnormally.\n", argv[0]);
exit( 1 );
}
GETSPACINGSTR( spacing, xlfdname ) ;
if ( !strcmp( "p", spacing ) || !strcmp( "P", spacing ) ) {
USAGE2("%s cannot edit proportional fonts.(SPACING \"%s\")\n", argv[0], spacing );
exit( 1 );
}
GETCHARSETSTR( char_set, xlfdname ) ;
switch( code_area ) {
case SYSTM :
Head.code_category = ALL_CODE ;
Head.start_code = MIN_CODE ;
Head.end_code = MAX_CODE ;
break ;
case SYSTM | CDSET1 :
Head.code_category = ALL_CODE ;
Head.start_code = MIN_CODE ;
Head.end_code = MAX_CODE ;
break ;
default :
COMM_SBFNT_SETUDCAREA( argv[0], Head, char_set, code_area, num_gr, gr ) ;
break ;
}
if( start_code && end_code ) {
Head.start_code = check_code(argv[0], start_code, START_CODE, char_set, num_gr, gr );
if(Head.start_code < 0) {
exit( 1 );
}
Head.end_code = check_code(argv[0], end_code, END_CODE, char_set, num_gr, gr );
if(Head.end_code < 0) {
exit( 1 );
}
}
if ( Head.start_code > Head.end_code ) {
USAGE1("%s : The specification of extract start/end code is improper.\n", argv[0]);
exit( 1 );
}
COMM_SBFNT_CONVCODETOGI( char_set, Head ) ;
/* open to output file */
if ( Head.out_file == NULL ) {
Head.output = stdout;
} else {
if ( stat(Head.out_file, &st) != 0 ) {
if ((Head.output = fopen(Head.out_file, "w")) == NULL) {
put_error_and_exit( &Head, GPF_OPEN_OUT, argv[0] );
}
} else {
Head.text_file = Head.out_file;
if ( ( Head.out_file = GetTmpPath( Head.out_file ) ) == NULL ) {
put_error_and_exit( &Head, MKTMP_ERROR, argv[0] );
}
if ( ( Head.output = fopen( Head.out_file, "w" ) ) == NULL ) {
put_error_and_exit( &Head, GPF_OPEN_OUT, argv[0] );
}
}
}
if ( pipe( fd ) != 0 ) {
put_error_and_exit( &Head, PIPE_ERROR, argv[0] );
}
switch( fork() ) {
case 0:
close( fd[0] );
close( 1 );
if ( dup( fd[1] ) < 0 ) {
put_error_and_exit( &Head, DUP_ERROR, argv[0] );
}
close( fd[1] );
execl( oakgtobdf, oakgtobdf, Head.in_file, 0 );
put_error_and_exit( &Head, EXEC_ERROR, argv[0] );
case -1:
/* fork fail */
put_error_and_exit( &Head, FORK_ERROR, argv[0] );
default:
close( fd[1] );
Head.input = fdopen( fd[0], "r" );
}
if ( rtn = CnvBDFtoGPF( &Head, num_gr, gr, code_area ) ) {
wait( 0 );
fclose( Head.input );
if ( Head.out_file ) {
unlink( Head.out_file );
}
put_error_and_exit( &Head, rtn, argv[0] );
}
wait(0);
fclose( Head.input );
signal( SIGHUP, SIG_IGN );
signal( SIGINT, SIG_IGN );
signal( SIGQUIT, SIG_IGN );
signal( SIGTERM, SIG_IGN );
if ( Head.text_file ) {
fclose( Head.output );
Link_NewFile( Head.out_file, Head.text_file );
unlink( Head.out_file );
}
exit( 0 );
}
static int
CnvBDFtoGPF( head, num_gr, gr, code_area )
struct btophead *head;
int num_gr ;
FalGlyphRegion *gr ;
int code_area ;
{
int rtn;
char bdfbuf[BUFSIZE];
/* readto BDF head information */
if ((rtn = ReadBdfHeader(head, bdfbuf))) {
return(rtn);
}
if (head->p_width == USE_ORG_SIZE) {
head->p_width = head->bdf_width;
}
if (head->p_height == USE_ORG_SIZE) {
head->p_height = head->bdf_height;
}
if ((head->p_width != head->bdf_width) ||
(head->p_height != head->bdf_height)) {
head->zoomf = 1;
} else {
head->zoomf = 0;
}
if ((head->code = (int *)malloc(sizeof(int)*head->num_chars)) == NULL) {
return(MALLOC_ERROR);
}
if ((head->ptn = (char **)malloc(sizeof(char *)*head->num_chars)) == NULL) {
return(MALLOC_ERROR);
}
if ((rtn = readBdfToMemory(head, bdfbuf, num_gr, gr, code_area))) {
return(rtn);
}
WriteGpfHeader(head);
if ((rtn = WritePtnToGpf(head))) {
return(rtn);
}
return(0);
}
static void
put_error_and_exit(btop, er_no, prog_name)
struct btophead *btop;
int er_no;
char *prog_name;
{
ErrMsgTable_AndExit( er_no, btop->in_file, NULL,
NULL, btop->out_file,
NULL,
prog_name
);
return;
}
static void
put_help(prog_name)
char *prog_name;
{
USAGE1("Usage : %s -xlfd xlfd_name\n", prog_name);
USAGE("\t\t[-g character_size][-p character_pattern_file_name]\n");
USAGE("\t\t[-style style]\n");
USAGE("\t\t[-start start_code] [-end end_code]\n");
USAGE("\t\t[-width character_width] [-height character_height]\n");
COMM_HELP_MSG ;
USAGE1("%s can extract glyphs in cpf file format in the following code area.\n", prog_name);
USAGE("codeset \t\tcode area\n");
USAGE("----------------------------------------\n");
DispUdcCpArea() ;
USAGE("If the -start and -end option is omitted, the start/end code of each extractive area is specified.\n");
USAGE("The xlfd name and character size may be obtained using dtlsgpf command.\n");
return;
}
static void
Usage(prog_name)
char *prog_name;
{
put_help( prog_name );
exit(1);
}
static int
check_width( prog_name, len_str )
char *prog_name;
char *len_str;
{
return( check_width_height( prog_name, len_str, 0) );
}
static int
check_height( prog_name, len_str )
char *prog_name;
char *len_str;
{
return( check_width_height( prog_name, len_str, 1) );
}
static int
check_width_height( prog_name, len_str, mode )
char *prog_name;
char *len_str;
int mode; /* width ... 0 , height ... 1 */
{
int ret;
char *tmp;
ret = (int)strtol( len_str, &tmp, 10 ); /* <-- ret = atoi( len_str ) */
if ((tmp == len_str) || (ret < MIN_FONT_WIDTH) || (ret > MAX_FONT_WIDTH)) {
switch( mode ) {
case 0:
USAGE2("%s : The specification of the character width is improper.\"%s\"¡¥\n",
prog_name, len_str);
break;
case 1:
USAGE2("%s : The specification of the character height is improper.\"%s\"¡¥\n",
prog_name, len_str);
break;
default:
break;
}
return(0);
}
return( ret );
}
static int
check_code( prog_name, code_str, mode, charset, num_gr, gr )
char *prog_name;
char *code_str;
int mode; /* start_code ... 0, end_code ... 1 */
char *charset ;
int num_gr ;
FalGlyphRegion *gr ;
{
int err_flg = 0;
int code_num;
char *tmp;
FalGIInf *gi = NULL;
int num_gi ;
int i, code ;
code = (int)strtol(code_str, &tmp, 16);
if ( tmp == code_str ) {
err_flg = 1;
}
if( COMM_SBFNT_ISSBFNT( charset ) ) {
code_num = code ;
CONVGLYPHINDEX( code_num ) ;
} else {
if( fal_code_to_glyph( locale, code, &gi, &num_gi) ) {
USAGE2("%s : Failed to convert code point into glyph index.\"%s\" \n", prog_name, code_str ) ;
err_flg = 1;
}
if( num_gi==1 ){
code_num = gi[0].glyph_index ;
err_flg = 0 ;
}else{
for( i=0; i<num_gi; i++ ) {
if( !strcmp( gi[i].charset_str, char_set ) ) {
code_num = gi[i].glyph_index ;
err_flg = 0 ;
break ;
} else err_flg = 1 ;
}
}
}
XFree(gi);
if( !err_flg ) {
for( i=0; i<num_gr; i++ ) {
if( (code_num >= gr[i].start) && (code_num <= gr[i].end) )
return( code_num );
}
}
switch( mode ) {
case 0:
USAGE2("%s : The specification of the extract start code is improper.\"%s\"¡¥\n",
prog_name, code_str);
break;
case 1:
USAGE2("%s : The specification of the extract end code is improper.\"%s\"¡¥\n",
prog_name, code_str);
break;
default:
USAGE2("%s : The specification of the extract code is improper.\"%s\"¡¥\n",
prog_name, code_str);
}
return(-1);
}
static int
readBdfToMemory(head, buf, num_gr, gr, code_area)
struct btophead *head;
char *buf;
int num_gr ;
FalGlyphRegion *gr ;
int code_area ;
{
int code, mwidth, num_char, bsize, rtn;
char *ptn;
num_char = 0;
mwidth = (head->bdf_width + 7) / 8;
bsize = mwidth * head->bdf_height;
while(1) {
if ((rtn = GetBdfCode(head, buf, &code)) < 0) {
return(rtn); /* contain BDF_INVAL */
} else if (rtn == FILE_END) {
head->num_chars = num_char;
break;
}
if (
( code < head->start_code) || ( code > head->end_code )
||( !IN_CODE( head->code_category, SHIFT_ON( code ) ) )
||(
(head->code_category == ALL_CODE) &&
!( code_area & SYSTM ) &&
IsInRegion( code, num_gr, gr )
)
) {
continue;
}
head->code[num_char] = code;
if ( ( ptn = head->ptn[num_char++] = (char *)malloc( bsize ) ) == NULL ) {
return(MALLOC_ERROR);
}
if ((rtn = GetBdfPtn(head, buf, ptn, mwidth, bsize)) != 0) {
return(rtn);
}
}
return(0);
}

View file

@ -0,0 +1,31 @@
XCOMM $XConsortium: Imakefile /main/6 1996/09/09 11:19:55 drk $
DESTDIR = $(CDE_INSTALLATION_TOP)
BINDIR = /bin
FONTLIST = /config
OPT1 = -DDEFAULT_CODESET='"'3'"'
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"'
OPT4 = -DDTUDCFONTSLISTDIR='"'$(CDE_INSTALLATION_TOP)$(FONTLIST)'"'
DEFINES = $(OPT1) $(OPT2) $(OPT3) $(OPT4)
INCLUDES = -I../include\
-I../libfal\
-I../libfal/include
DEPLIBS = ../libfuty/liboakfuty.a ../libfal/libfal.a $(DEPXLIB)
LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB)
SYS_LIBRARIES = -lc
SRCS = lsgpf.c
OBJS = lsgpf.o
ComplexProgramTarget(dtlsgpf)

View file

@ -0,0 +1,927 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: lsgpf.c /main/7 1996/11/08 02:05:57 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdio.h>
#include <errno.h>
#include <locale.h>
#include <string.h>
#include "FaLib.h"
#include "falfont.h"
#include "bdfgpf.h"
#include "udcutil.h"
static void dsp_info_list();
static void dsp_title();
static void dspinfo_1line();
static void disp_no_fontslist();
static void sort_offset_list() ;
static int sort_fontlist() ;
static void dsp_error_title() ;
static int dsp_error_files() ;
static void put_help();
static int search_fontfile_name() ;
static int get_new_target() ;
static char *utillocale ;
static char *fontdir ;
static char *command_name ;
typedef struct {
int num;
struct {
int start;
int end;
}entry[BUFSIZE];
}MISS_ENTRY;
/* request for sort */
#define REQ_STYLE (1<<1)
#define REQ_CHARSIZE (1<<2)
#define REQ_LETTER (1<<3)
#define REQ_DELEQUAL (1<<16)
/* error flag */
#define NO_FONT (1<<1)
#define SAME_FONT (1<<2)
#define REDEFINED_FONT (1<<3)
/* request flag */
#define A_OPT (1<<1)
#define L_OPT (1<<2)
#define X_OPT (1<<3)
#define C_OPT (1<<4)
int
main( argc, argv )
int argc;
char *argv[];
{
FalFontDataList *lst_m; /* font information list struct */
FalFontData key; /* font reference information creation struct */
MISS_ENTRY unknown_m ; /* error */
int i, j;
int code_sw; /* code set flag */
int mask;
int code_set ;
int errflg ;
int dsp_opt ;
/* initialize */
command_name = argv[0] ;
errflg = 0 ;
unknown_m.num = 0;
code_sw = 0;
dsp_opt = 0 ;
/* get locale strings */
if( (utillocale = (char *)getenv( "LANG" )) == NULL ){
utillocale = "C" ;
}
if( (fontdir = (char *)getenv( "DTUDCFONTS" )) == (char *)NULL ) {
fontdir = DTUDCFONTSLISTDIR ;
}
/*
* dtlsgpf check on which options are required.
*/
for (i=1 ; i < argc ; i++) {
if (!strcmp(argv[i], "-help")) {
put_help(argv[0]);
exit(0);
}
if (*argv[i] != '-') {
put_help(argv[0]);
exit(1);
}
if ( !strcmp( argv[i], "-codeset" ) ) {
char *cbuf ;
if ( (i+1) >= argc ){
put_help( argv[0] );
exit( 1 );
}
i++;
code_set = (int)strtol( argv[i], &cbuf, 10 ) ;
if( argv[i] == cbuf ) {
put_help( argv[0] );
exit( 1 );
}
code_sw = 1 ;
}
for (j=1; argv[i][j] != '\0' ; j++) {
char req ;
req = argv[i][j] ;
if ( req == 'l') dsp_opt |= L_OPT ;
else if ( req == 'a') dsp_opt |= A_OPT ;
else if ( req == 'x') dsp_opt |= X_OPT ;
else if ( req == 'C') dsp_opt |= C_OPT ;
else {
put_help(argv[0]);
exit( 1 );
}
}
}
/* "-ax" -> "-a" */
if( dsp_opt == ( A_OPT | X_OPT ) ) dsp_opt = A_OPT ;
/*
* display information list of UDC code region
*/
if( dsp_opt & C_OPT ){
fprintf(stdout ,"codeset\t\tcode area\n");
fprintf(stdout ,"--------------------------------------------\n");
if ( DispUdcCpArea( stdout ) == -1 ){
ErrMsgTable_FalGetFontList( argv[0], fal_utyerror, fal_utyderror );
exit( 1 );
}
exit( 0 );
}
/*
* get an information list of UDC fonts
*/
mask = 0;
mask = FAL_FONT_MASK_UNDEFINED | FAL_FONT_MASK_DEFINED ;
if( code_sw ) {
mask |= FAL_FONT_MASK_CODE_SET ;
key.cd_set = FALGETFALCODESET( code_set ) ;
}
/* get font information list */
if ( FalGetFontList( &key, mask, &lst_m ) == FAL_ERROR ){
ErrMsgTable_FalGetFontList( argv[0], fal_utyerror, fal_utyderror );
exit( 1 );
}
/* sort element of font infomation list */
if( sort_fontlist( lst_m ) == FAL_ERROR ) {
FalFreeFontList( lst_m );
return FAL_ERROR ;
}
/*
* dtlsgpf shows UDC informations as user's request.
*/
dsp_title( stdout, dsp_opt );
if ( lst_m->num == 0) {
disp_no_fontslist( dsp_opt ) ;
} else {
dsp_info_list( argv[0], dsp_opt, lst_m, &unknown_m, &errflg );
if (unknown_m.num != 0) {
if( dsp_opt & L_OPT ) {
dsp_error_title(argv[0], &errflg, dsp_opt );
if( dsp_error_files( lst_m, &unknown_m ) ) {
exit( 1 );
}
}
}
}
FalFreeFontList( lst_m );
exit( 0 );
}
static void
dsp_info_list( com, dspopt, lst, unknown_file_lst, errflg )
char *com;
int dspopt;
FalFontDataList *lst;
MISS_ENTRY *unknown_file_lst;
int *errflg ;
{
FalFontDataList srt_lst;
int i, j ;
int entry, entry_end;
int ret;
char *filename; /* file base's name */
char fname[BUFSIZE];
char tmpfname[BUFSIZE];
int srt_cnt, *sort_list, cnt, mask ;
if( lst->num == 0 ){
return ;
}
srt_lst.num = lst->num ;
srt_lst.list = (FalFontData *)malloc( sizeof(FalFontData) * lst->num ) ;
if( srt_lst.list == NULL ) {
USAGE("dtlsgpf : malloc error.\n" ) ;
exit(1) ;
}
for (i=0, srt_cnt=0 ; i < lst->num ; i++) {
int letter_cmp;
entry = entry_end = i;
for (j=i ;
(j < lst->num) &&
!strcmp(lst->list[j].style.name, lst->list[entry].style.name) &&
(lst->list[j].size.h == lst->list[entry].size.h ) ;
j++)
{
if( (lst->list[j].letter.h == 0) ||
(lst->list[j].letter.w == 0) ) break ;
entry_end = j;
}
if ( entry == entry_end ) {
if ( dspopt & L_OPT || dspopt & X_OPT )
dspinfo_1line( lst->list[entry], stdout,
unknown_file_lst, entry,
errflg, dspopt );
else memmove( &(srt_lst.list[srt_cnt++]),
&(lst->list[entry]),
sizeof(FalFontData) );
continue;
}
letter_cmp = lst->list[entry].letter.h;
for (j=entry ; j <= entry_end ; j++) {
if (lst->list[j].letter.h != letter_cmp) {
break;
}
}
if (j > entry_end) {
ret = GetDefaultFile( lst->list[entry].size.h,
lst->list[entry].style.name, fname);
if ( ret < 0 ) {
fname[0]='\0';
for ( j = entry; j <= entry_end; j++ ) {
if ( dspopt & L_OPT || dspopt & X_OPT )
dspinfo_1line( lst->list[j], stdout,
unknown_file_lst, j,
errflg, dspopt );
else memmove(
&(srt_lst.list[srt_cnt++]),
&(lst->list[j]),
sizeof(FalFontData) );
}
i = entry_end;
continue ;
}
for( j = entry; j <= entry_end; j++ ) {
ret = search_fontfile_name(
lst->list[j], tmpfname,
unknown_file_lst, j, errflg
) ;
if( ret == -1 ) continue ;
else if( ret == -2 ) exit(1) ;
filename = falcom_get_base_name( tmpfname ) ;
if ( !strcmp( filename, fname ) ){
if ( dspopt & L_OPT || dspopt & X_OPT )
dspinfo_1line( lst->list[j], stdout,
unknown_file_lst, j,
errflg, dspopt );
else memmove(
&(srt_lst.list[srt_cnt++]),
&(lst->list[j]),
sizeof(FalFontData) );
break;
}
}
i = entry_end;
continue;
}
ret = GetDefaultFile(
lst->list[entry].size.h,
lst->list[entry].style.name,
fname
);
if( ret ) {
switch ( ret ) {
case -1:
for ( j = entry; j <= entry_end; j++ ) {
if ( dspopt & L_OPT || dspopt & X_OPT )
dspinfo_1line(
lst->list[j], stdout,
unknown_file_lst, j,
errflg, dspopt );
else memmove(
&(srt_lst.list[srt_cnt++]),
&(lst->list[j]),
sizeof(FalFontData) );
}
break ;
case -2:
unknown_file_lst->entry[ unknown_file_lst->num ].start = entry;
unknown_file_lst->entry[ unknown_file_lst->num ].end = entry_end;
unknown_file_lst->num++;
*errflg |= REDEFINED_FONT ;
break ;
case -3:
USAGE4("%s : The user defined character information file cannot be read.\"%s/%s/%s \"\n\n",
com, fontdir, utillocale, UDFLIST_DEF );
exit(1) ;
case -4:
USAGE4("%s : The mistake is found in the description of the user defined character information file.\"%s/%s/%s \"\n\n",
com, utillocale, fontdir, UDFLIST_DEF );
for ( j = entry; j <= entry_end; j++ ) {
if ( dspopt & L_OPT || dspopt & X_OPT )
dspinfo_1line( lst->list[j], stdout,
unknown_file_lst, j,
errflg, dspopt );
else memmove(
&(srt_lst.list[srt_cnt++]),
&(lst->list[j]),
sizeof(FalFontData) );
}
break ;
}
i = entry_end;
continue;
}
for ( j = entry; j <= entry_end; j++ ) {
ret = search_fontfile_name(
lst->list[j], tmpfname,
unknown_file_lst, j, errflg
) ;
if( ret == -1 ) continue ;
else if( ret == -2 ) exit(1) ;
filename = falcom_get_base_name( tmpfname ) ;
if ( !strcmp( filename, fname ) ){
if ( dspopt & L_OPT || dspopt & X_OPT )
dspinfo_1line( lst->list[j], stdout,
unknown_file_lst, j,
errflg, dspopt );
else memmove(
&(srt_lst.list[srt_cnt++]),
&(lst->list[j]),
sizeof(FalFontData) );
break;
}
}
if ( j > entry_end ) {
unknown_file_lst->entry[ unknown_file_lst->num ].start = entry;
unknown_file_lst->entry[ unknown_file_lst->num ].end = entry_end;
unknown_file_lst->num++;
*errflg |= REDEFINED_FONT ;
}
i = entry_end;
}
/*
* dtlsgpf displays the infomations of user defined characters.
*/
if ( !(dspopt & L_OPT) ) { /* display character size and style */
srt_lst.num = srt_cnt ;
if ( dspopt & A_OPT )
mask = REQ_STYLE | REQ_CHARSIZE | REQ_LETTER | REQ_DELEQUAL ;
else
mask = REQ_CHARSIZE | REQ_DELEQUAL ;
sort_offset_list( &srt_lst, mask, &sort_list, &cnt ) ;
for (i=0 ; i<cnt; i++)
dspinfo_1line( srt_lst.list[sort_list[i]], stdout,
unknown_file_lst, sort_list[i],
errflg, dspopt );
free( sort_list ) ;
free( srt_lst.list ) ;
}
}
static void
dsp_error_title(com, errflg, dspopt )
char *com;
int *errflg ;
int dspopt ;
{
USAGE("\n\n" );
if( dspopt & A_OPT ) {
if( *errflg & SAME_FONT )
USAGE1("%s : There are fonts that are same character size and have same style, \ncode set and XLFD. It is not possible to select user defined character fonts uniquely.\n\n", com);
USAGE("Please inquire of the system manager.\n\n");
} else {
if( *errflg & NO_FONT )
USAGE1("\n%s : Mistake is found in the name of user defined character fonts \nfollowing character size and style.\n\n", com);
if( *errflg & REDEFINED_FONT )
USAGE3(" Please describe the following file name in the user defined character \ninformation file(%s/%s/%s).\n\n",
fontdir, utillocale, UDFLIST_DEF );
}
}
static int
dsp_error_files( lst, unknown )
FalFontDataList *lst;
MISS_ENTRY *unknown;
{
int i,j;
int entry_start, entry_end;
char *filename;
char tmp_fname[BUFSIZE];
int ret ;
if ( unknown->num == 0 ){
return 0;
}
for (i=0 ; i<unknown->num ; i++) {
entry_start = unknown->entry[i].start;
entry_end = unknown->entry[i].end;
USAGE1("\tcode set \t%d \n",
FALCODESETTONUM( lst->list[entry_start].cd_set ) ) ;
USAGE1("\tcharacter_size \t%d\n",
lst->list[entry_start].size.h ) ;
USAGE1("\tstyle \t\t%s \n", lst->list[entry_start].style.name ) ;
USAGE("\n" );
for ( j = entry_start; j <= entry_end; j++ ) {
ret = search_fontfile_name( lst->list[j], tmp_fname, NULL, 0, 0 ) ;
if( ret == -1 ){
USAGE("\t\tThere is no font file that is required." );
USAGE1("\t%s\n", lst->list[j].xlfdname );
continue ;
} else if( ret == -2 ){
return -1 ;
}
filename = tmp_fname ;
USAGE1("\t\t%s", filename );
USAGE1("\t%s\n", lst->list[j].xlfdname );
}
USAGE("\n" );
}
USAGE("\n" );
return 0;
}
#define SORTOFFSETNUM {\
offset = size_offset_list[j] ;\
size_offset_list[j] = size_offset_list[i] ;\
size_offset_list[i] = offset ;\
}
static void
sort_offset_list( flist, mask, sort_list, data_cnt )
FalFontDataList *flist ;
int mask ;
int **sort_list ;
int *data_cnt ;
{
int *size_offset_list ;
int cnt, i, j ;
int offset ;
int exist ;
if( flist->num == 0 ){
return ;
}
if( (size_offset_list = (int *)malloc( flist->num * sizeof(int) )) == NULL )
{
USAGE("dtlsgpf: malloc error.\n" );
exit(1) ;
}
for( i=0 ; i < flist->num; i++ ) size_offset_list[i] = -1 ;
for( i=0, cnt=0; i < flist->num; i++ ) {
if( mask & REQ_DELEQUAL ) {
exist = REQ_DELEQUAL ;
for( j=0; j<cnt; j++ ) {
if( size_offset_list[j] == -1 ) break ;
if( (mask & REQ_CHARSIZE) &&
(flist->list[size_offset_list[j]].size.h == flist->list[i].size.h)
) {
exist |= REQ_CHARSIZE ;
}
if( (mask & REQ_LETTER) &&
(flist->list[size_offset_list[j]].letter.h == flist->list[i].letter.h)
) {
exist |= REQ_LETTER ;
}
if( (mask & REQ_STYLE) &&
!strcmp(flist->list[size_offset_list[j]].style.name, flist->list[i].style.name)
) {
exist |= REQ_STYLE ;
}
if( exist == mask ) break ;
else exist = REQ_DELEQUAL ;
} /* size_offset_list */
if( exist == mask ) continue ;
} /* REQ_DELEQUAL */
size_offset_list[cnt++] = i ;
} /* flist */
/* sort data */
for( i=0; i<cnt-1; i++ ) {
for( j=i+1; j<cnt; j++ ) {
if( mask & REQ_LETTER ) {
if( flist->list[size_offset_list[i]].letter.h >
flist->list[size_offset_list[j]].letter.h)
{
SORTOFFSETNUM ;
}
}
if( mask & REQ_CHARSIZE ) {
if( flist->list[size_offset_list[i]].size.h >
flist->list[size_offset_list[j]].size.h)
{
SORTOFFSETNUM ;
}
}
if( mask & REQ_STYLE ) {
if( strcoll(flist->list[size_offset_list[i]].style.name,
flist->list[size_offset_list[j]].style.name) > 0 )
{
SORTOFFSETNUM ;
}
}
}
}
*sort_list = size_offset_list ;
*data_cnt = cnt ;
}
static void
dsp_title( fp, dspopt )
FILE *fp;
int dspopt ;
{
if( dspopt & L_OPT || dspopt & X_OPT ) {
fprintf(fp, "\n" ) ;
if( dspopt & X_OPT ) fprintf(fp, " code set" );
if( dspopt & L_OPT ) fprintf(fp, "\tfilename\t" );
if( (dspopt != X_OPT) && (dspopt != (L_OPT | X_OPT)) )
fprintf(fp, "character size\t" );
COMM_DSP_LETTER_T ;
if( dspopt & A_OPT ) fprintf(fp, "style \t" );
COMM_DSP_PRM ;
if( dspopt != X_OPT ) fprintf(fp, "\n" ) ;
if( dspopt & X_OPT ) fprintf(fp, "\tXLFD\n" );
fprintf(fp ,"-----------------------------------------------------------------------------\n");
}
}
static void
dspinfo_1line( data, fp, unknown_file_lst, offset, errflg, dspopt )
FalFontData data;
FILE *fp;
MISS_ENTRY *unknown_file_lst;
int offset ;
int *errflg ;
int dspopt ;
{
int dsp_on ;
char *namep;
char tmp_fname[BUFSIZE];
int ret ;
dsp_on = 0;
/* get font informations */
ret = search_fontfile_name( data, tmp_fname, unknown_file_lst, offset, errflg ) ;
if( ret == -1 ) return ;
else if( ret == -2 ) exit(1) ;
namep = tmp_fname ;
/* display font informations */
if( dspopt & X_OPT ) fprintf( fp, "%d \t", FALCODESETTONUM( data.cd_set ) );
if( dspopt & L_OPT ) fprintf( fp, "%s\t", namep );
if( (dspopt != X_OPT) &&
(dspopt != (L_OPT | X_OPT))
) {
fprintf( fp, "%d", data.size.h );
}
if( dspopt & A_OPT ) {
if( data.letter.h ) {
if( !(dspopt & L_OPT) )
fprintf( fp, ".%d", data.letter.h );
else
fprintf( fp, "\t%4d", data.letter.h );
}
fprintf( fp, "\t" );
fprintf( fp, "%s", data.style.name );
}
if( dspopt & L_OPT ) {
fprintf( fp, "\t" );
if( data.prm & FAL_FONT_DISPLAY ) {
fprintf( fp, "display");
dsp_on = 1;
}
if( data.prm & FAL_FONT_PRINTER ) {
if( dsp_on ) {
fprintf( fp, " & ");
}
fprintf( fp, "printer");
}
}
if( dspopt != X_OPT ){
fprintf( fp, "\n");
if( dspopt & X_OPT ) fprintf( fp, "\t" );
}
if( dspopt & X_OPT ) fprintf( fp, "%s\n", data.xlfdname );
if( dspopt != X_OPT ){
if( dspopt & X_OPT ) fprintf( fp, "\n" );
}
}
static void
disp_no_fontslist( dspopt )
int dspopt ;
{
fprintf( stdout, "\nThere are no fonts that are used for user defined character.\n" ) ;
}
static void
put_help( prog_name )
char *prog_name;
{
USAGE1("Usage : %s [-lax][-la][-lx][-C][-codeset number][-help]\n", prog_name);
USAGE("\t-l : display of file name and character size\n");
USAGE("\t-a : display of style(FAMILY_NAME) information\n");
USAGE("\t-x : display of XLFD information\n");
USAGE("\t-C : display of code area informations\n");
USAGE("\t-codeset : specification of the codeset\n");
USAGE("\t-help : display of of the command parameter informations\n");
USAGE(" (If the option is not specified, only the character size are displayed.)\n");
}
static int
search_fontfile_name( data, fname, unknown_file_lst, offset, errflg )
FalFontData data ;
char *fname ;
MISS_ENTRY *unknown_file_lst;
int offset ;
int *errflg ;
{
FalFontID fid ;
FalFontDataList *flist ;
int mask ;
char *tmp_fname ;
mask =
FAL_FONT_MASK_UNDEFINED | FAL_FONT_MASK_DEFINED |
FAL_FONT_MASK_XLFDNAME |
FAL_FONT_MASK_SIZE_H |
FAL_FONT_MASK_STYLE_NAME | FAL_FONT_MASK_CODE_SET
;
if( data.size.w >= 0 ) mask |= FAL_FONT_MASK_SIZE_W ;
if( data.letter.w ) mask |= FAL_FONT_MASK_LETTER_W ;
if( data.letter.h ) mask |= FAL_FONT_MASK_LETTER_H ;
if( data.letter.x ) mask |= FAL_FONT_MASK_LETTER_X ;
if( data.letter.y ) mask |= FAL_FONT_MASK_LETTER_Y ;
if( data.style.def ) mask |= FAL_FONT_MASK_STYLE_DEF ;
if( data.shape.name ) mask |= FAL_FONT_MASK_SHAPE_NAME ;
if( data.shape.def ) mask |= FAL_FONT_MASK_SHAPE_DEF ;
COMM_SBCHR_SETFONTDATA( data, mask ) ;
if( data.prm ) mask |= FAL_FONT_MASK_PERMISSION ;
fid = FalOpenSysFont( &data, mask, &flist ) ;
if( fid == 0 ) {
memset( fname, '\0', sizeof(fname) ) ;
if( flist ){
FalFreeFontList( flist ) ;
if( unknown_file_lst ) {
unknown_file_lst->entry[ unknown_file_lst->num ].start = offset ;
unknown_file_lst->entry[ unknown_file_lst->num ].end = offset ;
unknown_file_lst->num++;
*errflg |= SAME_FONT ;
}
return(-1);
} else {
switch( fal_utyerror ) {
case _FAL_OPEN_ER :
case _FAL_READ_ER :
case _FAL_STAT_ER :
switch( fal_utyderror ) {
case EACCES :
case ENOENT :
if( unknown_file_lst ) {
unknown_file_lst->entry[ unknown_file_lst->num ].start = offset ;
unknown_file_lst->entry[ unknown_file_lst->num ].end = offset ;
unknown_file_lst->num++;
*errflg |= NO_FONT ;
}
return(-1) ;
default :
USAGE2("System call error occurred. fal_utyerror = %d fal_utyderror = %d\n", fal_utyerror, fal_utyderror ) ;
return(-2) ;
}
case _FAL_FONT_ER :
if( unknown_file_lst ) {
unknown_file_lst->entry[ unknown_file_lst->num ].start = offset ;
unknown_file_lst->entry[ unknown_file_lst->num ].end = offset ;
unknown_file_lst->num++;
*errflg |= NO_FONT ;
}
return(-1) ;
case _FAL_MALOC_ER :
USAGE("malloc error occurred.\n" ) ;
return(-2) ;
default :
USAGE1("%s : cannot get font information list.\n", command_name ) ;
return(-2) ;
}
}
}
if( FalFontIDToFileName( fid, &tmp_fname ) == FAL_ERROR ) {
USAGE1("%s : cannot get file name.\n", command_name ) ;
FalCloseFont( fid ) ;
return(-2) ;
}
strcpy( fname, tmp_fname ) ;
FalFree( tmp_fname ) ;
FalCloseFont( fid ) ;
return(0) ;
}
static int
sort_fontlist( lst )
FalFontDataList *lst;
{
int i,j;
FalFontDataList srt;
FalFontData target;
int target_entry;
if( lst->num == 0 ){
return(0) ;
}
srt.num = lst->num;
if (( srt.list = (FalFontData *)malloc(sizeof(FalFontData) * srt.num)) == NULL) {
return FAL_ERROR;
}
memmove (srt.list, lst->list, sizeof(FalFontData) * srt.num);
/* start to sort */
for ( i=0 ; i < srt.num -1 ; i++ ) {
memmove( &target, &(srt.list[i]), sizeof(FalFontData));
target_entry = i;
for ( j=i+1 ; j < srt.num ; j++ ) {
if ( get_new_target( &target, &(srt.list[j]) ) ) {
memmove( &target, &(srt.list[j]), sizeof(FalFontData));
target_entry = j;
}
}
if (target_entry != i) {
memmove( &target, &(srt.list[target_entry]),
sizeof(FalFontData)
);
memmove( &(srt.list[i+1]), &(srt.list[i]),
sizeof(FalFontData)*(target_entry -i)
);
memmove( &(srt.list[i]), &target,
sizeof(FalFontData)
);
}
}
free(lst->list);
lst->list = srt.list;
return(0);
}
/* sort flag */
/* return data ¡§ sort ... 1 */
/* no sort ... 0 */
static int
get_new_target( target, choose )
FalFontData *target;
FalFontData *choose;
{
FalFontData diff;
DEF_STR_CHK ;
DEF_STR_SET ;
diff.style.def = choose->style.def - target->style.def;
str_chk.style = strcmp( choose->style.name, target->style.name ) ;
NEW_TARGET_SET( diff, choose, target, str_chk ) ;
diff.shape.def = choose->shape.def - target->shape.def;
if( (choose->shape.name != NULL) && (target->shape.name != NULL) ) {
str_chk.shape = strcmp( choose->shape.name, target->shape.name ) ;
}
diff.cd_set = choose->cd_set - target->cd_set;
diff.size.h = choose->size.h - target->size.h;
diff.size.w = choose->size.w - target->size.w;
diff.letter.h = choose->letter.h - target->letter.h;
diff.letter.w = choose->letter.w - target->letter.w;
/* codeset */
if ( diff.cd_set < 0 ) return 1;
if ( diff.cd_set > 0 ) return 0;
/* character size height */
if ( diff.size.h < 0 ) return 1;
if ( diff.size.h > 0 ) return 0;
/* letter size height */
if ( diff.letter.h < 0 ) return 1;
if ( diff.letter.h > 0 ) return 0;
/* character size wide */
if ( diff.size.w < 0 ) return 1;
if ( diff.size.w > 0 ) return 0;
/* letter size wide */
if ( diff.letter.w < 0 ) return 1;
if ( diff.letter.w > 0 ) return 0;
/* style */
if ( target->style.def == FAL_FONT_UNKNOWN ) {
if ( choose->style.def > 0 ) return 1;
/* style is FAL_FONT_UNKNOWN both "target" and "choose" */
if ( str_chk.style < 0 ) return 1;
if ( str_chk.style > 0) return 0;
} else if ( choose->style.def == FAL_FONT_UNKNOWN ) {
return 0;
}
/* target->style.def and choose->style.def is not FAL_FONT_UNKNOWN */
if ( diff.style.def < 0 ) return 1;
if ( diff.style.def > 0 ) return 0;
NEW_TARGET_CHK( diff, choose, target, str_chk ) ;
/* character style */
if ( target->shape.def == FAL_FONT_UNKNOWN ) {
if ( choose->shape.def > 0 ) return 1;
if ( str_chk.shape < 0 ) return 1;
if ( str_chk.shape > 0 ) return 0;
} else if (choose->shape.def == FAL_FONT_UNKNOWN ) {
return 0;
}
if ( diff.shape.def < 0 ) return 1;
if ( diff.shape.def > 0 ) return 0;
return 0;
}

View file

@ -0,0 +1,71 @@
.\" $XConsortium: dtudcfonted.1 /main/2 1996/10/29 15:41:16 drk $
.\"---
.\" (c) Copyright 1996 FUJITSU Ltd.
.\"---
.TH dtudcfonted 1X "20 Feb. 1996""
.BH "20 Feb. 1996""
.SH NAME
dtudcfonted - the User Defined Characters (UDCs) Font Editor
.SH SYNOPSIS
dtudcfonted [options]
.SH DESCRIPTION
The UDCs Editor provides the facilities that enable the user to edit
User Defined Characters font.
.P
The UDCs Editor uses lines and geometric shape drawing tools in order
to create new User Defined Character or modify existing ones.
It support PCF (Portable Compoled Formet) and SNF (Server Natural Format)
formats.
.sp .5
.SS Key Supported Tasks
.RS
.P
- Modify size of window.
.P
- Modify location of window.
.P
- Iconify window.
.P
- Edit a User Defined Character or existing icon.
.P
- Save the current font.
.P
- Undo the last operation.
.P
- Cut, copy, and paste areas within the UDCs Editor editing area.
.P
- Rotate selected area.
.P
- Copy User Defined Character.
.RE
.SH OPTIONS
The following options are available from the command line:
.sp 1.5
.BI \-pane_size " pane_size"
.sp .5
This option takes a size of UDCs Editor editing area.
.sp 1.5
.BI \-codepoint
.sp .5
This option specifies code format.
If you do not set this optiton, UDCs editor uses Glyph Index code.
If you do set this optiton, UDCs editor uses Code point code.
.sp 1.5
.SH RETURN VALUE
Exit values are:
.IP "\f30\fP" .5i
Successful completion.
.IP "\f3>0\fP" .5i
Error condition occurred.
.sp 1.5
.SH EXAMPLES
.IP "dtudcfonted" .5i
Starts the UDCs Editor.
.sp 1.5
.IP NOTE: .5i
UDCs Editor uses with root user.
.sp 1.5
.SH FILES
Files used by this component.
.IP "/.../dt/app-defaults/C/Dtudcfonted App-defaults file. " .5i
.IP "/.../dt/app-defaults/ja_JP/Dtudcfonted App-defaults file. " .5i

View file

@ -0,0 +1,186 @@
$ $XConsortium: dtudcfonted.msg
$ *************************************<+>*************************************
$ *****************************************************************************
$ **
$ ** File: dtudcfonted.msg
$ **
$ ** Project: Fujitsu DT UDC Font Editor
$ **
$ ** Description:
$ ** -----------
$ ** This file is the source for the message catalog for dtudcfonted
$ **
$ **
$ *****************************************************************************
$ **
$ ** (c) Copyright 1996 Fujitsu Ltd.
$ **
$set 2
$ *****************************************************************************
$ ** _DtMessage set for ufont.c
$ *****************************************************************************
$ This is footer message when registration of the character.
2 Registration processing inside.
$ Message4-8 are error messages when registration of the character.
4 Failed in the registration of the character.
6 Illegal code.
8 Because the memory allocation cannot be done, it is not possible to add.
$ Message10-16 are error messages when copying of the character.
10 There is no character of the specified code.
12 The mistake is found in the specified copy origin code.
14 The mistake is found in the specified copy target code.
16 There is no character in the specified area.
$ This is footer message.
18 Please wait for a while.
$ This is error message when copying of the character.
20 No copy origin code file is specified.
$ Message22-24 are error message of user defined character
22 Informations of user defined character cannot collect.\nThere is no font specified.
24 Informations of user defined character cannot collect.\nThere are plural fonts specified.
$ UDC is User Defined Character.
26 The specified font do not have any UDCs areas.
28 There are no memories any more.
30 The information of UDCs area is illegal.
32 The font file cannot read.\nPattern area was broken.
$ Dtudcfonted is name of this application.
34 Dtudcfonted cannot edit proportional character font.
36 There are unsaved edits.\nDo you want to save them before opening?
38 There are unsaved edits.\nDo you want to save them before exiting?
40 When the copy processing is done, the glyph\nimage within the following ranges is changed.\nDo you want to do the copy processing?\n\n
42 No write permission for this font. You should change the file access mode before saving.\n
$ There are user-visible labels in font-open dialog.
100 Select Items
102 - CodeSet:
104 - Style:
106 - Width:
108 - Height:
110 Open
112 Quit
$ There are user-visible labels in menubar.
114 Font
116 Edit
118 Character
120 Information
$ There are user-visible labels in File menu.
122 Open...
124 Save
126 Exit
$ There are user-visible labels in Edit menu.
$ Message135 is copy of cut&copy
128 Clear
130 Set
132 Reverse
134 Cut
135 Copy
136 Paste
138 Rotate
140 Vertical Roll
142 Horizontal Roll
144 Undo
$ There are user-visible labels in Character menu.
$ Message148 is copy of character
146 Add/Delete...
148 Copy...
$ There are user-visible labels in Information menu.
150 XLFD name...
152 Code Area...
$ There are user-visible labels in add/delete dialog.
154 Add
156 Delete
158 Cancel
$ There are user-visible labels in copy dialog.
$ Message166 is label of execute button
160 Code(hex):
162 Copy origin code(hex):
164 Copy target code(hex):
166 Copy
168 Overlay
170 OK
$ There are user-visible labels in unsaved edits.
172 Save
174 Do not Save
176 Save and Exit
178 Do not Save and Exit
$ There are user-visible labels in delete notice dialog.
$ This format is `Message180 (?? Message182)' and `Message184 (?? Message186)'.
$ These Message180 and Message182 are used in only one character.
$ These Message184 and Message186 are used in plural characters.
180 The following character will be deleted.
182 character
184 The following characters will be deleted.
186 characters
188 Register completed
190 Code :
192 Code range :
$ There are footer message label.
194 Message :
$ There are user-visible labels in code dialog.
196 code...
198 Page up
200 Page down
202 Apply
$ There are title.
204 dtudcfonted - Question
206 dtudcfonted - Warning
208 dtudcfonted - Error
210 dtudcfonted - Copy
212 dtudcfonted - Open
214 dtudcfonted - Add/Delete
216 dtudcfonted - XLFD
218 dtudcfonted - CodeArea
$ There are information message.
230 File name
232 XLFD name
234 Code area
$ There are error message of libfal.
300 Fatal error occurred.
301 Cannot open the font file.
302 Cannot read the font file.
303 There is no more memory.
304 Fatal error occurred.
305 The specified font file does not exist.
306 This font is not a pcf or snf font.
307 Cannot open fonts.list file.
308 The format of fonts.list file is illegal.
309 The descriptions of the fonts.list file are incorrect.
310 The format of fonts.list file is illegal.
311 Cannot open fonts.dir file.
312 Cannot read fonts.dir file.
313 Cannot read font properties.
314 Cannot get FONT property.
315 Cannot get FAMILY_NAME property.
316 This font file is already opened by other application.
317 Cannot lock font file.
318 Cannot unlock font file.
319 Cannot get lock information from the font file.
320 Cannot find the specified font file.
321 Cannot read NLS database.
322 Cannot get charset names from NLS database.
323 Charset name not defined in NLS database.
324 The specified font has not been opened.
325 Fatal error occurred.

View file

@ -0,0 +1,56 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* fssxeg.h 1.5 - Fujitsu source for CDEnext 96/07/18 13:19:30 */
/* $XConsortium: fssxeg.h /main/4 1996/07/19 20:32:54 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "udccom.h" /* 1995.10.09 */
#include "FaLib.h"
typedef int INT;
typedef short int SHORT;
typedef long int LONG;
typedef char CHAR;
typedef unsigned int UINT;
typedef unsigned short USHORT;
typedef unsigned char UCHAR;
#define ON 1
#define OFF 0
#define MAXPTNSIZE 128
#define MAXPTNBYTE MAXPTNSIZE*((MAXPTNSIZE+7)/8)
#define ERROR_VAL fal_utyerror
#define EXISTS_FLAG fal_utyexists
#define EDPANE_SIZE 400
#define EDLIST_MAX 30

View file

@ -0,0 +1,410 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: FaLib.h /main/5 1996/06/25 20:08:31 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#ifndef _FALIB_H
#define _FALIB_H
#ifdef __cplusplus
extern "C" {
#endif
#define FAL_ERROR -1
extern int fal_utyerror; /* library error information */
extern int fal_utyderror; /* library error information */
extern int fal_utyexists; /* existence's flag of font pattern */
extern unsigned long fal_utyerrno ; /* library error information */
extern char fal_err_file[] ;
/*
*
* structure of the font information
*
*/
/*
* the equipment of output permission
*/
#define FAL_FONT_DISPLAY 1
#define FAL_FONT_PRINTER 2
#define FAL_FONT_GLYPH_INDEX -1
/*
* codeset
*/
#define FAL_FONT_CS0 1
#define FAL_FONT_CS1 2
#define FAL_FONT_CS2 3
#define FAL_FONT_CS3 4
#define FAL_FONT_CS4 5
#define FAL_FONT_CS5 6
#define FAL_FONT_CS6 7
#define FAL_FONT_CS7 8
#define FAL_FONT_CS8 9
/*
* font search mask
*/
#define FAL_FONT_MASK_XLFDNAME (1L<<1)
#define FAL_FONT_MASK_SIZE_W (1L<<2)
#define FAL_FONT_MASK_SIZE_H (1L<<3)
#define FAL_FONT_MASK_LETTER_W (1L<<4)
#define FAL_FONT_MASK_LETTER_H (1L<<5)
#define FAL_FONT_MASK_LETTER_X (1L<<6)
#define FAL_FONT_MASK_LETTER_Y (1L<<7)
#define FAL_FONT_MASK_STYLE_DEF (1L<<8)
#define FAL_FONT_MASK_STYLE_NAME (1L<<9)
#define FAL_FONT_MASK_SHAPE_DEF (1L<<10)
#define FAL_FONT_MASK_SHAPE_NAME (1L<<11)
#define FAL_FONT_MASK_CODE_SET (1L<<14)
#define FAL_FONT_MASK_PERMISSION (1L<<15)
#define FAL_FONT_MASK_DEL_EQUALDATA (1L<<16)
#define FAL_FONT_MASK_CHECK_ALL 0x1FFFF
#define FAL_FONT_MASK_GLYPH_INDEX (1L<<17)
#define FAL_FONT_MASK_UPDATE (1L<<18)
#define FAL_FONT_MASK_DEFINED (1L<<19)
#define FAL_FONT_MASK_UNDEFINED (1L<<20)
/*
* undefined the character style,shape
*/
#define FAL_FONT_UNKNOWN 0
/*
* definition's data of character style
*/
#define FAL_FONT_MINCHO 1
#define FAL_FONT_STR_MINCHO "mincho"
#define FAL_FONT_GOTHIC 2
#define FAL_FONT_STR_GOTHIC "gothic"
#define FAL_FONT_MARU_GOTHIC 3
#define FAL_FONT_STR_MARU_GOTHIC "maru_gothic"
#define FAL_FONT_TEXTBOOK 4
#define FAL_FONT_STR_TEXTBOOK "textbook"
#define FAL_FONT_BRASH_GYOU 5
#define FAL_FONT_STR_BRASH_GYOU "brash_gyou"
#define FAL_FONT_BRASH_KAI 6
#define FAL_FONT_STR_BRASH_KAI "brash_kai"
#define FAL_FONT_HANDWRITING 7
#define FAL_FONT_STR_HANDWRITING "handwriting"
/*
* definition's data of character shape
*/
#define FAL_FONT_ZENKAKU 1
#define FAL_FONT_STR_ZENKAKU "zenkaku"
#define FAL_FONT_HANKAKU 2
#define FAL_FONT_STR_HANKAKU "hankaku"
#define FAL_FONT_QUARTER 3
#define FAL_FONT_STR_QUARTER "1/4kaku"
/*
* structures for font informations
*/
typedef struct {
int width; /* width */
int height; /* height */
int top; /* the head code */
int bottom; /* the final code */
} FalFontinfo ;
typedef struct {
int num;
char **path;
} FalFontPath;
typedef struct {
int def; /* definition data */
char *name; /* the information of the character line */
}FalFontDB;
/*
* structure of the font information
*/
typedef struct {
char *xlfdname; /* xlfd name */
struct {
int w; /* the width of the character size */
int h; /* the height of the character size */
}size;
struct {
int w; /* the width of the letter size */
int h; /* the height of the letter size */
int x; /* position x of the letter size */
int y; /* position y of the letter size */
}letter;
FalFontDB style; /* character style */
FalFontDB shape; /* character shape */
FalFontDB reserve ; /* reserve */
int cd_set; /* codeset */
int prm; /* the equipment of output permission */
}FalFontData;
typedef struct {
int num; /* the number of font data*/
FalFontData *list; /* the pointer to the array of
FalFontData structure */
}FalFontDataList;
/*
* UDC infomations
*/
typedef struct _FalCodeRegion {
int start ; /* first code */
int end ; /* last code */
} FalCodeRegion ;
typedef struct _FalGlyphRegion {
int start ; /* first glyph index */
int end ; /* last glyph index */
} FalGlyphRegion ;
typedef struct _FalGIInf {
char *charset_str; /* charcter set */
int glyph_index; /* glyph index */
} FalGIInf;
/*
* structure of the font identifier
*/
#include <X11/Xos.h>
#include <X11/Xmd.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include <stdlib.h>
#include <dirent.h>
#ifdef Bool
#undef Bool
#endif
#include "snfstruct.h"
#include "fontstruct.h"
#include "pcf.h"
struct pcf_inf {
FontInfoRec info;
xCharInfo org_bounds;
PCFTablePtr tables;
int ntables;
CARD32 bmp_fmt; /* bitOrder ,byteOrder, glyph, scan */
int nbitmaps;
CARD32 *offsets;
int sizebitmaps;
char *bitmaps;
CARD32 enc_fmt;
CARD16 *encodingOffsets;
};
typedef struct _Oak_Finf {
int ismmap; /* used mmap()? */
int fsize; /* file size */
int fd; /* file descripter */
int isFef;
char *buf; /* font file allocated on memory */
char *fname; /* name of font file */
/* added by Rudie */
int isPcf;
struct pcf_inf pcfinf;
/* added by Rudie */
FontInfoPtr pFinf;
CharInfoPtr pCinf;
unsigned char *pGlyphs;
unsigned int width;
unsigned int height;
unsigned int start;
unsigned int end;
int sptnBufL;
char *sptnBuf;
int dptnBufL;
char *dptnBuf;
int dbufL;
char *dbuf;
} Oak_FontInf;
typedef Oak_FontInf * FalFontID; /* font distinction */
/*
* function prototypes
*/
extern FalFontID FalOpenSysFont(
#if NeedFunctionPrototypes
FalFontData* /* open_font_data */,
int /* font_data_mask */,
FalFontDataList** /* missing_font_list_return */
#endif
) ;
extern int FalGetFontList(
#if NeedFunctionPrototypes
FalFontData* /* key_data */,
int /* mask */,
FalFontDataList** /* list_ret */
#endif
) ;
extern int FalFreeFontList(
#if NeedFunctionPrototypes
FalFontDataList* /* list */
#endif
) ;
extern char *
FalReadFont(
#if NeedFunctionPrototypes
FalFontID /* fid */ ,
int /* code */ ,
int /* width */ ,
int /* height */
#endif
) ;
extern int FalQueryFont(
#if NeedFunctionPrototypes
FalFontID /* fid */ ,
FalFontinfo* /* fontinfo */
#endif
) ;
extern int FalFontOfFontID(
#if NeedFunctionPrototypes
FalFontID /* fid */,
FalFontData* /* fontdata */
#endif
) ;
extern int FalCloseFont(
#if NeedFunctionPrototypes
FalFontID /* fid */
#endif
) ;
extern int FalFontIDToFileName(
#if NeedFunctionPrototypes
FalFontID /* fid */ ,
char** /* file_name */
#endif
) ;
extern int FalFree(
#if NeedFunctionPrototypes
void* /* list */
#endif
) ;
extern int FalGetUDCCPArea(
#if NeedFunctionPrototypes
char* /* locale */ ,
int /* code_set */ ,
char* /* charset_str */ ,
FalCodeRegion** /* cr */ ,
int* /* num_cr */
#endif
) ;
extern int FalGetUDCGIArea(
#if NeedFunctionPrototypes
char* /* locale */ ,
int /* codeset */ ,
char* /* charset_str */ ,
FalGlyphRegion** /* gr */ ,
int* /* num_gr */
#endif
) ;
extern FalFontID FalOpenFont() ;
/*
* Code set
*/
#define FALGETFALCODESET( cd_set ) ( ((cd_set)==-1) ? FAL_FONT_GLYPH_INDEX : (cd_set)+1 )
#define FALCODESETTONUM( cd_set ) ( ((cd_set)==FAL_FONT_GLYPH_INDEX) ? -1 : (cd_set)-1 )
/*
* fal_utyerrno
*/
#define FAL_FUNCNUM_GFLST 0x0
#define FAL_FUNCNUM_SRCHFNM 0x0
#define FAL_FUNCNUM_OPNFNT 0x0
#define FAL_FUNCNUM_FRFLST 0x0
#define FAL_FUNCNUM_RDFNT 0x0
#define FAL_FUNCNUM_QRY 0x0
#define FAL_FUNCNUM_FID 0x0
#define FAL_FUNCNUM_IDTOFNM 0x0
#define FAL_FUNCNUM_CLSFNT 0x0
#define FAL_FUNCNUM_CPA 0x0
#define FAL_FUNCNUM_GIA 0x0
#define FAL_FUNCNUM_FREE 0x0
#define FAL_ERR_NON 0x00
#define FAL_ERR_FNT_OPN 0x01
#define FAL_ERR_FNT_RD 0x02
#define FAL_ERR_MALLOC 0x03
#define FAL_ERR_PARM 0x04
#define FAL_ERR_STAT 0x05
#define FAL_ERR_FONT 0x06
#define FAL_ERR_FDATA_OPN 0x07
#define FAL_ERR_FDATA_RD 0x08
#define FAL_ERR_FDATA_DSC 0x09
#define FAL_ERR_FPATH 0x0a
#define FAL_ERR_FNTDIR_OPN 0x0b
#define FAL_ERR_FNTDIR_RD 0x0c
#define FAL_ERR_PROP_RD 0x0d
#define FAL_ERR_PROP_FONT 0x0e
#define FAL_ERR_PROP_FNAME 0x0f
#define FAL_ERR_LCKD 0x10
#define FAL_ERR_FILELCK 0x11
#define FAL_ERR_FILEUNLCK 0x12
#define FAL_ERR_FILEGETLCK 0x13
#define FAL_ERR_NOFONT 0x14
#define FAL_ERR_XLC_CRTDB 0x15
#define FAL_ERR_XLC_GETCHARST 0x16
#define FAL_ERR_XLC_NOCHARST 0x17
#define FAL_ERR_FID_RD 0x18
#define FAL_ERR_FATAL 0x19
#ifdef __cplusplus
}
#endif
#endif /* _FALIB_H */

View file

@ -0,0 +1,616 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: bdfgpf.h /main/7 1996/06/25 20:08:09 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "udccom.h"
struct btophead {
char *in_file;
char *out_file;
char *text_file;
FILE *input;
FILE *output;
int num_chars;
int p_width;
int p_height;
int bdf_width;
int bdf_height;
int bdf_x;
int bdf_y;
float bdf_point;
int bdf_xdpi;
int *code;
char **ptn;
int zoomf;
int code_category;
int start_code;
int end_code;
};
struct ptobhead {
char *in_file;
char *out_file;
char *bdf_file;
char *snf_file;
FILE *input;
FILE *output;
int num_chars;
int p_width;
int p_height;
int bdf_width;
int bdf_height;
int bdf_x;
int bdf_y;
float bdf_point;
int bdf_xdpi;
int reserve ;
int *code;
char **ptn;
int zoomf;
int code_category;
int start_code;
int end_code;
};
#define MIN_CODE 0x0000
#define MAX_CODE 0xFFFF
#define ALL_CODE 0
extern char *oakgtobdf;
extern char *bdftosnf;
extern char *bdftopcf;
#define TAB_CD 0x09
#define USE_ORG_SIZE -1
#define MAX_FONT_WIDTH 999
#define MIN_FONT_WIDTH 2
#define MAX_FONT_HEIGHT 999
#define MIN_FONT_HEIGHT 2
#ifdef BUFSIZE
#undef BUFSIZE
#endif /* BUFSIZE */
#define BUFSIZE 1024
/* KeyWord for BDF file */
#define STARTFONT "STARTFONT "
#define STARTFONTsz 10
#define FONTBOUNDINGBOX "FONTBOUNDINGBOX "
#define FONTBOUNDINGBOXsz 16
#define SIZE "SIZE "
#define SIZEsz 5
#define CHARS "CHARS "
#define CHARSsz 6
#define STARTCHAR "STARTCHAR "
#define STARTCHARsz 10
#define ENCODING "ENCODING "
#define ENCODINGsz 9
#define BITMAP "BITMAP"
#define BITMAPsz 6
#define ENDCHAR "ENDCHAR"
#define ENDCHARsz 7
#define ENDFONT "ENDFONT"
#define ENDFONTsz 7
#define CHARSET_REGISTRY "CHARSET_REGISTRY "
#define CHARSET_REGISTRYsz 17
/* KeyWord for GPF file */
#define NUMFONTS "numfonts:"
#define NUMFONTSsz 9
#define WIDTH "width:"
#define WIDTHsz 6
#define HEIGHT "height:"
#define HEIGHTsz 7
#define CODE "code:"
#define CODEsz 5
#define ENDDATA "enddata"
#define ENDDATAsz 7
#define FILE_END 99
#define FATAL_ERROR -1
#define BDF_OPEN -2
#define BDF_OPEN_IN -2
#define BDF_READ -3
#define BDF_WRITE -4
#define BDF_INVAL -5
#define GPF_OPEN -6
#define GPF_OPEN_IN -6
#define GPF_READ -7
#define GPF_WRITE -8
#define GPF_INVAL -9
#define PARAM_ERROR -10
#define BDF_OPEN_OUT -11
#define GPF_OPEN_OUT -12
#define BDF_OPEN_HEAD -13
#define BDF_READ_HEAD -14
/* system_ call error */
#define MALLOC_ERROR -15
#define FORK_ERROR -16
#define EXEC_ERROR -17
#define PIPE_ERROR -18
#define DUP_ERROR -19
#define POPEN_ERROR -20
#define PCLOSE_ERROR -21
#define FDOPEN_ERROR -22
#define STAT_ERROR -23
#define MKTMP_ERROR -24
#define PCFFONTC_ERROR -25
#define SNFFONTC_ERROR -26
#define SCAN_TO_NONSP(p) {\
while (*(p) != 0) {\
if ((*(p) == ' ') || (*(p) == TAB_CD) || (*(p) == 0xa1)) {\
(p)++;\
} else {\
break;\
}\
}\
}
#define SCAN_TO_SP(p) {\
while (*(p) != 0) {\
if ((*(p) == ' ') || (*(p) == TAB_CD) || (*(p) == 0xa1)) {\
break;\
} else {\
(p)++;\
}\
}\
}
#if defined( SVR4 ) || defined( SYSV )
#define WaitID( chld_pid, chld_stat ) waitpid( (chld_pid), &(chld_stat), WUNTRACED )
#else
#define WaitID( chld_pid, chld_stat ) {\
for(;;){\
int rtn ;\
rtn = wait3( &(chld_stat), WUNTRACED, NULL );\
if( rtn == (chld_pid) ) break ;\
if( rtn == -1 ){\
if( errno == EINTR ) continue ;\
else break ;\
}\
}\
}
#endif
#ifndef DEFAULT_CODESET
#define DEFAULT_CODESET "3"
#endif
/*
* tempory file
*/
#define TempFileKey "XXXXXX"
#define TEMPFILEKEY TempFileKey
#ifndef DEFAULT_TMPPATH
#define DEFAULT_TMPPATH "/var/tmp/"
#endif /* DEFAULT_TMPPATH */
/*
* Function prototypes
*/
extern int falcom_atoi(
#if NeedFunctionPrototypes
char* /* str */,
char /* ed_cod */,
int* /* val */
#endif
);
extern int GetDefaultFile(
#if NeedFunctionPrototypes
int /* size */,
char* /* style */,
char* /* fname */
#endif
);
extern int get_default_file(
#if NeedFunctionPrototypes
FILE* /* fp */,
int /* size */,
char* /* style */,
char* /* fname */
#endif
);
extern char *falcom_get_base_name(
#if NeedFunctionPrototypes
char* /* str */
#endif
);
extern int GetFileName(
#if NeedFunctionPrototypes
char* /* com */,
char* /* size_str */,
char* /* style */,
int /* codeset */,
char* /* ofile */
#endif
);
extern void ErrMsgTable_FalGetFontList(
#if NeedFunctionPrototypes
char* /* com */,
int /* utyerr */,
int /* utyderr */
#endif
);
extern void fal_cut_tailslash(
#if NeedFunctionPrototypes
char* /* name */
#endif
);
extern char *GetRealFileName(
#if NeedFunctionPrototypes
char* /* name */
#endif
);
extern int IsInRegion(
#if NeedFunctionPrototypes
int /* code */,
int /* num_gr */,
FalGlyphRegion* /* gr */
#endif
);
extern int GetUdcFileName(
#if NeedFunctionPrototypes
char* /* com */,
int /* code_no */,
char* /* xlfdname */,
char* /* fname */
#endif
);
extern int GetUdcRegion(
#if NeedFunctionPrototypes
char* /* com */,
int /* codeset */,
char* /* gpf_file */,
int* /* num_gr */,
FalGlyphRegion** /* gr */
#endif
);
extern int DispUdcCpArea(
#if NeedFunctionPrototypes
FILE* /* fp */
#endif
);
extern int GetUdcFontName(
#if NeedFunctionPrototypes
char* /* gpf_file */,
char* /* bdf_file */,
char** /* fontname */
#endif
);
extern int FileLock(
#if NeedFunctionPrototypes
int /* fd */
#endif
);
extern int FileUnLock(
#if NeedFunctionPrototypes
int /* fd */
#endif
);
extern int isLock(
#if NeedFunctionPrototypes
int /* fd */
#endif
);
extern int ReadBdfHeader(
#if NeedFunctionPrototypes
struct btophead* /* head */,
char* /* buf */
#endif
);
extern int ReadGpfHeader(
#if NeedFunctionPrototypes
struct ptobhead* /* head */,
char* /* buf */
#endif
);
extern int WriteBdfHeader(
#if NeedFunctionPrototypes
struct ptobhead* /* head */
#endif
);
extern void WriteGpfHeader(
#if NeedFunctionPrototypes
struct btophead* /* head */
#endif
);
extern int WritePtnToBdf(
#if NeedFunctionPrototypes
struct ptobhead* /* head */
#endif
);
extern int putDefaultChars(
#if NeedFunctionPrototypes
struct ptobhead* /* head */
#endif
);
extern int WritePtnToGpf(
#if NeedFunctionPrototypes
struct btophead* /* head */
#endif
);
extern int ReadBdfToMemory(
#if NeedFunctionPrototypes
struct btophead* /* head */,
char* /* buf */
#endif
);
extern int ReadBdfToMemory_with_init(
#if NeedFunctionPrototypes
struct btophead* /* head */,
int /* init_start */,
int /* init_end */,
char* /* buf */
#endif
);
extern int GetBdfCode(
#if NeedFunctionPrototypes
struct btophead* /* head */,
char* /* buf */,
int* /* code */
#endif
);
extern int GetBdfPtn(
#if NeedFunctionPrototypes
struct btophead* /* head */,
char* /* buf */,
char* /* ptn */,
int /* mwidth */,
int /* bsize */
#endif
);
extern int ReadGpfToMemory(
#if NeedFunctionPrototypes
struct ptobhead* /* head */,
char* /* buf */
#endif
);
extern int GetGpfCode(
#if NeedFunctionPrototypes
struct ptobhead* /* head */,
char* /* buf */,
int* /* code */
#endif
);
extern int GetGpfPtn(
#if NeedFunctionPrototypes
struct ptobhead* /* head */,
char* /* buf */,
char* /* ptn */,
int /* mwidth */,
int /* bsize */
#endif
);
extern void GetBdfLinePtn(
#if NeedFunctionPrototypes
char* /* mem */,
char* /* buf */,
int /* width */
#endif
);
extern void GetGpfLinePtn(
#if NeedFunctionPrototypes
char* /* mem */,
char* /* buf */,
int /* width */
#endif
);
extern int PutBdfPtn(
#if NeedFunctionPrototypes
unsigned char* /* ptn */,
int /* width */,
int /* height */,
FILE* /* fp */
#endif
);
extern int PutGpfPtn(
#if NeedFunctionPrototypes
char* /* ptn */,
int /* width */,
int /* height */,
FILE* /* fp */
#endif
);
extern int PtnZoom(
#if NeedFunctionPrototypes
char* /* dmem */,
char* /* smem */,
int /* sw */,
int /* sh */,
int /* dw */,
int /* dh */
#endif
);
extern char *GetTmpPath(
#if NeedFunctionPrototypes
char* /* path */
#endif
);
extern int ChkNumString(
#if NeedFunctionPrototypes
char* /* str */
#endif
);
extern void ErrMsgTable_AndExit(
#if NeedFunctionPrototypes
int /* er_no */,
char* /* snf_in */,
char* /* snf_out */,
char* /* gpf_in */,
char* /* gpf_out */,
char* /* bdf_in */,
char* /* prog_name */
#endif
);
extern void fatal_err_msg(
#if NeedFunctionPrototypes
int /* er_no */,
char* /* prog_name */
#endif
);
extern void ChatchSig() ;
extern void Put_File_Create_Err_Msg(
#if NeedFunctionPrototypes
int /* msg_level */,
char* /* org_name */,
char* /* tmp_name */,
char* /* save_name */,
char* /* com */
#endif
);
extern int Make_NewFefFile(
#if NeedFunctionPrototypes
char* /* org_name */,
char* /* tmp_name */,
mode_t /* mode */,
uid_t /* owner */,
gid_t /* group */,
char* /* com */
#endif
);
extern int Unlink_Tmpfile(
#if NeedFunctionPrototypes
char* /* file */,
char* /* com */
#endif
);
extern int Chmod_File (
#if NeedFunctionPrototypes
char* /* fname */,
mode_t /* mode */,
char* /* com */
#endif
);
extern int Chown_File (
#if NeedFunctionPrototypes
char* /* fname */,
uid_t /* owner */,
gid_t /* group */,
char* /* com */
#endif
);
extern int ChkPcfFontFile(
#if NeedFunctionPrototypes
char* /* filename */
#endif
);
extern int ChkSnfFontFile(
#if NeedFunctionPrototypes
char* /* filename */
#endif
);
extern char *get_cmd_path(
#if NeedFunctionPrototypes
char* /* path */,
char* /* cmd */
#endif
);
extern int SetCmdPath(
#if NeedFunctionPrototypes
char* /* com */,
char** /* path */,
char* /* dflt_path */,
char* /* cmd */
#endif
);
extern int
Link_NewFile(
#if NeedFunctionPrototypes
char * /* rd_file */,
char * /* wr_file */
#endif
) ;

View file

@ -0,0 +1,121 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: snfstruct.h /main/2 1996/02/10 16:25:06 cde-fuj $ */
/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
(c) Copyright 1995 FUJITSU LIMITED
This is source code modified by FUJITSU LIMITED under the Joint
Development Agreement for the CDEnext PST.
This is unpublished proprietary source code of FUJITSU LIMITED
******************************************************************/
#ifndef SNFSTRUCT_H
#define SNFSTRUCT_H 1
#include "font.h"
#include "misc.h"
#include <X11/Xlib.h>
/*
* This file describes the Server Natural Font format.
* SNF fonts are both CPU-dependent and frame buffer bit order dependent.
* This file is used by:
* 1) the server, to hold font information read out of font files.
* 2) font converters
*
* Each font file contains the following
* data structures, with no padding in-between.
*
* 1) The XFONTINFO structure
* hand-padded to a two-short boundary.
* maxbounds.byteoffset is the total number of bytes in the
* glpyh array
* maxbounds.bitOffset is thetotal width of the unpadded font
*
* 2) The XCHARINFO array
* indexed directly with character codes, both on disk
* and in memory.
*
* 3) Character glyphs
* padded in the server-natural way, and
* ordered in the device-natural way.
* End of glyphs padded to 32-bit boundary.
*
* 4) nProps font properties
*
* 5) a sequence of null-terminated strings, for font properties
*/
#define FONT_FILE_VERSION 4
typedef struct _FontProp {
CARD32 name; /* offset of string */
INT32 value; /* number or offset of string */
Bool indirect; /* value is a string offset */
} FontPropRec;
/*
* the following macro definitions describe a font file image in memory
*/
#define ADDRCharInfoRec( pfi) \
((CharInfoRec *) &(pfi)[1])
#define ADDRCHARGLYPHS( pfi) \
(((char *) &(pfi)[1]) + BYTESOFCHARINFO(pfi))
/*
* pad out glyphs to a CARD32 boundary
*/
#define ADDRXFONTPROPS( pfi) \
((DIXFontProp *) ((char *)ADDRCHARGLYPHS( pfi) + BYTESOFGLYPHINFO(pfi)))
#define ADDRSTRINGTAB( pfi) \
((char *)ADDRXFONTPROPS( pfi) + BYTESOFPROPINFO(pfi))
#define BYTESOFFONTINFO(pfi) (sizeof(FontInfoRec))
#define BYTESOFCHARINFO(pfi) (sizeof(CharInfoRec) * n2dChars(pfi))
#define BYTESOFPROPINFO(pfi) (sizeof(FontPropRec) * (pfi)->nProps)
#define BYTESOFSTRINGINFO(pfi) ((pfi)->lenStrings)
#define BYTESOFGLYPHINFO(pfi) (((pfi)->maxbounds.byteOffset+3) & ~0x3)
#define BYTESOFINKINFO(pfi) (sizeof(CharInfoRec) * (2 + n2dChars(pfi)))
#endif /* SNFSTRUCT_H */

View file

@ -0,0 +1,70 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: udccom.h /main/5 1996/07/19 20:31:51 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "udcopt.h"
/* default path of dtaddcpf */
#define DFLTPATH "/usr/dt/lib/dtudcfonted/dtaddcpf"
#define DFLTCMD "dtaddcpf"
/* commands for exchange font format */
#define SNFTOBDF_CMD "dtgpftobdf"
#define BDFTOPCF_CMD "bdftopcf"
/* default path for commands */
#define SNFTOBDF "/usr/dt/lib/dtudcfonted/dtgpftobdf"
#ifndef FONTC
#define BDFTOPCF "/usr/bin/X11/bdftopcf"
#else
#define BDFTOPCF FONTC
#endif
#define PCFTOBDF SNFTOBDF
/* suffix of font file */
#define BDFSUFFIX ".bdf"
#define PCFSUFFIX ".pcf"
/* font information file */
#define DTUDCFONTS "DTUDCFONTS"
#ifndef DTUDCFONTSLISTDIR
#define DTUDCFONTSLISTDIR "/usr/dt/config"
#endif
/* default font path */
#ifndef DTUDCFONTPATH
#define DTUDCFONTPATH "/usr/lib/X11/fonts/misc"
#endif
/* defines for UDC fonts */
#define FONTS_LIST_FILE "fonts.list"
#define UDFLIST_DEF "udflist.def"
#define FONTSDIR "fonts.dir"

View file

@ -0,0 +1,269 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: udcopt.h /main/4 1996/11/08 01:59:43 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
/***********************************************************************
* SNF format font
**********************************************************************/
#define BDFTOSNF_CMD "bdftosnf"
#ifndef SNFFONTC
#define BDFTOSNF "/usr/bin/X11/bdftosnf"
#else
#define BDFTOSNF SNFFONTC
#endif
#define SNFSUFFIX ".snf"
#define FONT_FILE_PARM 0
#define COMM_SNF_POPEN( permission, snf_file, out_file, ep, buf, command ) { \
snprintf( (buf), sizeof((buf)), " -i " ) ; \
snprintf( (command), sizeof((command)), "%s %s > %s", bdftosnf, (buf), (out_file) ); \
}
#define COMM_SNF_FILEVERSION( snf_fd, finf, buf, permission ) { \
read( (snf_fd), (buf), sizeof(FontInfoRec) ); \
close( (snf_fd) ); \
(finf) = (FontInfoRec *) (buf) ; \
if( \
((finf)->version1 != FONT_FILE_VERSION) || \
((finf)->version2 != FONT_FILE_VERSION) \
) \
(permission) = -1 ; \
}
#define COMM_SNF_NEWTARGET( permission ) (permission) = 0
#define COMM_SNF_EXECLBDFTOSNF( permission, buf, snf_file ) { \
execl( bdftosnf, bdftosnf, "-i", 0 ); \
}
#define COMM_SNF_GETHEADER( fip, fp ) { \
(fip) = (FontInfoRec *)(fp); \
}
#define FAL_FONT_PRM 0
#define CHK_PROTECT_KEY( protect_key_data, openfontfile,\
fal_utyerror, fal_utyderror )
/* case of a snf former font */
#define FAL_GET_SNF_HEADER( buf, protect_key_data, fal_utyerror, fal_utyderror, fd, finf, openfontfile ) { \
(finf)->pFinf = ( FontInfoPtr )(buf); \
if ( \
((finf)->pFinf->version1 != (finf)->pFinf->version2) || \
((finf)->pFinf->version1 != FONT_FILE_VERSION) \
) { \
set_errfile_str( fal_err_file, (openfontfile) ) ; \
(fal_utyerror) = _FAL_FONT_ER; \
(fal_utyderror) = 0; \
fal_utyerrno = FAL_ERR_FONT ; \
fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; \
goto FalError01 ; \
} else { \
(finf)->isFef = TRUE ; \
(finf)->isPcf = FALSE; \
} \
}
/* falReadGpfProp() */
#define FAL_READ_SNF_HEADER( finf, protect_key_data, fal_utyerror, fal_utyderror ) { \
(finf)->isFef = TRUE; \
(finf)->isPcf = FALSE; \
(finf)->pFinf = ( FontInfoPtr )(finf)->buf ; \
if ( /* not a snf or fef format */ \
((finf)->pFinf->version1 != (finf)->pFinf->version2) || \
((finf)->pFinf->version1 != FONT_FILE_VERSION) \
) { \
return _FAL_TRY_NEXT ; \
} \
}
#define ISOPTFONT( file ) 1
/***********************************************************************
* glyph index
**********************************************************************/
#define SHIFTMASK 0x7F7F
#define SHIFT_OFF(co) (co)
#define SHIFT_ON(co) (co)
#define DEFAULTCHAR 0x2121
#define CONVGLYPHINDEX( code ) (code)
#define DISPCODEPOINT( char_set, code ) (code)
#define FAL_OPT_CONVGITOCP( codeset, code )
#define FAL_OPT_CONVCPTOGI( codeset, code )
/***********************************************************************
* options for commands
**********************************************************************/
#define NORMAL 0
#define SYSTM 1
#define CDSET1 (1<<2)
/* UDC code area */
#define IN_CODE( cc, co ) (( cc ) ? 1 : 1 )
/* libfuty */
#define COMM_SBOPT_CHECKSBOPT( com, code_area )
#define COMM_SBOPT_STRCMP( argv, cnt ) (((argv)[(cnt)] ? 0 : 0 ))
#define COMM_SBOPT_SETSBOPT( codearea )
#define COMM_TYPE_STRCMP( argv, cnt ) ( ((argv)[(cnt)] ? 0 : 0 ))
#define COMM_TYPE_SETTYPE( argc, argv, cnt, type )
/***********************************************************************
* options for commands
**********************************************************************/
#define COMM_SETDEFAULTSTYLE( style ) (style) = (char *)NULL
#define COMM_SETSTYLE_TO_FONTDATA( style, key, mask ) { \
if( style ) { \
char stylebuf[ BUFSIZE ] ; \
snprintf( stylebuf, sizeof(stylebuf), "%s", style ) ; \
key.style.name = stylebuf ; \
mask |= FAL_FONT_MASK_STYLE_NAME ; \
} \
}
#define COMM_ISDEFAULTCHAR( code ) 0
#define get_charset_registry(head, p)
#define put_default_chars(head, nchar, rtn) {\
if ( !(nchar) ) \
{\
(nchar)++;\
fprintf( (head)->output, "CHARS %d\n", (nchar) );\
if ( ( (rtn) = putDefaultChars( (head) ) ) != 0 ) {\
return (rtn);\
}\
} else {\
fprintf( (head)->output, "CHARS %d\n", (nchar) );\
}\
}
#define put_default_encode( head ) {\
fprintf((head)->output, "STARTCHAR %04x\n", DEFAULTCHAR );\
fprintf((head)->output, "ENCODING %d\n", DEFAULTCHAR );\
}
#define put_default_bitmap(head, bytew, posbit, i, j, ptnbuf, ptnbuf2, tmp) { \
for ((i) = 0; (i) < (bytew); (i)++) \
*((ptnbuf) + (i)) = (unsigned char)0x00;\
for ((j) = 0; (j) < (head)->bdf_height; (j)++) {\
for ((i) = 0; (i) < (bytew); (i)++) \
fprintf((head)->output, "%.2x", *((ptnbuf) + (i)));\
fprintf((head)->output, "\n");\
}\
}
#define COMM_SBFNT_ISSBFNT( p ) 0
#define COMM_SBFNT_CONVCODETOGI( char_set, head )
#define COMM_SBFNT_SETUDCAREA( com, head, char_set, code_area, num_gr, gr ) { \
(head).code_category = ALL_CODE ; \
(head).start_code = (gr)[0].start ; \
(head).end_code = (gr)[(num_gr)-1].end ; \
}
#define COMM_SET_CODESET( codeset, code_area )
#define COMM_SET_CODECATEGORY( char_set, code_area, head )
/*
* help message
*/
#define COMM_HELP_MSG { \
USAGE(" [-codeset number] [-help]\n"); \
USAGE("\n"); \
}
#define COMM_DSP_LETTER_T
#define COMM_DSP_PRM
#define COMM_HELP_MSG_STYLE USAGE("style (The default value is mincho style.)\n")
/***********************************************************************
* Options for libfal
**********************************************************************/
#define COMM_SBCHR_SETFONTDATA( data, mask )
#define COMM_SBCHR_STRDUP_P( data, odata )
#define FAL_DB_OPTION static FalFontDB *fal_db_opt
#define CHK_KEY_STR_OPTION( mask, key, flg )
#define FAL_FREE_FONTLIST_OPTION( list )
#define FAL_CLEAR_DATA_OPTION( tmp )
#define SET_STRUCT_OPTION( dup_p, elm, tmp_data, fal_utyerror, fal_db_group )
#define FAL_EQ_DATA_OPTION( flg, data, tmp_data )
#define FAL_CMP_DATA_OPTION( mask, op1, key )
#define DEF_STR_CHK struct { int style, shape; }str_chk
#define DEF_STR_SET { \
str_chk.style = 0; \
str_chk.shape = 0; \
}
#define NEW_TARGET_SET( diff, choose, target, str_chk )
#define NEW_TARGET_CHK( diff, choose, target, str_chk )
/***********************************************************************
* udflist.def
**********************************************************************/
#define COMM_GET_DEFAULTFILE_ERROR( buf, com, ret, height, style, list_d, list_c, list_l, statbuf ) {\
buf[0] = '\0' ;\
}
#define COMM_DISPERRORFILE( com, lst, style, i, size_str ) {\
USAGE1("%s : Two or more corresponding user defined characters exist.\n", com);\
USAGE("\tcode set\tXLFD\n" );\
USAGE("\t--------------------------------------------------\n" );\
for ( i = 0 ; i < lst->num; i++ ) {\
USAGE2("\t%d\t%s\n", lst->list[i].cd_set-1, lst->list[i].xlfdname );\
}\
}
/***********************************************************************
* fonts.list
**********************************************************************/
#define GETLISTFILEPATH( locale, srch_path, list_d, list_c, list_l, list_file ) { \
if ( ( (locale) = getenv( "FAL_LANG" ) ) == NULL ) { \
if( ((locale) = (char *)getenv( "LANG" )) == NULL ){\
(locale) = "C" ;\
}\
} \
if ( ( (srch_path) = getenv( DTUDCFONTS ) ) == NULL ) { \
snprintf( (list_d), sizeof(list_d), "%s/%s", DTUDCFONTSLISTDIR, (list_file) ); \
snprintf( (list_c), sizeof(list_c), "%s/C/%s", DTUDCFONTSLISTDIR, (list_file) ); \
snprintf( (list_l), sizeof(list_l), "%s/%s/%s", DTUDCFONTSLISTDIR, (locale), (list_file) ); \
} else { \
snprintf( (list_d), sizeof(list_d), "%s/%s", (srch_path), (list_file) ); \
snprintf( (list_c), sizeof(list_c), "%s/C/%s", (srch_path), (list_file) ); \
snprintf( (list_l), sizeof(list_l), "%s/%s/%s", (srch_path), (locale), (list_file) ); \
} \
}
#define SET_EXECDEFAULT( mask, def, undef ) { \
if( !((mask) & FAL_FONT_MASK_DEFINED) && !((mask) & FAL_FONT_MASK_UNDEFINED) ){ \
(def) = FALSE ; \
(undef) = TRUE ; \
}else{ \
if( (mask) & FAL_FONT_MASK_DEFINED ) (def) = TRUE ; \
else (def) = FALSE ; \
if( (mask) & FAL_FONT_MASK_UNDEFINED ) (undef) = TRUE ; \
else (undef) = FALSE ; \
} \
}
/*************************< end of udcopt.h >**************************/

View file

@ -0,0 +1,147 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: udcutil.h /main/3 1996/11/08 01:58:55 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#ifndef PRINT_USAGE
#define USAGE(a)
#define USAGE1(a, b)
#define USAGE2(a, b, c)
#define USAGE3(a, b, c, d)
#define USAGE4(a, b, c, d, e)
#else
#define USAGE(a) fprintf(stderr, a)
#define USAGE1(a, b) fprintf(stderr, a, b)
#define USAGE2(a, b, c) fprintf(stderr, a, b, c)
#define USAGE3(a, b, c, d) fprintf(stderr, a, b, c, d)
#define USAGE4(a, b, c, d, e) fprintf(stderr, a, b, c, d, e)
#endif
#define UDC_LINE_MAX 2048
/* macro for get character strings */
#define AllocString( str, orgstr, rtn ){ \
(str) = (char *)malloc( sizeof(char) * (strlen((orgstr))+1) ) ;\
if( !(str) ){\
return( (rtn) ) ;\
}\
strcpy( (str), (orgstr) ) ;\
}
#define AddString( str, addstr, rtn ){ \
(str) = (char *)realloc( (str), sizeof(char) * ( strlen((str)) + strlen((addstr)) + 1 ) ) ;\
if( !(str) ){\
return( (rtn) ) ;\
}\
strcat( (str), (addstr) ) ;\
}
#define ResizeString( str, rtn ){ \
(str) = (char *)realloc( (str), sizeof(char) * ( strlen((str)) + 1 ) ) ;\
if( !(str) ){\
return( (rtn) ) ;\
}\
}
#define FreeString( str ){ \
if( (str) ) {\
free( (str) ) ;\
}\
(str) = NULL ;\
}
/* access to "fonts.dir" */
#define XLFD_ELM_CNT 14
#define XLFD_ELM_FOUNDRY 1
#define XLFD_ELM_FAMILY_NAME 2
#define XLFD_ELM_WEIGHT_NAME 3
#define XLFD_ELM_SLANT 4
#define XLFD_ELM_SETWIDTH_NAME 5
#define XLFD_ELM_ADD_STYLE_NAME 6
#define XLFD_ELM_PIXEL_SIZE 7
#define XLFD_ELM_POINT_SIZE 8
#define XLFD_ELM_RESOLUTION_X 9
#define XLFD_ELM_RESOLUTION_Y 10
#define XLFD_ELM_SPACING 11
#define XLFD_ELM_AVERAGE_WIDTH 12
#define XLFD_ELM_CHARSET_REGISTRY 13
#define XLFD_ELM_CHARSET_ENCODING 14
static int udc_font_elm_cnt ;
static char udc_font_str_buffer[UDC_LINE_MAX] ;
static char *udc_font_sp ;
#define POINTXLFDELM( sp, xlfdname, elm_num ) { \
udc_font_sp = (xlfdname) ; \
udc_font_elm_cnt = 0 ;\
while(*udc_font_sp){\
if(*udc_font_sp == '-') udc_font_elm_cnt++ ;\
if( udc_font_elm_cnt == (elm_num) ){\
break ;\
}\
udc_font_sp++ ;\
}\
(sp) = udc_font_sp ;\
}
#define GETXLFDELMSTR( sp, xlfdname, elm_num ) { \
snprintf( udc_font_str_buffer, sizeof(udc_font_str_buffer), "%s", (xlfdname) ) ; \
udc_font_sp = udc_font_str_buffer ; \
udc_font_elm_cnt = 0 ;\
while(*udc_font_sp){\
if(*udc_font_sp == '-') udc_font_elm_cnt++ ;\
if( udc_font_elm_cnt == (elm_num) ){\
udc_font_sp++ ;\
break ;\
}\
udc_font_sp++ ;\
}\
(sp) = udc_font_sp ;\
while(*udc_font_sp){\
if(*udc_font_sp == '-') udc_font_elm_cnt++ ;\
if( udc_font_elm_cnt == (elm_num)+1 ){\
*udc_font_sp = '\0' ;\
break ;\
}\
udc_font_sp++ ;\
}\
}
#define GETCHARSETSTR( char_set, xlfdname ) { \
snprintf( udc_font_str_buffer, sizeof(udc_font_str_buffer), "%s", (xlfdname) ) ; \
POINTXLFDELM( (char_set), udc_font_str_buffer, XLFD_ELM_CHARSET_REGISTRY ) ; \
(char_set)++ ; \
}
#define GETSPACINGSTR( spacing, xlfdname ) { \
GETXLFDELMSTR( (spacing), (xlfdname), XLFD_ELM_SPACING ) ; \
}

View file

@ -0,0 +1,84 @@
XCOMM $XConsortium: Imakefile /main/16 1996/09/09 11:45:13 drk $
#define DoNormalLib YES
#define DoSharedLib NO
#define DoDebugLib NO
#define DoProfileLib NO
#define LibName fal
#define LibHeaders NO
#define LibInstall NO
FALDESTDIR = $(CDE_INSTALLATION_TOP)
FONTLIST = config
XLOCALEDIR = $(XPROJECTROOT)/lib/X11/locale
XFONTDIR = $(XPROJECTROOT)/lib/X11/fonts
UDCFONTPATH = $(XFONTDIR)/misc
FALOPT1 = -DDTUDCFONTPATH='"'$(XFONTDIR)/misc'"'
FALOPT2 = -DXLOCALEDIR='"'$(XLOCALEDIR)'"'
FALOPT3 = -DDTUDCFONTSLISTDIR='"'$(FALDESTDIR)/$(FONTLIST)'"'
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
DEPEND_DEFINES = $(DEPENDDEFINES)
DEFINES = $(FALOPT1) $(FALOPT2) $(OPT2) $(FALOPT3)
UDC_INC_PATH1 = -I./include
UDC_INC_PATH2 = -I../include
UDC_INC_PATH3 = -I./
INCLUDES = \
$(UDC_INC_PATH1)\
$(UDC_INC_PATH2)\
$(UDC_INC_PATH3)
SRCS1 = falfont.c readpcf.c \
syncx.c
SRCS2 = _faludcInf.c \
_fallcCT.c _fallcCharSet.c _fallcConv.c _fallcDB.c \
_fallcDefConv.c _fallcDynamic.c _fallcEuc.c _fallcFile.c \
_fallcGenConv.c _fallcGeneric.c _fallcInit.c _fallcPrTxt.c \
_fallcPubWrap.c _fallcPublic.c _fallcRM.c _fallcSjis.c \
_fallcStd.c _fallcTxtPr.c _fallcUTF.c _fallcUtil.c \
_fallcWrap.c \
_falomGeneric.c _falQuarks.c _falSetLocale.c _falrm.c
SRCS3 = _falutilbitmap.c
SRCS = $(SRCS1) $(SRCS2) $(SRCS3)
OBJS = falfont.o readpcf.o \
syncx.o \
_faludcInf.o \
_fallcCT.o _fallcCharSet.o _fallcConv.o _fallcDB.o \
_fallcDefConv.o _fallcDynamic.o _fallcEuc.o _fallcFile.o \
_fallcGenConv.o _fallcGeneric.o _fallcInit.o _fallcPrTxt.o \
_fallcPubWrap.o _fallcPublic.o _fallcRM.o _fallcSjis.o \
_fallcStd.o _fallcTxtPr.o _fallcUTF.o _fallcUtil.o \
_fallcWrap.o _falomGeneric.o _falQuarks.o _falSetLocale.o \
_falrm.o \
_falutilbitmap.o
all::
$(RM) fonts.list;\
$(CP) ./fonts.list.header ./fonts.list ;\
chmod ug+w fonts.list;\
key=`echo $(UDCFONTPATH) | sed -e 's/:/ /g'` ; \
for dir in $$key ; \
do \
echo $$dir: >> ./fonts.list ;\
done
#include <Library.tmpl>
install::
if [ -d $(DESTDIR)/$(FALDESTDIR)/$(FONTLIST) ]; then set +x; \
else (set -x; $(MKDIRHIER) $(DESTDIR)/$(FALDESTDIR)/$(FONTLIST)); fi ; \
(set -x ; $(CP) ./fonts.list $(DESTDIR)/$(FALDESTDIR)/$(FONTLIST) ; \
chmod 0644 $(DESTDIR)/$(FALDESTDIR)/$(FONTLIST)/fonts.list )
DependTarget()

View file

@ -0,0 +1,456 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* Quarks.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:31:17 */
/* $XConsortium: _falQuarks.c /main/2 1996/09/09 13:20:21 rswiston $ */
/***********************************************************
Copyright 1987, 1988, 1990 by Digital Equipment Corporation, Maynard,
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/*
Copyright (c) 1987, 1988, 1990 X Consortium
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from the X Consortium.
*/
#include "_fallibint.h"
#include <X11/Xresource.h>
/* Not cost effective, at least for vanilla MIT clients */
/* #define PERMQ */
typedef unsigned long Signature;
typedef unsigned long Entry;
#ifdef PERMQ
typedef unsigned char Bits;
#endif
static XrmQuark nextQuark = 1; /* next available quark number */
static unsigned long quarkMask = 0;
static Entry zero = 0;
static Entry *quarkTable = &zero; /* crock */
static unsigned long quarkRehash;
static XrmString **stringTable = NULL;
#ifdef PERMQ
static Bits **permTable = NULL;
#endif
static XrmQuark nextUniq = -1; /* next quark from falrmUniqueQuark */
#define QUANTUMSHIFT 8
#define QUANTUMMASK ((1 << QUANTUMSHIFT) - 1)
#define CHUNKPER 8
#define CHUNKMASK ((CHUNKPER << QUANTUMSHIFT) - 1)
#define LARGEQUARK ((Entry)0x80000000L)
#define QUARKSHIFT 18
#define QUARKMASK ((LARGEQUARK - 1) >> QUARKSHIFT)
#define XSIGMASK ((1L << QUARKSHIFT) - 1)
#define STRQUANTSIZE (sizeof(XrmString) * (QUANTUMMASK + 1))
#ifdef PERMQ
#define QUANTSIZE (STRQUANTSIZE + \
(sizeof(Bits) * ((QUANTUMMASK + 1) >> 3))
#else
#define QUANTSIZE STRQUANTSIZE
#endif
#define HASH(sig) ((sig) & quarkMask)
#define REHASHVAL(sig) ((((sig) % quarkRehash) + 2) | 1)
#define REHASH(idx,rehash) ((idx + rehash) & quarkMask)
#define NAME(q) stringTable[(q) >> QUANTUMSHIFT][(q) & QUANTUMMASK]
#ifdef PERMQ
#define BYTEREF(q) permTable[(q) >> QUANTUMSHIFT][((q) & QUANTUMMASK) >> 3]
#define ISPERM(q) (BYTEREF(q) & (1 << ((q) & 7)))
#define SETPERM(q) BYTEREF(q) |= (1 << ((q) & 7))
#define CLEARPERM(q) BYTEREF(q) &= ~(1 << ((q) & 7))
#endif
/* Permanent memory allocation */
#define WALIGN sizeof(unsigned long)
#define DALIGN sizeof(double)
#define NEVERFREETABLESIZE ((8192-12) & ~(DALIGN-1))
static char *neverFreeTable = NULL;
static int neverFreeTableSize = 0;
static char *permalloc(length)
register unsigned int length;
{
char *ret;
if (neverFreeTableSize < length) {
if (length >= NEVERFREETABLESIZE)
return Xmalloc(length);
if (! (ret = Xmalloc(NEVERFREETABLESIZE)))
return (char *) NULL;
neverFreeTableSize = NEVERFREETABLESIZE;
neverFreeTable = ret;
}
ret = neverFreeTable;
neverFreeTable += length;
neverFreeTableSize -= length;
return(ret);
}
#ifndef WORD64
typedef struct {char a; double b;} TestType1;
typedef struct {char a; unsigned long b;} TestType2;
#endif
#ifdef XTHREADS
static char *_falpermalloc();
char *falpermalloc(length)
unsigned int length;
{
char *p;
_XLockMutex(_Xglobal_lock);
p = _falpermalloc(length);
_XUnlockMutex(_Xglobal_lock);
return p;
}
#define falpermalloc _falpermalloc
static
#endif /* XTHREADS */
char *falpermalloc(length)
unsigned int length;
{
int i;
if (neverFreeTableSize && length < NEVERFREETABLESIZE) {
#ifndef WORD64
if ((sizeof(TestType1) !=
(sizeof(TestType2) - sizeof(unsigned long) + sizeof(double))) &&
!(length & (DALIGN-1)) &&
(i = (NEVERFREETABLESIZE - neverFreeTableSize) & (DALIGN-1))) {
neverFreeTableSize -= DALIGN - i;
neverFreeTable += DALIGN - i;
} else
#endif
if (i = (NEVERFREETABLESIZE - neverFreeTableSize) & (WALIGN-1)) {
neverFreeTableSize -= WALIGN - i;
neverFreeTable += WALIGN - i;
}
}
return permalloc(length);
}
static Bool
ExpandQuarkTable()
{
unsigned long oldmask, newmask;
register char c, *s;
register Entry *oldentries, *entries;
register Entry entry;
register int oldidx, newidx, rehash;
Signature sig;
XrmQuark q;
oldentries = quarkTable;
if (oldmask = quarkMask)
newmask = (oldmask << 1) + 1;
else {
if (!stringTable) {
stringTable = (XrmString **)Xmalloc(sizeof(XrmString *) *
CHUNKPER);
if (!stringTable)
return False;
stringTable[0] = (XrmString *)NULL;
}
#ifdef PERMQ
if (!permTable)
permTable = (Bits **)Xmalloc(sizeof(Bits *) * CHUNKPER);
if (!permTable)
return False;
#endif
stringTable[0] = (XrmString *)falpermalloc(QUANTSIZE);
if (!stringTable[0])
return False;
#ifdef PERMQ
permTable[0] = (Bits *)((char *)stringTable[0] + STRQUANTSIZE);
#endif
newmask = 0x1ff;
}
entries = (Entry *)Xmalloc(sizeof(Entry) * (newmask + 1));
if (!entries)
return False;
bzero((char *)entries, sizeof(Entry) * (newmask + 1));
quarkTable = entries;
quarkMask = newmask;
quarkRehash = quarkMask - 2;
for (oldidx = 0; oldidx <= oldmask; oldidx++) {
if (entry = oldentries[oldidx]) {
if (entry & LARGEQUARK)
q = entry & (LARGEQUARK-1);
else
q = (entry >> QUARKSHIFT) & QUARKMASK;
for (sig = 0, s = NAME(q); c = *s++; )
sig = (sig << 1) + c;
newidx = HASH(sig);
if (entries[newidx]) {
rehash = REHASHVAL(sig);
do {
newidx = REHASH(newidx, rehash);
} while (entries[newidx]);
}
entries[newidx] = entry;
}
}
if (oldmask)
Xfree((char *)oldentries);
return True;
}
#if NeedFunctionPrototypes
XrmQuark _falrmInternalStringToQuark(
register _Xconst char *name, register int len, register Signature sig,
Bool permstring)
#else
XrmQuark _falrmInternalStringToQuark(name, len, sig, permstring)
register XrmString name;
register int len;
register Signature sig;
Bool permstring;
#endif
{
register XrmQuark q;
register Entry entry;
register int idx, rehash;
register int i;
register char *s1, *s2;
char *new;
rehash = 0;
idx = HASH(sig);
_XLockMutex(_Xglobal_lock);
while (entry = quarkTable[idx]) {
if (entry & LARGEQUARK)
q = entry & (LARGEQUARK-1);
else {
if ((entry - sig) & XSIGMASK)
goto nomatch;
q = (entry >> QUARKSHIFT) & QUARKMASK;
}
for (i = len, s1 = (char *)name, s2 = NAME(q); --i >= 0; ) {
if (*s1++ != *s2++)
goto nomatch;
}
if (*s2) {
nomatch: if (!rehash)
rehash = REHASHVAL(sig);
idx = REHASH(idx, rehash);
continue;
}
#ifdef PERMQ
if (permstring && !ISPERM(q)) {
Xfree(NAME(q));
NAME(q) = (char *)name;
SETPERM(q);
}
#endif
_XUnlockMutex(_Xglobal_lock);
return q;
}
if (nextUniq == nextQuark)
goto fail;
if ((nextQuark + (nextQuark >> 2)) > quarkMask) {
if (!ExpandQuarkTable())
goto fail;
_XUnlockMutex(_Xglobal_lock);
return _falrmInternalStringToQuark(name, len, sig, permstring);
}
q = nextQuark;
if (!(q & QUANTUMMASK)) {
if (!(q & CHUNKMASK)) {
if (!(new = Xrealloc((char *)stringTable,
sizeof(XrmString *) *
((q >> QUANTUMSHIFT) + CHUNKPER))))
goto fail;
stringTable = (XrmString **)new;
#ifdef PERMQ
if (!(new = Xrealloc((char *)permTable,
sizeof(Bits *) *
((q >> QUANTUMSHIFT) + CHUNKPER))))
goto fail;
permTable = (Bits **)new;
#endif
}
new = falpermalloc(QUANTSIZE);
if (!new)
goto fail;
stringTable[q >> QUANTUMSHIFT] = (XrmString *)new;
#ifdef PERMQ
permTable[q >> QUANTUMSHIFT] = (Bits *)(new + STRQUANTSIZE);
#endif
}
if (!permstring) {
s2 = (char *)name;
#ifdef PERMQ
name = Xmalloc(len+1);
#else
name = permalloc(len+1);
#endif
if (!name)
goto fail;
for (i = len, s1 = (char *)name; --i >= 0; )
*s1++ = *s2++;
*s1++ = '\0';
#ifdef PERMQ
CLEARPERM(q);
}
else {
SETPERM(q);
#endif
}
NAME(q) = (char *)name;
if (q <= QUARKMASK)
entry = (q << QUARKSHIFT) | (sig & XSIGMASK);
else
entry = q | LARGEQUARK;
quarkTable[idx] = entry;
nextQuark++;
_XUnlockMutex(_Xglobal_lock);
return q;
fail:
_XUnlockMutex(_Xglobal_lock);
return NULLQUARK;
}
#if NeedFunctionPrototypes
XrmQuark falrmStringToQuark(
_Xconst char *name)
#else
XrmQuark falrmStringToQuark(name)
XrmString name;
#endif
{
register char c, *tname;
register Signature sig = 0;
if (!name)
return (NULLQUARK);
for (tname = (char *)name; c = *tname++; )
sig = (sig << 1) + c;
return _falrmInternalStringToQuark(name, tname-(char *)name-1, sig, False);
}
#if NeedFunctionPrototypes
XrmQuark falrmPermStringToQuark(
_Xconst char *name)
#else
XrmQuark falrmPermStringToQuark(name)
XrmString name;
#endif
{
register char c, *tname;
register Signature sig = 0;
if (!name)
return (NULLQUARK);
for (tname = (char *)name; c = *tname++; )
sig = (sig << 1) + c;
return _falrmInternalStringToQuark(name, tname-(char *)name-1, sig, True);
}
XrmQuark falrmUniqueQuark()
{
XrmQuark q;
_XLockMutex(_Xglobal_lock);
if (nextUniq == nextQuark)
q = NULLQUARK;
else
q = nextUniq--;
_XUnlockMutex(_Xglobal_lock);
return q;
}
XrmString falrmQuarkToString(quark)
register XrmQuark quark;
{
XrmString s;
_XLockMutex(_Xglobal_lock);
if (quark <= 0 || quark >= nextQuark)
s = NULLSTRING;
else {
#ifdef PERMQ
/* We have to mark the quark as permanent, since the caller might hold
* onto the string pointer forver.
*/
SETPERM(quark);
#endif
s = NAME(quark);
}
_XUnlockMutex(_Xglobal_lock);
return s;
}

View file

@ -0,0 +1,242 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* SetLocale.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:31:29 */
/* $XConsortium: _falSetLocale.c /main/1 1996/04/08 15:15:08 cde-fuj $ */
/*
* Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
* and Nippon Telegraph and Telephone Corporation
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of OMRON, NTT Software, and NTT
* not be used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. OMRON, NTT Software,
* and NTT make no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* OMRON, NTT SOFTWARE, AND NTT, DISCLAIM ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL OMRON, NTT SOFTWARE, OR NTT, BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Authors: Li Yuhong OMRON Corporation
* Tetsuya Kato NTT Software Corporation
* Hiroshi Kuribayashi OMRON Corporation
*
*/
/*
Copyright (c) 1987 X Consortium
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from the X Consortium.
*/
#include "_fallibint.h"
#include "_fallcint.h"
#include <X11/Xlocale.h>
#include <X11/Xos.h>
#ifdef X_LOCALE
/* alternative setlocale() for when the OS does not provide one */
#ifdef X_NOT_STDC_ENV
extern char *getenv();
#endif
#define MAXLOCALE 64 /* buffer size of locale name */
#if NeedFunctionPrototypes
char *
_falsetlocale(
int category,
_Xconst char *name
)
#else
char *
_falsetlocale(category, name)
int category;
char *name;
#endif
{
static char *xsl_name;
char *old_name;
XrmMethods methods;
XPointer state;
if (category != LC_CTYPE && category != LC_ALL)
return NULL;
if (!name) {
if (xsl_name)
return xsl_name;
return "C";
}
if (!*name)
name = getenv("LC_CTYPE");
if (!name || !*name)
name = getenv("LANG");
if (!name || !*name)
name = "C";
old_name = xsl_name;
xsl_name = (char *)name;
methods = _falrmInitParseInfo(&state);
xsl_name = old_name;
if (!methods)
return NULL;
name = (*methods->lcname)(state);
xsl_name = Xmalloc(strlen(name) + 1);
if (!xsl_name) {
xsl_name = old_name;
(*methods->destroy)(state);
return NULL;
}
strcpy(xsl_name, name);
if (old_name)
Xfree(old_name);
(*methods->destroy)(state);
return xsl_name;
}
#else /* X_LOCALE */
/*
* _fallcMapOSLocaleName is an implementation dependent routine that derives
* the LC_CTYPE locale name as used in the sample implementation from that
* returned by setlocale.
* Should match the code in Xt ExtractLocaleName.
*/
char *
_fallcMapOSLocaleName(osname, siname)
char *osname;
char *siname;
{
#if defined(hpux) || defined(CSRG_BASED) || defined(sun) || defined(SVR4) || defined(sgi) || defined(AIXV3) || defined(ultrix) || defined(WIN32)
#ifdef hpux
#define SKIPCOUNT 2
#define STARTCHAR ':'
#define ENDCHAR ';'
#else
#ifdef ultrix
#define SKIPCOUNT 2
#define STARTCHAR '\001'
#define ENDCHAR '\001'
#else
#ifdef WIN32
#define SKIPCOUNT 1
#define STARTCHAR '='
#define ENDCHAR ';'
#define WHITEFILL
#else
#if defined(AIXV3)
#define STARTCHAR ' '
#define ENDCHAR ' '
#else
#if !defined(sun) || defined(SVR4)
#define STARTCHAR '/'
#endif
#define ENDCHAR '/'
#endif
#endif
#endif
#endif
char *start;
char *end;
int len;
#ifdef SKIPCOUNT
int n;
#endif
start = osname;
#ifdef SKIPCOUNT
for (n = SKIPCOUNT;
--n >= 0 && start && (start = strchr (start, STARTCHAR));
start++)
;
if (!start)
start = osname;
#endif
#ifdef STARTCHAR
if (start && (start = strchr (start, STARTCHAR))) {
start++;
#endif
if (end = strchr (start, ENDCHAR)) {
len = end - start;
strncpy(siname, start, len);
*(siname + len) = '\0';
#ifdef WHITEFILL
for (start = siname; start = strchr(start, ' '); )
*start++ = '-';
#endif
return siname;
#ifdef STARTCHAR
}
#endif
}
#ifdef WHITEFILL
if (strchr(osname, ' ')) {
strcpy(siname, osname);
for (start = siname; start = strchr(start, ' '); )
*start++ = '-';
return siname;
}
#endif
#undef STARTCHAR
#undef ENDCHAR
#undef WHITEFILL
#endif
return osname;
}
#endif /* X_LOCALE */

View file

@ -0,0 +1,906 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcCT.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:33 */
/* $XConsortium: _fallcCT.c /main/1 1996/04/08 15:15:33 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
#include "_fallibint.h"
#include "_fallcPubI.h"
#include <X11/Xos.h>
#include <stdio.h>
typedef struct _StateRec {
XlcCharSet charset;
XlcCharSet GL_charset;
XlcCharSet GR_charset;
XlcCharSet ext_seg_charset;
int ext_seg_left;
} StateRec, *State;
typedef struct _CTDataRec {
char *name;
char *encoding; /* Compound Text encoding */
} CTDataRec, *CTData;
typedef struct _CTInfoRec {
XlcCharSet charset;
int encoding_len;
char *encoding; /* Compound Text encoding */
int ext_segment_len;
char *ext_segment; /* extended segment */
struct _CTInfoRec *next;
} CTInfoRec, *CTInfo;
static CTDataRec default_ct_data[] =
{
{ "ISO8859-1:GL", "\033(B" },
{ "ISO8859-1:GR", "\033-A" },
{ "ISO8859-2:GR", "\033-B" },
{ "ISO8859-3:GR", "\033-C" },
{ "ISO8859-4:GR", "\033-D" },
{ "ISO8859-7:GR", "\033-F" },
{ "ISO8859-6:GR", "\033-G" },
{ "ISO8859-8:GR", "\033-H" },
{ "ISO8859-5:GR", "\033-L" },
{ "ISO8859-9:GR", "\033-M" },
{ "JISX0201.1976-0:GL", "\033(J" },
{ "JISX0201.1976-0:GR", "\033)I" },
{ "GB2312.1980-0:GL", "\033$(A" },
{ "GB2312.1980-0:GR", "\033$)A" },
{ "JISX0208.1983-0:GL", "\033$(B" },
{ "JISX0208.1983-0:GR", "\033$)B" },
{ "KSC5601.1987-0:GL", "\033$(C" },
{ "KSC5601.1987-0:GR", "\033$)C" },
#ifdef notdef
{ "JISX0212.1990-0:GL", "\033$(D" },
{ "JISX0212.1990-0:GR", "\033$)D" },
{ "CNS11643.1986-1:GL", "\033$(G" },
{ "CNS11643.1986-1:GR", "\033$)G" },
{ "CNS11643.1986-2:GL", "\033$(H" },
{ "CNS11643.1986-2:GR", "\033$)H" },
/* Non-Standard Character Set Encodings */
{ "TIS620.2533-1:GR", "\033-T"},
#endif
} ;
#define XctC0 0x0000
#define XctHT 0x0009
#define XctNL 0x000a
#define XctESC 0x001b
#define XctGL 0x0020
#define XctC1 0x0080
#define XctCSI 0x009b
#define XctGR 0x00a0
#define XctCntrlFunc 0x0023
#define XctMB 0x0024
#define XctOtherCoding 0x0025
#define XctGL94 0x0028
#define XctGR94 0x0029
#define XctGR96 0x002d
#define XctNonStandard 0x002f
#define XctIgnoreExt 0x0030
#define XctNotIgnoreExt 0x0031
#define XctLeftToRight 0x0031
#define XctRightToLeft 0x0032
#define XctDirection 0x005d
#define XctDirectionEnd 0x005d
#define XctGL94MB 0x2428
#define XctGR94MB 0x2429
#define XctExtSeg 0x252f
#define XctOtherSeg 0x2f00
#define XctESCSeq 0x1b00
#define XctCSISeq 0x9b00
#define SKIP_I(str) while (*(str) >= 0x20 && *(str) <= 0x2f) (str)++;
#define SKIP_P(str) while (*(str) >= 0x30 && *(str) <= 0x3f) (str)++;
typedef struct {
XlcSide side;
int char_size;
int set_size;
int ext_seg_length;
int version;
CTInfo ct_info;
} CTParseRec, *CTParse;
static CTInfo ct_list = NULL;
static CTInfo
_XlcGetCTInfoFromEncoding(encoding, length)
register char *encoding;
register int length;
{
register CTInfo ct_info;
for (ct_info = ct_list; ct_info; ct_info = ct_info->next) {
if (length >= ct_info->encoding_len) {
if (ct_info->ext_segment) {
if (!strncmp(ct_info->encoding, encoding, 4) &&
!strncmp(ct_info->ext_segment, encoding + 6,
ct_info->ext_segment_len))
return ct_info;
} else if (!strncmp(ct_info->encoding, encoding,
ct_info->encoding_len)) {
return ct_info;
}
}
}
return (CTInfo) NULL;
}
static unsigned int
_XlcParseCT(parse, text, length)
register CTParse parse;
char **text;
int *length;
{
unsigned int ret = 0;
unsigned char ch;
register unsigned char *str = (unsigned char *) *text;
bzero((char *) parse, sizeof(CTParseRec));
switch (ch = *str++) {
case XctESC:
if (*str == XctOtherCoding && *(str + 1) == XctNonStandard
&& *(str + 2) >= 0x30 && *(str + 2) <= 0x3f && *length >= 6) {
/* non-standard encodings */
parse->side = XlcGLGR;
parse->set_size = 0;
str += 2;
if (*str <= 0x34) {
parse->char_size = *str - 0x30;
if (parse->char_size == 0) parse->char_size = 1;
ret = XctExtSeg;
parse->ct_info = _XlcGetCTInfoFromEncoding(*text, *length);
} else
ret = XctOtherSeg;
str++;
parse->ext_seg_length = (*str - 128) * 128 + *(str + 1) - 128;
str += 2;
goto done;
} else if (*str == XctCntrlFunc && *length >= 4 &&
*(str + 1) >= 0x20 && *(str + 1) <= 0x2f &&
(*(str + 2) == XctIgnoreExt ||
*(str + 2) == XctNotIgnoreExt)) {
/* ignore extension or not */
str++;
parse->version = *str++ - 0x20;
ret = *str++;
goto done;
}
if (*str == XctMB) { /* multiple-byte sets */
parse->char_size = 2;
str++;
} else
parse->char_size = 1;
switch (*str) {
case XctGL94:
parse->side = XlcGL;
parse->set_size = 94;
ret = (parse->char_size == 1) ? XctGL94 : XctGL94MB;
break;
case XctGR94:
parse->side = XlcGR;
parse->set_size = 94;
ret = (parse->char_size == 1) ? XctGR94 : XctGR94MB;
break;
case XctGR96:
if (parse->char_size == 1) {
parse->side = XlcGR;
parse->set_size = 96;
ret = XctGR96;
}
break;
}
if (ret) {
str++;
if (*str >= 0x24 && *str <= 0x2f) { /* non-standard */
ret = 0;
str++;
}
}
SKIP_I(str)
if (ret && *str < 0x40) /* non-standard */
ret = 0;
if (*str < 0x30 || *str > 0x7e || (char *) str - *text >= *length)
break;
if (ret == 0)
ret = XctESCSeq;
else {
if (parse->char_size == 2) {
if (*str >= 0x70)
parse->char_size = 4;
else if (*str >= 0x60)
parse->char_size = 3;
}
parse->ct_info = _XlcGetCTInfoFromEncoding(*text, *length);
}
str++;
goto done;
case XctCSI:
/* direction */
if (*str == XctLeftToRight && *(str + 1) == XctDirection) {
ret = XctLeftToRight;
str += 2;
goto done;
} else if (*str == XctRightToLeft && *(str + 1) == XctDirection) {
ret = XctRightToLeft;
str += 2;
goto done;
} else if (*str == XctDirectionEnd) {
ret = XctDirectionEnd;
str++;
goto done;
}
SKIP_P(str)
SKIP_I(str)
if (*str < 0x40 && *str > 0x7e)
break;
ret = XctCSISeq;
str++;
goto done;
}
if (ch & 0x80) {
if (ch < 0xa0)
ret = XctC1;
else
ret = XctGR;
} else {
if (ch == XctHT || ch == XctNL)
ret = ch;
else if (ch < 0x20)
ret = XctC0;
else
ret = XctGL;
}
return ret;
done:
*length -= (char *) str - *text;
*text = (char *) str;
return ret;
}
XlcCharSet
_fallcAddCT(name, encoding)
char *name;
char *encoding;
{
CTInfo ct_info;
XlcCharSet charset;
CTParseRec parse;
char *ct_ptr = encoding;
int length;
unsigned int type;
length = strlen(encoding);
switch (type = _XlcParseCT(&parse, &ct_ptr, &length)) {
case XctExtSeg:
case XctGL94:
case XctGL94MB:
case XctGR94:
case XctGR94MB:
case XctGR96:
if (parse.ct_info) /* existed */
return parse.ct_info->charset;
break;
default:
return (XlcCharSet) NULL;
}
charset = _fallcCreateDefaultCharSet(name, encoding);
if (charset == NULL)
return (XlcCharSet) NULL;
_fallcAddCharSet(charset);
ct_info = (CTInfo) Xmalloc(sizeof(CTInfoRec));
if (ct_info == NULL)
return (XlcCharSet) NULL;
ct_info->charset = charset;
ct_info->encoding = charset->ct_sequence;
ct_info->encoding_len = strlen(ct_info->encoding);
if (type == XctExtSeg) {
ct_info->ext_segment = ct_info->encoding + 6;
ct_info->ext_segment_len = strlen(ct_info->ext_segment);
} else {
ct_info->ext_segment = NULL;
ct_info->ext_segment_len = 0;
}
ct_info->next = ct_list;
ct_list = ct_info;
return charset;
}
static CTInfo
_XlcGetCTInfoFromCharSet(charset)
register XlcCharSet charset;
{
register CTInfo ct_info;
for (ct_info = ct_list; ct_info; ct_info = ct_info->next)
if (ct_info->charset == charset)
return ct_info;
return (CTInfo) NULL;
}
Bool
_fallcParseCharSet(charset)
XlcCharSet charset;
{
CTParseRec parse;
char *ptr, buf[BUFSIZ];
unsigned int type;
int length;
if (charset->ct_sequence == NULL)
return False;
ptr = charset->ct_sequence;
length = strlen(ptr);
type = _XlcParseCT(&parse, &ptr, &length);
if (charset->name) {
charset->xrm_name = falrmStringToQuark(charset->name);
snprintf(buf, sizeof(buf), "%s", charset->name);
if (ptr = strchr(buf, ':'))
*ptr = '\0';
charset->xrm_encoding_name = falrmStringToQuark(buf);
charset->encoding_name = falrmQuarkToString(charset->xrm_encoding_name);
} else {
charset->xrm_name = 0;
charset->encoding_name = NULL;
charset->xrm_encoding_name = 0;
}
charset->side = parse.side;
charset->char_size = parse.char_size;
charset->set_size = parse.set_size;
return True;
}
static void init_converter();
Bool
_fallcInitCTInfo()
{
register XlcCharSet charset;
register CTData ct_data;
register int num;
if (ct_list == NULL) {
num = sizeof(default_ct_data) / sizeof(CTDataRec);
for (ct_data = default_ct_data; num-- > 0; ct_data++) {
charset = _fallcAddCT(ct_data->name, ct_data->encoding);
if (charset == NULL)
continue;
}
init_converter();
}
return True;
}
static int
_XlcCheckCTSequence(state, ctext, ctext_len)
State state;
char **ctext;
int *ctext_len;
{
XlcCharSet charset;
CTParseRec parse;
CTInfo ct_info;
int length;
_XlcParseCT(&parse, ctext, ctext_len);
ct_info = parse.ct_info;
if (parse.ext_seg_length > 0) { /* XctExtSeg or XctOtherSeg */
if (ct_info) {
length = ct_info->ext_segment_len;
*ctext += length;
*ctext_len -= length;
state->ext_seg_left = parse.ext_seg_length - length;
state->ext_seg_charset = ct_info->charset;
} else {
state->ext_seg_left = parse.ext_seg_length;
state->ext_seg_charset = NULL;
}
} else if (ct_info) {
if (charset = ct_info->charset) {
if (charset->side == XlcGL)
state->GL_charset = charset;
else if (charset->side == XlcGR)
state->GR_charset = charset;
}
}
return 0;
}
static void
init_state(conv)
XlcConv conv;
{
State state = (State) conv->state;
static XlcCharSet GL_charset = NULL;
static XlcCharSet GR_charset = NULL;
if (GL_charset == NULL) {
GL_charset = _fallcGetCharSet("ISO8859-1:GL");
GR_charset = _fallcGetCharSet("ISO8859-1:GR");
}
state->GL_charset = state->charset = GL_charset;
state->GR_charset = GR_charset;
state->ext_seg_charset = NULL;
state->ext_seg_left = 0;
}
static int
cttocs(conv, from, from_left, to, to_left, args, num_args)
XlcConv conv;
XPointer *from;
int *from_left;
XPointer *to;
int *to_left;
XPointer *args;
int num_args;
{
register State state = (State) conv->state;
register unsigned char ch;
int length;
XlcCharSet charset = NULL;
char *ctptr, *bufptr;
int ctext_len, buf_len;
ctptr = *((char **) from);
bufptr = *((char **) to);
ctext_len = *from_left;
buf_len = *to_left;
while (ctext_len > 0 && buf_len > 0) {
if (state->ext_seg_left > 0) {
length = min(state->ext_seg_left, ctext_len);
length = min(length, buf_len);
ctext_len -= length;
state->ext_seg_left -= length;
if (state->ext_seg_charset) {
charset = state->ext_seg_charset;
buf_len -= length;
if (charset->side == XlcGL) {
while (length-- > 0)
*bufptr++ = *ctptr++ & 0x7f;
} else if (charset->side == XlcGR) {
while (length-- > 0)
*bufptr++ = *ctptr++ | 0x80;
} else {
while (length-- > 0)
*bufptr++ = *ctptr++;
}
if (state->ext_seg_left < 1)
state->ext_seg_charset = NULL;
}
break;
}
ch = *((unsigned char *) ctptr);
if (ch == 0x1b || ch == 0x9b) {
length = _XlcCheckCTSequence(state, &ctptr, &ctext_len);
if (length < 0)
return -1;
if (state->ext_seg_left > 0 && charset)
break;
} else {
if (charset) {
if (charset != (ch & 0x80 ? state->GR_charset :
state->GL_charset))
break;
} else
charset = ch & 0x80 ? state->GR_charset : state->GL_charset;
if ((ch < 0x20 && ch != '\0' && ch != '\n' && ch != '\t') ||
(ch >= 0x80 && ch < 0xa0))
return -1;
*bufptr++ = *ctptr++;
ctext_len--;
buf_len--;
}
}
if (charset)
state->charset = charset;
if (num_args > 0)
*((XlcCharSet *) args[0]) = state->charset;
*from_left -= ctptr - *((char **) from);
*from = (XPointer) ctptr;
*to_left -= bufptr - *((char **) to);
*to = (XPointer) bufptr;
return 0;
}
static int
cstoct(conv, from, from_left, to, to_left, args, num_args)
XlcConv conv;
XPointer *from;
int *from_left;
XPointer *to;
int *to_left;
XPointer *args;
int num_args;
{
State state = (State) conv->state;
XlcSide side;
unsigned char min_ch, max_ch;
register unsigned char ch;
int length;
CTInfo ct_info;
XlcCharSet charset;
char *csptr, *ctptr;
int csstr_len, ct_len;
if (num_args < 1)
return -1;
csptr = *((char **) from);
ctptr = *((char **) to);
csstr_len = *from_left;
ct_len = *to_left;
charset = (XlcCharSet) args[0];
ct_info = _XlcGetCTInfoFromCharSet(charset);
if (ct_info == NULL)
return -1;
side = charset->side;
if (ct_info->ext_segment) {
if (charset != state->ext_seg_charset && state->ext_seg_left < 1) {
length = ct_info->encoding_len;
if (ct_len < length)
return -1;
strcpy(ctptr, ct_info->encoding);
ctptr[4] = ((ct_info->ext_segment_len + csstr_len) / 128) | 0x80;
ctptr[5] = ((ct_info->ext_segment_len + csstr_len) % 128) | 0x80;
ctptr += length;
ct_len -= length;
state->ext_seg_left = csstr_len;
}
length = min(state->ext_seg_left, csstr_len);
state->ext_seg_left -= length;
if (side == XlcGL) {
while (length-- > 0)
*ctptr++ = *csptr++ & 0x7f;
} else if (side == XlcGR) {
while (length-- > 0)
*ctptr++ = *csptr++ | 0x80;
} else {
while (length-- > 0)
*ctptr++ = *csptr++;
}
state->ext_seg_charset = (state->ext_seg_left > 0) ? charset : NULL;
} else {
if ((side == XlcGR && charset != state->GR_charset) ||
(side == XlcGL && charset != state->GL_charset)) {
ct_len -= ct_info->encoding_len;
if (ct_len < 0)
return -1;
strcpy(ctptr, ct_info->encoding);
ctptr += ct_info->encoding_len;
}
min_ch = 0x20;
max_ch = 0x7f;
if (charset->set_size == 94) {
max_ch--;
if (charset->char_size > 1 || side == XlcGR)
min_ch++;
}
while (csstr_len > 0 && ct_len > 0) {
ch = *((unsigned char *) csptr++) & 0x7f;
if (ch < min_ch || ch > max_ch)
if (ch != 0x00 && ch != 0x09 && ch != 0x0a && ch != 0x1b)
continue; /* XXX */
if (side == XlcGL)
*ctptr++ = ch & 0x7f;
else if (side == XlcGR)
*ctptr++ = ch | 0x80;
else
*ctptr++ = ch;
csstr_len--;
ct_len--;
}
if (side == XlcGR)
state->GR_charset = charset;
else if (side == XlcGL)
state->GL_charset = charset;
}
*from_left -= csptr - *((char **) from);
*from = (XPointer) csptr;
*to_left -= ctptr - *((char **) to);
*to = (XPointer) ctptr;
return 0;
}
static int
strtocs(conv, from, from_left, to, to_left, args, num_args)
XlcConv conv;
XPointer *from;
int *from_left;
XPointer *to;
int *to_left;
XPointer *args;
int num_args;
{
State state = (State) conv->state;
register char *src, *dst;
unsigned char side;
register length;
src = (char *) *from;
dst = (char *) *to;
length = min(*from_left, *to_left);
side = *((unsigned char *) src) & 0x80;
while (side == (*((unsigned char *) src) & 0x80) && length-- > 0)
*dst++ = *src++;
*from_left -= src - (char *) *from;
*from = (XPointer) src;
*to_left -= dst - (char *) *to;
*to = (XPointer) dst;
if (num_args > 0)
*((XlcCharSet *)args[0]) = side ? state->GR_charset : state->GL_charset;
return 0;
}
static int
cstostr(conv, from, from_left, to, to_left, args, num_args)
XlcConv conv;
XPointer *from;
int *from_left;
XPointer *to;
int *to_left;
XPointer *args;
int num_args;
{
State state = (State) conv->state;
char *csptr, *string_ptr;
int csstr_len, str_len;
unsigned char ch;
int unconv_num = 0;
if (num_args < 1 || (state->GL_charset != (XlcCharSet) args[0] &&
state->GR_charset != (XlcCharSet) args[0]))
return -1;
csptr = *((char **) from);
string_ptr = *((char **) to);
csstr_len = *from_left;
str_len = *to_left;
while (csstr_len-- > 0 && str_len > 0) {
ch = *((unsigned char *) csptr++);
if ((ch < 0x20 && ch != 0x00 && ch != 0x09 && ch != 0x0a) ||
ch == 0x7f || ((ch & 0x80) && ch < 0xa0)) {
unconv_num++;
continue;
}
*((unsigned char *) string_ptr++) = ch;
str_len--;
}
*from_left -= csptr - *((char **) from);
*from = (XPointer) csptr;
*to_left -= string_ptr - *((char **) to);
*to = (XPointer) string_ptr;
return unconv_num;
}
static void
close_converter(conv)
XlcConv conv;
{
if (conv->state)
Xfree((char *) conv->state);
Xfree((char *) conv);
}
static XlcConv
create_conv(methods)
XlcConvMethods methods;
{
register XlcConv conv;
conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
if (conv == NULL)
return (XlcConv) NULL;
conv->state = (XPointer) Xmalloc(sizeof(StateRec));
if (conv->state == NULL)
goto err;
conv->methods = methods;
init_state(conv);
return conv;
err:
close_converter(conv);
return (XlcConv) NULL;
}
static XlcConvMethodsRec cttocs_methods = {
close_converter,
cttocs,
init_state
} ;
static XlcConv
open_cttocs(from_lcd, from_type, to_lcd, to_type)
XLCd from_lcd;
char *from_type;
XLCd to_lcd;
char *to_type;
{
return create_conv(&cttocs_methods);
}
static XlcConvMethodsRec cstoct_methods = {
close_converter,
cstoct,
init_state
} ;
static XlcConv
open_cstoct(from_lcd, from_type, to_lcd, to_type)
XLCd from_lcd;
char *from_type;
XLCd to_lcd;
char *to_type;
{
return create_conv(&cstoct_methods);
}
static XlcConvMethodsRec strtocs_methods = {
close_converter,
strtocs,
init_state
} ;
static XlcConv
open_strtocs(from_lcd, from_type, to_lcd, to_type)
XLCd from_lcd;
char *from_type;
XLCd to_lcd;
char *to_type;
{
return create_conv(&strtocs_methods);
}
static XlcConvMethodsRec cstostr_methods = {
close_converter,
cstostr,
init_state
} ;
static XlcConv
open_cstostr(from_lcd, from_type, to_lcd, to_type)
XLCd from_lcd;
char *from_type;
XLCd to_lcd;
char *to_type;
{
return create_conv(&cstostr_methods);
}
static void
init_converter()
{
_fallcSetConverter((XLCd) NULL, XlcNCompoundText, (XLCd) NULL, XlcNCharSet,
open_cttocs);
_fallcSetConverter((XLCd) NULL, XlcNString, (XLCd) NULL, XlcNCharSet,
open_strtocs);
_fallcSetConverter((XLCd) NULL, XlcNCharSet, (XLCd) NULL, XlcNCompoundText,
open_cstoct);
_fallcSetConverter((XLCd) NULL, XlcNCharSet, (XLCd) NULL, XlcNString,
open_cstostr);
}

View file

@ -0,0 +1,187 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcCharSet.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:33 */
/* $XConsortium: _fallcCharSet.c /main/1 1996/04/08 15:15:44 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
#include <stdio.h>
#include "_fallibint.h"
#include "_fallcPublic.h"
#if NeedVarargsPrototypes
char *
_fallcGetCSValues(XlcCharSet charset, ...)
#else
char *
_fallcGetCSValues(charset, va_alist)
XlcCharSet charset;
va_dcl
#endif
{
va_list var;
XlcArgList args;
char *ret;
int num_args;
Va_start(var, charset);
_fallcCountVaList(var, &num_args);
va_end(var);
Va_start(var, charset);
_fallcVaToArgList(var, num_args, &args);
va_end(var);
if (args == (XlcArgList) NULL)
return (char *) NULL;
if (charset->get_values)
ret = (*charset->get_values)(charset, args, num_args);
else
ret = args->name;
Xfree(args);
return ret;
}
typedef struct _XlcCharSetListRec {
XlcCharSet charset;
struct _XlcCharSetListRec *next;
} XlcCharSetListRec, *XlcCharSetList;
static XlcCharSetList charset_list = NULL;
XlcCharSet
_fallcGetCharSet(name)
char *name;
{
XlcCharSetList list;
XrmQuark xrm_name;
xrm_name = falrmStringToQuark(name);
for (list = charset_list; list; list = list->next) {
if (xrm_name == list->charset->xrm_name)
return (XlcCharSet) list->charset;
}
return (XlcCharSet) NULL;
}
Bool
_fallcAddCharSet(charset)
XlcCharSet charset;
{
XlcCharSetList list;
if (_fallcGetCharSet(charset->name))
return False;
list = (XlcCharSetList) Xmalloc(sizeof(XlcCharSetListRec));
if (list == NULL)
return False;
list->charset = charset;
list->next = charset_list;
charset_list = list;
return True;
}
static XlcResource resources[] = {
{ XlcNName, NULLQUARK, sizeof(char *),
XOffsetOf(XlcCharSetRec, name), XlcGetMask },
{ XlcNEncodingName, NULLQUARK, sizeof(char *),
XOffsetOf(XlcCharSetRec, encoding_name), XlcGetMask },
{ XlcNSide, NULLQUARK, sizeof(XlcSide),
XOffsetOf(XlcCharSetRec, side), XlcGetMask },
{ XlcNCharSize, NULLQUARK, sizeof(int),
XOffsetOf(XlcCharSetRec, char_size), XlcGetMask },
{ XlcNSetSize, NULLQUARK, sizeof(int),
XOffsetOf(XlcCharSetRec, set_size), XlcGetMask },
{ XlcNControlSequence, NULLQUARK, sizeof(char *),
XOffsetOf(XlcCharSetRec, ct_sequence), XlcGetMask }
};
static char *
get_values(charset, args, num_args)
register XlcCharSet charset;
register XlcArgList args;
register int num_args;
{
if (resources[0].xrm_name == NULLQUARK)
_fallcCompileResourceList(resources, XlcNumber(resources));
return _fallcGetValues((XPointer) charset, resources, XlcNumber(resources),
args, num_args, XlcGetMask);
}
XlcCharSet
_fallcCreateDefaultCharSet(name, ct_sequence)
char *name;
char *ct_sequence;
{
XlcCharSet charset;
charset = (XlcCharSet) Xmalloc(sizeof(XlcCharSetRec));
if (charset == NULL)
return (XlcCharSet) NULL;
bzero((char *) charset, sizeof(XlcCharSetRec));
charset->name = (char *) Xmalloc(strlen(name) + strlen(ct_sequence) + 2);
if (charset->name == NULL) {
Xfree((char *) charset);
return (XlcCharSet) NULL;
}
strcpy(charset->name, name);
charset->ct_sequence = charset->name + strlen(name) + 1;
strcpy(charset->ct_sequence, ct_sequence);
charset->get_values = get_values;
_fallcParseCharSet(charset);
return (XlcCharSet) charset;
}

View file

@ -0,0 +1,356 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcConv.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:34 */
/* $XConsortium: _fallcConv.c /main/1 1996/04/08 15:15:57 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
#include "_fallibint.h"
#include "_fallcPubI.h"
#include <stdio.h>
typedef XlcConv (*XlcConverter)();
typedef struct _fallcConverterListRec {
XLCd from_lcd;
char *from;
XrmQuark from_type;
XLCd to_lcd;
char *to;
XrmQuark to_type;
XlcConverter converter;
struct _fallcConverterListRec *next;
} XlcConverterListRec, *XlcConverterList;
static XlcConverterList conv_list = NULL;
static void
close_converter(conv)
XlcConv conv;
{
(*conv->methods->close)(conv);
}
static XlcConv
get_converter(from_lcd, from_type, to_lcd, to_type)
XLCd from_lcd;
XrmQuark from_type;
XLCd to_lcd;
XrmQuark to_type;
{
register XlcConverterList list, prev = NULL;
XlcConv conv;
for (list = conv_list; list; list = list->next) {
if (list->from_lcd == from_lcd && list->to_lcd == to_lcd
&& list->from_type == from_type && list->to_type == to_type) {
if (prev && prev != conv_list) { /* XXX */
prev->next = list->next;
list->next = conv_list;
conv_list = list;
}
return (*list->converter)(from_lcd, list->from, to_lcd, list->to);
}
prev = list;
}
return (XlcConv) NULL;
}
Bool
_fallcSetConverter(from_lcd, from, to_lcd, to, converter)
XLCd from_lcd;
char *from;
XLCd to_lcd;
char *to;
XlcOpenConverterProc converter;
{
register XlcConverterList list;
register XrmQuark from_type, to_type;
from_type = falrmStringToQuark(from);
to_type = falrmStringToQuark(to);
for (list = conv_list; list; list = list->next) {
if (list->from_lcd == from_lcd && list->to_lcd == to_lcd
&& list->from_type == from_type && list->to_type == to_type) {
list->converter = converter;
return True;
}
}
list = (XlcConverterList) Xmalloc(sizeof(XlcConverterListRec));
if (list == NULL)
return False;
list->from_lcd = from_lcd;
list->from = from;
list->from_type = from_type;
list->to_lcd = to_lcd;
list->to = to;
list->to_type = to_type;
list->converter = converter;
list->next = conv_list;
conv_list = list;
return True;
}
typedef struct _ConvRec {
XlcConv from_conv;
XlcConv to_conv;
} ConvRec, *Conv;
static int
indirect_convert(lc_conv, from, from_left, to, to_left, args, num_args)
XlcConv lc_conv;
XPointer *from;
int *from_left;
XPointer *to;
int *to_left;
XPointer *args;
int num_args;
{
Conv conv = (Conv) lc_conv->state;
XlcConv from_conv = conv->from_conv;
XlcConv to_conv = conv->to_conv;
XlcCharSet charset;
char buf[BUFSIZ], *cs;
XPointer tmp_args[1];
int cs_left, ret, length, unconv_num = 0;
if (from == NULL || *from == NULL) {
if (from_conv->methods->reset)
(*from_conv->methods->reset)(from_conv);
if (to_conv->methods->reset)
(*to_conv->methods->reset)(to_conv);
return 0;
}
while (*from_left > 0) {
cs = buf;
cs_left = BUFSIZ;
tmp_args[0] = (XPointer) &charset;
ret = (*from_conv->methods->convert)(from_conv, from, from_left, &cs,
&cs_left, tmp_args, 1);
if (ret < 0)
break;
length = cs_left = cs - buf;
cs = buf;
tmp_args[0] = (XPointer) charset;
ret = (*to_conv->methods->convert)(to_conv, &cs, &cs_left, to, to_left,
tmp_args, 1);
if (ret < 0) {
unconv_num += length / charset->char_size;
continue;
}
if (*to_left < 1)
break;
}
return unconv_num;
}
static void
close_indirect_converter(lc_conv)
XlcConv lc_conv;
{
Conv conv = (Conv) lc_conv->state;
if (conv) {
if (conv->from_conv)
close_converter(conv->from_conv);
if (conv->to_conv)
close_converter(conv->to_conv);
Xfree((char *) conv);
}
Xfree((char *) lc_conv);
}
static void
reset_indirect_converter(lc_conv)
XlcConv lc_conv;
{
Conv conv = (Conv) lc_conv->state;
if (conv) {
if (conv->from_conv && conv->from_conv->methods->reset)
(*conv->from_conv->methods->reset)(conv->from_conv);
if (conv->to_conv && conv->to_conv->methods->reset)
(*conv->to_conv->methods->reset)(conv->to_conv);
}
}
static XlcConvMethodsRec conv_methods = {
close_indirect_converter,
indirect_convert,
reset_indirect_converter
} ;
static XlcConv
open_indirect_converter(from_lcd, from, to_lcd, to)
XLCd from_lcd;
char *from;
XLCd to_lcd;
char *to;
{
XlcConv lc_conv, from_conv, to_conv;
Conv conv;
XrmQuark from_type, to_type;
static XrmQuark QChar, QCharSet, QCTCharSet = (XrmQuark) 0;
if (QCTCharSet == (XrmQuark) 0) {
QCTCharSet = falrmStringToQuark(XlcNCTCharSet);
QCharSet = falrmStringToQuark(XlcNCharSet);
QChar = falrmStringToQuark(XlcNChar);
}
from_type = falrmStringToQuark(from);
to_type = falrmStringToQuark(to);
if (from_type == QCharSet || from_type == QChar || to_type == QCharSet ||
to_type == QChar)
return (XlcConv) NULL;
lc_conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
if (lc_conv == NULL)
return (XlcConv) NULL;
lc_conv->methods = &conv_methods;
lc_conv->state = (XPointer) Xmalloc(sizeof(ConvRec));
if (lc_conv->state == NULL)
goto err;
conv = (Conv) lc_conv->state;
from_conv = get_converter(from_lcd, from_type, from_lcd, QCTCharSet);
if (from_conv == NULL)
from_conv = get_converter(from_lcd, from_type, from_lcd, QCharSet);
if (from_conv == NULL)
from_conv = get_converter((XLCd)NULL, from_type, (XLCd)NULL, QCharSet);
if (from_conv == NULL)
from_conv = get_converter(from_lcd, from_type, from_lcd, QChar);
if (from_conv == NULL)
goto err;
conv->from_conv = from_conv;
to_conv = get_converter(to_lcd, QCTCharSet, to_lcd, to_type);
if (to_conv == NULL)
to_conv = get_converter(to_lcd, QCharSet, to_lcd, to_type);
if (to_conv == NULL)
to_conv = get_converter((XLCd) NULL, QCharSet, (XLCd) NULL, to_type);
if (to_conv == NULL)
goto err;
conv->to_conv = to_conv;
return lc_conv;
err:
close_indirect_converter(lc_conv);
return (XlcConv) NULL;
}
XlcConv
_fallcOpenConverter(from_lcd, from, to_lcd, to)
XLCd from_lcd;
char *from;
XLCd to_lcd;
char *to;
{
XlcConv conv;
XrmQuark from_type, to_type;
from_type = falrmStringToQuark(from);
to_type = falrmStringToQuark(to);
if (conv = get_converter(from_lcd, from_type, to_lcd, to_type))
return conv;
return open_indirect_converter(from_lcd, from, to_lcd, to);
}
void
_fallcCloseConverter(conv)
XlcConv conv;
{
close_converter(conv);
}
int
_fallcConvert(conv, from, from_left, to, to_left, args, num_args)
XlcConv conv;
XPointer *from;
int *from_left;
XPointer *to;
int *to_left;
XPointer *args;
int num_args;
{
return (*conv->methods->convert)(conv, from, from_left, to, to_left, args,
num_args);
}
void
_fallcResetConverter(conv)
XlcConv conv;
{
if (conv->methods->reset)
(*conv->methods->reset)(conv);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,387 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcDefConv.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:35 */
/* $XConsortium: _fallcDefConv.c /main/1 1996/04/08 15:16:17 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
#include "_fallibint.h"
#include "_fallcPubI.h"
typedef struct _StateRec {
XlcCharSet charset;
XlcCharSet GL_charset;
XlcCharSet GR_charset;
XlcConv ct_conv;
int (*to_converter)();
} StateRec, *State;
static int
strtostr(conv, from, from_left, to, to_left, args, num_args)
XlcConv conv;
XPointer *from;
int *from_left;
XPointer *to;
int *to_left;
XPointer *args;
int num_args;
{
register char *src, *dst;
unsigned char side;
register length;
if (from == NULL || *from == NULL)
return 0;
src = (char *) *from;
dst = (char *) *to;
length = min(*from_left, *to_left);
if (num_args > 0) {
side = *((unsigned char *) src) & 0x80;
while (side == (*((unsigned char *) src) & 0x80) && length-- > 0)
*dst++ = *src++;
} else {
while (length-- > 0)
*dst++ = *src++;
}
*from_left -= src - (char *) *from;
*from = (XPointer) src;
*to_left -= dst - (char *) *to;
*to = (XPointer) dst;
if (num_args > 0) {
State state = (State) conv->state;
*((XlcCharSet *)args[0]) = side ? state->GR_charset : state->GL_charset;
}
return 0;
}
static int
wcstostr(conv, from, from_left, to, to_left, args, num_args)
XlcConv conv;
XPointer *from;
int *from_left;
XPointer *to;
int *to_left;
XPointer *args;
int num_args;
{
register wchar_t *src, side;
register char *dst;
register length;
if (from == NULL || *from == NULL)
return 0;
src = (wchar_t *) *from;
dst = (char *) *to;
length = min(*from_left, *to_left);
if (num_args > 0) {
side = *src & 0x80;
while (side == (*src & 0x80) && length-- > 0)
*dst++ = *src++;
} else {
while (length-- > 0)
*dst++ = *src++;
}
*from_left -= src - (wchar_t *) *from;
*from = (XPointer) src;
*to_left -= dst - (char *) *to;
*to = (XPointer) dst;
if (num_args > 0) {
State state = (State) conv->state;
*((XlcCharSet *)args[0]) = side ? state->GR_charset : state->GL_charset;
}
return 0;
}
static int
cstostr(conv, from, from_left, to, to_left, args, num_args)
XlcConv conv;
XPointer *from;
int *from_left;
XPointer *to;
int *to_left;
XPointer *args;
int num_args;
{
register char *src, *dst;
unsigned char side;
register length;
if (from == NULL || *from == NULL)
return 0;
if (num_args > 0) {
State state = (State) conv->state;
XlcCharSet charset = (XlcCharSet) args[0];
if (charset != state->GL_charset && charset != state->GR_charset)
return -1;
}
src = (char *) *from;
dst = (char *) *to;
length = min(*from_left, *to_left);
if (num_args > 0) {
side = *((unsigned char *) src) & 0x80;
while (side == (*((unsigned char *) src) & 0x80) && length-- > 0)
*dst++ = *src++;
} else {
while (length-- > 0)
*dst++ = *src++;
}
*from_left -= src - (char *) *from;
*from = (XPointer) src;
*to_left -= dst - (char *) *to;
*to = (XPointer) dst;
if (num_args > 0) {
State state = (State) conv->state;
*((XlcCharSet *)args[0]) = side ? state->GR_charset : state->GL_charset;
}
return 0;
}
static int
strtowcs(conv, from, from_left, to, to_left, args, num_args)
XlcConv conv;
XPointer *from;
int *from_left;
XPointer *to;
int *to_left;
XPointer *args;
int num_args;
{
register char *src;
register wchar_t *dst;
register length;
if (from == NULL || *from == NULL)
return 0;
if (num_args > 0) {
State state = (State) conv->state;
XlcCharSet charset = (XlcCharSet) args[0];
if (charset != state->GL_charset && charset != state->GR_charset)
return -1;
}
src = (char *) *from;
dst = (wchar_t *) *to;
length = min(*from_left, *to_left);
while (length-- > 0)
*dst++ = (wchar_t) *src++;
*from_left -= src - (char *) *from;
*from = (XPointer) src;
*to_left -= dst - (wchar_t *) *to;
*to = (XPointer) dst;
return 0;
}
static void
close_converter(conv)
XlcConv conv;
{
if (conv->state)
Xfree((char *) conv->state);
Xfree((char *) conv);
}
static XlcConv
create_conv(methods)
XlcConvMethods methods;
{
register XlcConv conv;
State state;
static XlcCharSet GL_charset = NULL;
static XlcCharSet GR_charset = NULL;
if (GL_charset == NULL) {
GL_charset = _fallcGetCharSet("ISO8859-1:GL");
GR_charset = _fallcGetCharSet("ISO8859-1:GR");
}
conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
if (conv == NULL)
return (XlcConv) NULL;
conv->state = NULL;
state = (State) Xmalloc(sizeof(StateRec));
if (state == NULL)
goto err;
state->GL_charset = state->charset = GL_charset;
state->GR_charset = GR_charset;
conv->methods = methods;
conv->state = (XPointer) state;
return conv;
err:
close_converter(conv);
return (XlcConv) NULL;
}
static XlcConvMethodsRec strtostr_methods = {
close_converter,
strtostr,
NULL
} ;
static XlcConv
open_strtostr(from_lcd, from_type, to_lcd, to_type)
XLCd from_lcd;
char *from_type;
XLCd to_lcd;
char *to_type;
{
return create_conv(&strtostr_methods);
}
static XlcConvMethodsRec wcstostr_methods = {
close_converter,
wcstostr,
NULL
} ;
static XlcConv
open_wcstostr(from_lcd, from_type, to_lcd, to_type)
XLCd from_lcd;
char *from_type;
XLCd to_lcd;
char *to_type;
{
return create_conv(&wcstostr_methods);
}
static XlcConvMethodsRec cstostr_methods = {
close_converter,
cstostr,
NULL
} ;
static XlcConv
open_cstostr(from_lcd, from_type, to_lcd, to_type)
XLCd from_lcd;
char *from_type;
XLCd to_lcd;
char *to_type;
{
return create_conv(&cstostr_methods);
}
static XlcConvMethodsRec strtowcs_methods = {
close_converter,
strtowcs,
NULL
} ;
static XlcConv
open_strtowcs(from_lcd, from_type, to_lcd, to_type)
XLCd from_lcd;
char *from_type;
XLCd to_lcd;
char *to_type;
{
return create_conv(&strtowcs_methods);
}
XLCd
_fallcDefaultLoader(name)
char *name;
{
XLCd lcd;
if (strcmp(name, "C"))
return (XLCd) NULL;
lcd = _fallcCreateLC(name, _fallcPublicMethods);
_fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_strtowcs);
_fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_strtostr);
_fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_strtostr);
_fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_strtostr);
_fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_strtostr);/* XXX */
_fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstostr);
_fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstostr);
_fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_wcstostr);
_fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstostr);
_fallcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_strtostr);
_fallcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_strtowcs);
_fallcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstostr);
_fallcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_strtowcs);
return lcd;
}

View file

@ -0,0 +1,73 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: _fallcDynamic.c /main/3 1996/05/08 19:00:37 drk $ */
/* lcDynamic.c 1.1 - Fujitsu source for CDEnext 95/12/07 10:56:55 */
/*
* Copyright 1995 by FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietry source code of FUJITSU LIMITED
*
* Modifier: Takanori Tateno FUJITSU LIMITED
*
*/
#include <stdio.h>
#include <string.h>
#include "_fallibint.h"
#ifdef USE_DYNAMIC_LOADER
#ifndef XLOCALEDIR
#define XLOCALEDIR "/usr/lib/X11/locale"
#endif
#define LCLIBNAME "xi18n.so"
extern void *dlopen();
extern void *dlsym();
extern int dlclose();
extern char *dlerror();
#define LAZY 1
#define NOW 2
#define GLOBAL 0x100
XLCd
_fallcDynamicLoader(name)
char *name;
{
char libpath[1024];
XLCdMethods _fallcGenericMethods;
XLCd lcd;
void *nlshandler;
sprintf(libpath,"%s/%s/%s",
XLOCALEDIR,name,LCLIBNAME);
nlshandler = dlopen(libpath,LAZY);
_fallcGenericMethods = (XLCdMethods)dlsym(nlshandler,
"genericMethods");
lcd = _fallcCreateLC(name,_fallcGenericMethods);
return lcd;
}
#endif /* USE_DYNAMIC_LOADER */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,377 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcFile.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:36 */
/* $XConsortium: _fallcFile.c /main/1 1996/04/08 15:16:48 cde-fuj $ */
/*
*
* Copyright IBM Corporation 1993
*
* All Rights Reserved
*
* License to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of IBM not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
*
* IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND
* NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
* IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
*/
#include <stdio.h>
#include <ctype.h>
#include "_fallibint.h"
#include "_fallcPubI.h"
#include <X11/Xos.h>
#ifdef X_NOT_STDC_ENV
extern char *getenv();
#endif
/************************************************************************/
#define iscomment(ch) ((ch) == '#' || (ch) == '\0')
#define isreadable(f) ((access((f), R_OK) != -1) ? 1 : 0)
/*
#define isspace(ch) ((ch) == ' ' || (ch) == '\t' || (ch) == '\n')
*/
static int
parse_line(line, argv, argsize)
char *line;
char **argv;
int argsize;
{
int argc = 0;
char *p = line;
while(argc < argsize){
while(isspace(*p)){
++p;
}
if(*p == '\0'){
break;
}
argv[argc++] = p;
while(! isspace(*p) && *p != '\0'){
++p;
}
if(*p == '\0'){
break;
}
*p++ = '\0';
}
return argc;
}
#ifndef XLOCALEDIR
#define XLOCALEDIR "/usr/lib/X11/locale"
#endif
static void
xlocaledir(path)
char *path;
{
char *dir, *p = path;
int len;
dir = getenv("XLOCALEDIR");
if(dir != NULL){
len = strlen(dir);
strcpy(p, dir);
p[len++] = ':';
p += len;
}
strcpy(p, XLOCALEDIR);
}
static int
parse_path(path, argv, argsize)
char *path;
char **argv;
int argsize;
{
char *p = path;
int i, n;
while((p = strchr(p, ':')) != NULL){
*p = ' '; /* place space on delimter */
}
n = parse_line(path, argv, argsize);
if(n == 0){
return 0;
}
for(i = 0; i < n; ++i){
int len;
p = argv[i];
len = strlen(p);
if(p[len - 1] == '/'){
/* eliminate slash */
p[len - 1] = '\0';
}
}
return n;
}
enum { LtoR, RtoL };
static char *
_XlcResolveName(lc_name, file_name, direction)
char *lc_name;
char *file_name;
int direction; /* mapping direction */
{
FILE *fp;
char buf[BUFSIZE], *name = NULL;
fp = fopen(file_name, "r");
if(fp == (FILE *)NULL){
return NULL;
}
while(fgets(buf, BUFSIZE, fp) != NULL){
char *p = buf;
int n;
char *args[2], *from, *to;
while(isspace(*p)){
++p;
}
if(iscomment(*p)){
continue;
}
n = parse_line(p, args, 2); /* get first 2 fields */
if(n != 2){
continue;
}
if(direction == LtoR){
from = args[0], to = args[1]; /* left to right */
}else{
from = args[1], to = args[0]; /* right to left */
}
if(! strcmp(from, lc_name)){
name = Xmalloc(strlen(to) + 1);
if(name != NULL){
strcpy(name, to);
}
break;
}
}
if(fp != (FILE *)NULL){
fclose(fp);
}
return name;
}
/*
#define isupper(ch) ('A' <= (ch) && (ch) <= 'Z')
#define tolower(ch) ((ch) - 'A' + 'a')
*/
static char *
lowercase(dst, src)
char *dst;
char *src;
{
char *s, *t;
for(s = src, t = dst; *s; ++s, ++t){
*t = isupper(*s) ? tolower(*s) : *s;
}
*t = '\0';
return dst;
}
/************************************************************************/
char *
_fallcFileName(lcd, category)
XLCd lcd;
char *category;
{
char lc_name[BUFSIZE];
char cat[BUFSIZE], dir[BUFSIZE];
int i, n;
char *args[256];
char *file_name = NULL;
if(lcd == (XLCd)NULL){
return NULL;
}
if(! _fallcResolveLocaleName(XLC_PUBLIC(lcd, siname), lc_name,
NULL, NULL, NULL)){
return NULL;
}
lowercase(cat, category);
xlocaledir(dir);
n = parse_path(dir, args, 256);
for(i = 0; i < n; ++i){
char buf[BUFSIZE], *name;
sprintf(buf, "%s/%s.dir", args[i], cat);
name = _XlcResolveName(lc_name, buf, RtoL);
if(name == NULL){
continue;
}
if(*name == '/'){
/* supposed to be absolute path name */
file_name = name;
}else{
sprintf(buf, "%s/%s", args[i], name);
Xfree(name);
file_name = Xmalloc(strlen(buf) + 1);
if(file_name == NULL){
break;
}
strcpy(file_name, buf);
}
if(isreadable(file_name)){
break;
}
Xfree(file_name);
file_name = NULL;
/* Then, try with next dir */
}
return file_name;
}
/************************************************************************/
#ifndef LOCALE_ALIAS
#define LOCALE_ALIAS "locale.alias"
#endif
int
_fallcResolveLocaleName(lc_name, full_name, language, territory, codeset)
char *lc_name;
char *full_name;
char *language;
char *territory;
char *codeset;
{
char dir[BUFSIZE], buf[BUFSIZE], *name = NULL;
int i, n;
char *args[256];
xlocaledir(dir);
n = parse_path(dir, args, 256);
for(i = 0; i < n; ++i){
sprintf(buf, "%s/%s", args[i], LOCALE_ALIAS);
name = _XlcResolveName(lc_name, buf, LtoR);
if(name != NULL){
break;
}
}
if(name != NULL){
snprintf(buf, sizeof(buf), "%s", name);
Xfree(name);
}else{
snprintf(buf, sizeof(buf), "%s", lc_name);
}
if(full_name != NULL){
strcpy(full_name, buf);
}
if(language || territory || codeset){
char *ptr, *name_p;
/*
* Decompose locale name
*/
if(language) *language = '\0';
if(territory) *territory = '\0';
if(codeset) *codeset = '\0';
name_p = buf;
ptr = language;
while (1) {
if (*name_p == '_') {
if (ptr)
*ptr = '\0';
ptr = territory;
} else if (*name_p == '.') {
if (ptr)
*ptr = '\0';
ptr = codeset;
} else {
if (ptr)
*ptr++ = *name_p;
if (*name_p == '\0')
break;
}
name_p++;
}
}
return (buf[0] != '\0') ? 1 : 0;
}
/************************************************************************/
#ifndef LOCALE_DIR
#define LOCALE_DIR "locale.dir"
#endif
int
_fallcResolveDBName(lc_name, file_name)
char *lc_name;
char *file_name;
{
char dir[BUFSIZE], buf[BUFSIZE], *name = NULL;
int i, n;
char *args[256];
xlocaledir(dir);
n = parse_path(dir, args, 256);
for(i = 0; i < n; ++i){
sprintf(buf, "%s/%s", args[i], LOCALE_DIR);
name = _XlcResolveName(lc_name, buf, RtoL);
if(name != NULL){
break;
}
}
if(name == NULL){
return 0;
}
strcpy(buf, name);
Xfree(name);
if(file_name != NULL){
strcpy(file_name, buf);
}
return 1;
}
/************************************************************************/
int
_fallcResolveI18NPath(path_name)
char *path_name;
{
if(path_name != NULL){
xlocaledir(path_name);
}
return 1;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,170 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* XlcGeneric.h 1.3 - Fujitsu source for CDEnext 95/12/07 10:53:07 */
/* $XConsortium: _fallcGeneric.h /main/1 1996/04/08 15:17:24 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
/*
* Copyright 1995 by FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietry source code of FUJITSU LIMITED
*
* Modifier: Takanori Tateno FUJITSU LIMITED
*
*/
#ifndef _XLCGENERIC_H_
#define _XLCGENERIC_H_
#include "_fallcPubI.h"
typedef struct _ByteInfo {
unsigned char start,end;
} ByteInfoRec, *ByteInfo;
typedef struct _ByteInfoList {
int M; /* 1 <= M <= length */
int byteinfo_num;
ByteInfo byteinfo;
} ByteInfoListRec, *ByteInfoList;
/* conversion_type values */
#define LOCALCONV 1
#define FILECONV 2
#define FUNCTIONCONV 4
typedef struct _Conversion {
unsigned long conversion_type;
int conv_num;
FontScope convlist;
char *cnv_file;
XlcConv cnvfunc;
} ConversionRec, *Conversion;
typedef struct _ExtdSegment {
char *name;
XlcSide side;
FontScope area;
int area_num;
XlcCharSet charset;
} ExtdSegmentRec, *ExtdSegment;
typedef struct _SegConvRec {
int length;
char *source_encoding;
XlcCharSet source;
char *destination_encoding;
XlcCharSet dest;
FontScopeRec range;
int conv_num;
FontScope conv;
} SegConvRec, *SegConv;
typedef struct _ParseInfoRec *ParseInfo;
typedef struct _CodeSetRec {
XlcCharSet *charset_list;
int num_charsets;
int cs_num;
XlcSide side;
int length;
ByteInfoList byteM;
Conversion mbconv;
Conversion ctconv;
ExtdSegment ctextseg;
ParseInfo parse_info;
unsigned long wc_encoding;
} CodeSetRec, *CodeSet;
typedef enum {
E_GL, /* GL encoding */
E_GR, /* GR encoding */
E_SS, /* single shift */
E_LSL, /* locking shift left */
E_LSR, /* locking shift right */
E_LAST
} EncodingType;
typedef struct _ParseInfoRec {
EncodingType type;
char *encoding;
CodeSet codeset;
} ParseInfoRec;
/*
* XLCd private data
*/
#define XLC_GENERIC(lcd, x) (((XLCdGeneric) lcd->core)->gen.x)
#define XLC_GENERIC_PART(lcd) (&(((XLCdGeneric) lcd->core)->gen))
typedef struct _XLCdGenericPart {
int codeset_num;
CodeSet *codeset_list;
unsigned char *mb_parse_table;
int mb_parse_list_num;
ParseInfo *mb_parse_list;
unsigned long wc_encode_mask;
unsigned long wc_shift_bits;
CodeSet initial_state_GL;
CodeSet initial_state_GR;
int segment_conv_num; /* UDC */
SegConv segment_conv; /* UDC */
#ifndef X_NOT_STDC_ENV
Bool use_stdc_env;
Bool force_convert_to_mb;
#endif
} XLCdGenericPart;
typedef struct _XLCdGenericRec {
XLCdCoreRec core;
XLCdPublicPart pub;
XLCdGenericPart gen;
} XLCdGenericRec, *XLCdGeneric;
extern XLCdMethods _fallcGenericMethods;
#endif /* _XLCGENERIC_H_ */

View file

@ -0,0 +1,186 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcInit.c 1.4 - Fujitsu source for CDEnext 96/03/11 17:13:15 */
/* $XConsortium: _fallcInit.c /main/1 1996/04/08 15:17:36 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*
* Modifier: Masayoshi Shimamura FUJITSU LIMITED
*
*/
#include "_fallibint.h"
#include "_fallcint.h"
#define USE_GENERIC_LOADER
#define USE_DEFAULT_LOADER
/*** #define USE_EUC_LOADER ***/
/*** #define USE_SJIS_LOADER ***/
/*** #define USE_JIS_LOADER ***/
/*** #define USE_UTF_LOADER ***/
extern XLCd _fallcDefaultLoader(
#if NeedFunctionPrototypes
char*
#endif
);
#ifdef DYNAMIC_LOAD
#ifdef sun
extern XLCd _falsunOsDynamicLoad(
#if NeedFunctionPrototypes
char*
#endif
);
#endif /* sun */
#ifdef AIXV3
extern XLCd _falaixOsDynamicLoad(
#if NeedFunctionPrototypes
char*
#endif
);
#endif /* AIXV3 */
#endif
#ifdef USE_GENERIC_LOADER
extern XLCd _fallcGenericLoader(
#if NeedFunctionPrototypes
char*
#endif
);
#endif
#ifdef USE_UTF_LOADER
extern XLCd _fallcUtfLoader(
#if NeedFunctionPrototypes
char*
#endif
);
#endif
#ifdef USE_EUC_LOADER
extern XLCd _fallcEucLoader(
#if NeedFunctionPrototypes
char*
#endif
);
#endif
#ifdef USE_SJIS_LOADER
extern XLCd _fallcSjisLoader(
#if NeedFunctionPrototypes
char*
#endif
);
#endif
#ifdef USE_JIS_LOADER
extern XLCd _XlcJisLoader(
#if NeedFunctionPrototypes
char*
#endif
);
#endif
#ifdef USE_DYNAMIC_LOADER
extern XLCd _fallcDynamicLoader(
#if NeedFunctionPrototypes
char*
#endif
);
#endif
/*
* The _fallcInitLoader function initializes the locale object loader list
* with vendor specific manner.
*/
void
_fallcInitLoader()
{
#ifdef USE_GENERIC_LOADER
_fallcAddLoader(_fallcGenericLoader, XlcHead);
#endif
#ifdef USE_DEFAULT_LOADER
_fallcAddLoader(_fallcDefaultLoader, XlcHead);
#endif
#ifdef USE_EUC_LOADER
_fallcAddLoader(_fallcEucLoader, XlcHead);
#endif
#ifdef USE_SJIS_LOADER
_fallcAddLoader(_fallcSjisLoader, XlcHead);
#endif
#ifdef USE_JIS_LOADER
_fallcAddLoader(_XlcJisLoader, XlcHead);
#endif
#ifdef USE_UTF_LOADER
_fallcAddLoader(_fallcUtfLoader, XlcHead);
#endif
#ifdef DYNAMIC_LOAD
#ifdef sun
_fallcAddLoader(_falsunOsDynamicLoad, XlcHead);
#endif /* sun */
#ifdef AIXV3
_fallcAddLoader(_falaixOsDynamicLoad, XlcHead);
#endif /* AIXV3 */
#endif /* DYNAMIC_LOAD */
#ifdef USE_DYNAMIC_LOADER
_fallcAddLoader(_fallcDynamicLoader, XlcHead);
#endif
}

View file

@ -0,0 +1,267 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcPrTxt.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:38 */
/* $XConsortium: _fallcPrTxt.c /main/1 1996/04/08 15:17:49 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
#include "_fallibint.h"
#include "_fallcPubI.h"
#include "_falutil.h"
#include <X11/Xatom.h>
static XPointer *
alloc_list(is_wide_char, count, nitems)
Bool is_wide_char;
int count;
int nitems;
{
if (is_wide_char) {
wchar_t **wstr_list;
wstr_list = (wchar_t **) Xmalloc(count * sizeof(wchar_t *));
if (wstr_list == NULL)
return (XPointer *) NULL;
*wstr_list = (wchar_t *) Xmalloc(nitems * sizeof(wchar_t));
if (*wstr_list == NULL) {
Xfree(wstr_list);
return (XPointer *) NULL;
}
return (XPointer *) wstr_list;
} else {
char **str_list;
str_list = (char **) Xmalloc(count * sizeof(char *));
if (str_list == NULL)
return (XPointer *) NULL;
*str_list = (char *) Xmalloc(nitems);
if (*str_list == NULL) {
Xfree(str_list);
return (XPointer *) NULL;
}
return (XPointer *) str_list;
}
}
static void
copy_list(is_wide_char, text, list, count)
Bool is_wide_char;
XPointer text;
XPointer *list;
int count;
{
int length;
if (is_wide_char) {
wchar_t *wc_text, *wstr, **wstr_list;
wc_text = (wchar_t *) text;
wstr_list = (wchar_t **) list;
for (wstr = *wstr_list; count > 0; count--, wstr_list++) {
_falwcscpy(wstr, wc_text);
*wstr_list = wstr;
length = _falwcslen(wstr) + 1;
wstr += length;
wc_text += length;
}
} else {
char *mb_text, *str, **str_list;
mb_text = (char *) text;
str_list = (char **) list;
for (str = *str_list; count > 0; count--, str_list++) {
strcpy(str, mb_text);
*str_list = str;
length = strlen(str) + 1;
str += length;
mb_text += length;
}
}
}
static int
_XTextPropertyToTextList(lcd, dpy, text_prop, to_type, list_ret, count_ret)
XLCd lcd;
Display *dpy;
XTextProperty *text_prop;
char *to_type;
XPointer **list_ret;
int *count_ret;
{
XlcConv conv;
char *from_type;
XPointer from, to, buf;
char *str_ptr, *last_ptr;
Atom encoding;
int from_left, to_left, buf_len, ret;
int unconv_num, nitems = text_prop->nitems;
Bool is_wide_char = False;
if (strcmp(XlcNWideChar, to_type) == 0)
is_wide_char = True;
if (nitems <= 0) {
*list_ret = NULL;
*count_ret = 0;
return Success;
}
if (text_prop->format != 8)
return XConverterNotFound;
encoding = text_prop->encoding;
if (encoding == XA_STRING)
from_type = XlcNString;
else if (encoding == falInternAtom(dpy, "COMPOUND_TEXT", False))
from_type = XlcNCompoundText;
else if (encoding == falInternAtom(dpy, XLC_PUBLIC(lcd, encoding_name), False))
from_type = XlcNMultiByte;
else
return XConverterNotFound;
if (is_wide_char) {
buf_len = text_prop->nitems + 1;
buf = (XPointer) Xmalloc(buf_len * sizeof(wchar_t));
} else {
buf_len = text_prop->nitems * XLC_PUBLIC(lcd, mb_cur_max) + 1;
buf = (XPointer) Xmalloc(buf_len);
}
if (buf == NULL)
return XNoMemory;
to = buf;
to_left = buf_len;
conv = _fallcOpenConverter(lcd, from_type, lcd, to_type);
if (conv == NULL) {
Xfree(buf);
return XConverterNotFound;
}
last_ptr = str_ptr = (char *) text_prop->value;
unconv_num = *count_ret = 0;
while (1) {
if (nitems == 0 || *str_ptr == 0) {
if (nitems)
str_ptr++;
from = (XPointer) last_ptr;
from_left = str_ptr - last_ptr;
last_ptr = str_ptr;
ret = _fallcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0);
if (ret < 0)
continue;
unconv_num += ret;
(*count_ret)++;
if (nitems == 0)
break;
_fallcResetConverter(conv);
} else
str_ptr++;
nitems--;
}
_fallcCloseConverter(conv);
if (is_wide_char)
*((wchar_t *) to) = (wchar_t) 0;
else
*((char *) to) = '\0';
to_left--;
*list_ret = alloc_list(is_wide_char, *count_ret, buf_len - to_left);
if (*list_ret)
copy_list(is_wide_char, buf, *list_ret, *count_ret);
Xfree(buf);
return unconv_num;
}
int
_falmbTextPropertyToTextList(lcd, dpy, text_prop, list_ret, count_ret)
XLCd lcd;
Display *dpy;
XTextProperty *text_prop;
char ***list_ret;
int *count_ret;
{
return _XTextPropertyToTextList(lcd, dpy, text_prop, XlcNMultiByte,
(XPointer **) list_ret, count_ret);
}
int
_falwcTextPropertyToTextList(lcd, dpy, text_prop, list_ret, count_ret)
XLCd lcd;
Display *dpy;
XTextProperty *text_prop;
wchar_t ***list_ret;
int *count_ret;
{
return _XTextPropertyToTextList(lcd, dpy, text_prop, XlcNWideChar,
(XPointer **) list_ret, count_ret);
}
void
_falwcFreeStringList(lcd, list)
XLCd lcd;
wchar_t **list;
{
if (list) {
if (*list)
Xfree(*list);
Xfree(list);
}
}

View file

@ -0,0 +1,277 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* XlcPubI.h 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:05 */
/* $XConsortium: _fallcPubI.h /main/1 1996/04/08 15:17:59 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
#ifndef _XLCPUBLICI_H_
#define _XLCPUBLICI_H_
#include "_fallcPublic.h"
#define XLC_PUBLIC(lcd, x) (((XLCdPublic) lcd->core)->pub.x)
#define XLC_PUBLIC_PART(lcd) (&(((XLCdPublic) lcd->core)->pub))
#define XLC_PUBLIC_METHODS(lcd) (&(((XLCdPublicMethods) lcd->methods)->pub))
/*
* XLCd public methods
*/
typedef struct _XLCdPublicMethodsRec *XLCdPublicMethods;
typedef XLCd (*XlcPubCreateProc)(
#if NeedFunctionPrototypes
char* /* name */,
XLCdMethods /* methods */
#endif
);
typedef Bool (*XlcPubInitializeProc)(
#if NeedFunctionPrototypes
XLCd /* lcd */
#endif
);
typedef void (*XlcPubDestroyProc)(
#if NeedFunctionPrototypes
XLCd /* lcd */
#endif
);
typedef char* (*XlcPubGetValuesProc)(
#if NeedFunctionPrototypes
XLCd /* lcd */,
XlcArgList /* args */,
int /* num_args */
#endif
);
typedef void (*XlcPubGetResourceProc)(
#if NeedFunctionPrototypes
XLCd /* lcd */,
char* /* category */,
char* /* class */,
char*** /* value */,
int* /* count */
#endif
);
typedef struct _XLCdPublicMethodsPart {
XLCdPublicMethods superclass;
XlcPubCreateProc create;
XlcPubInitializeProc initialize;
XlcPubDestroyProc destroy;
XlcPubGetValuesProc get_values;
XlcPubGetResourceProc get_resource;
} XLCdPublicMethodsPart;
typedef struct _XLCdPublicMethodsRec {
XLCdMethodsRec core;
XLCdPublicMethodsPart pub;
} XLCdPublicMethodsRec;
/*
* XLCd public data
*/
typedef struct _XLCdPublicPart {
char *siname; /* for _fallcMapOSLocaleName() */
char *language; /* language part of locale name */
char *territory; /* territory part of locale name */
char *codeset; /* codeset part of locale name */
char *encoding_name; /* encoding name */
int mb_cur_max; /* ANSI C MB_CUR_MAX */
Bool is_state_depend; /* state-depend encoding */
char *default_string; /* for falDefaultString() */
XPointer xlocale_db;
} XLCdPublicPart;
typedef struct _XLCdPublicRec {
XLCdCoreRec core;
XLCdPublicPart pub;
} XLCdPublicRec, *XLCdPublic;
extern XLCdMethods _fallcPublicMethods;
_XFUNCPROTOBEGIN
extern XLCd _fallcCreateLC(
#if NeedFunctionPrototypes
char* /* name */,
XLCdMethods /* methods */
#endif
);
extern void _fallcDestroyLC(
#if NeedFunctionPrototypes
XLCd /* lcd */
#endif
);
extern Bool _fallcParseCharSet(
#if NeedFunctionPrototypes
XlcCharSet /* charset */
#endif
);
extern XlcCharSet _fallcCreateDefaultCharSet(
#if NeedFunctionPrototypes
char* /* name */,
char* /* control_sequence */
#endif
);
extern XlcCharSet _fallcAddCT(
#if NeedFunctionPrototypes
char* /* name */,
char* /* control_sequence */
#endif
);
extern XrmMethods _falrmDefaultInitParseInfo(
#if NeedFunctionPrototypes
XLCd /* lcd */,
XPointer* /* state */
#endif
);
extern int _falmbTextPropertyToTextList(
#if NeedFunctionPrototypes
XLCd /* lcd */,
Display* /* dpy */,
XTextProperty* /* text_prop */,
char*** /* list_ret */,
int* /* count_ret */
#endif
);
extern int _falwcTextPropertyToTextList(
#if NeedFunctionPrototypes
XLCd /* lcd */,
Display* /* dpy */,
XTextProperty* /* text_prop */,
wchar_t*** /* list_ret */,
int* /* count_ret */
#endif
);
extern int _falmbTextListToTextProperty(
#if NeedFunctionPrototypes
XLCd /* lcd */,
Display* /* dpy */,
char** /* list */,
int /* count */,
XICCEncodingStyle /* style */,
XTextProperty* /* text_prop */
#endif
);
extern int _falwcTextListToTextProperty(
#if NeedFunctionPrototypes
XLCd /* lcd */,
Display* /* dpy */,
wchar_t** /* list */,
int /* count */,
XICCEncodingStyle /* style */,
XTextProperty* /* text_prop */
#endif
);
extern void _falwcFreeStringList(
#if NeedFunctionPrototypes
XLCd /* lcd */,
wchar_t** /* list */
#endif
);
extern int _fallcResolveLocaleName(
#if NeedFunctionPrototypes
char* /* lc_name */,
char* /* full_name */,
char* /* language */,
char* /* territory */,
char* /* codeset */
#endif
);
extern int _fallcResolveDBName(
#if NeedFunctionPrototypes
char* /* lc_name */,
char* /* file_name */
#endif
);
extern int _fallcResolveI18NPath(
#if NeedFunctionPrototypes
char* /* path_name */
#endif
);
extern XPointer _fallcCreateLocaleDataBase(
#if NeedFunctionPrototypes
XLCd /* lcd */
#endif
);
extern void _fallcDestroyLocaleDataBase(
#if NeedFunctionPrototypes
XLCd /* lcd */
#endif
);
extern void _fallcGetLocaleDataBase(
#if NeedFunctionPrototypes
XLCd /* lcd */,
char* /* category */,
char* /* name */,
char*** /* value */,
int* /* count */
#endif
);
_XFUNCPROTOEND
#endif /* _XLCPUBLICI_H_ */

View file

@ -0,0 +1,127 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcPubWrap.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:39 */
/* $XConsortium: _fallcPubWrap.c /main/1 1996/04/08 15:18:09 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
#include "_fallibint.h"
#include "_fallcPubI.h"
#if NeedVarargsPrototypes
char *
_falGetLCValues(XLCd lcd, ...)
#else
char *
_falGetLCValues(lcd, va_alist)
XLCd lcd;
va_dcl
#endif
{
va_list var;
XlcArgList args;
char *ret;
int num_args;
XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
Va_start(var, lcd);
_fallcCountVaList(var, &num_args);
va_end(var);
Va_start(var, lcd);
_fallcVaToArgList(var, num_args, &args);
va_end(var);
if (args == (XlcArgList) NULL)
return (char *) NULL;
ret = (*methods->get_values)(lcd, args, num_args);
Xfree(args);
return ret;
}
void
_fallcDestroyLC(lcd)
XLCd lcd;
{
XLCdPublicMethods methods = (XLCdPublicMethods) lcd->methods;
(*methods->pub.destroy)(lcd);
}
XLCd
_fallcCreateLC(name, methods)
char *name;
XLCdMethods methods;
{
XLCdPublicMethods pub_methods = (XLCdPublicMethods) methods;
XLCd lcd;
lcd = (*pub_methods->pub.create)(name, methods);
if (lcd == NULL)
return (XLCd) NULL;
if (lcd->core->name == NULL) {
lcd->core->name = (char*) Xmalloc(strlen(name) + 1);
if (lcd->core->name == NULL)
goto err;
strcpy(lcd->core->name, name);
}
if (lcd->methods == NULL)
lcd->methods = methods;
if ((*pub_methods->pub.initialize)(lcd) == False)
goto err;
return lcd;
err:
_fallcDestroyLC(lcd);
return (XLCd) NULL;
}

View file

@ -0,0 +1,325 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcPublic.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:39 */
/* $XConsortium: _fallcPublic.c /main/1 1996/04/08 15:18:20 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
#include <stdio.h>
#include "_fallibint.h"
#include "_fallcPubI.h"
static char *default_string();
static XLCd create();
static Bool initialize();
static void destroy();
static char *get_values();
static XLCdPublicMethodsRec publicMethods = {
{
destroy,
_fallcDefaultMapModifiers,
NULL,
NULL,
_falrmDefaultInitParseInfo,
_falmbTextPropertyToTextList,
_falwcTextPropertyToTextList,
_falmbTextListToTextProperty,
_falwcTextListToTextProperty,
_falwcFreeStringList,
default_string,
NULL,
NULL
},
{
NULL,
create,
initialize,
destroy,
get_values,
_fallcGetLocaleDataBase
}
};
XLCdMethods _fallcPublicMethods = (XLCdMethods) &publicMethods;
static char *
default_string(lcd)
XLCd lcd;
{
return XLC_PUBLIC(lcd, default_string);
}
static XLCd
create(name, methods)
char *name;
XLCdMethods methods;
{
XLCd lcd;
XLCdPublicMethods new;
lcd = (XLCd) Xmalloc(sizeof(XLCdRec));
if (lcd == NULL)
return (XLCd) NULL;
bzero((char *) lcd, sizeof(XLCdRec));
lcd->core = (XLCdCore) Xmalloc(sizeof(XLCdPublicRec));
if (lcd->core == NULL)
goto err;
bzero((char *) lcd->core, sizeof(XLCdPublicRec));
new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec));
if (new == NULL)
goto err;
*new = *((XLCdPublicMethods) methods);
lcd->methods = (XLCdMethods) new;
return lcd;
err:
Xfree(lcd);
return (XLCd) NULL;
}
static Bool
load_public(lcd)
XLCd lcd;
{
XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
char **values, *str;
int num;
if(_fallcCreateLocaleDataBase(lcd) == NULL)
return False;
_fallcGetResource(lcd, "XLC_XLOCALE", "mb_cur_max", &values, &num);
if (num > 0) {
pub->mb_cur_max = atoi(values[0]);
if (pub->mb_cur_max < 1)
pub->mb_cur_max = 1;
} else
pub->mb_cur_max = 1;
_fallcGetResource(lcd, "XLC_XLOCALE", "state_dependent", &values, &num);
if (num > 0 && !_fallcCompareISOLatin1(values[0], "True"))
pub->is_state_depend = True;
else
pub->is_state_depend = False;
_fallcGetResource(lcd, "XLC_XLOCALE", "encoding_name", &values, &num);
str = (num > 0) ? values[0] : "STRING";
pub->encoding_name = (char*) Xmalloc(strlen(str) + 1);
if (pub->encoding_name == NULL)
return False;
strcpy(pub->encoding_name, str);
return True;
}
static Bool
initialize_core(lcd)
XLCd lcd;
{
XLCdMethods methods = lcd->methods;
XLCdMethods core = &publicMethods.core;
if (methods->close == NULL)
methods->close = core->close;
if (methods->map_modifiers == NULL)
methods->map_modifiers = core->map_modifiers;
if (methods->open_om == NULL)
_falInitOM(lcd);
if (methods->init_parse_info == NULL)
methods->init_parse_info = core->init_parse_info;
if (methods->mb_text_prop_to_list == NULL)
methods->mb_text_prop_to_list = core->mb_text_prop_to_list;
if (methods->wc_text_prop_to_list == NULL)
methods->wc_text_prop_to_list = core->wc_text_prop_to_list;
if (methods->mb_text_list_to_prop == NULL)
methods->mb_text_list_to_prop = core->mb_text_list_to_prop;
if (methods->wc_text_list_to_prop == NULL)
methods->wc_text_list_to_prop = core->wc_text_list_to_prop;
if (methods->wc_free_string_list == NULL)
methods->wc_free_string_list = core->wc_free_string_list;
if (methods->default_string == NULL)
methods->default_string = core->default_string;
return True;
}
extern Bool _fallcInitCTInfo();
static Bool
initialize(lcd)
XLCd lcd;
{
XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
XLCdPublicMethodsPart *pub_methods = &publicMethods.pub;
XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
char lang[128], terr[128], code[128], *str;
char *name;
#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE)
char siname[256];
char *_fallcMapOSLocaleName();
#endif
_fallcInitCTInfo();
if (initialize_core(lcd) == False)
return False;
name = lcd->core->name;
#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE)
name = _fallcMapOSLocaleName(name, siname);
#endif
if (_fallcResolveLocaleName(name, NULL, lang, terr, code) == 0)
return False;
str = (char*) Xmalloc(strlen(name) + strlen(lang) + strlen(terr) +
strlen(code) + 4);
if (str == NULL)
return False;
strcpy(str, name);
pub->siname = str;
str += strlen(str) + 1;
strcpy(str, lang);
pub->language = str;
str += strlen(str) + 1;
strcpy(str, terr);
pub->territory = str;
str += strlen(str) + 1;
strcpy(str, code);
pub->codeset = str;
if (pub->default_string == NULL)
pub->default_string = "";
if (methods->get_values == NULL)
methods->get_values = pub_methods->get_values;
if (methods->get_resource == NULL)
methods->get_resource = pub_methods->get_resource;
return load_public(lcd);
}
static void
destroy_core(lcd)
XLCd lcd;
{
if (lcd->core) {
if (lcd->core->name)
Xfree(lcd->core->name);
Xfree(lcd->core);
}
if (lcd->methods)
Xfree(lcd->methods);
Xfree(lcd);
}
static void
destroy(lcd)
XLCd lcd;
{
XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
_fallcDestroyLocaleDataBase(lcd);
if (pub->siname)
Xfree(pub->siname);
if (pub->encoding_name)
Xfree(pub->encoding_name);
destroy_core(lcd);
}
static XlcResource resources[] = {
{ XlcNCodeset, NULLQUARK, sizeof(char *),
XOffsetOf(XLCdPublicRec, pub.codeset), XlcGetMask },
{ XlcNDefaultString, NULLQUARK, sizeof(char *),
XOffsetOf(XLCdPublicRec, pub.default_string), XlcGetMask },
{ XlcNEncodingName, NULLQUARK, sizeof(char *),
XOffsetOf(XLCdPublicRec, pub.encoding_name), XlcGetMask },
{ XlcNLanguage, NULLQUARK, sizeof(char *),
XOffsetOf(XLCdPublicRec, pub.language), XlcGetMask },
{ XlcNMbCurMax, NULLQUARK, sizeof(int),
XOffsetOf(XLCdPublicRec, pub.mb_cur_max), XlcGetMask },
{ XlcNStateDependentEncoding, NULLQUARK, sizeof(Bool),
XOffsetOf(XLCdPublicRec, pub.is_state_depend), XlcGetMask },
{ XlcNTerritory, NULLQUARK, sizeof(char *),
XOffsetOf(XLCdPublicRec, pub.territory), XlcGetMask }
};
static char *
get_values(lcd, args, num_args)
register XLCd lcd;
register XlcArgList args;
register int num_args;
{
XLCdPublic pub = (XLCdPublic) lcd->core;
if (resources[0].xrm_name == NULLQUARK)
_fallcCompileResourceList(resources, XlcNumber(resources));
return _fallcGetValues((XPointer) pub, resources, XlcNumber(resources), args,
num_args, XlcGetMask);
}

View file

@ -0,0 +1,311 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* XlcPublic.h 1.3 - Fujitsu source for CDEnext 95/12/07 10:53:08 */
/* $XConsortium: _fallcPublic.h /main/1 1996/04/08 15:18:31 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
/*
* Copyright 1995 by FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietry source code of FUJITSU LIMITED
*
* Modifier: Takanori Tateno FUJITSU LIMITED
*
*/
#ifndef _XLCPUBLIC_H_
#define _XLCPUBLIC_H_
#include "_fallcint.h"
#define XlcNCharSize "charSize"
#define XlcNCodeset "codeset"
#define XlcNControlSequence "controlSequence"
#define XlcNDefaultString "defaultString"
#define XlcNEncodingName "encodingName"
#define XlcNLanguage "language"
#define XlcNMbCurMax "mbCurMax"
#define XlcNName "name"
#define XlcNSetSize "setSize"
#define XlcNSide "side"
#define XlcNStateDependentEncoding "stateDependentEncoding"
#define XlcNTerritory "territory"
typedef enum {
XlcUnknown, XlcC0, XlcGL, XlcC1, XlcGR, XlcGLGR, XlcOther, XlcNONE
} XlcSide;
typedef struct _FonScope {
unsigned long start;
unsigned long end;
unsigned long shift;
unsigned long shift_direction;
} FontScopeRec, *FontScope;
typedef struct _UDCArea {
unsigned long start,end;
} UDCAreaRec, *UDCArea;
typedef struct _XlcCharSetRec *XlcCharSet;
typedef char* (*XlcGetCSValuesProc)(
#if NeedFunctionPrototypes
XlcCharSet /* charset */,
XlcArgList /* args */,
int /* num_args */
#endif
);
typedef struct _XlcCharSetRec {
char *name; /* character set name */
XrmQuark xrm_name;
char *encoding_name; /* XLFD encoding name */
XrmQuark xrm_encoding_name;
XlcSide side; /* GL, GR or others */
int char_size; /* number of bytes per character */
int set_size; /* graphic character sets */
char *ct_sequence; /* control sequence of CT */
XlcGetCSValuesProc get_values;
/* UDC */
Bool string_encoding;
UDCArea udc_area;
int udc_area_num;
} XlcCharSetRec;
/*
* conversion methods
*/
typedef struct _XlcConvRec *XlcConv;
typedef XlcConv (*XlcOpenConverterProc)(
#if NeedFunctionPrototypes
XLCd /* from_lcd */,
char* /* from_type */,
XLCd /* to_lcd */,
char* /* to_type */
#endif
);
typedef void (*XlcCloseConverterProc)(
#if NeedFunctionPrototypes
XlcConv /* conv */
#endif
);
typedef int (*XlcConvertProc)(
#if NeedFunctionPrototypes
XlcConv /* conv */,
XPointer* /* from */,
int* /* from_left */,
XPointer* /* to */,
int* /* to_left */,
XPointer* /* args */,
int /* num_args */
#endif
);
typedef void (*XlcResetConverterProc)(
#if NeedFunctionPrototypes
XlcConv /* conv */
#endif
);
typedef struct _XlcConvMethodsRec{
XlcCloseConverterProc close;
XlcConvertProc convert;
XlcResetConverterProc reset;
} XlcConvMethodsRec, *XlcConvMethods;
/*
* conversion data
*/
#define XlcNMultiByte "multiByte"
#define XlcNWideChar "wideChar"
#define XlcNCompoundText "compoundText"
#define XlcNString "string"
#define XlcNCharSet "charSet"
#define XlcNCTCharSet "CTcharSet"
#define XlcNChar "char"
typedef struct _XlcConvRec {
XlcConvMethods methods;
XPointer state;
} XlcConvRec;
_XFUNCPROTOBEGIN
extern Bool _falInitOM(
#if NeedFunctionPrototypes
XLCd /* lcd */
#endif
);
extern Bool _XInitIM(
#if NeedFunctionPrototypes
XLCd /* lcd */
#endif
);
extern char *_falGetLCValues(
#if NeedVarargsPrototypes
XLCd /* lcd */,
...
#endif
);
extern XlcCharSet _fallcGetCharSet(
#if NeedFunctionPrototypes
char* /* name */
#endif
);
extern Bool _fallcAddCharSet(
#if NeedFunctionPrototypes
XlcCharSet /* charset */
#endif
);
extern char *_fallcGetCSValues(
#if NeedVarargsPrototypes
XlcCharSet /* charset */,
...
#endif
);
extern XlcConv _fallcOpenConverter(
#if NeedFunctionPrototypes
XLCd /* from_lcd */,
char* /* from_type */,
XLCd /* to_lcd */,
char* /* to_type */
#endif
);
extern void _fallcCloseConverter(
#if NeedFunctionPrototypes
XlcConv /* conv */
#endif
);
extern int _fallcConvert(
#if NeedFunctionPrototypes
XlcConv /* conv */,
XPointer* /* from */,
int* /* from_left */,
XPointer* /* to */,
int* /* to_left */,
XPointer* /* args */,
int /* num_args */
#endif
);
extern void _fallcResetConverter(
#if NeedFunctionPrototypes
XlcConv /* conv */
#endif
);
extern Bool _fallcSetConverter(
#if NeedFunctionPrototypes
XLCd /* from_lcd */,
char* /* from_type */,
XLCd /* to_lcd */,
char* /* to_type */,
XlcOpenConverterProc /* open_converter */
#endif
);
extern void _fallcGetResource(
#if NeedFunctionPrototypes
XLCd /* lcd */,
char* /* category */,
char* /* class */,
char*** /* value */,
int* /* count */
#endif
);
extern char *_fallcFileName(
#if NeedFunctionPrototypes
XLCd /* lcd */,
char* /* category */
#endif
);
extern int _falwcslen(
#if NeedFunctionPrototypes
wchar_t* /* wstr */
#endif
);
extern wchar_t *_falwcscpy(
#if NeedFunctionPrototypes
wchar_t* /* wstr1 */,
wchar_t* /* wstr2 */
#endif
);
extern int _fallcCompareISOLatin1(
#if NeedFunctionPrototypes
char* /* str1 */,
char* /* str2 */
#endif
);
extern int _fallcNCompareISOLatin1(
#if NeedFunctionPrototypes
char* /* str1 */,
char* /* str2 */,
int /* len */
#endif
);
_XFUNCPROTOEND
#endif /* _XLCPUBLIC_H_ */

View file

@ -0,0 +1,145 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcRM.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:40 */
/* $XConsortium: _fallcRM.c /main/1 1996/04/08 15:18:41 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
#include "_fallibint.h"
#include "_fallcPubI.h"
#include <stdio.h>
typedef struct _StateRec {
XLCd lcd;
XlcConv conv;
} StateRec, *State;
static void
mbinit(state)
XPointer state;
{
_fallcResetConverter(((State) state)->conv);
}
static char
mbchar(state, str, lenp)
XPointer state;
char *str;
int *lenp;
{
XlcConv conv = ((State) state)->conv;
XlcCharSet charset;
char *from, *to, buf[BUFSIZ];
int from_left, to_left;
XPointer args[1];
from = str;
*lenp = from_left = XLC_PUBLIC(((State) state)->lcd, mb_cur_max);
to = buf;
to_left = BUFSIZ;
args[0] = (XPointer) &charset;
_fallcConvert(conv, (XPointer *) &from, &from_left, (XPointer *) &to,
&to_left, args, 1);
*lenp -= from_left;
/* XXX */
return buf[0];
}
static void
mbfinish(state)
XPointer state;
{
}
static char *
lcname(state)
XPointer state;
{
return ((State) state)->lcd->core->name;
}
static void
destroy(state)
XPointer state;
{
_fallcCloseConverter(((State) state)->conv);
_falCloseLC(((State) state)->lcd);
Xfree((char *) state);
}
static XrmMethodsRec rm_methods = {
mbinit,
mbchar,
mbfinish,
lcname,
destroy
} ;
XrmMethods
_falrmDefaultInitParseInfo(lcd, rm_state)
XLCd lcd;
XPointer *rm_state;
{
State state;
state = (State) Xmalloc(sizeof(StateRec));
if (state == NULL)
return (XrmMethods) NULL;
state->lcd = lcd;
state->conv = _fallcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNChar);
if (state->conv == NULL) {
Xfree((char *) state);
return (XrmMethods) NULL;
}
*rm_state = (XPointer) state;
return &rm_methods;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,328 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcStd.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:41 */
/* $XConsortium: _fallcStd.c /main/1 1996/04/08 15:19:02 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
#include "_fallibint.h"
#include "_fallcPubI.h"
int
_fallcmbtowc(lcd, wstr, str, len)
XLCd lcd;
wchar_t *wstr;
char *str;
int len;
{
static XLCd last_lcd = NULL;
static XlcConv conv = NULL;
XPointer from, to;
int from_left, to_left;
wchar_t tmp_wc;
if (lcd == NULL) {
lcd = _fallcCurrentLC();
if (lcd == NULL)
return -1;
}
if (str == NULL)
return XLC_PUBLIC(lcd, is_state_depend);
if (conv && lcd != last_lcd) {
_fallcCloseConverter(conv);
conv = NULL;
}
last_lcd = lcd;
if (conv == NULL) {
conv = _fallcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar);
if (conv == NULL)
return -1;
}
from = (XPointer) str;
from_left = len;
to = (XPointer) (wstr ? wstr : &tmp_wc);
to_left = 1;
if (_fallcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
return -1;
return (len - from_left);
}
int
_fallcwctomb(lcd, str, wc)
XLCd lcd;
char *str;
wchar_t wc;
{
static XLCd last_lcd = NULL;
static XlcConv conv = NULL;
XPointer from, to;
int from_left, to_left, length;
if (lcd == NULL) {
lcd = _fallcCurrentLC();
if (lcd == NULL)
return -1;
}
if (str == NULL)
return XLC_PUBLIC(lcd, is_state_depend);
if (conv && lcd != last_lcd) {
_fallcCloseConverter(conv);
conv = NULL;
}
last_lcd = lcd;
if (conv == NULL) {
conv = _fallcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
if (conv == NULL)
return -1;
}
from = (XPointer) &wc;
from_left = 1;
to = (XPointer) str;
length = to_left = XLC_PUBLIC(lcd, mb_cur_max);
if (_fallcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
return -1;
return (length - to_left);
}
int
_fallcmbstowcs(lcd, wstr, str, len)
XLCd lcd;
wchar_t *wstr;
char *str;
int len;
{
XlcConv conv;
XPointer from, to;
int from_left, to_left, ret;
if (lcd == NULL) {
lcd = _fallcCurrentLC();
if (lcd == NULL)
return -1;
}
conv = _fallcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar);
if (conv == NULL)
return -1;
from = (XPointer) str;
from_left = strlen(str);
to = (XPointer) wstr;
to_left = len;
if (_fallcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
ret = -1;
else {
ret = len - to_left;
if (wstr && to_left > 0)
wstr[ret] = (wchar_t) 0;
}
_fallcCloseConverter(conv);
return ret;
}
int
_fallcwcstombs(lcd, str, wstr, len)
XLCd lcd;
char *str;
wchar_t *wstr;
int len;
{
XlcConv conv;
XPointer from, to;
int from_left, to_left, ret;
if (lcd == NULL) {
lcd = _fallcCurrentLC();
if (lcd == NULL)
return -1;
}
conv = _fallcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
if (conv == NULL)
return -1;
from = (XPointer) wstr;
from_left = _falwcslen(wstr);
to = (XPointer) str;
to_left = len;
if (_fallcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
ret = -1;
else {
ret = len - to_left;
if (str && to_left > 0)
str[ret] = '\0';
}
_fallcCloseConverter(conv);
return ret;
}
int
_falmbtowc(wstr, str, len)
wchar_t *wstr;
char *str;
int len;
{
return _fallcmbtowc((XLCd) NULL, wstr, str, len);
}
int
_falmblen(str, len)
char *str;
int len;
{
return _falmbtowc((wchar_t *) NULL, str, len);
}
int
_falwctomb(str, wc)
char *str;
wchar_t wc;
{
return _fallcwctomb((XLCd) NULL, str, wc);
}
int
_falmbstowcs(wstr, str, len)
wchar_t *wstr;
char *str;
int len;
{
return _fallcmbstowcs((XLCd) NULL, wstr, str, len);
}
int
_falwcstombs(str, wstr, len)
char *str;
wchar_t *wstr;
int len;
{
return _fallcwcstombs((XLCd) NULL, str, wstr, len);
}
wchar_t *
_falwcscpy(wstr1, wstr2)
register wchar_t *wstr1, *wstr2;
{
wchar_t *wstr_tmp = wstr1;
while (*wstr1++ = *wstr2++)
;
return wstr_tmp;
}
wchar_t *
_falwcsncpy(wstr1, wstr2, len)
register wchar_t *wstr1, *wstr2;
register len;
{
wchar_t *wstr_tmp = wstr1;
while (len-- > 0)
if (!(*wstr1++ = *wstr2++))
break;
while (len-- > 0)
*wstr1++ = (wchar_t) 0;
return wstr_tmp;
}
int
_falwcslen(wstr)
register wchar_t *wstr;
{
register wchar_t *wstr_ptr = wstr;
while (*wstr_ptr)
wstr_ptr++;
return wstr_ptr - wstr;
}
int
_falwcscmp(wstr1, wstr2)
register wchar_t *wstr1, *wstr2;
{
for ( ; *wstr1 && *wstr2; wstr1++, wstr2++)
if (*wstr1 != *wstr2)
break;
return *wstr1 - *wstr2;
}
int
_falwcsncmp(wstr1, wstr2, len)
register wchar_t *wstr1, *wstr2;
register len;
{
for ( ; *wstr1 && *wstr2 && len > 0; wstr1++, wstr2++, len--)
if (*wstr1 != *wstr2)
break;
if (len <= 0)
return 0;
return *wstr1 - *wstr2;
}

View file

@ -0,0 +1,255 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcTxtPr.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:41 */
/* $XConsortium: _fallcTxtPr.c /main/1 1996/04/08 15:19:12 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
#include "_fallibint.h"
#include "_fallcPubI.h"
#include "_falutil.h"
#include <X11/Xatom.h>
#include <stdio.h>
static int
get_buf_size(is_wide_char, list, count)
Bool is_wide_char;
XPointer list;
int count;
{
register length = 0;
register char **mb_list;
register wchar_t **wc_list;
if (list == NULL)
return 0;
if (is_wide_char) {
wc_list = (wchar_t **) list;
for ( ; count-- > 0; wc_list++) {
if (*wc_list)
length += _falwcslen(*wc_list) + 1;
}
length *= 5; /* XXX */
} else {
mb_list = (char **) list;
for ( ; count-- > 0; mb_list++) {
if (*mb_list)
length += strlen(*mb_list) + 1;
}
length *= 3; /* XXX */
}
length = (length / BUFSIZ + 1) * BUFSIZ; /* XXX */
return length;
}
static int
_XTextListToTextProperty(lcd, dpy, from_type, list, count, style, text_prop)
XLCd lcd;
Display *dpy;
char *from_type;
XPointer list;
int count;
XICCEncodingStyle style;
XTextProperty *text_prop;
{
Atom encoding;
XlcConv conv;
char *to_type;
char **mb_list;
wchar_t **wc_list;
XPointer from;
char *to, *buf, *value;
int from_left, to_left, buf_len, nitems, unconv_num, ret, i;
Bool is_wide_char = False;
if (strcmp(XlcNWideChar, from_type) == 0)
is_wide_char = True;
buf_len = get_buf_size(is_wide_char, list, count);
if ((buf = (char *) Xmalloc(buf_len)) == NULL)
return XNoMemory;
switch (style) {
case XStringStyle:
case XStdICCTextStyle:
encoding = XA_STRING;
to_type = XlcNString;
break;
case XCompoundTextStyle:
encoding = falInternAtom(dpy, "COMPOUND_TEXT", False);
to_type = XlcNCompoundText;
break;
case XTextStyle:
encoding = falInternAtom(dpy, XLC_PUBLIC(lcd, encoding_name), False);
to_type = XlcNMultiByte;
if (is_wide_char == False) {
nitems = 0;
mb_list = (char **) list;
to = buf;
for (i = 0; i < count; i++) {
strcpy(to, *mb_list);
from_left = strlen(*mb_list) + 1;
nitems += from_left;
to += from_left;
mb_list++;
}
unconv_num = 0;
goto done;
}
break;
default:
Xfree(buf);
return XConverterNotFound;
}
if (count < 1) {
nitems = 0;
goto done;
}
retry:
conv = _fallcOpenConverter(lcd, from_type, lcd, to_type);
if (conv == NULL) {
Xfree(buf);
return XConverterNotFound;
}
if (is_wide_char)
wc_list = (wchar_t **) list;
else
mb_list = (char **) list;
to = buf;
to_left = buf_len;
unconv_num = 0;
for (i = 1; to_left > 0; i++) {
if (is_wide_char) {
from = (XPointer) *wc_list;
from_left = _falwcslen(*wc_list);
wc_list++;
} else {
from = (XPointer) *mb_list;
from_left = strlen(*mb_list);
mb_list++;
}
ret = _fallcConvert(conv, &from, &from_left, (XPointer *) &to, &to_left,
NULL, 0);
if (ret < 0)
continue;
if (ret > 0 && style == XStdICCTextStyle && encoding == XA_STRING) {
_fallcCloseConverter(conv);
encoding = falInternAtom(dpy, "COMPOUND_TEXT", False);
to_type = XlcNCompoundText;
goto retry;
}
unconv_num += ret;
*to++ = '\0';
to_left--;
if (i >= count)
break;
_fallcResetConverter(conv);
}
_fallcCloseConverter(conv);
nitems = to - buf;
done:
if (nitems <= 0)
nitems = 1;
value = (char *) Xmalloc(nitems);
if (value == NULL) {
Xfree(buf);
return XNoMemory;
}
if (nitems == 1)
*value = 0;
else
memcpy(value, buf, nitems);
nitems--;
Xfree(buf);
text_prop->value = (unsigned char *) value;
text_prop->encoding = encoding;
text_prop->format = 8;
text_prop->nitems = nitems;
return unconv_num;
}
int
_falmbTextListToTextProperty(lcd, dpy, list, count, style, text_prop)
XLCd lcd;
Display *dpy;
char **list;
int count;
XICCEncodingStyle style;
XTextProperty *text_prop;
{
return _XTextListToTextProperty(lcd, dpy, XlcNMultiByte, (XPointer) list,
count, style, text_prop);
}
int
_falwcTextListToTextProperty(lcd, dpy, list, count, style, text_prop)
XLCd lcd;
Display *dpy;
wchar_t **list;
int count;
XICCEncodingStyle style;
XTextProperty *text_prop;
{
return _XTextListToTextProperty(lcd, dpy, XlcNWideChar, (XPointer) list,
count, style, text_prop);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,195 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* XlcUTF.h 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:06 */
/* $XConsortium: _fallcUTF.h /main/1 1996/04/08 15:19:33 cde-fuj $ */
/******************************************************************
Copyright 1993 by SunSoft, Inc.
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear
in supporting documentation, and that the name of SunSoft, Inc.
not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.
SunSoft, Inc. makes no representations about the suitability of
this software for any purpose. It is provided "as is" without
express or implied warranty.
SunSoft Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
IN NO EVENT SHALL SunSoft, Inc. BE LIABLE FOR ANY SPECIAL, INDIRECT
OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
OR PERFORMANCE OF THIS SOFTWARE.
Author: Hiromu Inukai (inukai@Japan.Sun.COM) SunSoft, inc.
******************************************************************/
#include "_fallibint.h"
#include "_fallcGeneric.h"
#include <X11/Xos.h>
#include <stdio.h>
typedef unsigned short Rune; /* 16 bits */
#define Runeerror 0x80 /* decoding error in UTF */
#define Runeself 0x80 /* rune and UTF sequences are the same (<) */
#define UTFmax 3 /* maximum bytes per rune */
#define BADMAP (0xFFFD)
#define ESC 033
#define NRUNE 65536
#define NLATIN 0x6ff
#define LATINMAX 256
#define KUTENMAX 8407
#define KSCMAX 8743
#define GBMAX 8795
#define tab8859_1 "tab8859_1"
#define tab8859_2 "tab8859_2"
#define tab8859_3 "tab8859_3"
#define tab8859_4 "tab8859_4"
#define tab8859_5 "tab8859_5"
#define tab8859_6 "tab8859_6"
#define tab8859_7 "tab8859_7"
#define tab8859_8 "tab8859_8"
#define tab8859_9 "tab8859_9"
#define jis0208 "jis0208"
#define ksc5601 "ksc5601"
#define gb2312 "gb2312"
#define emit(x) *r = (Rune)x;
typedef enum {
N11n_none, /* No need to normalize (1byte) */
N11n_ja, /* Normalize for ja */
N11n_ko, /* Normalize for ko */
N11n_zh /* Normalize for zh */
} NormalizeType;
typedef struct _UtfDataRec {
XlcCharSet charset;
void (*initialize)( /* Table Initializer */
#if NeedNestedPrototypes
long *tbl,
long fallback
#endif
);
long *fromtbl; /* UTF -> CharSet */
NormalizeType type; /* Normalize type */
void (*cstorune)( /* CharSet -> UTF */
#if NeedNestedPrototypes
unsigned char c,
Rune *r
#endif
);
Bool already_init;
struct _UtfDataRec *next; /* next entry */
} UtfDataRec, *UtfData;
typedef struct _XlcUTFDataRec {
char *name;
XlcSide side;
void (*initialize)();
void (*cstorune)(
#if NeedNestedPrototypes
unsigned char c,
Rune *r
#endif
);
NormalizeType type;
long fallback_value;
} XlcUTFDataRec, *XlcUTFData;
typedef struct _StateRec {
XlcCharSet charset;
XlcCharSet GL_charset;
XlcCharSet GR_charset;
} StateRec, *State;
#define MAX_UTF_CHARSET (sizeof(default_utf_data)/sizeof(XlcUTFDataRec))
#define Char1 Runeself
#define Rune1 Runeself
#define Char21 0xA1
#define Rune21 0x0100
#define Char22 0xF6
#define Rune22 0x4016
#define Char3 0xFC
#define Rune3 0x10000 /* really 0x38E2E */
#define Esc 0xBE
#define Bad Runeerror
#define T1 0x00
#define Tx 0x80
#define T2 0xC0
#define T3 0xE0
#define T4 0xF0
#define T5 0xF8
#define T6 0xFC
#define Bit1 7
#define Bitx 6
#define Bit2 5
#define Bit3 4
#define Bit4 3
#define Bit5 2
#define Bit6 2
#define Mask1 (1<<Bit1)-1
#define Maskx (1<<Bitx)-1
#define Mask2 (1<<Bit2)-1
#define Mask3 (1<<Bit3)-1
#define Mask4 (1<<Bit4)-1
#define Mask5 (1<<Bit5)-1
#define Mask6 (1<<Bit6)-1
#define Wchar1 (1<<Bit1)-1
#define Wchar2 (1<<(Bit2+Bitx))-1
#define Wchar3 (1<<(Bit3+2*Bitx))-1
#define Wchar4 (1<<(Bit4+3*Bitx))-1
#define Wchar5 (1<<(Bit5+4*Bitx))-1
#ifndef EILSEQ
#define EILSEQ 123
#endif
#define J2S(_h, _l) { \
/* lower: 21-7e >> 40-9d,9e-fb >> 40-7e,(skip 7f),80-fc */ \
if (((_l) += (((_h)-- % 2) ? 0x1f : 0x7d)) > 0x7e) (_l)++; \
/* upper: 21-7e >> 81-af >> 81-9f,(skip a0-df),e0-ef */ \
if (((_h) = ((_h) / 2 + 0x71)) > 0x9f) (_h) += 0x40; \
}
#define S2J(_h, _l) { \
/* lower: 40-7e,80-fc >> 21-5f,61-dd >> 21-7e,7f-dc */ \
if (((_l) -= 0x1f) > 0x60) (_l)--; \
/* upper: 81-9f,e0-ef >> 00-1e,5f-6e >> 00-2e >> 21-7d */ \
if (((_h) -= 0x81) > 0x5e) (_h) -= 0x40; (_h) *= 2, (_h) += 0x21; \
/* upper: ,21-7d >> ,22-7e ; lower: ,7f-dc >> ,21-7e */ \
if ((_l) > 0x7e) (_h)++, (_l) -= 0x5e; \
}
#define ISJKANA(_b) (0xa0 <= (_b) && (_b) < 0xe0)
#define CANS2JH(_h) ((0x81 <= (_h) && (_h) < 0xf0) && !ISJKANA(_h))
#define CANS2JL(_l) (0x40 <= (_l) && (_l) < 0xfd && (_l) != 0x7f)
#define CANS2J(_h, _l) (CANS2JH(_h) && CANS2JL(_l))

View file

@ -0,0 +1,101 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcUtil.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:42 */
/* $XConsortium: _fallcUtil.c /main/1 1996/04/08 15:19:43 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
#include <stdio.h>
#include <ctype.h>
#include <X11/Xos.h>
#include "_fallibint.h"
#ifdef X_NOT_STDC_ENV
#ifndef toupper
#define toupper(c) ((int)(c) - 'a' + 'A')
#endif
#endif
int
_fallcCompareISOLatin1(str1, str2)
char *str1, *str2;
{
register char ch1, ch2;
for ( ; (ch1 = *str1) && (ch2 = *str2); str1++, str2++) {
if (islower(ch1))
ch1 = toupper(ch1);
if (islower(ch2))
ch2 = toupper(ch2);
if (ch1 != ch2)
break;
}
return *str1 - *str2;
}
int
_fallcNCompareISOLatin1(str1, str2, len)
char *str1, *str2;
int len;
{
register char ch1, ch2;
for ( ; (ch1 = *str1) && (ch2 = *str2) && len; str1++, str2++, len--) {
if (islower(ch1))
ch1 = toupper(ch1);
if (islower(ch2))
ch2 = toupper(ch2);
if (ch1 != ch2)
break;
}
if (len == 0)
return 0;
return *str1 - *str2;
}

View file

@ -0,0 +1,637 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* lcWrap.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:42 */
/* $XConsortium: _fallcWrap.c /main/1 1996/04/08 15:19:54 cde-fuj $ */
/*
Copyright (c) 1991 X Consortium
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from the X Consortium.
*/
/*
* Copyright 1991 by the Open Software Foundation
* Copyright 1993 by the TOSHIBA Corp.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of Open Software Foundation and TOSHIBA
* not be used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. Open Software
* Foundation and TOSHIBA make no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* OPEN SOFTWARE FOUNDATION AND TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN OR TOSHIBA BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* M. Collins OSF
*
* Katsuhisa Yano TOSHIBA Corp.
*/
#include <stdint.h>
#include "_fallibint.h"
#include "_fallcint.h"
#if defined(__linux__)
#include <locale.h>
#else
#include <X11/Xlocale.h>
#endif
#include <X11/Xos.h>
#ifdef WIN32
#undef close
#endif
#include "_falutil.h"
#ifdef __STDC__
#define Const const
#else
#define Const /**/
#endif
#ifdef X_NOT_STDC_ENV
extern char *getenv();
#endif
extern void _fallcInitLoader(
#if NeedFunctionPrototypes
void
#endif
);
#ifdef XTHREADS
LockInfoPtr _Xi18n_lock;
#endif
#if NeedFunctionPrototypes
char *
falSetLocaleModifiers(
_Xconst char *modifiers
)
#else
char *
falSetLocaleModifiers(modifiers)
char *modifiers;
#endif
{
XLCd lcd = _fallcCurrentLC();
char *user_mods;
if (!lcd)
return (char *) NULL;
if (!modifiers)
return lcd->core->modifiers;
user_mods = getenv("XMODIFIERS");
modifiers = (*lcd->methods->map_modifiers) (lcd,
user_mods, (char *)modifiers);
if (modifiers) {
if (lcd->core->modifiers)
Xfree(lcd->core->modifiers);
lcd->core->modifiers = (char *)modifiers;
}
return (char *)modifiers;
}
Bool
falSupportsLocale()
{
return _fallcCurrentLC() != (XLCd)NULL;
}
Bool _fallcValidModSyntax(mods, valid_mods)
char *mods;
char **valid_mods;
{
int i;
char **ptr;
while (mods && (*mods == '@')) {
mods++;
if (*mods == '@')
break;
for (ptr = valid_mods; *ptr; ptr++) {
i = strlen(*ptr);
if (strncmp(mods, *ptr, i) || ((mods[i] != '=')
#ifdef WIN32
&& (mods[i] != '#')
#endif
))
continue;
mods = strchr(mods+i+1, '@');
break;
}
}
return !mods || !*mods;
}
static Const char *im_valid[] = {"im", (char *)NULL};
/*ARGSUSED*/
char *
_fallcDefaultMapModifiers (lcd, user_mods, prog_mods)
XLCd lcd;
char *user_mods;
char *prog_mods;
{
int i;
char *mods;
if (!_fallcValidModSyntax(prog_mods, (char **)im_valid))
return (char *)NULL;
if (!_fallcValidModSyntax(user_mods, (char **)im_valid))
return (char *)NULL;
i = strlen(prog_mods) + 1;
if (user_mods)
i += strlen(user_mods);
mods = Xmalloc(i);
if (mods) {
strcpy(mods, prog_mods);
if (user_mods)
strcat(mods, user_mods);
#ifdef WIN32
{
char *s;
for (s = mods; s = strchr(s, '@'); s++) {
for (s++; *s && *s != '='; s++) {
if (*s == '#') {
*s = '=';
break;
}
}
}
}
#endif
}
return mods;
}
typedef struct _XLCdListRec {
struct _XLCdListRec *next;
XLCd lcd;
int ref_count;
} XLCdListRec, *XLCdList;
static XLCdList lcd_list = NULL;
typedef struct _XlcLoaderListRec {
struct _XlcLoaderListRec *next;
XLCdLoadProc proc;
} XlcLoaderListRec, *XlcLoaderList;
static XlcLoaderList loader_list = NULL;
void
_fallcRemoveLoader(proc)
XLCdLoadProc proc;
{
XlcLoaderList loader, prev;
if (loader_list == NULL)
return;
prev = loader = loader_list;
if (loader->proc == proc) {
loader_list = loader->next;
Xfree(loader);
return;
}
while (loader = loader->next) {
if (loader->proc == proc) {
prev->next = loader->next;
Xfree(loader);
return;
}
prev = loader;
}
return;
}
Bool
_fallcAddLoader(proc, position)
XLCdLoadProc proc;
XlcPosition position;
{
XlcLoaderList loader, last;
_fallcRemoveLoader(proc); /* remove old loader, if exist */
loader = (XlcLoaderList) Xmalloc(sizeof(XlcLoaderListRec));
if (loader == NULL)
return False;
loader->proc = proc;
if (loader_list == NULL)
position = XlcHead;
if (position == XlcHead) {
loader->next = loader_list;
loader_list = loader;
} else {
last = loader_list;
while (last->next)
last = last->next;
loader->next = NULL;
last->next = loader;
}
return True;
}
XLCd
_falOpenLC(name)
char *name;
{
XLCd lcd;
XlcLoaderList loader;
XLCdList cur;
#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE)
char siname[256];
char *_fallcMapOSLocaleName();
#endif
if (name == NULL) {
name = setlocale (LC_CTYPE, (char *)NULL);
#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE)
name = _fallcMapOSLocaleName (name, siname);
#endif
}
_XLockMutex(_Xi18n_lock);
/*
* search for needed lcd, if found return it
*/
for (cur = lcd_list; cur; cur = cur->next) {
if (!strcmp (cur->lcd->core->name, name)) {
lcd = cur->lcd;
cur->ref_count++;
goto found;
}
}
if (!loader_list)
_fallcInitLoader();
/*
* not there, so try to get and add to list
*/
for (loader = loader_list; loader; loader = loader->next) {
lcd = (*loader->proc)(name);
if (lcd) {
cur = (XLCdList) Xmalloc (sizeof(XLCdListRec));
if (cur) {
cur->lcd = lcd;
cur->ref_count = 1;
cur->next = lcd_list;
lcd_list = cur;
} else {
(*lcd->methods->close)(lcd);
lcd = (XLCd) NULL;
}
break;
}
}
found:
_XUnlockMutex(_Xi18n_lock);
return lcd;
}
void
_falCloseLC(lcd)
XLCd lcd;
{
XLCdList cur, *prev;
for (prev = &lcd_list; cur = *prev; prev = &cur->next) {
if (cur->lcd == lcd) {
if (--cur->ref_count < 1) {
(*lcd->methods->close)(lcd);
*prev = cur->next;
Xfree(cur);
}
break;
}
}
}
/*
* Get the XLCd for the current locale
*/
XLCd
_fallcCurrentLC()
{
XLCd lcd;
static XLCd last_lcd = NULL;
lcd = _falOpenLC((char *) NULL);
if (last_lcd)
_falCloseLC(last_lcd);
last_lcd = lcd;
return lcd;
}
XrmMethods
_falrmInitParseInfo(state)
XPointer *state;
{
XLCd lcd = _falOpenLC((char *) NULL);
if (lcd == (XLCd) NULL)
return (XrmMethods) NULL;
return (*lcd->methods->init_parse_info)(lcd, state);
}
int
falmbTextPropertyToTextList(dpy, text_prop, list_ret, count_ret)
Display *dpy;
XTextProperty *text_prop;
char ***list_ret;
int *count_ret;
{
XLCd lcd = _fallcCurrentLC();
if (lcd == NULL)
return XLocaleNotSupported;
return (*lcd->methods->mb_text_prop_to_list)(lcd, dpy, text_prop, list_ret,
count_ret);
}
int
falwcTextPropertyToTextList(dpy, text_prop, list_ret, count_ret)
Display *dpy;
XTextProperty *text_prop;
wchar_t ***list_ret;
int *count_ret;
{
XLCd lcd = _fallcCurrentLC();
if (lcd == NULL)
return XLocaleNotSupported;
return (*lcd->methods->wc_text_prop_to_list)(lcd, dpy, text_prop, list_ret,
count_ret);
}
int
falmbTextListToTextProperty(dpy, list, count, style, text_prop)
Display *dpy;
char **list;
int count;
XICCEncodingStyle style;
XTextProperty *text_prop;
{
XLCd lcd = _fallcCurrentLC();
if (lcd == NULL)
return XLocaleNotSupported;
return (*lcd->methods->mb_text_list_to_prop)(lcd, dpy, list, count, style,
text_prop);
}
int
falwcTextListToTextProperty(dpy, list, count, style, text_prop)
Display *dpy;
wchar_t **list;
int count;
XICCEncodingStyle style;
XTextProperty *text_prop;
{
XLCd lcd = _fallcCurrentLC();
if (lcd == NULL)
return XLocaleNotSupported;
return (*lcd->methods->wc_text_list_to_prop)(lcd, dpy, list, count, style,
text_prop);
}
void
falwcFreeStringList(list)
wchar_t **list;
{
XLCd lcd = _fallcCurrentLC();
if (lcd == NULL)
return;
(*lcd->methods->wc_free_string_list)(lcd, list);
}
char *
falDefaultString()
{
XLCd lcd = _fallcCurrentLC();
if (lcd == NULL)
return (char *) NULL;
return (*lcd->methods->default_string)(lcd);
}
void
_fallcCopyFromArg(src, dst, size)
char *src;
register char *dst;
register int size;
{
if (size == sizeof(long))
*((long *) dst) = (long) src;
#ifdef LONG64
else if (size == sizeof(int))
*((int *) dst) = (int) (intptr_t) src;
#endif
else if (size == sizeof(short))
*((short *) dst) = (short) (intptr_t) src;
else if (size == sizeof(char))
*((char *) dst) = (char) (intptr_t) src;
else if (size == sizeof(XPointer))
*((XPointer *) dst) = (XPointer) src;
else if (size > sizeof(XPointer))
memcpy(dst, (char *) src, size);
else
memcpy(dst, (char *) &src, size);
}
void
_fallcCopyToArg(src, dst, size)
register char *src;
register char **dst;
register int size;
{
if (size == sizeof(long))
*((long *) *dst) = *((long *) src);
else if (size == sizeof(short))
*((short *) *dst) = *((short *) src);
else if (size == sizeof(char))
*((char *) *dst) = *((char *) src);
else if (size == sizeof(XPointer))
*((XPointer *) *dst) = *((XPointer *) src);
else
memcpy(*dst, src, size);
}
void
_fallcCountVaList(var, count_ret)
va_list var;
int *count_ret;
{
register int count;
for (count = 0; va_arg(var, char *); count++)
va_arg(var, XPointer);
*count_ret = count;
}
void
_fallcVaToArgList(var, count, args_ret)
va_list var;
register int count;
XlcArgList *args_ret;
{
register XlcArgList args;
*args_ret = args = (XlcArgList) Xmalloc(sizeof(XlcArg) * count);
if (args == (XlcArgList) NULL)
return;
for ( ; count-- > 0; args++) {
args->name = va_arg(var, char *);
args->value = va_arg(var, XPointer);
}
}
void
_fallcCompileResourceList(resources, num_resources)
register XlcResourceList resources;
register int num_resources;
{
for ( ; num_resources-- > 0; resources++)
resources->xrm_name = falrmPermStringToQuark(resources->name);
}
char *
_fallcGetValues(base, resources, num_resources, args, num_args, mask)
XPointer base;
XlcResourceList resources;
int num_resources;
XlcArgList args;
int num_args;
unsigned long mask;
{
XlcResourceList res;
XrmQuark xrm_name;
int count;
for ( ; num_args-- > 0; args++) {
res = resources;
count = num_resources;
xrm_name = falrmPermStringToQuark(args->name);
for ( ; count-- > 0; res++) {
if (xrm_name == res->xrm_name && (mask & res->mask)) {
_fallcCopyToArg(base + res->offset, &args->value, res->size);
break;
}
}
if (count < 0)
return args->name;
}
return NULL;
}
char *
_fallcSetValues(base, resources, num_resources, args, num_args, mask)
XPointer base;
XlcResourceList resources;
int num_resources;
XlcArgList args;
int num_args;
unsigned long mask;
{
XlcResourceList res;
XrmQuark xrm_name;
int count;
for ( ; num_args-- > 0; args++) {
res = resources;
count = num_resources;
xrm_name = falrmPermStringToQuark(args->name);
for ( ; count-- > 0; res++) {
if (xrm_name == res->xrm_name && (mask & res->mask)) {
_fallcCopyFromArg(args->value, base + res->offset, res->size);
break;
}
}
if (count < 0)
return args->name;
}
return NULL;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,197 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* locking.h 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:43 */
/* $XConsortium: _fallocking.h /main/1 1996/04/08 15:21:32 cde-fuj $ */
/*
Copyright (c) 1992 X Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.
*/
/*
* Author: Stephen Gildea, MIT X Consortium
*
* locking.h - data types for C Threads locking.
* Used by XlibInt.c, locking.c, LockDis.c
*/
#ifndef _X_locking_H_
#define _X_locking_H_
#define xmalloc(s) Xmalloc(s)
#define xfree(s) Xfree(s)
#include <X11/Xthreads.h>
struct _XCVList {
xcondition_t cv;
xReply *buf;
struct _XCVList *next;
};
extern xthread_t (*_Xthread_self_fn)( /* in XlibInt.c */
#if NeedFunctionPrototypes
void
#endif
);
/* Display->lock is a pointer to one of these */
struct _XLockInfo {
xmutex_t mutex; /* mutex for critical sections */
int reply_bytes_left; /* nbytes of the reply still to read */
Bool reply_was_read; /* _XReadEvents read a reply for _XReply */
struct _XCVList *reply_awaiters; /* list of CVs for _XReply */
struct _XCVList **reply_awaiters_tail;
struct _XCVList *event_awaiters; /* list of CVs for _XReadEvents */
struct _XCVList **event_awaiters_tail;
Bool reply_first; /* who may read, reply queue or event queue */
/* for XLockDisplay */
int locking_level; /* how many times into XLockDisplay we are */
xthread_t locking_thread; /* thread that did XLockDisplay */
xcondition_t cv; /* wait if another thread has XLockDisplay */
xthread_t reading_thread; /* cache */
xthread_t conni_thread; /* thread in XProcessInternalConnection */
xcondition_t writers; /* wait for writable */
int num_free_cvls;
struct _XCVList *free_cvls;
/* used only in XlibInt.c */
void (*pop_reader)(
#if NeedNestedPrototypes
Display* /* dpy */,
struct _XCVList** /* list */,
struct _XCVList*** /* tail */
#endif
);
struct _XCVList *(*push_reader)(
#if NeedNestedPrototypes
Display * /* dpy */,
struct _XCVList*** /* tail */
#endif
);
void (*condition_wait)(
#if NeedNestedPrototypes
xcondition_t /* cv */,
xmutex_t /* mutex */
#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
, char* /* file */,
int /* line */
#endif
#endif
);
void (*internal_lock_display)(
#if NeedNestedPrototypes
Display* /* dpy */,
Bool /* wskip */
#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
, char* /* file */,
int /* line */
#endif
#endif
);
/* used in XlibInt.c and locking.c */
void (*condition_signal)(
#if NeedNestedPrototypes
xcondition_t /* cv */
#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
, char* /* file */,
int /* line */
#endif
#endif
);
void (*condition_broadcast)(
#if NeedNestedPrototypes
xcondition_t /* cv */
#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
, char* /* file */,
int /* line */
#endif
#endif
);
/* used in XlibInt.c and XLockDis.c */
void (*lock_wait)(
#if NeedNestedPrototypes
Display* /* dpy */
#endif
);
void (*user_lock_display)(
#if NeedNestedPrototypes
Display* /* dpy */
#endif
);
void (*user_unlock_display)(
#if NeedNestedPrototypes
Display* /* dpy */
#endif
);
struct _XCVList *(*create_cvl)(
#if NeedNestedPrototypes
Display * /* dpy */
#endif
);
};
#define UnlockNextEventReader(d) if ((d)->lock) \
(*(d)->lock->pop_reader)((d),&(d)->lock->event_awaiters,&(d)->lock->event_awaiters_tail)
#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
#define ConditionWait(d,c) if ((d)->lock) \
(*(d)->lock->condition_wait)(c, (d)->lock->mutex,__FILE__,__LINE__)
#define ConditionSignal(d,c) if ((d)->lock) \
(*(d)->lock->condition_signal)(c,__FILE__,__LINE__)
#define ConditionBroadcast(d,c) if ((d)->lock) \
(*(d)->lock->condition_broadcast)(c,__FILE__,__LINE__)
#else
#define ConditionWait(d,c) if ((d)->lock) \
(*(d)->lock->condition_wait)(c, (d)->lock->mutex)
#define ConditionSignal(d,c) if ((d)->lock) \
(*(d)->lock->condition_signal)(c)
#define ConditionBroadcast(d,c) if ((d)->lock) \
(*(d)->lock->condition_broadcast)(c)
#endif
typedef struct _LockInfoRec {
xmutex_t lock;
} LockInfoRec;
#endif /* _X_locking_H_ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,204 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* XomGeneric.h 1.6 - Fujitsu source for CDEnext 96/02/29 18:02:52 */
/* $XConsortium: _falomGeneric.h /main/1 1996/04/08 15:20:29 cde-fuj $ */
/*
* Copyright 1992, 1993 by TOSHIBA Corp.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of TOSHIBA not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. TOSHIBA make no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Katsuhisa Yano TOSHIBA Corp.
* mopi@osa.ilab.toshiba.co.jp
*/
/*
* Copyright 1995 by FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*
* Modifier: Takanori Tateno FUJITSU LIMITED
*
*/
#ifndef _XOMGENERIC_H_
#define _XOMGENERIC_H_
#include "_fallcPublic.h"
#define XOM_GENERIC(om) (&((XOMGeneric) om)->gen)
#define XOC_GENERIC(font_set) (&((XOCGeneric) font_set)->gen)
/* For VW/UDC */
typedef struct _CodeRangeRec {
unsigned long start;
unsigned long end;
unsigned long dmy1;
unsigned long dmy2;
} CodeRangeRec, *CodeRange;
typedef struct _VRotateRec {
char *charset_name; /* Charset name */
XlcSide side; /* Encoding side */
int num_cr;
CodeRange code_range;
char *xlfd_name;
XFontStruct *font;
} VRotateRec, *VRotate;
typedef enum {
XOMMultiByte,
XOMWideChar
} XOMTextType;
typedef struct _FontDataRec {
char *name;
XlcSide side;
/* For VW/UDC */
int scopes_num;
FontScope scopes;
char *xlfd_name;
XFontStruct *font;
} FontDataRec, *FontData;
#define VROTATE_NONE 0
#define VROTATE_PART 1
#define VROTATE_ALL 2
typedef struct _OMDataRec {
int charset_count;
XlcCharSet *charset_list;
int font_data_count;
FontData font_data;
/* For VW/UDC */
int substitute_num;
FontData substitute;
/* Vertical Writing */
int vmap_num;
FontData vmap;
int vrotate_type;
int vrotate_num;
CodeRange vrotate;
} OMDataRec, *OMData;
typedef struct _XOMGenericPart {
int data_num;
OMData data;
Bool on_demand_loading;
char *object_name;
} XOMGenericPart;
typedef struct _XOMGenericRec {
XOMMethods methods;
XOMCoreRec core;
XOMGenericPart gen;
} XOMGenericRec, *XOMGeneric;
/*
* XOC dependent data
*/
typedef struct _FontSetRec {
int id;
int charset_count;
XlcCharSet *charset_list;
int font_data_count;
FontData font_data;
char *font_name;
XFontStruct *info;
XFontStruct *font;
XlcSide side;
Bool is_xchar2b;
/* For VW/UDC */
int substitute_num;
FontData substitute;
/* Vertical Writing */
int vmap_num;
FontData vmap;
int vrotate_num;
VRotate vrotate;
} FontSetRec, *FontSet;
typedef struct _XOCGenericPart {
XlcConv mbs_to_cs;
XlcConv wcs_to_cs;
int font_set_num;
FontSet font_set;
} XOCGenericPart;
typedef struct _XOCGenericRec {
XOCMethods methods;
XOCCoreRec core;
XOCGenericPart gen;
} XOCGenericRec, *XOCGeneric;
_XFUNCPROTOBEGIN
extern XOM _falomGenericOpenOM(
#if NeedFunctionPrototypes
XLCd /* lcd */,
Display* /* dpy */,
XrmDatabase /* rdb */,
_Xconst char* /* res_name */,
_Xconst char* /* res_class */
#endif
);
extern XlcConv _XomInitConverter(
#if NeedFunctionPrototypes
XOC /* oc */,
XOMTextType /* type */
#endif
);
extern int _XomConvert(
#if NeedFunctionPrototypes
XOC /* oc */,
XlcConv /* conv */,
XPointer* /* from */,
int* /* from_left */,
XPointer* /* to */,
int* /* to_left */,
XPointer* /* args */,
int /* num_args */
#endif
);
_XFUNCPROTOEND
#endif /* _XOMGENERIC_H_ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* XrmI.h 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:12 */
/* $XConsortium: _falrmI.h /main/1 1996/04/08 15:22:08 cde-fuj $ */
/*
Copyright (c) 1990 X Consortium
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from the X Consortium.
*/
/*
* Macros to abstract out reading the file, and getting its size.
*
* You may need to redefine these for various other operating systems.
*/
#include <X11/Xos.h>
#include <sys/stat.h>
#ifdef WIN32
#define OpenFile(name) open((name), O_RDONLY|O_TEXT)
#else
#define OpenFile(name) open((name), O_RDONLY)
#endif
#define CloseFile(fd) close((fd))
#define ReadFile(fd,buf,size) read((fd), (buf), (size))
#define GetSizeOfFile(name,size) \
{ \
struct stat status_buffer; \
if ( (stat((name), &status_buffer)) == -1 ) \
size = -1; \
else \
size = status_buffer.st_size; \
}

View file

@ -0,0 +1,692 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: _faludcInf.c /main/4 1996/10/15 10:28:13 drk $ */
/* udcInf.c 1.4 - Fujitsu source for CDEnext 96/03/19 13:41:00 */
/*
* Copyright 1995 by FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietry source code of FUJITSU LIMITED
*
* Modifier: Takanori Tateno FUJITSU LIMITED
*
*/
#include <stdio.h>
#include <stdint.h>
#include <locale.h>
#include "syncx.h"
#include "_fallibint.h"
#include "_fallcint.h"
#include "_fallcPubI.h"
#include "_fallcGeneric.h"
#include "_falomGeneric.h"
/*
external symbols
*/
extern FontData falread_EncodingInfo();
extern int fal_get_codeset();
extern int fal_utyderror ;
extern int fal_utyerror ;
extern unsigned long fal_utyerrno ;
#define FAL_ERROR -1
/*
UDC structure define
*/
typedef struct _FalGlyphRegion {
unsigned long start;
unsigned long end;
} FalGlyphRegion ;
/*
* "code" no jyoui "i" byte me wo "unsigned char" toshite kaesu.
*/
static unsigned char getbyte(code,i)
unsigned long code;
int i;
{
unsigned long byteL;
unsigned char byte;
byteL = code >> (8*(3-i));
byte = (unsigned char)(0x000000ff & byteL);
return(byte);
}
/*
get codeset which described by charset_str and locale.
for examples ...
locale : ja_JP
charset_str : JISX0208.1983-0
*/
fal_get_codeset(locale,charset_str,codeset,num_codeset)
char *locale;
char *charset_str;
int **codeset;
int *num_codeset;
{
XLCdRec lcdrec;
XLCd lcd;
XLCdPublicRec xlcdp;
XPointer rdb;
int num = 0,count,num_ret=0,i,*ret;
char **value,buf[128],*ptr;
fal_utyderror = 0;
fal_utyerror = 0;
if((locale == NULL) || (charset_str == NULL)){
fal_utyerror = 5;
fal_utyderror = 1;
fal_utyerrno = 0x04 ;
return(FAL_ERROR);
}
if(codeset == NULL){
fal_utyerror = 5;
fal_utyderror = 2;
fal_utyerrno = 0x04 ;
return(FAL_ERROR);
}
/* create XLCd */
xlcdp.pub.siname = locale;
lcdrec.core = (XLCdCore)&xlcdp;
lcd = &lcdrec;
/* create X RDB (X NLS DB) */
rdb = _fallcCreateLocaleDataBase(lcd);
if(rdb == NULL){
fal_utyerror = 1;
fal_utyerrno = 0x15 ;
return(FAL_ERROR);
}
for(num=0;;num++){
/* XLC_FONTSET */
sprintf(buf, "fs%d.font.primary", num);
_fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
if(count < 1){
break ;
}
for(i=0;i<count;i++){
strcpy(buf,value[i]);
ptr = (char *)strchr(buf,(int)':');
*ptr = 0;
if(!_fallcCompareISOLatin1(charset_str,buf)){
num_ret += 1;
if(num_ret == 1){
ret = (int *)Xmalloc(sizeof(int));
} else {
ret =
(int *)Xrealloc(ret,num_ret*sizeof(int));
}
if(ret == NULL){
fal_utyerrno = 0x03 ;
return(FAL_ERROR);
}
ret[num_ret-1]=num;
break ;
}
}
}
if(num_ret == 0){
*num_codeset = 0;
*codeset = NULL;
return (0xff);
}
*num_codeset = num_ret;
*codeset = ret;
return 0;
}
static Bool gi_to_vgi(gi,vgi,scope)
unsigned long gi,*vgi;
FontScope scope;
{
if(scope->shift_direction == (unsigned long)'+'){
gi -= scope->shift;
} else {
gi += scope->shift;
}
if(gi >= scope->start && gi <= scope->end){
*vgi = gi;
return(True);
}
return(False);
}
static void shift_area(udc,scope)
FalGlyphRegion *udc;
FontScope scope;
{
if(scope->shift_direction == (unsigned long)'+'){
udc->start += scope->shift;
udc->end += scope->shift;
} else {
udc->start -= scope->shift;
udc->end -= scope->shift;
}
}
/*
get UDC area with glyph index.
for examples ...
locale : ja_JP
charset_str : JISX0208.1983-0
*/
FalGetUDCGIArea(locale,codeset,charset_str,gr,num_gr)
char *locale;
int codeset;
char *charset_str;
FalGlyphRegion **gr;
int *num_gr;
{
XLCdRec lcdrec;
XLCd lcd;
XLCdPublicRec xlcdp;
XPointer rdb;
FalGlyphRegion *udc;
int num = 0,count,num_ret=0;
int i,j,k;
char **value,buf[128],ptr;
FontData font_data;
fal_utyderror = 0;
fal_utyerror = 0;
fal_utyerrno = 0x00 ;
if((locale == NULL) || (charset_str == NULL)){
fal_utyerror = 5;
fal_utyderror = 1;
fal_utyerrno = 0x04;
fal_utyerrno |= (0x0b<<8) ;
return(FAL_ERROR);
}
if(gr == NULL){
fal_utyerror = 5;
fal_utyderror = 1;
fal_utyerrno = 0x04;
fal_utyerrno |= (0x0b<<8) ;
return(FAL_ERROR);
}
if(num_gr == NULL){
fal_utyerror = 5;
fal_utyderror = 2;
fal_utyerrno = 0x04;
fal_utyerrno |= (0x0b<<8) ;
return(FAL_ERROR);
}
/* create XLCd */
xlcdp.pub.siname = locale;
lcdrec.core = (XLCdCore)&xlcdp;
lcd = &lcdrec;
/* create X RDB (X NLS DB) */
rdb = _fallcCreateLocaleDataBase(lcd);
if(rdb == NULL){
fal_utyerror = 1;
fal_utyerrno = 0x15 ;
fal_utyerrno |= (0x0b<<8) ;
return(FAL_ERROR);
}
udc = NULL;
/* XLC_FONTSET */
sprintf(buf, "fs%d.charset.udc_area", codeset-1);
_fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
if(count > 0){
udc = (FalGlyphRegion *)Xmalloc(count * sizeof(FalGlyphRegion));
if(udc == NULL){
fal_utyerrno = 0x03 ;
fal_utyerrno |= (0x0b<<8) ;
return(FAL_ERROR);
}
for(i=0;i<count;i++){
sscanf(value[i],"\\x%lx,\\x%lx", &(udc[i].start), &(udc[i].end));
}
}
*num_gr = count;
sprintf(buf, "fs%d.font.primary", codeset-1);
_fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
if(count > 0){
font_data = falread_EncodingInfo(count,value);
for(i=0;i<count;i++){
if( !_fallcCompareISOLatin1(font_data[i].name,charset_str)){
for(j=0;j<(*num_gr);j++){
for(k=0;k<font_data[i].scopes_num;k++){
if(udc[j].start == font_data[i].scopes[k].start
&& font_data[i].scopes[k].shift){
shift_area(&udc[j],&(font_data[i].scopes[k]));
}
}
}
}
}
}
*gr = udc;
return 0;
}
/*
* Code convert wo tomonau UDC area no kakutoku
* GetUDCCPArea() / glyph_to_code()
*
*/
int fal_gi_to_vgi(lcd,locale,charset_str,codeset,gi,vgi,charsetname)
XLCd lcd;
char *locale;
char *charset_str;
int codeset;
unsigned long gi;
unsigned long *vgi;
char *charsetname;
{
FalGlyphRegion *udc;
int num = 0,count,num_ret=0;
int i,j,k;
char **value,buf[128],ptr;
FontData font_data = NULL;
sprintf(buf, "fs%d.charset.name", codeset-1);
_fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
if(count > 0){
strcpy(charsetname,value[0]);
}
sprintf(buf, "fs%d.font.primary", codeset-1);
_fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
if(count > 0){
font_data = falread_EncodingInfo(count,value);
for(i=0;i<count;i++){
if( !_fallcCompareISOLatin1(font_data[i].name,charset_str)){
for(k=0;k<font_data[i].scopes_num;k++){
if( gi_to_vgi(gi,vgi,&(font_data[i].scopes[k])) == True){
XFree(font_data);
return(True);
}
}
}
}
}
/*
free_fontdata(font_data);
*/
*vgi = gi;
XFree(font_data);
return(True);
}
Bool falnon_standard(lcd,charset)
XLCd lcd;
XlcCharSet charset;
{
char buf[256];
int count,i;
char **value;
if(charset->ct_sequence == NULL){
return(False);
}
for(i=0;;i++){
sprintf(buf, "csd%d.charset_name", i);
_fallcGetLocaleDataBase(lcd, "XLC_CHARSET_DEFINE", buf, &value, &count);
if(count > 0){
if(!_fallcNCompareISOLatin1(value[0],
charset->name,strlen(value[0])) ){
return(True);
}
} else {
return(False);
}
}
}
void
falmake_none_standard(from,charset,src)
char *from;
XlcCharSet charset;
char *src;
{
int name_len,seq_len,i;
name_len = 2 + strlen(charset->encoding_name) + 1;
seq_len = strlen(charset->ct_sequence);
strcpy(from,charset->ct_sequence);
from[seq_len] = name_len / 128 + 128;
from[seq_len+1] = name_len % 128 + 128;
strcpy(&from[seq_len + 2],charset->encoding_name);
from[seq_len+name_len-1] = 0x02; /* STX */
strcpy(&from[seq_len + name_len],src);
}
int
fal_glyph_to_code(locale,charset_str,codeset,glyph_index,codepoint)
char *locale;
char *charset_str;
int codeset;
unsigned long glyph_index;
unsigned long *codepoint;
{
XLCd lcd;
unsigned char *from; int from_left;
unsigned char *to ; int to_left = 10;
unsigned char *dst;
unsigned char byte;
unsigned long from32[25];
unsigned long to32[25];
int i,j;
char tmp[256],charsetname[256],src[10];
XlcConv conv;
XlcCharSet charset;
XPointer args[2];
from = (unsigned char *)from32;
to = (unsigned char *)to32;
dst = (unsigned char *)to32;
memset(dst,0,25);
lcd = (XLCd) (uintptr_t) _fallcGenericLoader(locale);
fal_gi_to_vgi(lcd,locale,charset_str,codeset,
glyph_index,&glyph_index,charsetname);
for(i=0,j=0;i<4;i++){
byte = getbyte(glyph_index,i);
if(byte){
src[j] = byte;
j ++;
}
}
src[j] = 0;
/* get charset */
/*
sprintf(tmp,"%s%s",charset_str,":GL");
charset_name = strdup(tmp);
*/
charset = _fallcGetCharSet(charsetname);
if(charset == NULL){
fal_utyerrno = 0x16 ;
return(FAL_ERROR);
}
/* make ct */
if( falnon_standard(lcd,charset)) {
falmake_none_standard(from,charset,src);
} else if(charset->ct_sequence){
snprintf((char *)from, sizeof(from32), "%s%s", charset->ct_sequence,src);
} else {
snprintf((char *)from, sizeof(from32), "%s", src);
}
/* compound text -> multi byte */
conv = _fallcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte);
from_left = strlen((char *)from);
_fallcConvert(conv,(XPointer *)&from,&from_left,
(XPointer *)&to, &to_left,args,0);
_fallcCloseConverter(conv);
_fallcDestroyLC(lcd);
*codepoint = 0;
for(i=0;dst[i];i++){
*codepoint = ((*codepoint << 8) | dst[i]) ;
}
return(0);
}
typedef struct _FalCodeRegion {
unsigned long start,end;
} FalCodeRegion ;
int
FalGetUDCCPArea(locale,codeset,charset_str,cr,num_cr)
char *locale;
int codeset;
char *charset_str;
FalCodeRegion **cr;
int *num_cr;
{
int i,num_gr,ret;
FalGlyphRegion *gr;
FalCodeRegion *crr;
fal_utyerror = 0;
fal_utyderror = 0;
if(cr == NULL){
fal_utyerror = 5;
fal_utyderror = 1;
fal_utyerrno = 0x04 ;
fal_utyerrno |= (0x0a<<8) ;
return(FAL_ERROR);
}
if(num_cr == NULL){
fal_utyerror = 5;
fal_utyderror = 2;
fal_utyerrno = 0x04 ;
fal_utyerrno |= (0x0a<<8) ;
return(FAL_ERROR);
}
ret = FalGetUDCGIArea(locale,codeset,charset_str,&gr,&num_gr);
if(ret == FAL_ERROR){
fal_utyerrno &= 0xff ;
fal_utyerrno |= (0x0a<<8) ;
return(ret);
}
crr = (FalCodeRegion *)Xmalloc(num_gr*sizeof(FalCodeRegion));
if(crr == NULL){
Xfree(gr);
fal_utyerrno = 0x03 ;
fal_utyerrno |= (0x0a<<8) ;
return(FAL_ERROR);
}
for(i=0;i<num_gr;i++){
ret = fal_glyph_to_code(locale,charset_str,codeset,
gr[i].start, &(crr[i].start));
if(ret == FAL_ERROR){
fal_utyerrno |= (0x0a<<8) ;
Xfree(gr);
Xfree(crr);
return(ret);
}
ret = fal_glyph_to_code(locale,charset_str,codeset,
gr[i].end, &(crr[i].end));
if(ret == FAL_ERROR){
fal_utyerrno |= (0x0a<<8) ;
Xfree(gr);
Xfree(crr);
return(ret);
}
}
Xfree(gr);
*cr = crr;
*num_cr = num_gr;
return(0);
}
/*
* code_to_glyph()
*
*/
typedef struct _FalGIInf {
char *charset_str;
unsigned long glyph_index;
} FalGIInf ;
/*
*
*
*/
static Bool vgi_to_gi(gi,vgi,scope)
unsigned long *gi,vgi;
FontScope scope;
{
if(vgi >= scope->start && vgi <= scope->end){
if(scope->shift_direction == (unsigned long)'+'){
*gi = vgi + scope->shift;
} else {
*gi = vgi - scope->shift;
}
return(True);
}
return(False);
}
/*
*
*
*/
static Bool
fal_vgi_to_gi(lcd,locale,vglyph,glyph,charset,charsetname)
XLCd lcd;
char *locale;
unsigned long vglyph;
unsigned long *glyph;
XlcCharSet charset;
char *charsetname;
{
int num = 0,count,num_ret=0;
int i,j,k;
char **value,buf[128],ptr;
FontData font_data = NULL;
CodeSet cs;
for(i=0;;i++){
sprintf(buf, "fs%d.charset.name",i);
_fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
if(count > 0){
if(!_fallcNCompareISOLatin1(charset->name,value[0],
strlen(charset->name))){
break;
}
} else {
fal_utyerrno = 0x17 ;
return(False);
}
}
/*
sprintf(buf, "fs%d.charset.name", codeset-1);
_fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
if(count > 0){
strcpy(charsetname,value[0]);
}
*/
sprintf(buf, "fs%d.font.primary", i);
_fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
if(count > 0){
font_data = falread_EncodingInfo(count,value);
for(i=0;i<count;i++){
for(k=0;k<font_data[i].scopes_num;k++){
if( vgi_to_gi(glyph,vglyph,&(font_data[i].scopes[k])) == True){
strcpy(charsetname,font_data[i].name);
XFree(font_data);
return(True);
}
}
}
}
*glyph = vglyph;
XFree(font_data);
return(True);
}
int
fal_code_to_glyph(locale,codepoint,gi,num_gi)
char *locale;
unsigned long codepoint;
FalGIInf **gi;
int *num_gi;
{
XLCd lcd;
unsigned char *from; int from_left;
unsigned char *to ; int to_left = 10;
unsigned char *dst;
unsigned char byte;
unsigned int from32[25];
unsigned int to32[25];
int i,j;
char tmp[256],charsetname[256],src[10];
XlcConv conv;
XlcCharSet charset;
XPointer args[2];
unsigned long glyph,vglyph;
from = (unsigned char *)from32;
to = (unsigned char *)to32;
dst = (unsigned char *)to32;
memset(dst,0,25);
lcd = (XLCd) (uintptr_t) _fallcGenericLoader(locale);
for(i=0,j=0;i<4;i++){
byte = getbyte(codepoint,i);
if(byte){
src[j] = byte;
j ++;
}
}
src[j] = 0;
snprintf((char *)from, sizeof(from32), "%s", src);
/* multi byte -> vgi */
conv = _fallcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet);
from_left = strlen((char *)from);
args[0] = (XPointer) &charset;
_fallcConvert(conv,(XPointer *)&from,&from_left,
(XPointer *)&to, &to_left,args,1);
/* vgi -> gi */
vglyph = 0;
for(i=0;dst[i];i++){
vglyph = ((vglyph << 8) | dst[i]) ;
}
if(fal_vgi_to_gi(lcd,locale,vglyph,&glyph,charset,charsetname)==False){
_fallcCloseConverter(conv);
_fallcDestroyLC(lcd);
*num_gi = 0;
return(0);
}
_fallcCloseConverter(conv);
_fallcDestroyLC(lcd);
*gi = (FalGIInf *)Xmalloc(sizeof(FalGIInf));
if(*gi == NULL){
fal_utyerrno = 0x03 ;
return(FAL_ERROR);
}
(*gi)->charset_str = (char *)Xmalloc(strlen(charsetname)+1);
strcpy((*gi)->charset_str,charsetname);
(*gi)->glyph_index = glyph;
*num_gi = 1;
return(0);
}

View file

@ -0,0 +1,930 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* Xutil.h 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:12 */
/* $XConsortium: _falutil.h /main/1 1996/04/08 15:20:39 cde-fuj $ */
/***********************************************************
Copyright (c) 1987 X Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#ifndef _XUTIL_H_
#define _XUTIL_H_
/* You must include "syncx.h" before including this file */
/*
* Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
* value (x, y, width, height) was found in the parsed string.
*/
#define NoValue 0x0000
#define XValue 0x0001
#define YValue 0x0002
#define WidthValue 0x0004
#define HeightValue 0x0008
#define AllValues 0x000F
#define XNegative 0x0010
#define YNegative 0x0020
/*
* new version containing base_width, base_height, and win_gravity fields;
* used with WM_NORMAL_HINTS.
*/
typedef struct {
long flags; /* marks which fields in this structure are defined */
int x, y; /* obsolete for new window mgrs, but clients */
int width, height; /* should set so old wm's don't mess up */
int min_width, min_height;
int max_width, max_height;
int width_inc, height_inc;
struct {
int x; /* numerator */
int y; /* denominator */
} min_aspect, max_aspect;
int base_width, base_height; /* added by ICCCM version 1 */
int win_gravity; /* added by ICCCM version 1 */
} XSizeHints;
/*
* The next block of definitions are for window manager properties that
* clients and applications use for communication.
*/
/* flags argument in size hints */
#define USPosition (1L << 0) /* user specified x, y */
#define USSize (1L << 1) /* user specified width, height */
#define PPosition (1L << 2) /* program specified position */
#define PSize (1L << 3) /* program specified size */
#define PMinSize (1L << 4) /* program specified minimum size */
#define PMaxSize (1L << 5) /* program specified maximum size */
#define PResizeInc (1L << 6) /* program specified resize increments */
#define PAspect (1L << 7) /* program specified min and max aspect ratios */
#define PBaseSize (1L << 8) /* program specified base for incrementing */
#define PWinGravity (1L << 9) /* program specified window gravity */
/* obsolete */
#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)
typedef struct {
long flags; /* marks which fields in this structure are defined */
Bool input; /* does this application rely on the window manager to
get keyboard input? */
int initial_state; /* see below */
Pixmap icon_pixmap; /* pixmap to be used as icon */
Window icon_window; /* window to be used as icon */
int icon_x, icon_y; /* initial position of icon */
Pixmap icon_mask; /* icon mask bitmap */
XID window_group; /* id of related window group */
/* this structure may be extended in the future */
} XWMHints;
/* definition for flags of XWMHints */
#define InputHint (1L << 0)
#define StateHint (1L << 1)
#define IconPixmapHint (1L << 2)
#define IconWindowHint (1L << 3)
#define IconPositionHint (1L << 4)
#define IconMaskHint (1L << 5)
#define WindowGroupHint (1L << 6)
#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \
IconPositionHint|IconMaskHint|WindowGroupHint)
#define XUrgencyHint (1L << 8)
/* definitions for initial window state */
#define WithdrawnState 0 /* for windows that are not mapped */
#define NormalState 1 /* most applications want to start this way */
#define IconicState 3 /* application wants to start as an icon */
/*
* Obsolete states no longer defined by ICCCM
*/
#define DontCareState 0 /* don't know or care */
#define ZoomState 2 /* application wants to start zoomed */
#define InactiveState 4 /* application believes it is seldom used; */
/* some wm's may put it on inactive menu */
/*
* new structure for manipulating TEXT properties; used with WM_NAME,
* WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND.
*/
typedef struct {
unsigned char *value; /* same as Property routines */
Atom encoding; /* prop type */
int format; /* prop data format: 8, 16, or 32 */
unsigned long nitems; /* number of data items in value */
} XTextProperty;
#define XNoMemory -1
#define XLocaleNotSupported -2
#define XConverterNotFound -3
typedef enum {
XStringStyle, /* STRING */
XCompoundTextStyle, /* COMPOUND_TEXT */
XTextStyle, /* text in owner's encoding (current locale)*/
XStdICCTextStyle /* STRING, else COMPOUND_TEXT */
} XICCEncodingStyle;
typedef struct {
int min_width, min_height;
int max_width, max_height;
int width_inc, height_inc;
} XIconSize;
typedef struct {
char *res_name;
char *res_class;
} XClassHint;
/*
* These macros are used to give some sugar to the image routines so that
* naive people are more comfortable with them.
*/
#define XDestroyImage(ximage) \
((*((ximage)->f.destroy_image))((ximage)))
#define XGetPixel(ximage, x, y) \
((*((ximage)->f.get_pixel))((ximage), (x), (y)))
#define XPutPixel(ximage, x, y, pixel) \
((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)))
#define XSubImage(ximage, x, y, width, height) \
((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height)))
#define XAddPixel(ximage, value) \
((*((ximage)->f.add_pixel))((ximage), (value)))
/*
* Compose sequence status structure, used in calling XLookupString.
*/
typedef struct _XComposeStatus {
XPointer compose_ptr; /* state table pointer */
int chars_matched; /* match state */
} XComposeStatus;
/*
* Keysym macros, used on Keysyms to test for classes of symbols
*/
#define IsKeypadKey(keysym) \
(((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal))
#define IsPrivateKeypadKey(keysym) \
(((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))
#define IsCursorKey(keysym) \
(((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select))
#define IsPFKey(keysym) \
(((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4))
#define IsFunctionKey(keysym) \
(((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35))
#define IsMiscFunctionKey(keysym) \
(((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break))
#define IsModifierKey(keysym) \
((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
|| ((KeySym)(keysym) == XK_Mode_switch) \
|| ((KeySym)(keysym) == XK_Num_Lock))
/*
* opaque reference to Region data type
*/
typedef struct _XRegion *Region;
/* Return values from XRectInRegion() */
#define RectangleOut 0
#define RectangleIn 1
#define RectanglePart 2
/*
* Information used by the visual utility routines to find desired visual
* type from the many visuals a display may support.
*/
typedef struct {
Visual *visual;
VisualID visualid;
int screen;
int depth;
#if defined(__cplusplus) || defined(c_plusplus)
int c_class; /* C++ */
#else
int class;
#endif
unsigned long red_mask;
unsigned long green_mask;
unsigned long blue_mask;
int colormap_size;
int bits_per_rgb;
} XVisualInfo;
#define VisualNoMask 0x0
#define VisualIDMask 0x1
#define VisualScreenMask 0x2
#define VisualDepthMask 0x4
#define VisualClassMask 0x8
#define VisualRedMaskMask 0x10
#define VisualGreenMaskMask 0x20
#define VisualBlueMaskMask 0x40
#define VisualColormapSizeMask 0x80
#define VisualBitsPerRGBMask 0x100
#define VisualAllMask 0x1FF
/*
* This defines a window manager property that clients may use to
* share standard color maps of type RGB_COLOR_MAP:
*/
typedef struct {
Colormap colormap;
unsigned long red_max;
unsigned long red_mult;
unsigned long green_max;
unsigned long green_mult;
unsigned long blue_max;
unsigned long blue_mult;
unsigned long base_pixel;
VisualID visualid; /* added by ICCCM version 1 */
XID killid; /* added by ICCCM version 1 */
} XStandardColormap;
#define ReleaseByFreeingColormap ((XID) 1L) /* for killid field above */
/*
* return codes for XReadBitmapFile and XWriteBitmapFile
*/
#define BitmapSuccess 0
#define BitmapOpenFailed 1
#define BitmapFileInvalid 2
#define BitmapNoMemory 3
/****************************************************************
*
* Context Management
*
****************************************************************/
/* Associative lookup table return codes */
#define XCSUCCESS 0 /* No error. */
#define XCNOMEM 1 /* Out of memory */
#define XCNOENT 2 /* No entry in table */
typedef int XContext;
#define XUniqueContext() ((XContext) falrmUniqueQuark())
#define XStringToContext(string) ((XContext) falrmStringToQuark(string))
_XFUNCPROTOBEGIN
/* The following declarations are alphabetized. */
extern XClassHint *XAllocClassHint (
#if NeedFunctionPrototypes
void
#endif
);
extern XIconSize *XAllocIconSize (
#if NeedFunctionPrototypes
void
#endif
);
extern XSizeHints *XAllocSizeHints (
#if NeedFunctionPrototypes
void
#endif
);
extern XStandardColormap *XAllocStandardColormap (
#if NeedFunctionPrototypes
void
#endif
);
extern XWMHints *XAllocWMHints (
#if NeedFunctionPrototypes
void
#endif
);
extern XClipBox(
#if NeedFunctionPrototypes
Region /* r */,
XRectangle* /* rect_return */
#endif
);
extern Region XCreateRegion(
#if NeedFunctionPrototypes
void
#endif
);
extern char *falDefaultString(
#if NeedFunctionPrototypes
void
#endif
);
extern int XDeleteContext(
#if NeedFunctionPrototypes
Display* /* display */,
XID /* rid */,
XContext /* context */
#endif
);
extern XDestroyRegion(
#if NeedFunctionPrototypes
Region /* r */
#endif
);
extern XEmptyRegion(
#if NeedFunctionPrototypes
Region /* r */
#endif
);
extern XEqualRegion(
#if NeedFunctionPrototypes
Region /* r1 */,
Region /* r2 */
#endif
);
extern int XFindContext(
#if NeedFunctionPrototypes
Display* /* display */,
XID /* rid */,
XContext /* context */,
XPointer* /* data_return */
#endif
);
extern Status XGetClassHint(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XClassHint* /* class_hints_return */
#endif
);
extern Status XGetIconSizes(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XIconSize** /* size_list_return */,
int* /* count_return */
#endif
);
extern Status XGetNormalHints(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XSizeHints* /* hints_return */
#endif
);
extern Status XGetRGBColormaps(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XStandardColormap** /* stdcmap_return */,
int* /* count_return */,
Atom /* property */
#endif
);
extern Status XGetSizeHints(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XSizeHints* /* hints_return */,
Atom /* property */
#endif
);
extern Status XGetStandardColormap(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XStandardColormap* /* colormap_return */,
Atom /* property */
#endif
);
extern Status XGetTextProperty(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* window */,
XTextProperty* /* text_prop_return */,
Atom /* property */
#endif
);
extern XVisualInfo *XGetVisualInfo(
#if NeedFunctionPrototypes
Display* /* display */,
long /* vinfo_mask */,
XVisualInfo* /* vinfo_template */,
int* /* nitems_return */
#endif
);
extern Status XGetWMClientMachine(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop_return */
#endif
);
extern XWMHints *XGetWMHints(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */
#endif
);
extern Status XGetWMIconName(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop_return */
#endif
);
extern Status XGetWMName(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop_return */
#endif
);
extern Status XGetWMNormalHints(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XSizeHints* /* hints_return */,
long* /* supplied_return */
#endif
);
extern Status XGetWMSizeHints(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XSizeHints* /* hints_return */,
long* /* supplied_return */,
Atom /* property */
#endif
);
extern Status XGetZoomHints(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XSizeHints* /* zhints_return */
#endif
);
extern XIntersectRegion(
#if NeedFunctionPrototypes
Region /* sra */,
Region /* srb */,
Region /* dr_return */
#endif
);
extern void XConvertCase(
#if NeedFunctionPrototypes
KeySym /* sym */,
KeySym* /* lower */,
KeySym* /* upper */
#endif
);
extern int XLookupString(
#if NeedFunctionPrototypes
XKeyEvent* /* event_struct */,
char* /* buffer_return */,
int /* bytes_buffer */,
KeySym* /* keysym_return */,
XComposeStatus* /* status_in_out */
#endif
);
extern Status XMatchVisualInfo(
#if NeedFunctionPrototypes
Display* /* display */,
int /* screen */,
int /* depth */,
int /* class */,
XVisualInfo* /* vinfo_return */
#endif
);
extern XOffsetRegion(
#if NeedFunctionPrototypes
Region /* r */,
int /* dx */,
int /* dy */
#endif
);
extern Bool XPointInRegion(
#if NeedFunctionPrototypes
Region /* r */,
int /* x */,
int /* y */
#endif
);
extern Region XPolygonRegion(
#if NeedFunctionPrototypes
XPoint* /* points */,
int /* n */,
int /* fill_rule */
#endif
);
extern int XRectInRegion(
#if NeedFunctionPrototypes
Region /* r */,
int /* x */,
int /* y */,
unsigned int /* width */,
unsigned int /* height */
#endif
);
extern int XSaveContext(
#if NeedFunctionPrototypes
Display* /* display */,
XID /* rid */,
XContext /* context */,
_Xconst char* /* data */
#endif
);
extern XSetClassHint(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XClassHint* /* class_hints */
#endif
);
extern XSetIconSizes(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XIconSize* /* size_list */,
int /* count */
#endif
);
extern XSetNormalHints(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XSizeHints* /* hints */
#endif
);
extern void XSetRGBColormaps(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XStandardColormap* /* stdcmaps */,
int /* count */,
Atom /* property */
#endif
);
extern XSetSizeHints(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XSizeHints* /* hints */,
Atom /* property */
#endif
);
extern XSetStandardProperties(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
_Xconst char* /* window_name */,
_Xconst char* /* icon_name */,
Pixmap /* icon_pixmap */,
char** /* argv */,
int /* argc */,
XSizeHints* /* hints */
#endif
);
extern void XSetTextProperty(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop */,
Atom /* property */
#endif
);
extern void XSetWMClientMachine(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop */
#endif
);
extern XSetWMHints(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XWMHints* /* wm_hints */
#endif
);
extern void XSetWMIconName(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop */
#endif
);
extern void XSetWMName(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop */
#endif
);
extern void XSetWMNormalHints(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XSizeHints* /* hints */
#endif
);
extern void XSetWMProperties(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XTextProperty* /* window_name */,
XTextProperty* /* icon_name */,
char** /* argv */,
int /* argc */,
XSizeHints* /* normal_hints */,
XWMHints* /* wm_hints */,
XClassHint* /* class_hints */
#endif
);
extern void XmbSetWMProperties(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
_Xconst char* /* window_name */,
_Xconst char* /* icon_name */,
char** /* argv */,
int /* argc */,
XSizeHints* /* normal_hints */,
XWMHints* /* wm_hints */,
XClassHint* /* class_hints */
#endif
);
extern void XSetWMSizeHints(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XSizeHints* /* hints */,
Atom /* property */
#endif
);
extern XSetRegion(
#if NeedFunctionPrototypes
Display* /* display */,
GC /* gc */,
Region /* r */
#endif
);
extern void XSetStandardColormap(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XStandardColormap* /* colormap */,
Atom /* property */
#endif
);
extern XSetZoomHints(
#if NeedFunctionPrototypes
Display* /* display */,
Window /* w */,
XSizeHints* /* zhints */
#endif
);
extern XShrinkRegion(
#if NeedFunctionPrototypes
Region /* r */,
int /* dx */,
int /* dy */
#endif
);
extern Status XStringListToTextProperty(
#if NeedFunctionPrototypes
char** /* list */,
int /* count */,
XTextProperty* /* text_prop_return */
#endif
);
extern XSubtractRegion(
#if NeedFunctionPrototypes
Region /* sra */,
Region /* srb */,
Region /* dr_return */
#endif
);
extern int falmbTextListToTextProperty(
#if NeedFunctionPrototypes
Display* /* display */,
char** /* list */,
int /* count */,
XICCEncodingStyle /* style */,
XTextProperty* /* text_prop_return */
#endif
);
extern int falwcTextListToTextProperty(
#if NeedFunctionPrototypes
Display* /* display */,
wchar_t** /* list */,
int /* count */,
XICCEncodingStyle /* style */,
XTextProperty* /* text_prop_return */
#endif
);
extern void falwcFreeStringList(
#if NeedFunctionPrototypes
wchar_t** /* list */
#endif
);
extern Status XTextPropertyToStringList(
#if NeedFunctionPrototypes
XTextProperty* /* text_prop */,
char*** /* list_return */,
int* /* count_return */
#endif
);
extern int falmbTextPropertyToTextList(
#if NeedFunctionPrototypes
Display* /* display */,
XTextProperty* /* text_prop */,
char*** /* list_return */,
int* /* count_return */
#endif
);
extern int falwcTextPropertyToTextList(
#if NeedFunctionPrototypes
Display* /* display */,
XTextProperty* /* text_prop */,
wchar_t*** /* list_return */,
int* /* count_return */
#endif
);
extern XUnionRectWithRegion(
#if NeedFunctionPrototypes
XRectangle* /* rectangle */,
Region /* src_region */,
Region /* dest_region_return */
#endif
);
extern XUnionRegion(
#if NeedFunctionPrototypes
Region /* sra */,
Region /* srb */,
Region /* dr_return */
#endif
);
extern int XWMGeometry(
#if NeedFunctionPrototypes
Display* /* display */,
int /* screen_number */,
_Xconst char* /* user_geometry */,
_Xconst char* /* default_geometry */,
unsigned int /* border_width */,
XSizeHints* /* hints */,
int* /* x_return */,
int* /* y_return */,
int* /* width_return */,
int* /* height_return */,
int* /* gravity_return */
#endif
);
extern XXorRegion(
#if NeedFunctionPrototypes
Region /* sra */,
Region /* srb */,
Region /* dr_return */
#endif
);
_XFUNCPROTOEND
#endif /* _XUTIL_H_ */

View file

@ -0,0 +1,210 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: _falutilbitmap.c /main/1 1996/04/08 15:22:19 cde-fuj $ */
/*
Copyright (c) 1990, 1994 X Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
/* Utility functions for reformating font bitmaps */
static unsigned char _reverse_byte[0x100] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
/*
* Invert bit order within each BYTE of an array.
*/
void
BitOrderInvert(buf, nbytes)
register unsigned char *buf;
register int nbytes;
{
register unsigned char *rev = _reverse_byte;
for (; --nbytes >= 0; buf++)
*buf = rev[*buf];
}
/*
* Invert byte order within each 16-bits of an array.
*/
void
TwoByteSwap(buf, nbytes)
register unsigned char *buf;
register int nbytes;
{
register unsigned char c;
for (; nbytes > 0; nbytes -= 2, buf += 2)
{
c = buf[0];
buf[0] = buf[1];
buf[1] = c;
}
}
/*
* Invert byte order within each 32-bits of an array.
*/
void
FourByteSwap(buf, nbytes)
register unsigned char *buf;
register int nbytes;
{
register unsigned char c;
for (; nbytes > 0; nbytes -= 4, buf += 4)
{
c = buf[0];
buf[0] = buf[3];
buf[3] = c;
c = buf[1];
buf[1] = buf[2];
buf[2] = c;
}
}
/*
* Repad a bitmap
*/
int
RepadBitmap (pSrc, pDst, srcPad, dstPad, width, height)
char *pSrc, *pDst;
unsigned srcPad, dstPad;
int width, height;
{
int srcWidthBytes,dstWidthBytes;
int row,col;
char *pTmpSrc,*pTmpDst;
switch (srcPad) {
case 1:
srcWidthBytes = (width+7)>>3;
break;
case 2:
srcWidthBytes = ((width+15)>>4)<<1;
break;
case 4:
srcWidthBytes = ((width+31)>>5)<<2;
break;
case 8:
srcWidthBytes = ((width+63)>>6)<<3;
break;
default:
return 0;
}
switch (dstPad) {
case 1:
dstWidthBytes = (width+7)>>3;
break;
case 2:
dstWidthBytes = ((width+15)>>4)<<1;
break;
case 4:
dstWidthBytes = ((width+31)>>5)<<2;
break;
case 8:
dstWidthBytes = ((width+63)>>6)<<3;
break;
default:
return 0;
}
width = srcWidthBytes;
if (width > dstWidthBytes)
width = dstWidthBytes;
pTmpSrc= pSrc;
pTmpDst= pDst;
for (row = 0; row < height; row++)
{
for (col = 0; col < width; col++)
*pTmpDst++ = *pTmpSrc++;
while (col < dstWidthBytes)
{
*pTmpDst++ = '\0';
col++;
}
pTmpSrc += srcWidthBytes - width;
}
return dstWidthBytes * height;
}

View file

@ -0,0 +1,95 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* Xvarargs.h 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:13 */
/* $XConsortium: _falvarargs.h /main/1 1996/04/08 15:22:42 cde-fuj $ */
/*
Copyright (c) 1985, 1986, 1987, 1988, 1989 X Consortium
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from the X Consortium.
*/
#ifndef _XVARARGS_H_
#define _XVARARGS_H_
#ifdef __HIGHC__
#ifndef _STDARG_H
#define _STDARG_H
typedef char *va_list;
/* Amount of space required in an argument list for an arg of type TYPE.
TYPE may alternatively be an expression whose type is used. */
#define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
#define va_start(AP, LASTARG) \
(AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)))
#define va_end(AP)
#define va_arg(AP, TYPE) \
(AP += __va_rounded_size (TYPE), \
*((TYPE *) (AP - __va_rounded_size (TYPE))))
#endif /* _STDARG_H */
#define Va_start(a,b) va_start(a,b)
#else /* !__HIGHC__ */
#if NeedVarargsPrototypes
# include <stdarg.h>
# define Va_start(a,b) va_start(a,b)
#else
# include <varargs.h>
# define Va_start(a,b) va_start(a)
#endif
#endif /* __HIGHC__ */
#endif /* _XVARARGS_H_ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,88 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: falfont.h /main/5 1996/06/25 20:05:39 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#define GETNUMCHARS(pFinf) \
(((pFinf)->lastCol - (pFinf)->firstCol + 1) * \
((pFinf)->lastRow - (pFinf)->firstRow + 1))
#define GETHIGHT(pCinf) \
((pCinf)->metrics.ascent + (pCinf)->metrics.descent)
#define _FAL_OK 1
/* fal_utyerror */
#define _FAL_OPEN_ER 1
#define _FAL_DIR_NOACCSS 1
#define _FAL_READ_ER 2
#define _FAL_READ_PATH_ER 2
#define _FAL_MALOC_ER 3
#define _FAL_PKEY_ER 4
#define _FAL_PARM_ER 5
#define _FAL_STAT_ER 6
#define _FAL_FONT_ER 7
#define _FAL_FLST_ER 7
#define _FAL_DATA_OPEN_ER 8
#define _FAL_DATA_READ_ER 9
/* fal_utyderror */
/* FalOpenFont */
#define _FAL_O_P_PKEY_DER 1
#define _FAL_O_P_CS_DER 2
/* FalQueryFont */
#define _FAL_Q_P_FINF_DER 1
#define _FAL_Q_P_FONT_DER 2
/* FalReadFont */
#define _FAL_R_P_FINF_DER 1
#define _FAL_R_P_W_DER 2
#define _FAL_R_P_H_DER 3
/* FalGetFontList */
#define _FAL_L_P_LST_DER 1
#define _FAL_L_P_KEY_DER 2
#define _FAL_TRY_NEXT 0xFF
#include "udccom.h"
#define SNF_BOUND 32
#define FILE_SUFFIX( file ) \
( strrchr( file, '.' ) ? strrchr( file, '.' ) : "" )
#define FAL_DATA_ELM 13
#define FAL_LINE_MAX 1024
/* update _Oak_Finf */
#define FAL_UPDATE_FONTINFO 1
#define FAL_READ_FONTINFO 0
/* Buffer of file name */
extern char fal_err_file_buf[] ;

View file

@ -0,0 +1,26 @@
#############################################################################
##### #####
##### fonts.list #####
##### #####
##### All Rights Reserved, Copyright (C) FUJITSU LIMITED 1995 #####
##### #####
#############################################################################
#
# This file is referenced by :
#
# dtudcfonted
# dtudcexch
# dtaddcpf
# dtcpgpf
# dtgpftocpf
# dtcpftogpf
# dtgpftobdf
# dtbdftocpf
# dtcpftobdf
# and dtlsgpf.
#
# font path ==> path1:
# path2:
# :
# pathN:
#

View file

@ -0,0 +1,116 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: font.h /main/1 1995/09/14 20:54:34 cde-fuj2 $ */
/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
(c) Copyright 1995 FUJITSU LIMITED
This is source code modified by FUJITSU LIMITED under the Joint
Development Agreement for the CDEnext PST.
This is unpublished proprietary source code of FUJITSU LIMITED
******************************************************************/
#ifndef FONT_H
#define FONT_H 1
#include "servermd.h"
#define NullCharInfo ((CharInfoPtr)0)
#define NullFontInfo ((FontInfoPtr)0)
#define LeftToRight 0
#define RightToLeft 1
/*
* for linear char sets
*/
#define n1dChars(pfi) ((pfi)->lastCol - (pfi)->firstCol + 1)
#define chFirst firstCol /* usage: pfi->chFirst */
#define chLast lastCol /* usage: pfi->chLast */
/*
* for 2D char sets
*/
#define n2dChars(pfi) (((pfi)->lastCol - (pfi)->firstCol + 1) * \
((pfi)->lastRow - (pfi)->firstRow + 1))
#define ADDRXTHISCHARINFO( pf, ch ) \
((CharInfoRec *) &((pf)->pCI[(ch) - (pf)->pFI->chFirst]))
#define GLWIDTHPIXELS(pci) \
((pci)->metrics.rightSideBearing - (pci)->metrics.leftSideBearing)
#define GLHEIGHTPIXELS(pci) \
((pci)->metrics.ascent + (pci)->metrics.descent)
#define GLYPHWIDTHBYTES(pci) (((GLYPHWIDTHPIXELS(pci))+7) >> 3)
#define GLYPHHEIGHTPIXELS(pci) (pci->metrics.ascent + pci->metrics.descent)
#define GLYPHWIDTHPIXELS(pci) (pci->metrics.rightSideBearing \
- pci->metrics.leftSideBearing)
#define GLWIDTHPADDED( bc) ((bc+7) & ~0x7)
#if GLYPHPADBYTES == 0 || GLYPHPADBYTES == 1
#define GLYPHWIDTHBYTESPADDED(pci) (GLYPHWIDTHBYTES(pci))
#define PADGLYPHWIDTHBYTES(w) (((w)+7)>>3)
#endif
#if GLYPHPADBYTES == 2
#define GLYPHWIDTHBYTESPADDED(pci) ((GLYPHWIDTHBYTES(pci)+1) & ~0x1)
#define PADGLYPHWIDTHBYTES(w) (((((w)+7)>>3)+1) & ~0x1)
#endif
#if GLYPHPADBYTES == 4
#define GLYPHWIDTHBYTESPADDED(pci) ((GLYPHWIDTHBYTES(pci)+3) & ~0x3)
#define PADGLYPHWIDTHBYTES(w) (((((w)+7)>>3)+3) & ~0x3)
#endif
#if GLYPHPADBYTES == 8 /* for a cray? */
#define GLYPHWIDTHBYTESPADDED(pci) ((GLYPHWIDTHBYTES(pci)+7) & ~0x7)
#define PADGLYPHWIDTHBYTES(w) (((((w)+7)>>3)+7) & ~0x7)
#endif
typedef struct _FontProp *FontPropPtr;
typedef struct _CharInfo *CharInfoPtr;
typedef struct _FontInfo *FontInfoPtr;
typedef unsigned int DrawDirection;
typedef struct _ExtentInfo *ExtentInfoPtr;
#endif /* FONT_H */

View file

@ -0,0 +1,122 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: fontstruct.h /main/3 1996/04/08 15:58:01 cde-fuj $ */
/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
(c) Copyright 1995 FUJITSU LIMITED
This is source code modified by FUJITSU LIMITED under the Joint
Development Agreement for the CDEnext PST.
This is unpublished proprietary source code of FUJITSU LIMITED
******************************************************************/
#ifndef FONTSTRUCT_H
#define FONTSTRUCT_H 1
#include "font.h"
#include "misc.h"
typedef struct _CharInfo {
xCharInfo metrics; /* info preformatted for Queries */
unsigned byteOffset:24; /* byte offset of the raster from pGlyphs */
Bool exists:1; /* true iff glyph exists for this char */
unsigned pad:7; /* must be zero for now */
} CharInfoRec;
typedef struct _FontInfo {
unsigned int version1; /* version stamp */
unsigned int allExist;
unsigned int drawDirection;
unsigned int noOverlap; /* true if:
* max(rightSideBearing-characterWidth)
* <= minbounds->metrics.leftSideBearing
*/
unsigned int constantMetrics;
unsigned int terminalFont; /* Should be deprecated! true if:
constant metrics &&
leftSideBearing == 0 &&
rightSideBearing == characterWidth &&
ascent == fontAscent &&
descent == fontDescent
*/
unsigned int linear:1; /* true if firstRow == lastRow */
unsigned int constantWidth:1; /* true if minbounds->metrics.characterWidth
* == maxbounds->metrics.characterWidth
*/
unsigned int inkInside:1; /* true if for all defined glyphs:
* leftSideBearing >= 0 &&
* rightSideBearing <= characterWidth &&
* -fontDescent <= ascent <= fontAscent &&
* -fontAscent <= descent <= fontDescent
*/
unsigned int inkMetrics:1; /* ink metrics != bitmap metrics */
/* used with terminalFont */
/* see font's pInk{CI,Min,Max} */
unsigned int padding:28;
unsigned int firstCol;
unsigned int lastCol;
unsigned int firstRow;
unsigned int lastRow;
unsigned int nProps;
unsigned int lenStrings; /* length in bytes of string table */
unsigned int chDefault; /* default character */
int fontDescent; /* minimum for quality typography */
int fontAscent; /* minimum for quality typography */
CharInfoRec minbounds; /* MIN of glyph metrics over all chars */
CharInfoRec maxbounds; /* MAX of glyph metrics over all chars */
unsigned int pixDepth; /* intensity bits per pixel */
unsigned int glyphSets; /* number of sets of glyphs, for
sub-pixel positioning */
unsigned int version2; /* version stamp double-check */
} FontInfoRec;
typedef struct _ExtentInfo {
DrawDirection drawDirection;
int fontAscent;
int fontDescent;
int overallAscent;
int overallDescent;
int overallWidth;
int overallLeft;
int overallRight;
} ExtentInfoRec;
#endif /* FONTSTRUCT_H */

View file

@ -0,0 +1,181 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: misc.h /main/7 1996/04/08 15:58:10 cde-fuj $ */
/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
(c) Copyright 1995 FUJITSU LIMITED
This is source code modified by FUJITSU LIMITED under the Joint
Development Agreement for the CDEnext PST.
This is unpublished proprietary source code of FUJITSU LIMITED
******************************************************************/
#ifndef MISC_H
#define MISC_H 1
/*
* X internal definitions
*
*/
extern unsigned long globalSerialNumber;
extern unsigned long serverGeneration;
#ifndef NULL
#if __STDC__ && !NOSTDHDRS
#include <stddef.h>
#else
#define NULL 0
#endif
#endif
#define MAXSCREENS 3
#define MAXCLIENTS 128
#define MAXFORMATS 8
#define MAXVISUALS_PER_SCREEN 50
typedef unsigned char *pointer;
typedef int Bool;
typedef unsigned long PIXEL;
typedef unsigned long ATOM;
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#include "os.h" /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */
#define NullBox ((BoxPtr)0)
#define MILLI_PER_MIN (1000 * 60)
#define MILLI_PER_SECOND (1000)
/* this next is used with None and ParentRelative to tell
PaintWin() what to use to paint the background. Also used
in the macro IS_VALID_PIXMAP */
#define USE_BACKGROUND_PIXEL 3
#define USE_BORDER_PIXEL 3
/* byte swap a long literal */
#define lswapl(x) ((((x) & 0xff) << 24) |\
(((x) & 0xff00) << 8) |\
(((x) & 0xff0000) >> 8) |\
(((x) >> 24) & 0xff))
/* byte swap a short literal */
#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))
#ifndef abs
#define abs(a) ((a) > 0 ? (a) : -(a))
#endif
#ifndef fabs
#define fabs(a) ((a) > 0.0 ? (a) : -(a)) /* floating absolute value */
#endif
#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
/* this assumes b > 0 */
#define modulus(a, b, d) if (((d) = (a) % (b)) < 0) (d) += (b)
/*
* return the least significant bit in x which is set
*
* This works on 1's complement and 2's complement machines.
* If you care about the extra instruction on 2's complement
* machines, change to ((x) & (-(x)))
*/
#define lowbit(x) ((x) & (~(x) + 1))
#define MAXSHORT 32767
#define MINSHORT -MAXSHORT
/* some macros to help swap requests, replies, and events */
#define LengthRestB(stuff) \
(((unsigned long)stuff->length << 2) - sizeof(*stuff))
#define LengthRestS(stuff) \
(((unsigned long)stuff->length << 1) - (sizeof(*stuff) >> 1))
#define LengthRestL(stuff) \
((unsigned long)stuff->length - (sizeof(*stuff) >> 2))
#define SwapRestS(stuff) \
SwapShorts((short *)(stuff + 1), LengthRestS(stuff))
#define SwapRestL(stuff) \
SwapLongs((long *)(stuff + 1), LengthRestL(stuff))
/* byte swap a long */
#define swapl(x, n) n = ((char *) (x))[0];\
((char *) (x))[0] = ((char *) (x))[3];\
((char *) (x))[3] = n;\
n = ((char *) (x))[1];\
((char *) (x))[1] = ((char *) (x))[2];\
((char *) (x))[2] = n;
/* byte swap a short */
#define swaps(x, n) n = ((char *) (x))[0];\
((char *) (x))[0] = ((char *) (x))[1];\
((char *) (x))[1] = n
/* copy long from src to dst byteswapping on the way */
#define cpswapl(src, dst) \
((char *)&(dst))[0] = ((char *) &(src))[3];\
((char *)&(dst))[1] = ((char *) &(src))[2];\
((char *)&(dst))[2] = ((char *) &(src))[1];\
((char *)&(dst))[3] = ((char *) &(src))[0];
/* copy short from src to dst byteswapping on the way */
#define cpswaps(src, dst)\
((char *) &(dst))[0] = ((char *) &(src))[1];\
((char *) &(dst))[1] = ((char *) &(src))[0];
extern void SwapLongs();
extern void SwapShorts();
typedef struct _DDXPoint *DDXPointPtr;
typedef struct _Box *BoxPtr;
#endif /* MISC_H */

View file

@ -0,0 +1,169 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: os.h /main/6 1996/05/28 15:33:04 ageorge $ */
/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
(c) Copyright 1995 FUJITSU LIMITED
This is source code modified by FUJITSU LIMITED under the Joint
Development Agreement for the CDEnext PST.
This is unpublished proprietary source code of FUJITSU LIMITED
******************************************************************/
#ifndef OS_H
#define OS_H
#include "misc.h"
#ifdef INCLUDE_ALLOCA_H
#include <alloca.h>
#endif
#define NullFID ((FID) 0)
#define SCREEN_SAVER_ON 0
#define SCREEN_SAVER_OFF 1
#define SCREEN_SAVER_FORCER 2
#if defined(stellar)
#define MAX_REQUEST_SIZE 65535
#else
#define MAX_REQUEST_SIZE 16384
#endif
typedef pointer FID;
typedef struct _FontPathRec *FontPathPtr;
typedef struct _NewClientRec *NewClientPtr;
#ifndef NO_ALLOCA
/*
* os-dependent definition of local allocation and deallocation
* If you want something other than Xalloc/Xfree for ALLOCATE/DEALLOCATE
* LOCAL then you add that in here.
*/
#if defined(__HIGHC__)
extern char *alloca();
#if HCVERSION < 21003
#define ALLOCATE_LOCAL(size) alloca((int)(size))
pragma on(alloca);
#else /* HCVERSION >= 21003 */
#define ALLOCATE_LOCAL(size) _Alloca((int)(size))
#endif /* HCVERSION < 21003 */
#define DEALLOCATE_LOCAL(ptr) /* as nothing */
#endif /* defined(__HIGHC__) */
#if defined(__GNUC__)
#if !defined(__linux__)
#ifdef alloca
#undef alloca
#endif
#define alloca ___builtin_alloca
#endif
#define ALLOCATE_LOCAL(size) alloca((int)(size))
#define DEALLOCATE_LOCAL(ptr) /* as nothing */
#else /* ! __GNUC__ */
/*
* warning: mips alloca is unsuitable in the server, do not use.
*/
#if defined(vax) || defined(sun) || defined(stellar)
/*
* Some System V boxes extract alloca.o from /lib/libPW.a; if you
* decide that you don't want to use alloca, you might want to fix
* ../os/4.2bsd/Imakefile
*/
char *alloca();
#define ALLOCATE_LOCAL(size) alloca((int)(size))
#define DEALLOCATE_LOCAL(ptr) /* as nothing */
#endif /* who does alloca */
#endif /* __GNUC__ */
#endif /* NO_ALLOCA */
#ifndef ALLOCATE_LOCAL
#define ALLOCATE_LOCAL(size) Xalloc((unsigned long)(size))
#define DEALLOCATE_LOCAL(ptr) Xfree((pointer)(ptr))
#endif /* ALLOCATE_LOCAL */
#define xalloc(size) Xalloc((unsigned long)(size))
#define xrealloc(ptr, size) Xrealloc((pointer)(ptr), (unsigned long)(size))
#define xfree(ptr) Xfree((pointer)(ptr))
int ReadRequestFromClient();
#ifndef strcat
char *strcat();
#endif
#ifndef strncat
char *strncat();
#endif
#ifndef strcpy
char *strcpy();
#endif
#ifndef strncpy
char *strncpy();
#endif
Bool CloseDownConnection();
FontPathPtr GetFontPath();
FontPathPtr ExpandFontNamePattern();
FID FiOpenForRead();
void CreateWellKnownSockets();
int SetDefaultFontPath();
void FreeFontRecord();
int SetFontPath();
void ErrorF();
void Error();
void FatalError();
void ProcessCommandLine();
void Xfree();
void FlushAllOutput();
void FlushIfCriticalOutputPending();
unsigned long *Xalloc();
unsigned long *Xrealloc();
long GetTimeInMillis();
#endif /* OS_H */

View file

@ -0,0 +1,107 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: pcf.h /main/2 1996/02/10 16:25:46 cde-fuj $ */
/*
*
* Copyright 1990 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
(c) Copyright 1995 FUJITSU LIMITED
This is source code modified by FUJITSU LIMITED under the Joint
Development Agreement for the CDEnext PST.
This is unpublished proprietary source code of FUJITSU LIMITED
*/
#ifndef _PCF_H_
#define _PCF_H_
/*
* Information used to read/write PCF fonts
*/
typedef struct _PCFTable {
CARD32 type;
CARD32 format;
CARD32 size;
CARD32 offset;
} PCFTableRec, *PCFTablePtr;
#define PCF_FILE_VERSION (('p'<<24)|('c'<<16)|('f'<<8)|1)
#define PCF_FORMAT_MASK 0xffffff00
#define PCF_DEFAULT_FORMAT 0x00000000
#define PCF_INKBOUNDS 0x00000200
#define PCF_ACCEL_W_INKBOUNDS 0x00000100
#define PCF_COMPRESSED_METRICS 0x00000100
#define PCF_FORMAT_MATCH(a,b) (((a)&PCF_FORMAT_MASK) == ((b)&PCF_FORMAT_MASK))
#define PCF_GLYPH_PAD_MASK (3<<0)
#define PCF_BYTE_MASK (1<<2)
#define PCF_BIT_MASK (1<<3)
#define PCF_SCAN_UNIT_MASK (3<<4)
#define PCF_BYTE_ORDER(f) (((f) & PCF_BYTE_MASK)?MSBFirst:LSBFirst)
#define PCF_BIT_ORDER(f) (((f) & PCF_BIT_MASK)?MSBFirst:LSBFirst)
#define PCF_GLYPH_PAD_INDEX(f) ((f) & PCF_GLYPH_PAD_MASK)
#define PCF_GLYPH_PAD(f) (1<<PCF_GLYPH_PAD_INDEX(f))
#define PCF_SCAN_UNIT_INDEX(f) (((f) & PCF_SCAN_UNIT_MASK) >> 4)
#define PCF_SCAN_UNIT(f) (1<<PCF_SCAN_UNIT_INDEX(f))
#define PCF_FORMAT_BITS(f) ((f) & (PCF_GLYPH_PAD_MASK|PCF_BYTE_MASK|PCF_BIT_MASK|PCF_SCAN_UNIT_MASK))
#define PCF_SIZE_TO_INDEX(s) ((s) == 4 ? 2 : (s) == 2 ? 1 : 0)
#define PCF_INDEX_TO_SIZE(b) (1<<b)
#define PCF_FORMAT(bit,byte,glyph,scan) (\
(PCF_SIZE_TO_INDEX(scan) << 4) | \
(((bit) == MSBFirst ? 1 : 0) << 3) | \
(((byte) == MSBFirst ? 1 : 0) << 2) | \
(PCF_SIZE_TO_INDEX(glyph) << 0))
#define PCF_PROPERTIES (1<<0)
#define PCF_ACCELERATORS (1<<1)
#define PCF_METRICS (1<<2)
#define PCF_BITMAPS (1<<3)
#define PCF_INK_METRICS (1<<4)
#define PCF_BDF_ENCODINGS (1<<5)
#define PCF_SWIDTHS (1<<6)
#define PCF_GLYPH_NAMES (1<<7)
#define PCF_BDF_ACCELERATORS (1<<8)
#endif /* _PCF_H_ */

View file

@ -0,0 +1,294 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: servermd.h /main/2 1996/04/08 15:58:29 cde-fuj $ */
/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
(c) Copyright 1995 FUJITSU LIMITED
This is source code modified by FUJITSU LIMITED under the Joint
Development Agreement for the CDEnext PST.
This is unpublished proprietary source code of FUJITSU LIMITED
******************************************************************/
#ifndef SERVERMD_H
#define SERVERMD_H 1
/*
* The vendor string identifies the vendor responsible for the
* server executable.
*/
#ifndef VENDOR_STRING
#define VENDOR_STRING "MIT X Consortium"
#endif
/*
* The vendor release number identifies, for the purpose of submitting
* traceable bug reports, the release number of software produced
* by the vendor.
*/
#ifndef VENDOR_RELEASE
#define VENDOR_RELEASE 4
#endif
/*
* Machine dependent values:
* GLYPHPADBYTES should be chosen with consideration for the space-time
* trade-off. Padding to 0 bytes means that there is no wasted space
* in the font bitmaps (both on disk and in memory), but that access of
* the bitmaps will cause odd-address memory references. Padding to
* 2 bytes would ensure even address memory references and would
* be suitable for a 68010-class machine, but at the expense of wasted
* space in the font bitmaps. Padding to 4 bytes would be good
* for real 32 bit machines, etc. Be sure that you tell the font
* compiler what kind of padding you want because its defines are
* kept separate from this. See server/include/font.h for how
* GLYPHPADBYTES is used.
*
* Along with this, you should choose an appropriate value for
* GETLEFTBITS_ALIGNMENT, which is used in ddx/mfb/maskbits.h. This
* constant choses what kind of memory references are guarenteed during
* font access; either 1, 2 or 4, for byte, word or longword access,
* respectively. For instance, if you have decided to to have
* GLYPHPADBYTES == 4, then it is pointless for you to have a
* GETLEFTBITS_ALIGNMENT > 1, because the padding of the fonts has already
* guarenteed you that your fonts are longword aligned. On the other
* hand, even if you have chosen GLYPHPADBYTES == 1 to save space, you may
* also decide that the computing involved in aligning the pointer is more
* costly than an odd-address access; you choose GETLEFTBITS_ALIGNMENT == 1.
*
* Next, choose the tuning parameters which are appropriate for your
* hardware; these modify the behaviour of the raw frame buffer code
* in ddx/mfb and ddx/cfb. Defining these incorrectly will not cause
* the server to run incorrectly, but defining these correctly will
* cause some noticeable speed improvements:
*
* AVOID_MEMORY_READ - (8-bit cfb only)
* When stippling pixels on the screen (polytext and pushpixels),
* don't read long words from the display and mask in the
* appropriate values. Rather, perform multiple byte/short/long
* writes as appropriate. This option uses many more instructions
* but runs much faster when the destination is much slower than
* the CPU and at least 1 level of write buffer is availible (2
* is much better). Defined currently for SPARC and MIPS.
*
* FAST_CONSTANT_OFFSET_MODE - (cfb and mfb)
* This define is used on machines which have no auto-increment
* addressing mode, but do have an effectively free constant-offset
* addressing mode. Currently defined for MIPS and SPARC, even though
* I remember the cg6 as performing better without it (cg3 definitely
* performs better with it).
*
* LARGE_INSTRUCTION_CACHE -
* This define increases the number of times some loops are
* unrolled. On 68020 machines (with 256 bytes of i-cache),
* this define will slow execution down as instructions miss
* the cache frequently. On machines with real i-caches, this
* reduces loop overhead, causing a slight performance improvement.
* Currently defined for MIPS and SPARC
*
* FAST_UNALIGNED_READS -
* For machines with more memory bandwidth than CPU, this
* define uses unaligned reads for 8-bit BitBLT instead of doing
* aligned reads and combining the results with shifts and
* logical-ors. Currently defined for 68020 and vax.
* PLENTIFUL_REGISTERS -
* For machines with > 20 registers. Currently used for
* unrolling the text painting code a bit more. Currently
* defined for MIPS.
*/
#ifdef vax
#define IMAGE_BYTE_ORDER LSBFirst /* Values for the VAX only */
#define BITMAP_BIT_ORDER LSBFirst
#define GLYPHPADBYTES 1
#define GETLEFTBITS_ALIGNMENT 4
#define FAST_UNALIGNED_READS
#endif /* vax */
#ifdef sun
#if defined(sun386) || defined(sun5)
# define IMAGE_BYTE_ORDER LSBFirst /* Values for the SUN only */
# define BITMAP_BIT_ORDER LSBFirst
#else
# define IMAGE_BYTE_ORDER MSBFirst /* Values for the SUN only */
# define BITMAP_BIT_ORDER MSBFirst
#endif
#ifdef sparc
# define AVOID_MEMORY_READ
# define LARGE_INSTRUCTION_CACHE
# define FAST_CONSTANT_OFFSET_MODE
#endif
#ifdef mc68020
#define FAST_UNALIGNED_READS
#endif
#define GLYPHPADBYTES 4
#define GETLEFTBITS_ALIGNMENT 1
#endif /* sun */
#if defined(ibm032) || defined (ibm)
#ifdef i386
# define IMAGE_BYTE_ORDER LSBFirst /* Value for PS/2 only */
#else
# define IMAGE_BYTE_ORDER MSBFirst /* Values for the RT only*/
#endif
#define BITMAP_BIT_ORDER MSBFirst
#define GLYPHPADBYTES 1
#define GETLEFTBITS_ALIGNMENT 4
/* ibm pcc doesn't understand pragmas. */
#endif /* ibm */
#ifdef hpux
#define IMAGE_BYTE_ORDER MSBFirst /* Values for the HP only */
#define BITMAP_BIT_ORDER MSBFirst
#define GLYPHPADBYTES 2 /* to match product server */
#define GETLEFTBITS_ALIGNMENT 1
#endif /* hpux */
#if defined(M4315) || defined(M4317) || defined(M4319) || defined(M4330)
#define IMAGE_BYTE_ORDER MSBFirst /* Values for Pegasus only */
#define BITMAP_BIT_ORDER MSBFirst
#define GLYPHPADBYTES 4
#define GETLEFTBITS_ALIGNMENT 1
#define FAST_UNALIGNED_READS
#endif /* tektronix */
#ifdef mips
#ifdef MIPSEL
# define IMAGE_BYTE_ORDER LSBFirst /* Values for the PMAX only */
# define BITMAP_BIT_ORDER LSBFirst
# define GLYPHPADBYTES 4
# define GETLEFTBITS_ALIGNMENT 1
#else
# define IMAGE_BYTE_ORDER MSBFirst /* Values for the MIPS only */
# define BITMAP_BIT_ORDER MSBFirst
# define GLYPHPADBYTES 4
# define GETLEFTBITS_ALIGNMENT 1
#endif
#define AVOID_MEMORY_READ
#define FAST_CONSTANT_OFFSET_MODE
#define LARGE_INSTRUCTION_CACHE
#define PLENTIFUL_REGISTERS
#endif /* mips */
#ifdef stellar
#define IMAGE_BYTE_ORDER MSBFirst /* Values for the stellar only*/
#define BITMAP_BIT_ORDER MSBFirst
#define GLYPHPADBYTES 4
#define GETLEFTBITS_ALIGNMENT 4
/*
* Use SysV random number generator.
*/
#define random rand
#endif /* stellar */
/* size of buffer to use with GetImage, measured in bytes. There's obviously
* a trade-off between the amount of stack (or whatever ALLOCATE_LOCAL gives
* you) used and the number of times the ddx routine has to be called.
*
* for a 1024 x 864 bit monochrome screen with a 32 bit word we get
* 8192/4 words per buffer
* (1024/32) = 32 words per scanline
* 2048 words per buffer / 32 words per scanline = 64 scanlines per buffer
* 864 scanlines / 64 scanlines = 14 buffers to draw a full screen
*/
#if defined(stellar)
#define IMAGE_BUFSIZE (64*1024)
#else
#define IMAGE_BUFSIZE 8192
#endif
/* pad scanline to a longword */
#if defined(ibm) && defined(i386)
#define BITMAP_SCANLINE_UNIT 8
#else
#define BITMAP_SCANLINE_UNIT 32
#endif
#define BITMAP_SCANLINE_PAD 32
#define LOG2_BITMAP_PAD 5
#define LOG2_BYTES_PER_SCANLINE_PAD 2
/*
* This returns the number of padding units, for depth d and width w.
* For bitmaps this can be calculated with the macros above.
* Other depths require either grovelling over the formats field of the
* screenInfo or hardwired constants.
*/
typedef struct _PaddingInfo {
int padRoundUp; /* pixels per pad unit - 1 */
int padPixelsLog2; /* log 2 (pixels per pad unit) */
int padBytesLog2; /* log 2 (bytes per pad unit) */
} PaddingInfo;
extern PaddingInfo PixmapWidthPaddingInfo[];
#define PixmapWidthInPadUnits(w, d) \
(((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \
PixmapWidthPaddingInfo[d].padPixelsLog2)
/*
* Return the number of bytes to which a scanline of the given
* depth and width will be padded.
*/
#define PixmapBytePad(w, d) \
(PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2)
#endif /* SERVERMD_H */

View file

@ -0,0 +1,903 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: readpcf.c /main/5 1996/06/05 16:42:29 ageorge $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "FaLib.h"
#include "falfont.h"
#ifndef GLYPHPADOPTIONS
#define GLYPHPADOPTIONS 4
#endif
static CARD32 getLSB32();
static int getINT32();
static int getINT16();
static Bool seekToType();
static void getMetric();
static Bool getAccel();
int falInitReadPcf();
static void ByteSwap();
static void repadBits();
int falPcfGlyph();
void falGetPcfGSize();
int falInitReadPcfProp() ;
int falInitReadSnfProp() ;
int falReadGpfProp() ;
extern void BitOrderInvert() ;
extern void set_errfile_str() ;
static CARD32
getLSB32( p)
unsigned char *p;
{
CARD32 c;
c = *p++;
c |= (CARD32)(*p++) << 8;
c |= (CARD32)(*p++) << 16;
c |= (CARD32)(*p) << 24;
return c;
}
static int
getINT32( p, format)
unsigned char *p;
CARD32 format;
{
CARD32 c;
if (PCF_BYTE_ORDER(format) == MSBFirst) {
c = (CARD32)(*p++) << 24;
c |= (CARD32)(*p++) << 16;
c |= (CARD32)(*p++) << 8;
c |= (CARD32)(*p);
} else {
c = (CARD32)(*p++);
c |= (CARD32)(*p++) << 8;
c |= (CARD32)(*p++) << 16;
c |= (CARD32)(*p) << 24;
}
return (int)c;
}
static int
getINT16( p, format)
unsigned char *p;
CARD32 format;
{
CARD32 c;
if (PCF_BYTE_ORDER(format) == MSBFirst) {
c = (CARD32)(*p++) << 8;
c |= (CARD32)(*p);
} else {
c = (CARD32)(*p++);
c |= (CARD32)(*p) << 8;
}
return (int)c;
}
static Bool
seekToType( tables, ntables, type, formatp, sizep, offsetp)
PCFTablePtr tables;
int ntables;
CARD32 type;
CARD32 *formatp;
CARD32 *sizep;
CARD32 *offsetp;
{
int i;
for ( i = 0; i < ntables; i++) {
if ( getLSB32( (unsigned char *)&tables[i].type ) == type) {
if ( formatp)
*formatp = getLSB32( (unsigned char *)&tables[i].format);
if ( sizep)
*sizep = getLSB32( (unsigned char *)&tables[i].size);
if ( offsetp)
*offsetp = getLSB32( (unsigned char *)&tables[i].offset);
return(TRUE);
}
}
return(FALSE);
}
static void
getMetric( buf, format, metric)
caddr_t buf;
CARD32 format;
xCharInfo *metric;
{
metric->leftSideBearing = getINT16( (unsigned char *)buf, (CARD32)format);
buf += 2;
metric->rightSideBearing = getINT16( (unsigned char *)buf, (CARD32)format);
buf += 2;
metric->characterWidth = getINT16( (unsigned char *)buf, (CARD32)format);
buf += 2;
metric->ascent = getINT16( (unsigned char *)buf, (CARD32)format);
buf += 2;
metric->descent = getINT16( (unsigned char *)buf, (CARD32)format);
buf += 2;
metric->attributes = getINT16( (unsigned char *)buf, (CARD32)format);
buf += 2;
}
static Bool
getAccel( pFontInfo, maxink, buf_top, tables, ntables, type)
FontInfoPtr pFontInfo;
xCharInfo *maxink;
caddr_t buf_top;
PCFTablePtr tables;
int ntables;
CARD32 type;
{
CARD32 format;
CARD32 offset;
caddr_t buffer;
if ( !seekToType( tables, ntables, (CARD32)type, &format, (CARD32 *)NULL, &offset))
return FALSE;
buffer = buf_top + offset;
format = getLSB32( (unsigned char *)buffer );
buffer += 4;
if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT) &&
!PCF_FORMAT_MATCH(format, PCF_ACCEL_W_INKBOUNDS)) {
return FALSE;
}
pFontInfo->noOverlap = *buffer++;
pFontInfo->constantMetrics = *buffer++;
pFontInfo->terminalFont = *buffer++;
pFontInfo->constantWidth = *buffer++;
pFontInfo->inkInside = *buffer++;
pFontInfo->inkMetrics = *buffer++;
pFontInfo->drawDirection = *buffer++;
/* pFontInfo->anamorphic = FALSE; */
/* natural alignment */ buffer++;
pFontInfo->fontAscent = getINT32( (unsigned char *)buffer, (CARD32)format);
buffer += 4;
pFontInfo->fontDescent = getINT32( (unsigned char *)buffer, (CARD32)format);
buffer +=4;
/* pFontInfo->maxOverlap = getINT32( (unsigned char *)buffer, (CARD32)format); */ buffer += 4;
getMetric(buffer, format, &pFontInfo->minbounds.metrics);
buffer += 12;
getMetric(buffer, format, &pFontInfo->maxbounds.metrics);
buffer += 12;
if (PCF_FORMAT_MATCH(format, PCF_ACCEL_W_INKBOUNDS)) {
buffer += 12;
getMetric( buffer, format, maxink);
} else {
*maxink = pFontInfo->maxbounds.metrics;
}
return TRUE;
}
int
falInitReadPcf( pcfinf, buftop)
struct pcf_inf *pcfinf;
caddr_t buftop;
{
CARD32 format;
CARD32 offset;
CARD32 *bitmapSizes;
xCharInfo maxink;
caddr_t buffp;
if ( getLSB32( (unsigned char *)buftop ) != PCF_FILE_VERSION)
goto Bail;
pcfinf->ntables = getLSB32( (unsigned char *)(buftop + 4) );
pcfinf->tables = (PCFTablePtr)(buftop + 8);
if ( !getAccel( &pcfinf->info, &maxink, buftop, pcfinf->tables, pcfinf->ntables,
(CARD32)PCF_BDF_ACCELERATORS))
if ( !getAccel( &pcfinf->info, &maxink, buftop, pcfinf->tables, pcfinf->ntables,
(CARD32)PCF_ACCELERATORS))
goto Bail;
pcfinf->org_bounds = pcfinf->info.maxbounds.metrics;
if ( !seekToType( pcfinf->tables, pcfinf->ntables, (CARD32)PCF_BITMAPS,
&format, (CARD32 *)NULL, &offset))
goto Bail;
buffp = buftop + offset;
format = getLSB32( (unsigned char *)buffp );
buffp += 4;
if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
goto Bail;
pcfinf->nbitmaps = getINT32( (unsigned char *)buffp, (CARD32)format);
buffp += 4;
pcfinf->offsets = (CARD32 *)buffp;
buffp += sizeof( *pcfinf->offsets) * pcfinf->nbitmaps;
bitmapSizes = (CARD32 *)buffp;
pcfinf->sizebitmaps = getINT32( (unsigned char *)&bitmapSizes[PCF_GLYPH_PAD_INDEX(format)], (CARD32)format);
pcfinf->bmp_fmt = format;
buffp += sizeof( *bitmapSizes) * GLYPHPADOPTIONS;
pcfinf->bitmaps = buffp;
buffp += pcfinf->sizebitmaps;
if ( !seekToType( pcfinf->tables, pcfinf->ntables, (CARD32)PCF_BDF_ENCODINGS,
&format, (CARD32 *)NULL, &offset))
goto Bail;
buffp = buftop + offset;
format = getLSB32( (unsigned char *)buffp );
buffp += 4;
if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
goto Bail;
pcfinf->info.firstCol = getINT16( (unsigned char *)buffp, (CARD32)format);
buffp += 2;
pcfinf->info.lastCol = getINT16( (unsigned char *)buffp, (CARD32)format);
buffp += 2;
pcfinf->info.firstRow = getINT16( (unsigned char *)buffp, (CARD32)format);
buffp += 2;
pcfinf->info.lastRow = getINT16( (unsigned char *)buffp, (CARD32)format);
buffp += 2;
/*
pcfinf->info.defaultCh = getINT16( (unsigned char *)buffp, (CARD32)format); buffp += 2;
*/
pcfinf->info.chDefault = getINT16( (unsigned char *)buffp, (CARD32)format);
buffp += 2;
pcfinf->info.allExist = FALSE;
pcfinf->enc_fmt = format;
pcfinf->encodingOffsets = (CARD16 *)buffp;
return 0;
Bail:
return -1;
}
static void
ByteSwap( p, scan)
char *p;
int scan;
{
char w;
switch( scan) {
case 1:
break;
case 2:
w = *p;
*p = *(p + 1);
*(p + 1) = w;
break;
case 4:
w = *p;
*p = *(p + 3);
*(p + 3) = w;
w = *(p + 1);
*(p + 1) = *(p + 2);
*(p + 2) = w;
break;
}
}
static void
repadBits( src, format, width, height, dest)
char *src;
CARD32 format;
int width, height;
char *dest;
{
int bit, byte, glyph, scan;
int src_bytewidth, dest_bytewidth;
char work[8];
int i, j;
bit = PCF_BIT_ORDER( format);
byte = PCF_BYTE_ORDER( format);
glyph = PCF_GLYPH_PAD( format);
scan = PCF_SCAN_UNIT( format);
src_bytewidth = (( width + ( 8 * glyph ) - 1)/( 8 * glyph)) * glyph;
dest_bytewidth = ( width + 7) /8;
for ( i = 0; i < height; i++, src += src_bytewidth,
dest += dest_bytewidth) {
for ( j = 0; j < src_bytewidth; j += scan) {
memcpy( work, src + j, scan);
if ( bit == LSBFirst)
BitOrderInvert( work, scan );
if ( byte == LSBFirst)
ByteSwap( work, scan);
if (( j + scan) >= dest_bytewidth) {
memcpy( dest + j, work, dest_bytewidth - j);
break;
}
memcpy( dest + j, work, scan);
}
}
}
int
falPcfGlyph( glyph, finf, code)
char *glyph;
Oak_FontInf *finf;
int code;
{
int encode;
int inner_code;
char *bitmap;
int encodingOffset;
int codeRow, codeCol;
int bytewidth;
int bmp_adj, ptn_adj;
int adj_hi;
int cpy_height;
int bmp_height;
if ( !glyph){
fal_utyerrno = FAL_ERR_PARM ;
return FAL_ERROR ;
}
inner_code = code;
codeCol = inner_code & 0xff;
codeRow = (inner_code >> 8) & 0xff;
/* code check */
if (
((code < finf->start) || (code > finf->end))||
((codeCol < finf->pFinf->firstCol)||(codeCol > finf->pFinf->lastCol))||
((codeRow < finf->pFinf->firstRow)||(codeRow > finf->pFinf->lastRow))
) {
fal_utyexists = 1;
return(-1);
}
encode = (codeRow - finf->pFinf->firstRow) * ( finf->pFinf->lastCol - finf->pFinf->firstCol + 1);
encode += codeCol - finf->pFinf->firstCol;
encodingOffset = getINT16( (unsigned char *)(finf->pcfinf.encodingOffsets + encode), finf->pcfinf.enc_fmt);
if (encodingOffset == 0xFFFF) {
fal_utyexists = 1;
return(-1);
}
fal_utyexists = 0;
bitmap = finf->pcfinf.bitmaps + getINT32( (unsigned char *)(finf->pcfinf.offsets + encodingOffset), finf->pcfinf.bmp_fmt);
bmp_height = finf->pFinf->maxbounds.metrics.ascent
+ finf->pFinf->maxbounds.metrics.descent;
if (( adj_hi = finf->pFinf->maxbounds.metrics.ascent
- finf->pcfinf.org_bounds.ascent) > 0) {
bytewidth = 8 * PCF_GLYPH_PAD( finf->pcfinf.bmp_fmt);
bytewidth = (( finf->width + bytewidth - 1)/ bytewidth ) * PCF_GLYPH_PAD( finf->pcfinf.bmp_fmt);
bmp_adj = bytewidth * adj_hi;
ptn_adj = 0;
if (( cpy_height = bmp_height - adj_hi) > finf->height)
cpy_height = finf->height;
} else if ( adj_hi < 0) {
adj_hi *= -1;
bytewidth = ( finf->width + 7) / 8;
bmp_adj = 0;
ptn_adj = bytewidth * adj_hi;
if (( cpy_height = finf->height - adj_hi) > bmp_height)
cpy_height = bmp_height;
} else {
bmp_adj = 0;
ptn_adj = 0;
cpy_height = finf->height;
}
repadBits( bitmap + bmp_adj , finf->pcfinf.bmp_fmt, finf->width, cpy_height, glyph + ptn_adj);
return(0);
}
void
falGetPcfGSize( pcfinf, widthp, heightp)
struct pcf_inf *pcfinf;
unsigned int *widthp, *heightp;
{
unsigned int w, h;
w = pcfinf->org_bounds.rightSideBearing
- pcfinf->org_bounds.leftSideBearing;
h = pcfinf->org_bounds.ascent + pcfinf->org_bounds.descent;
*widthp = w;
*heightp = h;
}
/********************************************************
*
* functions for collect GPF file properties
*
*******************************************************/
#include "fontstruct.h"
static char *getPcfFontProp();
static char *getSnfFontProp();
/*
* read properties and get font style and
* letter size
*/
int
falReadFontProp( file, protect_key_data, databuff, islock )
char *file ; /* name of font file */
int protect_key_data ;
FalFontData *databuff ;
int islock ;
{
Oak_FontInf finf;
int fd ;
char *buf;
char *openfontfile;
struct stat st;
int rtn ;
/* initialezation */
openfontfile = file ;
/* read a condition of a fontfile */
if ( stat( openfontfile, &st ) < 0 ) {
set_errfile_str( fal_err_file, openfontfile ) ;
fal_utyerror = _FAL_STAT_ER;
fal_utyderror = errno;
fal_utyerrno = FAL_ERR_STAT ;
return FAL_ERROR;
}
if ( st.st_size < sizeof( FontInfoRec ) ) {
fal_utyerror = _FAL_FONT_ER;
fal_utyderror = 0;
fal_utyerrno = FAL_ERR_FONT ;
return FAL_ERROR;
}
/* open a fontfile */
if ( (fd = open( openfontfile, ((islock)? O_RDONLY : O_RDWR) )) < 0 ) {
switch( errno ) {
case EACCES :
return _FAL_TRY_NEXT ;
default :
set_errfile_str( fal_err_file, openfontfile ) ;
fal_utyerror = _FAL_OPEN_ER;
fal_utyderror = errno;
fal_utyerrno = FAL_ERR_FNT_OPN ;
return FAL_ERROR;
}
}
#if defined( SVR4 )
buf = (char *)mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if ( buf != (char *)-1 ) {
/* if "mmap" is normal end */
close( fd );
finf.ismmap = TRUE;
finf.fsize = st.st_size;
} else {
/* if "mmap" is abnormal end , try "read()" */
finf.ismmap = FALSE;
if ( !(buf = (char *)malloc(st.st_size)) ) {
fal_utyerror = _FAL_MALOC_ER;
fal_utyderror = 0;
fal_utyerrno = FAL_ERR_MALLOC ;
close( fd );
return FAL_ERROR;
}
if ( read(fd, buf, st.st_size) != st.st_size ) {
set_errfile_str( fal_err_file, openfontfile ) ;
fal_utyerror = _FAL_READ_ER;
fal_utyderror = errno;
fal_utyerrno = FAL_ERR_FNT_RD ;
free( buf );
close( fd );
return FAL_ERROR;
}
}
#else
finf.ismmap = FALSE;
if ( !(buf = (char *)malloc( st.st_size )) ) {
fal_utyerror = _FAL_MALOC_ER;
fal_utyderror = 0;
fal_utyerrno = FAL_ERR_MALLOC ;
close( fd );
return FAL_ERROR;
}
if ( read(fd, buf, st.st_size) != st.st_size ) {
set_errfile_str( fal_err_file, openfontfile ) ;
fal_utyerror = _FAL_READ_ER;
fal_utyderror = errno;
fal_utyerrno = FAL_ERR_FNT_RD ;
free( buf );
close( fd );
return FAL_ERROR;
}
#endif
finf.fname = openfontfile ;
finf.buf = buf ;
/*
* open GPF font file
*/
rtn = falReadGpfProp( FAL_UPDATE_FONTINFO, &finf, protect_key_data, databuff ) ;
#if defined( SVR4 )
if ( finf.ismmap == TRUE ) {
munmap( buf, finf.fsize );
} else {
free(buf);
close(fd);
}
#else
free( buf );
close( fd );
#endif
return( rtn ) ;
}
/*
* get properties of GPF format file
*/
int
falReadGpfProp( updflg, finf, protect_key_data, databuff )
int updflg ;
Oak_FontInf *finf;
int protect_key_data ;
FalFontData *databuff ;
{
char *openfontfile;
int rtn ;
/* initialize */
openfontfile = finf->fname ;
if( updflg == FAL_UPDATE_FONTINFO ) {
/* case of a PCF format font */
if ( strcmp( FILE_SUFFIX( openfontfile ), PCFSUFFIX ) == 0 ) {
finf->isFef = FALSE;
finf->isPcf = TRUE;
}
else /* case of a SNF format font */
{
FAL_READ_SNF_HEADER( finf, protect_key_data, fal_utyerror, fal_utyderror ) ;
}
} /* updflg */
/*
* get font properties
*/
if ( finf->isFef ){
/* read SNF format property */
if ( rtn = falInitReadSnfProp( finf, (caddr_t)finf->pFinf, databuff ) ) {
if( rtn == _FAL_TRY_NEXT ){
return( rtn ) ;
}
fal_utyerror = _FAL_FONT_ER;
fal_utyderror = 0;
return FAL_ERROR;
}
} else if ( finf->isPcf ) {
/* read PCF format property */
if ( rtn = falInitReadPcfProp( updflg, finf, databuff ) ) {
if( rtn == _FAL_TRY_NEXT ){
return( rtn ) ;
}
fal_utyerror = _FAL_FONT_ER;
fal_utyderror = 0;
return FAL_ERROR;
}
if( updflg == FAL_UPDATE_FONTINFO ) {
finf->pFinf = &finf->pcfinf.info;
finf->pCinf = NULL;
finf->pGlyphs = NULL;
}
} else {
fal_utyerror = _FAL_FONT_ER;
fal_utyderror = 0;
fal_utyerrno = FAL_ERR_FONT ;
return FAL_ERROR;
}
return(0);
}
/*
* get properties of PCF format file
*/
int
falInitReadPcfProp( updflg, finf, databuff )
int updflg ;
Oak_FontInf *finf;
FalFontData *databuff ;
{
struct pcf_inf *pcfinf;
caddr_t buftop;
xCharInfo maxink;
caddr_t buffp;
int lb, rb, as, ds ;
pcfinf = &finf->pcfinf ;
buftop = finf->buf ;
if ( getLSB32( (unsigned char *)buftop ) != PCF_FILE_VERSION)
return _FAL_TRY_NEXT ;
if( updflg == FAL_UPDATE_FONTINFO ) {
pcfinf->ntables = getLSB32( (unsigned char *)(buftop + 4) );
pcfinf->tables = (PCFTablePtr)(buftop + 8);
if ( !getAccel( &pcfinf->info, &maxink, buftop, pcfinf->tables,
pcfinf->ntables, (CARD32)PCF_BDF_ACCELERATORS)) {
if ( !getAccel( &pcfinf->info, &maxink, buftop, pcfinf->tables,
pcfinf->ntables, (CARD32)PCF_ACCELERATORS)) {
fal_utyerrno = FAL_ERR_FONT ;
goto Bail;
}
}
}
/*
* read property
*/
if( updflg == FAL_UPDATE_FONTINFO ) {
pcfinf->org_bounds = pcfinf->info.maxbounds.metrics;
}
lb = pcfinf->org_bounds.leftSideBearing ;
rb = pcfinf->org_bounds.rightSideBearing ;
as = pcfinf->org_bounds.ascent ;
ds = pcfinf->org_bounds.descent ;
databuff->size.w = rb - lb ;
databuff->size.h = as + ds ;
/*
* read property "FONT"
*/
if ( buffp = getPcfFontProp( buftop, pcfinf->tables,
pcfinf->ntables, "FONT" )) {
if( (databuff->xlfdname = (char *)strdup( buffp )) == (char *)NULL ){
fal_utyerrno = FAL_ERR_MALLOC ;
goto Bail;
}
}else{
set_errfile_str( fal_err_file, finf->fname ) ;
fal_utyerrno = FAL_ERR_PROP_FONT ;
return( _FAL_TRY_NEXT ) ;
}
/*
* read property "FAMILY_NAME"
*/
if ( buffp = getPcfFontProp( buftop, pcfinf->tables,
pcfinf->ntables, "FAMILY_NAME")) {
if( (databuff->style.name = (char *)strdup( buffp )) == NULL ){
fal_utyerrno = FAL_ERR_MALLOC ;
goto Bail ;
}
}else{
set_errfile_str( fal_err_file, finf->fname ) ;
fal_utyerrno = FAL_ERR_PROP_FNAME ;
return( _FAL_TRY_NEXT ) ;
}
return 0;
Bail:
return -1;
}
static char *
getPcfFontProp( buftop, tables, ntables, propname)
caddr_t buftop;
PCFTablePtr tables;
int ntables;
char *propname;
{
caddr_t buffer;
int name_ofs;
int i ;
int nprops;
char *propstr ;
CARD32 format, offset;
if ( !seekToType( tables, ntables, (CARD32)PCF_PROPERTIES, &format, (CARD32 *)NULL, &offset))
return NULL;
buffer = buftop + offset;
format = getLSB32( (unsigned char *)buffer );
buffer += 4;
if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT))
return NULL;
nprops = getINT32( (unsigned char *)buffer, (CARD32)format);
buffer += 4;
propstr = buffer + (4 * ((nprops * 9 + 3) / 4)) + 4;
for ( i=0; i < nprops ; i++ ) {
name_ofs = getINT32( (unsigned char *)buffer, (CARD32)format ) ;
buffer += 4 ; /* name */
if ( strcmp( propstr + name_ofs, propname) == 0) {
if ( *buffer) { /* isStringProp */
return( propstr + getINT32( (unsigned char *)(buffer + 1), (CARD32)format) );
}else{
return((char *)(intptr_t)getINT32( (unsigned char *)(buffer + 1), (CARD32)format) );
}
}
buffer += 5 ; /* isStringProp + value */
}
return( NULL);
}
/*
* get properties of SNF format file
*/
int
falInitReadSnfProp( finf, buftop, databuff )
Oak_FontInf *finf; /* pointer to the infomation structure */
caddr_t buftop; /* font file */
FalFontData *databuff ;
{
caddr_t stprop ;
int lb, rb, as, ds ;
char *propptr ;
char *fnt = NULL, *fam ;
int nprops, bitmapSize, num_chars ;
/* initialize pointer */
nprops = finf->pFinf->nProps ;
num_chars = ( finf->pFinf->lastRow - finf->pFinf->firstRow + 1 ) *
( finf->pFinf->lastCol - finf->pFinf->firstCol + 1 ) ;
bitmapSize = BYTESOFGLYPHINFO(finf->pFinf) ;
stprop = buftop ;
stprop += sizeof(FontInfoRec) ;
stprop += num_chars * sizeof(CharInfoRec) ;
stprop += bitmapSize ;
/*
* read property "FONTBOUNDINGBOX"
*/
lb = finf->pFinf->maxbounds.metrics.leftSideBearing ;
rb = finf->pFinf->maxbounds.metrics.rightSideBearing ;
as = finf->pFinf->maxbounds.metrics.ascent ;
ds = finf->pFinf->maxbounds.metrics.descent ;
/*
* read property "FONT"
*/
if ( propptr = getSnfFontProp( stprop, nprops, "FONT" )) {
if( (fnt = (char *)strdup( propptr )) == NULL ){
fal_utyerrno = FAL_ERR_MALLOC ;
goto Bail;
}
}else{
set_errfile_str( fal_err_file, finf->fname ) ;
fal_utyerrno = FAL_ERR_PROP_FONT ;
return( _FAL_TRY_NEXT ) ;
}
/*
* read property "FAMILY_NAME"
*/
if ( propptr = getSnfFontProp( stprop, nprops, "FAMILY_NAME")) {
if( (fam = (char *)strdup( propptr )) == NULL ){
fal_utyerrno = FAL_ERR_MALLOC ;
goto Bail ;
}
}else{
set_errfile_str( fal_err_file, finf->fname ) ;
fal_utyerrno = FAL_ERR_PROP_FNAME ;
free(fnt);
return( _FAL_TRY_NEXT ) ;
}
/*
* set data buffer
*/
databuff->size.w = rb - lb ;
databuff->size.h = as + ds ;
databuff->xlfdname = fnt ;
databuff->style.name = fam ;
return 0;
Bail:
free(fnt);
return -1;
}
static char *
getSnfFontProp( buftop, nprops, propname )
caddr_t buftop;
int nprops ;
char *propname;
{
caddr_t buffer;
int name_ofs;
int i ;
char *propstr ;
FontPropRec *ProcRec ;
ProcRec = (FontPropRec *)buftop ;
buffer = (char *)buftop ;
propstr = buffer + nprops * sizeof(FontPropRec) ;
for ( i=0; i < nprops ; i++, ProcRec++ ) {
name_ofs = ProcRec->name ;
if( strcmp( propstr + name_ofs, propname ) == 0 ){
if( ProcRec->indirect ){
return( propstr + ProcRec->value ) ;
}else{
return( (char *) (intptr_t) ProcRec->value ) ;
}
}
}
return( NULL);
}
/***********************< end of readpcf.c >********************/

View file

@ -0,0 +1,75 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: syncx.c /main/3 1996/07/04 02:32:52 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdio.h>
/* "fal" -> "X" */
/* GetFProp.c falGetFontProperty() : Xlib.h */
/* omDefault.c _falwcDefaultTextPerCharExtents(): omGeneric.c */
/* IntAtom.c falInternAtom() : Xlib.h */
/* Font.c falFreeFont() : Xlib.h */
/* FontInfo.c falFreeFontInfo() : Xlib.h */
/* TextToStr.c falFreeStringList() : Xlib.h */
/* FontNames.c falFreeFontNames() : Xlib.h */
/* Bool */ falGetFontProperty() { return 0 ; }
/* Status */ _falwcDefaultTextPerCharExtents(){ return 0 ; }
void _falmbDefaultDrawImageString() { return ; }
/* Atom */ falInternAtom() { return 0 ; }
int _falwcGenericDrawString() { return 0 ; }
char **_falParseBaseFontNameList() { return NULL ; }
/* XFontStruct * */ falLoadQueryFont() { return 0 ; }
falFreeFont() { return 0 ; }
falFreeFontInfo() { return 0 ; }
/* char ** */ falListFonts() { return 0 ; }
void _falmbGenericDrawImageString() { return ; }
void _falwcDefaultDrawImageString() { return ; }
int _falmbDefaultDrawString() { return 0 ; }
int _falmbGenericTextEscapement() { return 0 ; }
void falFreeStringList() { return ; }
/* falrmStringToQuark() { return 0 ; } */
/* falrmPermStringToQuark() { return 0 ; } */
int _falwcDefaultDrawString() { return 0 ; }
/* char * */ falGetAtomName() { return 0 ; }
int _falwcGenericTextExtents() { return 0 ; }
int _falmbGenericTextExtents() { return 0 ; }
void _falwcGenericDrawImageString() { return ; }
falFreeFontNames() { return 0 ; }
/* falrmQuarkToString() { return 0 ; } */
int _falwcDefaultTextExtents() { return 0 ; }
/* Status */ _falmbGenericTextPerCharExtents(){ return 0 ; }
int _falmbDefaultTextEscapement() { return 0 ; }
int _falwcGenericTextEscapement() { return 0 ; }
int _falmbDefaultTextExtents() { return 0 ; }
/* char ** */ falListFontsWithInfo() { return 0 ; }
int _falwcDefaultTextEscapement() { return 0 ; }
/* Status */ _falwcGenericTextPerCharExtents(){ return 0 ; }
/* _fallcMapOSLocaleName() { return 0 ; } */
int _falmbGenericDrawString() { return 0 ; }
/* Status */ _falmbDefaultTextPerCharExtents(){ return 0 ; }

View file

@ -0,0 +1,77 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: syncx.h /main/2 1996/06/25 20:04:52 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include "_falutil.h"
extern XrmQuark falrmStringToQuark(
#if NeedFunctionPrototypes
_Xconst char* /* string */
#endif
);
extern XrmString falrmQuarkToString(
#if NeedFunctionPrototypes
XrmQuark /* quark */
#endif
);
extern char *falGetAtomName(
#if NeedFunctionPrototypes
Display* /* display */,
Atom /* atom */
#endif
);
extern char **falListFonts(
#if NeedFunctionPrototypes
Display* /* display */,
_Xconst char* /* pattern */,
int /* maxnames */,
int* /* actual_count_return */
#endif
);
extern char **falListFontsWithInfo(
#if NeedFunctionPrototypes
Display* /* display */,
_Xconst char* /* pattern */,
int /* maxnames */,
int* /* count_return */,
XFontStruct** /* info_return */
#endif
);
extern XFontStruct *falLoadQueryFont(
#if NeedFunctionPrototypes
Display* /* display */,
_Xconst char* /* name */
#endif
);

View file

@ -0,0 +1,32 @@
XCOMM $XConsortium: Imakefile /main/5 1996/09/09 11:20:01 drk $
#define DoNormalLib YES
#define DoSharedLib NO
#define DoDebugLib NO
#define DoProfileLib NO
#define LibName oakfuty
#define LibHeaders NO
#define LibInstall NO
FONTLIST = /config
OPT1 = -DDEFAULT_CODESET='"'3'"'
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"'
OPT4 = -DDTUDCFONTSLISTDIR='"'$(CDE_INSTALLATION_TOP)$(FONTLIST)'"'
OPT5 = -DDEFAULT_TMPPATH='"'/var/tmp/'"'
DEFINES = $(OPT1) $(OPT2) $(OPT3) $(OPT4) $(OPT5)
INCLUDES = -I../include -I../libfal/include -I../libfal
SRCS = oakfuty.c getfname.c lock.c
OBJS = oakfuty.o getfname.o lock.o
#include <Library.tmpl>
DependTarget()

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more