int CIOLIBCALL ciolib_getmouse(struct mouse_event *mevent) { int retval=0; while(!ciolib_mouse_initialized) SLEEP(1); if(listCountNodes(&state.output)) { struct out_mouse_event *out; out=listShiftNode(&state.output); if(out==NULL) return(-1); if(mevent != NULL) { mevent->event=out->event; mevent->bstate=out->bstate; mevent->kbsm=out->kbsm; mevent->startx=out->startx; mevent->starty=out->starty; mevent->endx=out->endx; mevent->endy=out->endy; } free(out); } else { fprintf(stderr,"WARNING: attempt to get a mouse key when none pending!\n"); if(mevent != NULL) memset(mevent,0,sizeof(struct mouse_event)); retval=-1; } return(retval); }
int main(int arg, char** argv) { int i; char* p; char str[32]; link_list_t list; listInit(&list,0); for(i=0; i<100; i++) { sprintf(str,"%u",i); listPushNodeString(&list,str); } while((p=listShiftNode(&list))!=NULL) printf("%d %s\n",listCountNodes(&list),p), free(p); /* Yes, this test code leaks heap memory. :-) */ gets(str); return 0; }
static BOOL list_wait(link_list_t* list, long timeout) { #if defined(LINK_LIST_THREADSAFE) if(timeout<0) /* infinite */ return listSemWait(list); if(timeout==0) /* poll */ return listSemTryWait(list); return listSemTryWaitBlock(list,timeout); #else clock_t start; long count; start=msclock(); while((count=listCountNodes(list))==0) { if(timeout==0) break; if(timeout>0 && msclock()-start > timeout) break; YIELD(); } return(INT_TO_BOOL(count)); #endif }
int CIOLIBCALL mouse_pending(void) { while(!ciolib_mouse_initialized) SLEEP(1); return(listCountNodes(&state.output)); }
long DLLCALL msgQueueWriteLevel(msg_queue_t* q) { return listCountNodes(msgQueueWriteList(q)); }