- bug fix in coc_server.c
- bug fixes in tecs - new system to determine host:port in six and tecs_client
This commit is contained in:
32
tecs/term.c
32
tecs/term.c
@@ -5,6 +5,8 @@
|
||||
#include <sys/time.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "term.h"
|
||||
#include "myc_mem.h"
|
||||
#include "myc_str.h"
|
||||
@@ -184,9 +186,10 @@ static int hist_pos=0; /* position when scrolling through the history */
|
||||
static int hist_end=0; /* end of history. Always history[hist_end]==NULL */
|
||||
|
||||
FILE *term_open_pref(int temp, char *head, char *mode) {
|
||||
char buf[PATH_MAX+1], wd[PATH_MAX];
|
||||
char buf[PATH_MAX+1], old[PATH_MAX+1], wd[PATH_MAX];
|
||||
char *usr, *home, *p;
|
||||
int l;
|
||||
FILE *fil;
|
||||
|
||||
usr = getenv("USER");
|
||||
if (temp && usr==NULL) return NULL;
|
||||
@@ -209,28 +212,41 @@ FILE *term_open_pref(int temp, char *head, char *mode) {
|
||||
}
|
||||
} else {
|
||||
home = buf;
|
||||
|
||||
}
|
||||
} else {
|
||||
home=getenv("HOME");
|
||||
if (!home) return NULL;
|
||||
}
|
||||
if (temp) {
|
||||
/* usr is now the username, or lnsg_<subdirectory> */
|
||||
str_copy(buf, "/tmp/");
|
||||
/* old file name */
|
||||
str_copy(old, "/tmp/");
|
||||
str_append(old, head);
|
||||
str_append(old, ".");
|
||||
str_append(old, usr);
|
||||
/* new file name */
|
||||
str_copy(buf, "/tmp/six/");
|
||||
mkdir(buf, S_IRWXU+S_IRGRP+S_IXGRP+S_IROTH+S_IXOTH);
|
||||
str_append(buf, head);
|
||||
str_append(buf, ".");
|
||||
str_append(buf, usr);
|
||||
str_append(buf, usr); /* usr is the username, or lnsg_<subdirectory> */
|
||||
} else {
|
||||
/* old file name */
|
||||
str_copy(old, home);
|
||||
str_append(old, "/.");
|
||||
str_append(old, head);
|
||||
/* new file name */
|
||||
str_copy(buf, home);
|
||||
str_append(buf, "/");
|
||||
str_append(buf, "/.six/");
|
||||
mkdir(buf, S_IRWXU+S_IRGRP+S_IXGRP+S_IROTH+S_IXOTH);
|
||||
str_append(buf, head);
|
||||
}
|
||||
rename(old, buf); /* if old file exists, rename it to new */
|
||||
if (*mode == 'd') {
|
||||
unlink(buf);
|
||||
return NULL;
|
||||
} else {
|
||||
return fopen(buf, mode);
|
||||
fil = fopen(buf, mode);
|
||||
return fil;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +301,7 @@ void term_read_hist(char *id) {
|
||||
char buf[1024], *lin;
|
||||
|
||||
str_copy(filehead, id);
|
||||
str_append(filehead, "_hist.");
|
||||
str_append(filehead, "_hist");
|
||||
fil=term_open_pref(1, filehead, "r");
|
||||
if (fil==NULL) return;
|
||||
hist_end=0;
|
||||
|
||||
Reference in New Issue
Block a user