editlib.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1984-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* Pat Sullivan *
* *
***********************************************************************/
/*
* Miscellaneous routine needed for standalone library for edit modes
*/
#define read ______read
#include "io.h"
#include "terminal.h"
#include "history.h"
#include "edit.h"
#ifdef LDYNAMIC
# include "dlldefs.h"
#endif
#ifdef TIOCLBIC
# ifdef _sys_ioctl
# endif /* _sys_ioctl */
#endif /* TIOCLBIC */
#ifdef __EXPORT__
# define extern __EXPORT__
#endif
#define e_create "cannot create"
char opt_flag = 0;
static int editfd;
static int output = 0;
static char beenhere;
#if 0 /* almost always false. Makes a good block comment */
**********************************************************************
*
*
*
*
* edit_Init();
**********************************************************************
#endif /* 0 */
int edit_Init()
{
register char *sp;
if(!beenhere)
{
beenhere = 1;
hist_open();
if(sp)
{
}
}
return(1);
}
/*
* read routine with edit modes
*/
#ifdef LDYNAMIC
#ifdef __STDC__
#else
#endif
int fd;
void *buf;
size_t n;
{
ssize_t r;
static int here;
static int loop;
static void* dll;
static char msg[] = "ie: cannot intercept read() system call\n";
/*
* on some systems read() is globally bound by the
* runtime linker which may get us into a loop if
* another library intercepts read() between us and
* the system library
* on these systems the (dllnext)() call bypasses
* any intermediate libraries and gets directly to
* the system library
*/
if (here++)
{
if (loop++)
return -1;
goto bad;
readfn = 0;
}
if (!readfn)
{
goto bad;
goto bad;
}
here--;
return r;
bad:
return -1;
}
#endif /* LDYNAMIC */
int fd;
void *buf;
size_t n;
{
register int r, flag;
edit_Init();
switch(flag)
{
case EMACS:
case GMACS:
tty_set(-1);
break;
case VIRAW:
case EDITVI:
tty_set(-1);
break;
default:
{
#ifdef SYSCALL
#else
#endif /* SYSCALL */
}
}
{
/* write and flush history */
int c = buff[r];
buff[r] = 0;
hist_eof();
hist_flush();
buff[r] = c;
}
return(r);
}
#ifndef __EXPORT__
int fd;
void *buf;
size_t n;
{
}
int fd;
void *buf;
size_t n;
{
}
int fd;
void *buf;
size_t n;
{
}
int fd;
void *buf;
size_t n;
{
}
#endif
/*
* enable edit mode <mode> on file number <fd>
* the NOHIST bit can also be set to avoid writing the history file
* <fd> cannot be file two
*/
int fd;
int mode;
{
if(fd==2)
return(-1);
return(retval);
}
/*
* flush the output queue and reset the output stream
*/
register int fd;
{
return;
p_flush();
}
/*
* flush the output if necessary and null terminate the buffer
*/
void p_flush()
{
register int count;
{
/* leave previous buffer as a null terminated string */
}
}
/*
* print a given character
*/
void p_char(c)
register int c;
{
p_flush();
}
/*
* print a string optionally followed by a character
*/
register char *string;
int c;
{
register int cc;
while(1)
{
cc = c,c = 0;
else
string++;
if(cc==0)
break;
p_flush();
}
}
/*
* copy string a to string b and return pointer to end of string b
*/
char *ed_movstr(a,b)
register const char *a;
register char *b;
{
while(*b++ = *a++);
return(--b);
}
/*
* print and error message and exit
*/
{
p_char(':');
p_char(' ');
exit(2);
}
/*
* print a prompt
*/
register char *string;
{
register int c;
#ifdef TIOCLBIC
int mode;
#endif /* TIOCLBIC */
while(c= *string++)
{
*dp++ = c;
p_char(c);
}
*dp = 0;
p_flush();
}