⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r19.c

📁 手持机读写GSM标准的CPU卡代码,包括手持机的液晶显示
💻 C
字号:
//#include "glue.h"
#include <sys/types.h>
#include <errno.h>
#include <sys/stat.h>
int isatty(int fd);
/*
 * isatty -- returns 1 if connected to a terminal device,
 *           returns 0 if not. Since we're hooked up to a
 *           serial port, we'll say yes _AND return a 1.
 */
//*************************
int isatty(int fd)
{
  //return (1);
   return(0);
}
//*************************
/*
 * read  -- read bytes from the serial port. Ignore fd, since
 *          we only have stdin.
 * Return on newline
 * erase last char on backspace.
 */
int read(int fd,char *buf,int nbytes)
{
    return (0);
}
//*************************
off_t lseek(int fd,off_t offset,int whence)
{
  errno = ESPIPE;
  return ((off_t)-1);
}
//*************************

/*
 * write -- write bytes to the serial port. Ignore fd, since
 *          stdout and stderr are the same. Since we have no filesystem,
 *          open will only return an error.
 */
int write(int fd,char *buf,int nbytes)
{
  return (0);
}
//*************************
/*
 * close -- We don't need to do anything, but pretend we did.
 */
int close(int fd)
{
  return (0);
}
//*************************
/*
 * fstat -- Since we have no file system, we just return an error.
 */
int fstat(int fd,struct stat *buf)
{
  return (0);
}
//*************************
char *heap_ptr;

/*
 * sbrk -- changes heap size size. Get nbytes more
 *         RAM. We just increment a pointer in what's
 *         left of memory on the board.
 */
char* sbrk(int nbytes)
{
extern char _heap_bottom;
extern char _heap_top;
char* base;
	if (!heap_ptr)
       heap_ptr = (char *)&_heap_bottom;
    if((heap_ptr+nbytes)>&(_heap_top)) {
       errno = ENOMEM;
       return ((char *)-1);
    }
    else {
       base = heap_ptr;
       heap_ptr += nbytes;
       return (base);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -