diff options
| author | Franklin Wei <frankhwei536@gmail.com> | 2014-07-13 19:54:47 -0400 |
|---|---|---|
| committer | Franklin Wei <frankhwei536@gmail.com> | 2014-07-13 19:54:47 -0400 |
| commit | 79bd2194539aa559078de9afb1500a2e754ee501 (patch) | |
| tree | d4f1bd4fec8d118ad2ea95632597d60ef094029f /util.c | |
| parent | a46ef7c627eb6ee71f195d95c3e18a9c4e04a85c (diff) | |
| download | wargames-server-79bd2194539aa559078de9afb1500a2e754ee501.zip wargames-server-79bd2194539aa559078de9afb1500a2e754ee501.tar.gz wargames-server-79bd2194539aa559078de9afb1500a2e754ee501.tar.bz2 wargames-server-79bd2194539aa559078de9afb1500a2e754ee501.tar.xz | |
Added server
Diffstat (limited to 'util.c')
| -rw-r--r-- | util.c | 46 |
1 files changed, 30 insertions, 16 deletions
@@ -14,18 +14,18 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * * Contact the author at contact@fwei.tk */ #include "strings.h" #include "util.h" #include <ctype.h> -#include <curses.h> #include <string.h> #include <unistd.h> - - +#include <stdlib.h> +int out_fd; +extern int pipes[FD_SETSIZE][2]; void allLower(char* str) { for(int i=0;str[i];++i) @@ -35,21 +35,11 @@ void allLower(char* str) } void print_string(const char* str) /* print string, slowly */ { - int window_height; - int junk; - getmaxyx(stdscr, window_height, junk); int i=0; while(str[i]) { - addch(str[i]); - int cursx, cursy; - getyx(stdscr, cursy, cursx); - if(cursy==window_height) - { - scroll(stdscr); - } - usleep(SLEEP_TIME); - refresh(); + write(out_fd, &str[i], 1); + fsync(out_fd); ++i; } } @@ -66,4 +56,28 @@ void remove_punct(char* buf) } } } +void clear(void) +{ +} +void refresh(void) +{ + fsync(out_fd); +} +int getnstr(char* buf, int max) +{ + printf("reading...\n"); + memset(buf, 0, sizeof(buf)); + int back=0; + char c=0; + do { + read(pipes[out_fd][0], &c, 1); + if(c!='\n') + { + buf[back]=c; + ++back; + } + } + while(back<max && c!='\n'); + return OK; +} |