* Copyright (c) 1988 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
"@(#) Copyright (c) 1988 The Regents of the University of California.\n\
static char sccsid
[] = "@(#)mset.c 4.2 (Berkeley) 4/26/91";
* this program outputs the user's 3270 mapping table in a form suitable
* for inclusion in the environment. Typically, this might be used
* setenv MAP3270 "`mset`"
#else /* defined(unix) */
#endif /* defined(unix) */
#include "../ctlr/function.h"
#include "../api/astosc.h"
#include "../general/globals.h"
char *match_end
; /* start of NEXT state's match string */
struct regstate
*forward
;
struct regstate
*backward
;
static struct regstate regstates
[500], *rptr
= 0; /* for sorting states */
static char array
[5000]; /* lot's of room */
static int toshell
= 0; /* export to shell */
static int numbchars
= 0; /* number of chars in envir. var */
if (strncmp(str1
, "PFK", 3) == 0 && strncmp(str2
, "PFK", 3) == 0
&& strlen(str1
) != strlen(str2
)) {
return(strlen(str1
) - strlen(str2
));
return(strcmp(str1
, str2
));
forwRegister(regptr
, sptr
)
struct regstate
*regptr
, *sptr
;
regptr
->forward
= sptr
->forward
;
(sptr
->forward
)->backward
= regptr
;
backRegister(regptr
, sptr
)
struct regstate
*regptr
, *sptr
;
regptr
->backward
= sptr
->backward
;
(sptr
->backward
)->forward
= regptr
;
register struct regstate
*regptr
;
static struct regstate
*pivot
= regstates
;
register struct regstate
*sptr
= pivot
;
if (pivot
== regstates
) { /* first time called */
regptr
->backward
= pivot
++;
pivot
->backward
= regptr
;
regptr
->forward
= pivot
++;
if ((check
= MyStrcmp(regptr
->result
, pivot
->result
)) < 0) {
if (sptr
->backward
== regstates
) {
backRegister(regptr
, sptr
);
check
= MyStrcmp(regptr
->result
, sptr
->result
);
forwRegister(regptr
, sptr
);
if ((sptr
->forward
)->result
== 0) {
forwRegister(regptr
, sptr
);
check
= MyStrcmp(regptr
->result
, sptr
->result
);
backRegister(regptr
, sptr
);
if (pivot
->forward
->result
) {
addString(strcount
, character
)
static char *string
= array
;
if (rptr
->match_start
== 0) {
rptr
->match_start
= string
;
for (i
=0; i
< strcount
; i
++) {
*string
++ = *((rptr
-1)->match_start
+i
);
static char savename
[20] = " "; /* for deciding if name is new */
printString(string
, begin
, tc_name
)
register char *st1
, *st2
;
static char suffix
= 'A';
int new = strcmp(savename
, tc_name
);
char delim
= new ? ';' : '|';
numbchars
+= 5 + (new ? strlen(tc_name
) : -1);
if (toshell
&& numbchars
> 1011) {
numbchars
= 5 + strlen(tc_name
);
printf(";\nsetenv MAP3270%c ", suffix
++);
if (strcmp(" ", savename
)) {
printf("%c%c", '\\', delim
);
printf("%s=%c'", tc_name
,'\\');
(void) strcpy(savename
, tc_name
);
if (toshell
&& numbchars
>= 1016) { /* leave room for ctrl and delim */
printf(";\nsetenv MAP3270%c ", suffix
++);
printf("%c%c", '\\', pchar
);
printf("%c%c%c%c", '\\', '\\', '\\', pchar
);
printf("%c%c", '\\', pchar
);
printf("%c%c%c", '\\', '\\', pchar
);
printf("%c%c", '\\', pchar
);
while ((pchar
= *st2
++) != 0) {
printf("%c%c", '\\', pchar
);
* print the string to here
* add the current match to the string,
recurse(strcount
, head
->next
);
if (head
->result
!= STATE_GOTO
) {
rptr
->match_end
= addString(strcount
, head
->match
);
rptr
->result
= astosc
[head
->result
].name
;
(void) addString(strcount
, head
->match
);
recurse(strcount
+1, head
->address
);
char *keybdPointer
= (char *) 0;
char *commandName
= argv
[0];
while ((argc
> 1) && (argv
[1][0] == '-')) {
if (!strcmp(argv
[1], "-picky")) {
} else if (!strcmp(argv
[1], "-shell")) {
fprintf(stderr
, "usage: %s [-picky] [-shell] [keyboardname]\n",
fprintf(stderr
, "usage: %s [-picky] [-shell] [keyboardname]\n",
head
= InitControl(keybdPointer
, picky
, ascii_to_index
);
keybdPointer
= getenv("KEYBD");
keybdPointer
= getenv("TERM");
keybdPointer
= "3a"; /* use 3a as the terminal */
printf("set noglob;\nsetenv MAP3270 ");
printf("%s{", keybdPointer
);
numbchars
= 2 + strlen(keybdPointer
);
/* now, run through the table registering entries */
for (rptr
= regstates
[0].forward
; rptr
->result
!= 0;
printString(rptr
->match_end
, rptr
->match_start
, rptr
->result
);
printf("%c;};\nunset noglob;\n", '\\');