|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 2448 (0x990) Types: TextFile Notes: UNIX file Names: »inqwin.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code └─⟦f4b8d8c84⟧ UNIX Filesystem └─⟦this⟧ »unimenu/src/menu/inqwin.c«
#ifndef LINT static char sccs_id[] = "@(#)inqwin.c 1.1 15:34:55 4/6/85"; #endif /* * inqwin get the window number they want to run in * First look to see if there is a next available window. * We just run through each window number looking to * see if a process is running in it. If there is no * process in it, we then check to see if it exists. * if it doesn't exist, then we have to make it by * running mkwin. * * returns (char *) window */ #include <sys/types.h> #include <sys/stat.h> #include <windows.h> extern int Runwin; char *inqwin(prompt) char *prompt; { int windno; int isactive; char *choice; char *inquire(); WINDOW wbuf; char winstr[10]; static char buf[40]; static char m[] = "\nWindow is in use or cannot be accessed."; for ( ;; ) /* until we get an error or a good window */ { windno = -1; if (prompt && *prompt ) strcpy(buf, prompt); else strcpy(buf, "Window number? "); choice = inquire(buf); /* get some input */ if ( !choice ) break; /* canceled */ if ( !(*choice) ) /* typed a return */ { windno = first_empty(); break; } else /* entered something */ { windno = atoi(choice); if ( windno == Runwin ) /* the current window */ return ( (char *) 0 ); #ifdef ACTIVEWIN if ( window(ACTIVEWIN, windno, &isactive) || isactive ) { printf(m, windno); /* can't use this one */ CRblk(0); } else #endif if ( dump_win(&wbuf) ) CRblk(m); else break; /* window ok */ } } if ( windno < 0 ) /* couldn't find a window */ return ( (char *) 0 ); winstr[0] = windno % 10 + '0'; /* note: limited to 10 windows */ winstr[1] = ' '; winstr[2] = '\0'; strcpy(buf, "runwin "); strcat(buf, winstr); return (buf); } first_empty() { WINDOW wbuf; int windno; int isactive; for (windno = 0; windno < USR_WINDS; windno++ ) { if ( windno == Runwin ) continue; #ifdef ACTIVEWIN /* i'm not sure how to do this yet... */ if ( window(ACTIVEWIN, windno, &isactive)) { printf("\nWindow system call error.\n"); CRblk(0); return ( -1 ); } if ( isactive ) /* window is in use */ continue; #endif if ( !dump_win(&wbuf) && wbuf.w_bf_rows ) break; } /* * we now either have an empty window or we ran out of * windows */ if ( windno > USR_WINDS ) { printf("\nNo windows are available.\n"); CRblk(0); return (-1); } printf("\nUsing window %d.\n", windno ); return ( windno ); }