📄 tm_getline.c
字号:
/* *---------------------------------------------------------------------- * micro T-Kernel * * Copyright (C) 2006-2007 by Ken Sakamura. All rights reserved. * micro T-Kernel is distributed under the micro T-License. *---------------------------------------------------------------------- * * Version: 1.00.00 * Released by T-Engine Forum(http://www.t-engine.org) at 2007/03/26. * *---------------------------------------------------------------------- */#include <typedef.h>#include <stddef.h>#include <tk/syslib.h>IMPORT void sio_send_frame( const UB* buf, INT size );IMPORT void sio_recv_frame( UB* buf, INT size );/* * special key is not supported */EXPORT INT tm_getline( UB *buff ){ UB* p = buff; int len = 0; static const char LF = 0x0a; INT imask; DI(imask); for (;;) { sio_recv_frame(p, 1); sio_send_frame(p, 1); /* echo back */ if (*p == 0x0d) { sio_send_frame((const VP)&LF, 1); *p = 0x00; return len; } else if (*p == 0x03) { *p = 0x00; return -1; } p++; len++; } EI(imask); return len;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -