many fixes
This commit is contained in:
parent
78f4d71855
commit
9c70da9ed7
2
Makefile
2
Makefile
@ -10,7 +10,7 @@ EXE=telegram
|
|||||||
all: $(SRC) $(EXE)
|
all: $(SRC) $(EXE)
|
||||||
|
|
||||||
$(EXE): $(OBJ)
|
$(EXE): $(OBJ)
|
||||||
$(LD) $(LDFLAGS) $(OBJ) -o $@
|
$(LD) $(OBJ) $(LDFLAGS) -o $@
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(CC) $(CFLAGS) $< -o $@
|
$(CC) $(CFLAGS) $< -o $@
|
||||||
|
15
interface.c
15
interface.c
@ -36,7 +36,7 @@ int init_token (char **q) {
|
|||||||
char *r = *q;
|
char *r = *q;
|
||||||
while (*r == ' ') { r ++; }
|
while (*r == ' ') { r ++; }
|
||||||
if (!*r) { return 0; }
|
if (!*r) { return 0; }
|
||||||
q = &r;
|
*q = r;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ char *get_token (char **q, int *l) {
|
|||||||
char *r = *q;
|
char *r = *q;
|
||||||
while (*r == ' ') { r ++; }
|
while (*r == ' ') { r ++; }
|
||||||
if (!*r) {
|
if (!*r) {
|
||||||
q = &r;
|
*q = r;
|
||||||
*l = 0;
|
*l = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -56,8 +56,9 @@ char *get_token (char **q, int *l) {
|
|||||||
} else {
|
} else {
|
||||||
neg = 0;
|
neg = 0;
|
||||||
}
|
}
|
||||||
|
r++;
|
||||||
}
|
}
|
||||||
q = &r;
|
*q = r;
|
||||||
*l = r - s;
|
*l = r - s;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -74,7 +75,7 @@ int get_complete_mode (void) {
|
|||||||
int n = 0;
|
int n = 0;
|
||||||
int flags = -1;
|
int flags = -1;
|
||||||
while (*command) {
|
while (*command) {
|
||||||
if ((int)strlen (*command) == l && !memcmp (r, *command, l)) {
|
if (!strncmp (r, *command, l)) {
|
||||||
flags = commands_flags[n];
|
flags = commands_flags[n];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -95,12 +96,10 @@ int get_complete_mode (void) {
|
|||||||
|
|
||||||
int complete_string_list (char **list, int index, const char *text, int len, char **R) {
|
int complete_string_list (char **list, int index, const char *text, int len, char **R) {
|
||||||
index ++;
|
index ++;
|
||||||
int cc = 0;
|
while (list[index] && strncmp (list[index], text, len)) {
|
||||||
while (cc <= 1 && list[index] && strncmp (list[index], text, len)) {
|
|
||||||
index ++;
|
index ++;
|
||||||
if (!list[index]) { index = 0; cc ++; }
|
|
||||||
}
|
}
|
||||||
if (list[index] && cc <= 1) {
|
if (list[index]) {
|
||||||
*R = strdup (list[index]);
|
*R = strdup (list[index]);
|
||||||
return index;
|
return index;
|
||||||
} else {
|
} else {
|
||||||
|
33
loop.c
33
loop.c
@ -8,6 +8,8 @@
|
|||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
#include <readline/history.h>
|
#include <readline/history.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
extern char *default_username;
|
extern char *default_username;
|
||||||
extern char *auth_token;
|
extern char *auth_token;
|
||||||
@ -16,7 +18,36 @@ void set_default_username (const char *s);
|
|||||||
|
|
||||||
|
|
||||||
int main_loop (void) {
|
int main_loop (void) {
|
||||||
assert (0);
|
fd_set inp, outp;
|
||||||
|
struct timeval tv;
|
||||||
|
while (1) {
|
||||||
|
FD_ZERO (&inp);
|
||||||
|
FD_ZERO (&outp);
|
||||||
|
FD_SET (0, &inp);
|
||||||
|
tv.tv_sec = 1;
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
|
int lfd = 0;
|
||||||
|
|
||||||
|
if (select (lfd + 1, &inp, &outp, NULL, &tv) < 0) {
|
||||||
|
if (errno == EINTR) {
|
||||||
|
/* resuming from interrupt, so not an error situation,
|
||||||
|
this generally happens when you suspend your
|
||||||
|
messenger with "C-z" and then "fg". This is allowed "
|
||||||
|
*/
|
||||||
|
rl_reset_line_state ();
|
||||||
|
rl_forced_update_display ();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
perror ("select()");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FD_ISSET (0, &inp)) {
|
||||||
|
rl_callback_read_char ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int loop (void) {
|
int loop (void) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user