This commit is contained in:
cvs
2003-03-13 14:03:07 +00:00
parent 9a5bd901d8
commit 731e48d920
6 changed files with 121 additions and 103 deletions

View File

@ -8,7 +8,7 @@
typedef struct { char *instr; char *host; int port; char *user; int cod; } Instrument;
static Instrument list[]={
{ "DMC", "lnsa05.psi.ch", 9753, "DMC" , 1},
{ "TOPSI", "lnsa07.psi.ch", 9753, "TOPSI" , 1},
{ "TOPSI", "pc4120.psi.ch", 9753, "TOPSI" , 1},
{ "SANS", "lnsa10.psi.ch", 9753, "SANS" , 1},
{ "HRPT", "lnsa11.psi.ch", 9753, "HRPT" , 1},
{ "TRICS", "lnsa18.psi.ch", 9753, "TRICS" , 1},

37
tecs/make_opt Normal file
View File

@ -0,0 +1,37 @@
#---------------------------------------------------------------------------
# Makefile options for the TECS Client library and TecsServer
# for Redhat linux on llc3 or llc4
#
# Markus Zolliker, March 2003
#--------------------------------------------------------------------------
SINQ=/afs/psi.ch/project/sinq/linux
SICS=..
# -- GNU make
# -- all prerequisites:
Q=$^
# -- Fortran source:
F=$<
# -- C source
C=$<
CC = gcc
FC = g77
CFLAGS = -DLINUX -g
FFLAGS = -u -fvxt -g
ARFLAGS = cr
# FORTIFYOBJ = fortify.o
# -- system dependent routines
SYS_FILE =sys_linux
# -- PGPLOT library
PGLIB =$(SINQ)/pgplot/libpgplot.a -L/usr/X11R6/lib -lX11
# -- library for ASYNSRV
HARDSUPLIB=$(SICS)/hardsup/libhlib.a
# -- readline library
RDLIB =-lreadline -ltermcap

69
tecs/make_tecs Normal file
View File

@ -0,0 +1,69 @@
#---------------------------------------------------------------------------
# Makefile for the TECS Client library and TecsServer
#
# Markus Zolliker, March 2000
# may now be used on different systems without change M.Z.01.2002
# included in a machine-specific makefile
#--------------------------------------------------------------------------
include make_opt
LIBR_OBJ =coc_util.o myc_err.o myc_str.o myc_buf.o myc_time.o \
$(FORTIFYOBJ)
SERV_OBJ =tecs.o coc_server.o tecs_lsc.o tecs_serial.o coc_logfile.o \
tecs_data.o $(LIBR_OBJ)
CLI_OBJ =tecs_cli.o coc_client.o $(LIBR_OBJ)
TCLI_OBJ =$(SYS_FILE).o $(SYS_FILE)_c.o $(CLI_OBJ)
TECLI_OBJ =tecs_client.o tecs_plot.o sys_util.o str.o instr_hosts.o \
$(TCLI_OBJ)
.f.o:
$(FC) $(FFLAGS) -c $F
.c.o:
$(CC) $(CFLAGS) -c $C
default: libtecsl.a
all: libtecsl.a TecsServer TecsClient keep_running
test: tecs_cli.c
echo $(VPATH) $C
libtecsl.a: $(CLI_OBJ)
- rm $@
$(AR) $(ARFLAGS) $@ $Q
ranlib $@
TecsServer: $(SERV_OBJ)
$(CC) $(CFLAGS) -o $@ $Q -lm $(HARDSUPLIB)
TecsClient: $(TECLI_OBJ)
$(FC) -o $@ $Q $(PGLIB) $(RDLIB)
libtecs.so: tecs_c.c $(CLI_OBJ)
$(CC) $(CFLAGS) -shared -o $@ $Q
tecs_serial.o: tecs_serial.c
$(CC) $(CFLAGS) -I$(SICS)/hardsup -c $C
six: six.c term.c sys_select.c libtecsl.a
$(CC) $(CFLAGS) -o $@ $Q
rstart: rstart.c myc_str.o myc_err.o instr_hosts.o
$(CC) $(CFLAGS) -o $@ $Q
serverd: serverd.c myc_str.o myc_err.o coc_util.o myc_buf.o
$(CC) $(CFLAGS) -o $@ $Q
starts: starts.c myc_str.o myc_err.o coc_util.o myc_buf.o
$(CC) $(CFLAGS) -o $@ $Q
keep_running: keep_running.c
$(CC) $(CFLAGS) -o $@ $Q
clean:
- rm *.o
- rm *.a
- rm TecsServer
- rm TecsClient

View File

@ -1,94 +1 @@
#---------------------------------------------------------------------------
# Makefile for the TECS Client library and TecsServer
#
# Markus Zolliker, March 2000
# may now be used on different systems without change M.Z.01.2002
#--------------------------------------------------------------------------
#------------ for DigitalUnix (add -DFORTIFY to CC_... for fortified version)
OPT_$(OSTYPE)=ao
ao_CC=cc -std1 -g -warnprotos -I../ -I. -I../hardsup
ao_FOR=f77 -u -g
ao_TECLI_LIB=-L/data/lnslib/lib -lpgplot -lX11 -lXm -so_archive
ao_SYS_FILE=sys_aunix
#---------- for Redhat linux with tcsh (rita2)
OPT_($OSTYPE)=lr
lr_CC= gcc -I/usr/local/include -I. -I../ -I../hardsup -DLINUX -g
lr_FOR= g77 -u -fvxt -g
lr_SYS_FILE=sys_linux
lr_TECLI_LIB=pgplot/libpgplot.a -L/usr/X11R6/lib -lX11
#------------
#---------- for Redhat linux with bash on llc3 or llc4
OPT_$(HOSTNAME)=ll
ll_CC=$(lr_CC)
ll_FOR=$(lr_FOR)
ll_SYS_FILE=$(lr_SYS_FILE)
ll_TECLI_LIB=/afs/psi.ch/project/sinq/linux/pgplot/libpgplot.a \
-L/usr/X11R6/lib -lX11
#------------
OPT=$(OPT_llc3)$(OPT_llc4)$(OPT_linux)$(OPT_osf1)
CC =$($(OPT)_CC)
FOR =$($(OPT)_FOR)
TECLI_LIB=$($(OPT)_TECLI_LIB)
SYS_FILE =$($(OPT)_SYS_FILE)
LIBR_OBJ= coc_util.o myc_err.o myc_str.o myc_buf.o myc_time.o
SERV_OBJ= tecs.o coc_server.o tecs_lsc.o tecs_serial.o coc_logfile.o tecs_data.o $(LIBR_OBJ)
CLI_OBJ= tecs_cli.o coc_client.o $(LIBR_OBJ)
TCLI_OBJ= $(SYS_FILE).o $(SYS_FILE)_c.o $(CLI_OBJ)
TECLI_OBJ= tecs_client.o tecs_plot.o sys_util.o str.o instr_hosts.o $(TCLI_OBJ)
.f.o:
$(FOR) -c $*.f
.c.o:
$(CC) -c $*.c
libtecsl.a: $(CLI_OBJ)
- rm libtecsl.a
ar cr libtecsl.a $(CLI_OBJ)
ranlib libtecsl.a
test:
echo $(CC)x$(OPT)
all: libtecsl.a bin/TecsServer bin/TecsClient bin/keep_running
six: bin/six
bin/TecsServer: $(SERV_OBJ)
- rm bin/TecsServer
$(CC) -o bin/TecsServer $(SERV_OBJ) -lm -L../hardsup -lhlib
bin/TecsClient: $(TECLI_OBJ)
$(FOR) -o bin/TecsClient $(TECLI_OBJ) \
$(TECLI_LIB) -lreadline -ltermcap
bin/libtecs.so: tecs_c.c $(CLI_OBJ)
$(CC) -shared -o bin/libtecs.so tecs_c.c $(CLI_OBJ)
bin/six: six.c term.c sys_select.c libtecsl.a
$(CC) -o bin/six six.c term.c sys_select.c libtecsl.a
rstart: rstart.c myc_str.o myc_err.o instr_hosts.o
$(CC) -o rstart rstart.c myc_str.o myc_err.o instr_hosts.o
serverd: serverd.c myc_str.o myc_err.o coc_util.o myc_buf.o
$(CC) -o serverd serverd.c myc_str.o myc_err.o coc_util.o myc_buf.o -lm
starts: starts.c myc_str.o myc_err.o coc_util.o myc_buf.o
$(CC) -o starts starts.c myc_str.o myc_err.o coc_util.o myc_buf.o -lm
bin/keep_running: keep_running.c
$(CC) -o bin/keep_running keep_running.c
clean:
- rm *.o
- rm *.a
- rm bin/TecsServer
- rm bin/TecsClient
include make_tecs

View File

@ -4,12 +4,12 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "coc_util.h"
#include "myc_err.h"
#include "myc_str.h"
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include "coc_util.h"
#include "myc_err.h"
#include "myc_str.h"
#include "term.h"
int CocCreateSockAdr(

View File

@ -5,6 +5,7 @@
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include "myc_mem.h"
#include "sys_select.h"
#define ESC_TMO 1000
@ -133,8 +134,8 @@ static int hist_pos=0; /* position when scrolling through the history */
static int hist_end=0; /* end of history. Always history[hist_end]==NULL */
int term_get_line(char *buf, int size, int *pos, char *prompt, fd_set *mask) {
char key;
int i,j,l,iret;
char key, *lin;
int i,j,l,iret,buflen;
char tmp[512];
buf[size-1]='\0'; /* make sure buf is null terminated */
@ -174,10 +175,14 @@ int term_get_line(char *buf, int size, int *pos, char *prompt, fd_set *mask) {
/* fputs("\r\033[K", stdout); */
i=hist_end-1; if (i<0) i=HISTORY_LINES-1;
if ((history[i]==NULL || 0!=strcmp(history[i], buf)) && buf[0]!='\0') { /* do not save equal and empty lines */
history[hist_end]=malloc(strlen(buf)+1);
strncpy(history[hist_end], buf, size);
buflen=strlen(buf)+1;
lin=MALLOC(buflen);
strncpy(lin, buf, buflen);
history[hist_end]=lin;
hist_end++; if (hist_end>=HISTORY_LINES) hist_end=0;
if (history[hist_end]!=NULL) free(history[hist_end]); /* clear line at end of history */
if (history[hist_end]!=NULL) {
FREE(history[hist_end]); /* clear line at end of history */
}
history[hist_end]==NULL;
}
hist_pos=hist_end;