/* ------------------------------------------------------------------------------------- // _sdyALIsPlaying //------------------------------------------------------------------------------------- // Returns "sdyTrue" if a sound is playing "sdyFalse" otherwise. //------------------------------------------------------------------------------------- */ sdyBool SDYAPI sdyALIsPlaying(SDY_SOUND* pSound) { assert(pSound); assert(g_cAudLines); if(!pSound || !g_cAudLines) return sdyFalse; if(csearch(g_cAudLines, pSound)) return sdyTrue; return sdyDrvIsPlaying(pSound->pBuffer); }
/* ------------------------------------------------------------------------------------- // _sdyALPop //------------------------------------------------------------------------------------- */ sdyBool SDYAPI _sdyALPop(SDY_SOUND* pSoundPop) { assert(pSoundPop); assert(g_cAudLines); /* do not try to pop a non playing sound */ assert(csearch(g_cAudLines, pSoundPop)); if(!csearch(g_cAudLines, pSoundPop)) return sdyFalse; /* remove from play-list */ crndpop(g_cAudLines, pSoundPop); /* TODO: The sound should be already stopped here! */ /* stop the sound by the driver */ if(sdyDrvIsPlaying(pSoundPop->pBuffer)) sdyDrvStop(pSoundPop->pBuffer); /* rewind sound for the next playback */ sdyManRewindSound(pSoundPop); /* destroy internal duplicates */ if(pSoundPop->bDuplicate) { _sdyALDestroyDuplicate(pSoundPop); return sdyTrue; } /* close "AutoRemove" sounds */ if(pSoundPop->bAutoRemove) { sdyManCloseSound(pSoundPop); return sdyTrue; } return sdyTrue; }
int main(int argc, char *argv[]) { struct info i; enum FMT fmt; int ch; fmt = NOTSET; i.fd = STDIN_FILENO; opterr = 0; while (optind < argc && strspn(argv[optind], "-aefg") == strlen(argv[optind]) && (ch = getopt(argc, argv, "aef:g")) != -1) switch(ch) { case 'a': /* undocumented: POSIX compatibility */ fmt = POSIX; break; case 'e': fmt = BSD; break; case 'f': if ((i.fd = open(optarg, O_RDONLY | O_NONBLOCK)) < 0) err(1, "%s", optarg); break; case 'g': fmt = GFLAG; break; default: goto args; } args: argc -= optind; argv += optind; if (tcgetattr(i.fd, &i.t) < 0) errx(1, "not a terminal"); if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0 ) err(1, "TIOCGETD"); if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0) warn("TIOCGWINSZ"); switch(fmt) { case NOTSET: if (*argv) break; /* FALLTHROUGH */ case BSD: case POSIX: print(&i.t, &i.win, i.ldisc, fmt); break; case GFLAG: gprint(&i.t, &i.win, i.ldisc); break; } for (i.set = i.wset = 0; *argv; ++argv) { if (ksearch(&argv, &i)) continue; if (csearch(&argv, &i)) continue; if (msearch(&argv, &i)) continue; if (isdigit(**argv)) { const char *error; int speed; speed = strtonum(*argv, 0, INT_MAX, &error); if (error) err(1, "%s", *argv); cfsetospeed(&i.t, speed); cfsetispeed(&i.t, speed); i.set = 1; continue; } if (!strncmp(*argv, "gfmt1", sizeof("gfmt1") - 1)) { gread(&i.t, *argv + sizeof("gfmt1") - 1); i.set = 1; continue; } warnx("illegal option -- %s", *argv); usage(); } if (i.set && tcsetattr(i.fd, 0, &i.t) < 0) err(1, "tcsetattr"); if (i.wset && ioctl(i.fd, TIOCSWINSZ, &i.win) < 0) warn("TIOCSWINSZ"); return (0); }
int main(int argc, char *argv[]) { struct info i; enum FMT fmt; int ch; setprogname(argv[0]); (void)setlocale(LC_ALL, ""); fmt = STTY_NOTSET; i.fd = STDIN_FILENO; opterr = 0; while (optind < argc && strspn(argv[optind], "-aefg") == strlen(argv[optind]) && (ch = getopt(argc, argv, "aef:g")) != -1) switch(ch) { case 'a': /* undocumented: POSIX compatibility */ fmt = STTY_POSIX; break; case 'e': fmt = STTY_BSD; break; case 'f': if ((i.fd = open(optarg, O_RDONLY | O_NONBLOCK)) < 0) err(1, "%s", optarg); break; case 'g': fmt = STTY_GFLAG; break; case '?': default: goto args; } args: argc -= optind; argv += optind; if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0) err(1, "TIOCGETD"); if (tcgetattr(i.fd, &i.t) < 0) err(1, "tcgetattr"); if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0) warn("TIOCGWINSZ"); switch(fmt) { case STTY_NOTSET: if (*argv) break; /* FALLTHROUGH */ case STTY_BSD: case STTY_POSIX: print(&i.t, &i.win, i.ldisc, fmt); break; case STTY_GFLAG: gprint(&i.t); break; } for (i.set = i.wset = 0; *argv; ++argv) { if (ksearch(&argv, &i)) continue; if (csearch(&argv, &i)) continue; if (msearch(&argv, &i)) continue; if (isdigit((unsigned char)**argv)) { int speed; speed = atoi(*argv); cfsetospeed(&i.t, speed); cfsetispeed(&i.t, speed); i.set = 1; continue; } if (!strncmp(*argv, "gfmt1", sizeof("gfmt1") - 1)) { gread(&i.t, *argv + sizeof("gfmt1") - 1); i.set = 1; continue; } warnx("illegal option -- %s", *argv); usage(); } if (i.set && tcsetattr(i.fd, 0, &i.t) < 0) err(1, "tcsetattr"); if (i.wset && ioctl(i.fd, TIOCSWINSZ, &i.win) < 0) warn("TIOCSWINSZ"); exit(0); /* NOTREACHED */ }
void prog() { char word[25],meaning[100],hword[25]; int menuchoice,rep,l,h; node *temp; node *t; FILE *fp; clrscr(); temp=treefromfile(); if(temp==NULL) { printf("File does not exist or dictionary is empty..."); getch(); } while(1) { clrscr(); menuchoice=showmenu(); // scanf("%d",&menuchoice); switch(menuchoice) { case 1:{ frame(); printf("\nEnter word : \n"); scanf("%s",word); printf("\nEnter meaning : " ); flushall(); gets(meaning); if(temp==NULL) { temp=maketree(word,meaning); } else { addword(temp,word,meaning); } break; } case 2:{ frame(); if(temp==NULL) { printf("\nThe dictionary is empty...\n"); } else { printf("\nFind meaning of : \n"); flushall(); gets(word); t=csearch(temp,word); if(t==NULL) { printf("\nWord not found...\n"); printf("\nDo you want to add this word to database: \n1>yes\n2>No\n"); scanf("%d",&rep); if(rep==1) { frame(); printf("\nEnter word : %s\n",word); //scanf("%s",word); printf("\nEnter meaning : " ); flushall(); gets(meaning); if(temp==NULL) { temp=maketree(word,meaning); } else { addword(temp,word,meaning); } } else { printf("\nReturning to main menu...\n"); } } else { printf("\n%s : ",t->word); puts(t->meaning); } } getch(); break; } case 3:{ frame(); if(temp==NULL) printf("Dictionary is empty..."); else displayall(temp); getch(); break; } case 4:{ clrscr(); printf("\n\n\tEnter word: "); scanf("%s",word); printf("\n\tEnter meaning: "); gets(meaning); change(temp,word,meaning); break; } case 5: { clrscr(); frame(); printf("\nHow many last searched words to be displayed:"); scanf("%d",&h); fp=fopen("c:\\history.txt","r" ); if(fp==NULL) { printf("\nUnable to read history file...\n"); printf("\n\n\tThere is no history of searched words...\n"); } else { gotoxy(1,20); for(l=0;l<15;l++) { printf("||||"); } gotoxy(1,1); printf("\n\t\tHISTORY\n\n"); printf("\nLast %d words which were searched are:\n\n",h); for(l=0;l<h;l++) { fscanf(fp,"%s",hword); printf("\t%d>\t%s",l+1,hword); } } fclose(fp); getch(); break; } case 6:{ filefromtree(temp); end(); exit(1); break; } default:{ printf("Wrong!! Enter Again"); delay(1000); prog(); break; } } } }