ANU News Patch Patch ID: 930729_newsextract.c!newsmgr@drunivac.drew.edu Date: 29-Jul-1993 Author: Dave Costa newsmgr@drunivac.drew.edu News Version: 6.1beta7 News Files: NewsExtract.C, NewsCmd.CLD, News.Hlp Description: Add /Local qualifier to Print command, which directs printed output to a printer attached to the local terminal. *** newsextract.c --- newsextract_new.c ************** *** 30,32 **-- **/ --- 30,34 ----- + ** V6.1b7 29-Jul-1993 Dave Costa newsmgr@drunivac.drew.edu + ** - Added /Local qualifier to print to support terminal printers **-- **/ ************** *** 41,46 #ifdef vax11c #include sjcdef #else #include #endif --- 43,51 ----- #ifdef vax11c #include sjcdef + #include ttdef + #include tt2def + #include iodef #else #include #include ************** *** 43,48 #include sjcdef #else #include #endif static --- 48,56 ----- #include iodef #else #include + #include + #include + #include #endif static ************** *** 496,501 } *pjobs = 0; static short param_name[] = {SJC$_PARAMETER_1,SJC$_PARAMETER_2,SJC$_PARAMETER_3, SJC$_PARAMETER_4,SJC$_PARAMETER_5,SJC$_PARAMETER_6, SJC$_PARAMETER_7,SJC$_PARAMETER_8}; --- 504,519 ----- } *pjobs = 0; static + struct local_print_job { + struct local_print_job *next; + char filename[256]; + int delete_it; + int copies; + } *lpjobs = 0; + + int local = 1; + + static short param_name[] = {SJC$_PARAMETER_1,SJC$_PARAMETER_2,SJC$_PARAMETER_3, SJC$_PARAMETER_4,SJC$_PARAMETER_5,SJC$_PARAMETER_6, SJC$_PARAMETER_7,SJC$_PARAMETER_8}; ************** *** 823,827 err_line(stat_output); } int submit_it(g,m) int g, m; --- 841,921 ----- err_line(stat_output); } + void printer_on(void) + { + printf("\x01b[5i"); + } + + void printer_off(void) + { + printf("\x01b[4i"); + } + + void dbgw(message) + char *message; + { + FILE *test; + test = fopen("dua2:[newsmgr]test.dat","a"); + fputs(message,test); + fclose(test); + } + + void ljc_add_file(file_name,delete_it) + char *file_name; + int delete_it; + { + char strn[256]; + int p_val = 1,p_len = 0; + struct local_print_job *l; + $DESCRIPTOR(desc,strn); + + l = (struct local_print_job *) malloc (sizeof *l); + strcpy(l->filename,file_name); + l->delete_it = delete_it; + if (cli$get_value(c$dsc("COPIES"),&desc,&p_len) & 1) + { + strn[p_len] = '\0'; + sscanf(strn,"%d",&p_val); + l->copies = p_val; + } + else l->copies = 1; + l->next = lpjobs; + lpjobs = l; + } + + void ljc_close_job(job) + struct local_print_job *job; + { + FILE *fpr; + char buff[512]; + short channel; + int *iostat,*term_mode,change_mode = 0; + + fpr = fopen(job->filename,"r"); + if (sys$assign(c$dsc("SYS$COMMAND"),&channel,0,0) & 1) { + iostat = (int *) malloc(8); + term_mode = (int *) malloc(8); + if (sys$qiow(0,channel,IO$_SENSEMODE,iostat,0,0,term_mode,8,0,0,0,0) & 1) + if (!(term_mode[1] & TT$M_MECHFORM)) { + term_mode[1] = term_mode[1] | TT$M_MECHFORM; + change_mode = (sys$qiow(0,channel,IO$_SETMODE,iostat,0,0,term_mode,8,0,0,0,0) & 1); + } + } + printer_on(); + while (job->copies--) + { + rewind(fpr); + while (fgets(buff,512,fpr)) puts(buff); + printf("\f"); + } + printer_off(); + if (change_mode) { + term_mode[1] = term_mode[1] ^ TT$M_MECHFORM; + change_mode = (sys$qiow(0,channel,IO$_SETMODE,iostat,0,0,term_mode,0,0,0,0) & 1); + } + fclose(fpr); + if (job->delete_it) delete(job->filename); + } + int submit_it(g,m) int g, m; ************** *** 878,884 del_file = 1; } else fclose(fp); ! sjc_add_file(full_name,del_file); ++n_extracted; } else { --- 972,979 ----- del_file = 1; } else fclose(fp); ! if (local) ljc_add_file(full_name,del_file); ! else sjc_add_file(full_name,del_file); ++n_extracted; } else { ************** *** 1070,1075 * the necessary print job entry in the VMS queues. * Bug Fix: remove use of variable t 29/5/89 */ void print_exit() { --- 1166,1174 ----- * the necessary print job entry in the VMS queues. * Bug Fix: remove use of variable t 29/5/89 */ + /* Also, check the list lpjobs and call ljc_close_job to print the + * file on the user's local printer. + */ void print_exit() { ************** *** 1074,1079 void print_exit() { struct print_job *p; c$cks(1); while ((p = pjobs) != 0) { --- 1173,1179 ----- void print_exit() { struct print_job *p; + struct local_print_job *l; c$cks(1); while ((p = pjobs) != 0) { ************** *** 1084,1089 pjobs = p->pnext; free(p); } } /* --- 1184,1194 ----- pjobs = p->pnext; free(p); } + while ((l = lpjobs) != 0) { + ljc_close_job(l); + lpjobs = l->next; + free(l); + } } /* ************** *** 1150,1155 } } /* * do_print * --- 1255,1273 ----- } } + int prn_port(void) + { + unsigned short channel = 0; + unsigned int *iostat,*term_mode; + + if (!(sys$assign(c$dsc("SYS$COMMAND"),&channel,0,0) & 1)) return(0); + iostat = (unsigned int *) malloc(8); + term_mode = (unsigned int *) malloc(12); + if (!(sys$qiow(0,channel,IO$_SENSEMODE,iostat,0,0,term_mode,12,0,0,0,0) + & 1)) return(0); + return(term_mode[2] & TT2$M_PRINTER); + } + /* * do_print ************** *** 1152,1157 /* * do_print * */ --- 1270,1276 ----- /* * do_print + * */ ************** *** 1157,1163 static int dprint() { ! int fd; char full_name[256], retry_command[512], *c, --- 1276,1282 ----- static int dprint() { ! int fd,wait; char full_name[256], retry_command[512], *c, ************** *** 1186,1192 cj_itm = (struct it *) pmalloc(60 * (sizeof *cj_itm)); fill_qual_block(); fill_local_block(); ! if (do_dirwrite("SYS$SCRATCH:NEWS_PRINT.TMP",1)) loop_search(submit_it); if (print_directory) { --- 1305,1318 ----- cj_itm = (struct it *) pmalloc(60 * (sizeof *cj_itm)); fill_qual_block(); fill_local_block(); ! if ((local = cli$present(c$dsc("LOCAL"))) & 1) ! local = !(cli$present(c$dsc("QUEUE")) & 1); ! else local = local & 1; ! if (local && !prn_port()) { ! sprintf(err_oline,"No printer port!"); ! err_line(err_oline); ! return(0); ! } if (do_dirwrite("SYS$SCRATCH:NEWS_PRINT.TMP",1)) loop_search(submit_it); if (print_directory) { fd = fileno(pdf); ************** *** 1188,1194 fill_local_block(); if (do_dirwrite("SYS$SCRATCH:NEWS_PRINT.TMP",1)) loop_search(submit_it); - if (print_directory) { fd = fileno(pdf); getname(fd,full_name); --- 1314,1319 ----- return(0); } if (do_dirwrite("SYS$SCRATCH:NEWS_PRINT.TMP",1)) loop_search(submit_it); if (print_directory) { fd = fileno(pdf); getname(fd,full_name); ************** *** 1193,1199 fd = fileno(pdf); getname(fd,full_name); fclose(pdf); ! sjc_add_file(full_name,1); ++n_extracted; } --- 1318,1325 ----- fd = fileno(pdf); getname(fd,full_name); fclose(pdf); ! if (local) ljc_add_file(full_name,1); ! else sjc_add_file(full_name,1); ++n_extracted; } ************** *** 1197,1203 ++n_extracted; } ! if (!fhead) n_extracted = 0; if (n_extracted) { sprintf(err_oline,"Print: %d items selected ",n_extracted); if (cli$present(c$dsc("WAIT")) & 1) { --- 1323,1329 ----- ++n_extracted; } ! wait = cli$present(c$dsc("WAIT")) & 1; if (n_extracted) { sprintf(err_oline,"Print: %d items selected ",n_extracted); if (!wait) ************** *** 1200,1206 if (!fhead) n_extracted = 0; if (n_extracted) { sprintf(err_oline,"Print: %d items selected ",n_extracted); ! if (cli$present(c$dsc("WAIT")) & 1) { struct print_job *p, *t; strcat(err_oline,"(Print on EXIT)"); --- 1326,1342 ----- wait = cli$present(c$dsc("WAIT")) & 1; if (n_extracted) { sprintf(err_oline,"Print: %d items selected ",n_extracted); ! if (!wait) ! if (local) ! { ! struct local_print_job *l; ! l = lpjobs; ! ljc_close_job(l); ! lpjobs = l->next; ! free(l); ! } ! else sjc_close_job(); ! else if (!local) { struct print_job *p, *t; strcat(err_oline,"(Print on EXIT)"); ************** *** 1245,1251 t->paf = fhead; t->pnext = (struct print_job *) 0; } - else sjc_close_job(); } else sprintf(err_oline,"Print: No items selected"); err_line(err_oline); --- 1381,1386 ----- t->paf = fhead; t->pnext = (struct print_job *) 0; } } else sprintf(err_oline,"Print: No items selected"); err_line(err_oline); *** newscmd.cld --- newscmd_new.cld ************** *** 27,29 !-- ! --- 27,31 ----- + ! 6.1b7 29-Jul-1993 Dave Costa newsmgr@drunivac.drew.edu + ! - Added /Local qualifier to print to support terminal printers !-- ! ************** *** 1009,1015 qualifier LOWERCASE qualifier OPERATOR value(required) qualifier PARAMETERS value(required,list) ! qualifier QUEUE value (required) qualifier RESTART qualifier BURST value(type=PRINT_BFT) qualifier COPIES value(required) --- 1011,1018 ----- qualifier LOWERCASE qualifier OPERATOR value(required) qualifier PARAMETERS value(required,list) ! qualifier QUEUE value(required) ! qualifier LOCAL nonnegatable qualifier RESTART qualifier BURST value(type=PRINT_BFT) qualifier COPIES value(required) ************** *** 1024,1029 qualifier NEWSGROUPS value(required,list) disallow (NOTERANGE and MARKER) or (AUTHOR and FROM) or (UNSEEN and UNREAD) or (NOTERANGE and NEWSGROUPS) define verb PURGE routine do_mail_purge --- 1027,1033 ----- qualifier NEWSGROUPS value(required,list) disallow (NOTERANGE and MARKER) or (AUTHOR and FROM) or (UNSEEN and UNREAD) or (NOTERANGE and NEWSGROUPS) + or (LOCAL and (QUEUE or BURST or FLAG or TRAILER)) define verb PURGE routine do_mail_purge *** news.hlp --- news_new.hlp ************** *** 1,4 ! 1 HELP NEWS is an implementation of the USENET NEWS system for VMS. This is a bulletin board system, allowing users to read items posted to the board, --- 1,5 ----- ! ! 6.1b7 29-Jul-1993 Dave Costa newsmgr@drunivac.drew.edu ! ! - Added /Local qualifier to print to support terminal printers 1 HELP ************** *** 1,5 1 HELP NEWS is an implementation of the USENET NEWS system for VMS. This is a bulletin board system, allowing users to read items posted to the board, post replies to existing items, and create new items on the board. NEWS --- 1,8 ----- ! 6.1b7 29-Jul-1993 Dave Costa newsmgr@drunivac.drew.edu ! - Added /Local qualifier to print to support terminal printers + 1 HELP + NEWS is an implementation of the USENET NEWS system for VMS. This is a bulletin board system, allowing users to read items posted to the board, post replies to existing items, and create new items on the board. NEWS ************** *** 2388,2393 Specifies whether or not to include the full item headers in the printed text. /MARKER /MARKER [=tag] --- 2391,2404 ----- Specifies whether or not to include the full item headers in the printed text. + + /LOCAL + /LOCAL + + Specifies that printing is to be performed by the local terminal's + printer. This qualifier cannot be used with the /QUEUE qualifier or + any qualifiers intended strictly for use with line-printer queues + (BURST, FLAG, etc.). The /QUEUE qualifier will override this qualifier. /MARKER /MARKER [=tag] *** patchlist.h;-1 --- patchlist.h ************** *** 1,1 =+=+= End =+=+= --- 1,2 ----- + 930729_newsextract.c!newsmgr@drunivac.drew.edu =+=+= End =+=+=