initial ncurses stuff
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <list.h>
|
#include <list.h>
|
||||||
|
#include <ncurses.h>
|
||||||
|
|
||||||
#define MAXBUFSIZE 30
|
#define MAXBUFSIZE 30
|
||||||
#define BACKLOG 10
|
#define BACKLOG 10
|
||||||
@@ -25,6 +26,7 @@ LIST *receivelist, *sendlist;
|
|||||||
pthread_mutex_t sendmut, receivemut;
|
pthread_mutex_t sendmut, receivemut;
|
||||||
int sockfd, confd, client;
|
int sockfd, confd, client;
|
||||||
char *remote_machine, *local_port, *remote_port;
|
char *remote_machine, *local_port, *remote_port;
|
||||||
|
int row, col;
|
||||||
/*
|
/*
|
||||||
void *input(void *arg) {
|
void *input(void *arg) {
|
||||||
char msg[128];
|
char msg[128];
|
||||||
@@ -65,8 +67,9 @@ void *sender(void *arg) {
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
memset(msg, 0, 128);
|
memset(msg, 0, 128);
|
||||||
printf("Type a message: ");
|
mvprintw(row - 2, 0, "Type a message: ");
|
||||||
fgets(msg, sizeof(msg), stdin);
|
refresh();
|
||||||
|
getstr(msg);
|
||||||
bytes = send(confd, msg, sizeof(msg), 0);
|
bytes = send(confd, msg, sizeof(msg), 0);
|
||||||
if (bytes == -1) {
|
if (bytes == -1) {
|
||||||
perror("send");
|
perror("send");
|
||||||
@@ -235,6 +238,8 @@ int main(int argc, char* argv[]) {
|
|||||||
servinfo = q;
|
servinfo = q;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
initscr();
|
||||||
|
getmaxyx(stdscr, row, col);
|
||||||
pthread_create(&send_thread, NULL, sender, NULL);
|
pthread_create(&send_thread, NULL, sender, NULL);
|
||||||
pthread_create(&receive_thread, NULL, receiver, NULL);
|
pthread_create(&receive_thread, NULL, receiver, NULL);
|
||||||
/*pthread_create(&input_thread, NULL, input, NULL);
|
/*pthread_create(&input_thread, NULL, input, NULL);
|
||||||
@@ -249,6 +254,7 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
close(confd);
|
close(confd);
|
||||||
|
endwin();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user