kbput.c

来自「详细介绍了一篇关于pci开发的接口芯片」· C语言 代码 · 共 32 行

C
32
字号
/*  CXL - Copyright (c) 1987-1989 by Mike Smedley - All Rights Reserved  */
/*  KBPUT.C     - puts a keystroke into the CXL keyboard "buffer"  */

#include <stdlib.h>
#include "cxldef.h"
#include "cxlkey.h"

int kbput(unsigned xch)
{
    struct _kbuf_t *kbuf,*temp;

    /* allocate space for another keypress record */
    if((kbuf=malloc(sizeof(struct _kbuf_t)))==NULL) return(1);

    /* find last record in linked list */
    if((temp=_kbinfo.kbuf)!=NULL) for(;temp->next!=NULL;temp=temp->next);

    /* add new record to end of linked list */
    kbuf->next=NULL;
    kbuf->prev=temp;
    if(temp!=NULL) temp->next=kbuf;

    /* add keypress info to new record */
    kbuf->xch=xch;

    /* if kbuf pointer was NULL, point it to new record */
    if(_kbinfo.kbuf==NULL) _kbinfo.kbuf=kbuf;

    /* return normally */
    return(0);
}

⌨️ 快捷键说明

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