libmenu: Fix cursor on exit from showmenus()
[syslinux.git] / sample / conio.c
blobe9660b982e85fc665cd1e202d2bc61df06e6792c
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2001-2008 H. Peter Anvin - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
14 * conio.c
16 * Output to the screen
19 #include <com32.h>
20 #include <stdarg.h>
22 #define NULL ((void *)0)
24 static inline void memset(void *buf, int ch, unsigned int len)
26 asm volatile ("cld; rep; stosb":"+D" (buf), "+c"(len):"a"(ch):"memory");
29 int putchar(int ch)
31 com32sys_t regs;
33 memset(&regs, 0, sizeof regs);
35 if (ch == '\n') {
36 /* \n -> \r\n */
37 putchar('\r');
40 regs.eax.b[1] = 0x02;
41 regs.edx.b[0] = ch;
42 __com32.cs_intcall(0x21, &regs, NULL);
44 return ch;
47 /* Note: doesn't put '\n' like the stdc version does */
48 int puts(const char *s)
50 int count = 0;
52 while (*s) {
53 putchar(*s);
54 count++;
55 s++;
58 return count;