home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / vms / 13999 < prev    next >
Encoding:
Internet Message Format  |  1992-08-23  |  33.3 KB

  1. Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!PFC.MIT.EDU!MRL
  2. From: MRL@PFC.MIT.EDU (MARK LONDON)
  3. Newsgroups: comp.os.vms
  4. Subject: LASER New (different) LASER symbiont. 2/7
  5. Message-ID: <086A6D22BF33402E1D@NERUS.PFC.MIT.EDU>
  6. Date: 22 Aug 92 16:22:00 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Distribution: world
  9. Organization: The Internet
  10. Lines: 1031
  11.  
  12. -+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
  13. X*`09/processor=laser /on=alw: alw
  14. X*
  15. X* NOTE: change /separate=(...trailer) to (...flag) if your laser printer
  16. X*       stacks right side up.
  17. X*
  18. X*/
  19. X
  20. X#include iodef
  21. X#include stdio
  22. X#include ssdef
  23. X#include descrip
  24. X#include rms
  25. X#include ctype
  26. X#include stdlib
  27. X#include brkdef
  28. X#include "smbdef.h"
  29. X#include quidef
  30. X#include prvdef
  31. X#include "lbrdef.h"
  32. X#include ttdef
  33. X#include opcdef
  34. X
  35. X#define TRUE`091
  36. X#define FALSE`090
  37. X
  38. X#define MAXITEMS 60`09`09`09/* max expected items from jobctl */
  39. X#define min(a,b) ( ((a)<(b)) ? (a) : (b) )
  40. X#define max(a,b) ( ((a)>(b)) ? (a) : (b) )`20
  41. X#define WRITELASER(p1,p2) `7Bstat = sys$qiow(0,laserchan, IO$_WRITEPBLK, 0,
  42. V 0, 0,\
  43. Xp1, p2, 0, 0, 0, 0); checkstat(stat,"writelaser"); iocount++;`7D
  44. X#define WRITELASERBUF(p1,p2) `7B\
  45. Xolen = p2;while (olen > 0)\
  46. X`7Bstat = sys$qiow(0,laserchan, IO$_WRITEPBLK, 0, 0, 0,\
  47. Xp1+p2-olen, min(1536,olen), 0, 0, 0, 0); checkstat(stat,"writelaser");\
  48. Xolen -= min(1536,olen); iocount++;`7D`7D
  49. X#define WRITESTRING(p1) WRITELASER(p1,strlen(p1))
  50. Xextern short laserchan;`09`09`09/* laserwriter channel */
  51. X`09
  52. Xglobalvalue LASER$_STREAMNOTSTART,LASER$_MAXITEMS,
  53. X`09    LASER$_CREATELOG,LASER$_STARTJOB,LASER$_ERROR,
  54. X`09    LASER$_STALLED,LASER$_RESUMED,
  55. X`09    LASER$_ITEMNOTFOUND,LASER$_TOOMANYTABS,
  56. X`09    LASER$_USERDATA,LASER$_JOBID,LASER$_TIMEOUT,LASER$_ABORT,
  57. X`09    LASER$_FLUSHED,LASER$_SETUPNOTFOUND,LASER$_INVPARAM;
  58. X
  59. Xvoid jobctl_ast();`09`09`09/* job controller ast routine */
  60. Xvoid laser_read_ast();`09`09`09/* laser read completion ast routine */
  61. Xvoid ltatimeout();
  62. Xvoid statetimeout();
  63. X
  64. Xstruct `7B
  65. X`09int`09item_code;`09`09/* code */
  66. X`09unsigned short `09item_size;`09/* size of item */
  67. X`09char`09*buffer;`09`09/* address of item */
  68. X`7D item`5BMAXITEMS`5D;
  69. X
  70. Xint stop_task;`09`09`09/* stop task flag */
  71. Xint stop_reason;`09`09/* stop task reason code */
  72. Xint spooled_file;`09`09/* TRUE if spooled file */
  73. Xint laser_efn;`09`09`09/* laser read event flag */
  74. Xint startpage;`09`09`09/* task start page */
  75. Xint endpage;`09`09`09/* task end page */
  76. Xint jobstart;`09`09`09/* job start page */
  77. Xint ansi;`09`09`09/* TRUE if ansi specified */
  78. Xint ascii;`09`09`09/* TRUE if ascii main file */
  79. Xint hex;`09`09`09/* TRUE if hexified main file */
  80. Xint tek;`09`09`09/* TRUE if tektronix main file */
  81. Xint ps;`09`09`09`09/* TRUE if postscript main file */
  82. Xint string;`09`09`09/* TRUE if string main file */
  83. Xint status_idle;`09`09/* TRUE if idle status received */
  84. Xint status_error;`09`09/* TRUE if error message received */
  85. Xint land;                       /* TRUE if landscape */
  86. Xint port;                       /* TRUE if portrait */
  87. Xint notify_qual;
  88. Xint nup;
  89. Xint olen;
  90. Xchar queue_name`5B128`5D;
  91. Xshort queue_name_l;
  92. Xint iocount,oldiocount;
  93. Xunsigned short laser_iosb`5B4`5D;`09/* laser read iosb */
  94. Xchar laser_buf`5B1024`5D;`09`09/* laser read buffer */
  95. Xstruct FAB main_fab;`09`09/* main file rms stuff */
  96. Xstruct NAM main_nam;
  97. Xstruct RAB main_rab;
  98. Xstruct FAB log_fab;`09`09/* log file rms stuff */
  99. Xstruct RAB log_rab;
  100. X
  101. Xstruct dsc$descriptor_d library_spec = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0
  102. V`7D;
  103. Xstruct dsc$descriptor_d buffer_des = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0`7
  104. VD;
  105. Xstruct dsc$descriptor_d savelog = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0`7D;
  106. Xint userlog = -1;`09`09`09/* user log file */
  107. Xint notify = FALSE;
  108. X
  109. Xchar msg`5B255`5D = "\007\007\007\r\n";`09/* error message to user */
  110. Xstruct dsc$descriptor_s errmsg_dsc = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0`7
  111. VD;
  112. X
  113. Xchar user_text`5B20`5D;`09`09/* user name to send error message to */
  114. Xstruct dsc$descriptor_s user_notify = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, &u
  115. Vser_text`7D;
  116. X
  117. Xint ii = 0;`09`09`09`09/* item index */
  118. Xint start_task = FALSE;`09`09`09/* start task flag */
  119. Xint patchneeded = FALSE;`09`09/* TRUE if patch module sent */
  120. Xint stopoutput = FALSE;
  121. Xint lta_device = FALSE;
  122. Xint ltaefn,stateefn;
  123. Xint statetime`5B2`5D= `7B-1*900000000,-1`7D;
  124. Xint jobnum = -1,entry_num;
  125. Xshort msglen = 0;
  126. Xchar message`5B257`5D;
  127. Xstruct dsc$descriptor_s msgd =
  128. X`09`09`7Bsizeof(message)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, message`7D;
  129. Xstruct `7B`09`09`09`09/* operator message to printer */
  130. X    char type;
  131. X    char target;
  132. X    short fill;
  133. X    long id;
  134. X    char text`5B257`5D;
  135. X`7D oprmsg = `7BOPC$_RQ_RQST, OPC$M_NM_PRINT, 0, 0`7D;
  136. X
  137. Xstruct dsc$descriptor_s oprmsg_dsc =`20
  138. X`09`7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, &oprmsg`7D;
  139. X
  140. Xmain()
  141. X`7B
  142. X`09int stat;
  143. X`09laserchan = 0;
  144. X`09
  145. X`09preset();`09`09`09`09/* initialize symbiont */
  146. X`09
  147. X`09do `7B
  148. X
  149. X`09`09while (!start_task) `7B`09`09/* wait for start_task */
  150. X`09`09`09stat = sys$hiber();
  151. X`09`09`09checkstat(stat,"wait start_task");
  152. X`09`09`7D
  153. X
  154. X`09`09processtask();`09`09`09/* do a job */
  155. X`09`7D while (TRUE);
  156. X`7D
  157. X
  158. Xsndmsg(type)
  159. Xint type;
  160. X`7B
  161. X`09sys$setrwm(0);
  162. X`09if (type) `7B
  163. X`09`09oprmsg_dsc.dsc$w_length = errmsg_dsc.dsc$w_length + 8;
  164. X`09`09strncpy(oprmsg.text,errmsg_dsc.dsc$a_pointer,
  165. X`09`09`09errmsg_dsc.dsc$w_length);
  166. X`09`09sys$sndopr(&oprmsg_dsc, 0);
  167. X`09`7D`20
  168. X `09sys$brkthru(0, &errmsg_dsc, &user_notify,
  169. X `09`09`09BRK$C_USERNAME,0,32,BRK$M_CLUSTER,0,5,0,0);
  170. X`09sys$setrwm(1);
  171. X`7D
  172. X
  173. Xjobid(type)
  174. Xint type;
  175. X`7B
  176. X`09struct dsc$descriptor_s temp = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0`7D;
  177. X`09static char job`5B255`5D;
  178. X`09int stat, i;
  179. X        if (getitemdescrip(SMBMSG$K_JOB_NAME, &temp, FALSE))
  180. X                strncpy(job, temp.dsc$a_pointer, temp.dsc$w_length);
  181. X        else
  182. X                temp.dsc$w_length = 0;
  183. X`09job`5Btemp.dsc$w_length`5D = 0;
  184. X`09stat = sys$getmsg(LASER$_JOBID, &msglen, &msgd, 15, 0);
  185. X`09checkstat(stat,"$getmsg");
  186. X`09message`5Bmsglen`5D = 0;
  187. X`09queue_name`5Bqueue_name_l`5D = 0;
  188. X`09i = errmsg_dsc.dsc$w_length;
  189. X`09strcpy(errmsg_dsc.dsc$a_pointer+i,"\r\n%");
  190. X`09sprintf(errmsg_dsc.dsc$a_pointer+i+3,&message`5B1`5D,&job,entry_num,&queu
  191. Ve_name);
  192. X`09errmsg_dsc.dsc$w_length = strlen(errmsg_dsc.dsc$a_pointer);
  193. X`09sndmsg(type);
  194. X`7D
  195. X
  196. X/**`09check_operator - checks for a laserwriter message that should
  197. X*`09`09`09 go to the operator.
  198. X*`09returns TRUE if message sent to operator.
  199. X*/
  200. Xcheck_operator()
  201. X`7B
  202. X`09int i,stat;
  203. X
  204. X`09if (strncmp(laser_buf, "%%`5B status: ", 12) == 0) `7B
  205. X`09`09if (strncmp(laser_buf, "%%`5B status: idle", 16) == 0) `7B
  206. X`09`09`09status_idle = TRUE;
  207. X`09`09`09sys$wake(0,0);
  208. X`09`09`09return TRUE;
  209. X`09`09`7D else if (status_error)
  210. X`09`09`09return TRUE;`09
  211. X`09`09else if (strncmp(laser_buf, "%%`5B status: offline", 19) == 0) `7B
  212. X`09`09`09strcpy(&laser_buf`5B18`5D,&laser_buf`5B12`5D);`20
  213. X`09`09`09strcpy(&laser_buf`5B4`5D,"PrinterError");
  214. X`09`09`7D else
  215. X`09`09`09strcpy(&laser_buf`5B4`5D,&laser_buf`5B12`5D);
  216. X`09`7D
  217. X
  218. X`09if (strncmp(laser_buf,"%%`5B PrinterError:", 17) == 0) `7B
  219. X`09`09stat = sys$getmsg(LASER$_ERROR, &msglen, &msgd, 15, 0);
  220. X`09`09checkstat(stat,"$getmsg");
  221. X`09`09if (strlen(laser_buf) > 245) laser_buf`5B245`5D = 0;
  222. X`09`09strncpy(&msg`5B5`5D,message,msglen);
  223. X`09`09strncpy(&msg`5Bmsglen+5`5D,&laser_buf`5B17`5D,strlen(laser_buf)-17);
  224. X`09`09errmsg_dsc.dsc$w_length =
  225. X`09`09`09strlen(laser_buf) - 17 + msglen;
  226. X`09`09errmsg_dsc.dsc$a_pointer = &msg`5B5`5D;
  227. X`09`09jobid(1);
  228. X`09`09status_error = TRUE;
  229. X`09`09return TRUE;
  230. X`09`7D
  231. X
  232. X`09if (strncmp(laser_buf, "%%`5B patch needed `5D%%", 20) == 0) `7B
  233. X`09`09patchneeded = TRUE;
  234. X`09`09return TRUE;
  235. X`09`7D
  236. X
  237. X`09if (strncmp(laser_buf, "stop", 4) == 0) `7B
  238. X`09`09stopoutput = TRUE;
  239. X`09`09return TRUE;
  240. X`09`7D
  241. X
  242. X`09if (strstr(laser_buf, "not a known parameter")) `7B
  243. X                stop_reason = LASER$_INVPARAM;
  244. X`09`09return FALSE;
  245. X`09`7D
  246. X
  247. X`09if (strncmp(laser_buf, "%%`5B start page #=", 17) == 0 && status_idle) `7
  248. VB
  249. X`09`09sscanf(&laser_buf`5B17`5D, "%d", &startpage);
  250. X`09`09sys$wake(0,0);`09`09`09/* wakeup sync waiting */
  251. X`09`09return TRUE;
  252. X`09`7D
  253. X`09
  254. X`09if (strncmp(laser_buf, "%%`5B end page   #=", 17) == 0 && status_idle) `7
  255. VB
  256. X`09`09sscanf(&laser_buf`5B17`5D, "%d", &endpage);
  257. X`09`09sys$wake(0,0);`09`09`09/* wakeup sync waiting */
  258. X`09`09return TRUE;
  259. X`09`7D
  260. X
  261. X/*  Abort the job if we see "%%`5B Flushing:"`09`09     */
  262. X/*  Don't override an already existing stop_reason condition */
  263. X
  264. X`09if (strncmp(laser_buf, "%%`5B Flushing:", 13) == 0
  265. X`09    && startpage && status_idle && !stopoutput) `7B
  266. X`09`09if (stop_reason == 0) stop_reason = LASER$_FLUSHED;
  267. X`09`09return FALSE;`09`09`09/* write in log */
  268. X`09`7D
  269. X
  270. X`09if (strncmp(laser_buf,"%%`5B Error:", 10) == 0 &&
  271. X`09`09(userlog == 0 `7C`7C userlog == -1) && !stopoutput) `7B
  272. X`09`09stat = sys$getmsg(LASER$_ERROR, &msglen, &msgd, 15, 0);
  273. X`09`09checkstat(stat,"$getmsg");
  274. X`09`09if (strlen(laser_buf) > 245) laser_buf`5B245`5D = 0;
  275. X`09`09strncpy(&msg`5B5`5D,message,msglen);
  276. X`09`09strncpy(&msg`5Bmsglen+5`5D,&laser_buf`5B10`5D,strlen(laser_buf)-10);
  277. X`09`09errmsg_dsc.dsc$w_length =
  278. X`09`09`09strlen(laser_buf) - 10 + msglen - 4;
  279. X`09`09errmsg_dsc.dsc$a_pointer = &msg`5B5`5D;
  280. X`09`09jobid(1);
  281. X`09`09if (userlog == -1) userlog = -2;
  282. X`09`09status_error = TRUE;
  283. X`09`09return FALSE;
  284. X`09`7D
  285. X
  286. X`09if (!stopoutput && startpage && !stop_reason && !stop_task &&`20
  287. X`09`09isalpha(laser_buf`5B0`5D)) `7B
  288. X`09`09if (notify_qual) `7B
  289. X`09`09`09stat = sys$getmsg(LASER$_USERDATA, &msglen, &msgd, 15, 0);
  290. X`09`09`09checkstat(stat,"$getmsg");
  291. X`09`09`09if (strlen(laser_buf) > 245) laser_buf`5B245`5D = 0;
  292. X`09`09`09strncpy(&msg`5B5`5D,message,msglen);
  293. X`09`09`09strncpy(&msg`5Bmsglen+5`5D,laser_buf,strlen(laser_buf));
  294. X`09`09`09errmsg_dsc.dsc$w_length =
  295. X`09`09`09`09strlen(laser_buf) + msglen;
  296. X`09`09`09errmsg_dsc.dsc$a_pointer = &msg`5B5`5D;
  297. X`09`09`09jobid(0);
  298. X`09`09`7D
  299. X`09`09return TRUE;
  300. X`09`7D
  301. X`09
  302. X`09if (stopoutput `7C`7C !startpage) return TRUE;
  303. X`09return FALSE;
  304. X`7D
  305. X
  306. X
  307. X/**`09checkspooled - check for a spooled file.
  308. X*
  309. X*`09If the filename has "`5B`5D_" in it, then this is a spooled file
  310. X*`09that the user wants to specify the form name for. Further,
  311. X*`09if the extension starts with "_", then it contains the
  312. X*`09user parameter list.  We forge the item list to make things
  313. X*`09look right.
  314. X*/
  315. Xcheckspooled()
  316. X`7B
  317. X`09struct dsc$descriptor_s temp = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0`7D;
  318. X`09struct dsc$descriptor_d dynd = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0`7D;
  319. X`09char *cp, *pp, spoolfile`5B255`5D;
  320. X`09int len, i, stat;
  321. X`09int ourindex;
  322. X`09char setup`5B257`5D;`09`09`09/* where to put setup name */
  323. X`09long iosb`5B2`5D;`09`09`09`09/* for $getquiw */
  324. X`09short setupl;`09`09`09`09/* returned length of setup */
  325. X`09struct `7B`09`09`09`09/* item list for $getquiw */
  326. X`09`09short`09l1;
  327. X`09`09short`09c1;
  328. X`09`09char`09*b1;
  329. X`09`09long`09*r1;
  330. X`09`09short`09l2;
  331. X`09`09short`09c2;
  332. X`09`09char`09*b2;
  333. X`09`09long`09*r2;
  334. X`09`09long`09end;
  335. X`09`7D itmlst = `7B0,  QUI$_SEARCH_NAME, 0, 0,
  336. X`09`09sizeof(setup)-1, QUI$_FORM_SETUP_MODULES, setup, &setupl,
  337. X`09`090`7D;
  338. X
  339. X`09spooled_file = FALSE;
  340. X`09
  341. X/*  get the file specification */
  342. X
  343. X`09if (!getitemdescrip(SMBMSG$K_FILE_SPECIFICATION, &temp, FALSE)) return;
  344. X`09
  345. X`09strncpy(spoolfile, temp.dsc$a_pointer, temp.dsc$w_length);
  346. X`09spoolfile`5Btemp.dsc$w_length`5D = 0;
  347. X`09`09
  348. X/*  check for `5B`5D_ */
  349. X`09
  350. X`09if (!(cp = strchr(spoolfile, '`5B'))) return;
  351. X`09if (!(*++cp == '`5D')) return;
  352. X`09spooled_file = TRUE;`09`09`09/* file is spooled */
  353. X`09if (!(*++cp == '_')) return;
  354. X`09
  355. X/*  find the extension and terminate the name string */`09
  356. X`09
  357. X`09if (!(pp = strchr(cp, '.'))) return;
  358. X`09*pp = 0;
  359. X`09cp++;
  360. X
  361. X/*  translate the form name into setup module names */
  362. X/*  If it won't translate, then pass on the form name */
  363. X
  364. X`09itmlst.l1 = strlen(cp);`09`09`09/* point to name */
  365. X`09itmlst.b1 = cp;
  366. X`09stat = sys$getquiw(0, QUI$_DISPLAY_FORM, 0, &itmlst, iosb, 0, 0);
  367. X`09checkstat(stat, "getquiw");
  368. X`09if ((iosb`5B0`5D & 1) != 1) `09`09/* if no translation */
  369. X`09`09strcpy(setup, cp);
  370. X`09else
  371. X`09`09setup`5Bsetupl`5D = 0;
  372. X
  373. X/*  forge the file setup module to have our setup module name */
  374. X/*  Note that the forge transfers the dynamic string "dynd" to "item" */
  375. X
  376. X`09ourindex = findandclritem(SMBMSG$K_FILE_SETUP_MODULES);
  377. X`09dynd.dsc$w_length = 0;`09`09/* get dynamic string */
  378. X`09dynd.dsc$a_pointer = 0;
  379. X`09len = strlen(setup);
  380. X`09str$copy_r(&dynd, &len, setup);
  381. X`09item`5Bourindex`5D.item_size = dynd.dsc$w_length;`09/* complete forge */
  382. X`09item`5Bourindex`5D.buffer = dynd.dsc$a_pointer;
  383. X
  384. X/*  forge the form name to have our form name */
  385. X`09
  386. X`09ourindex = findandclritem(SMBMSG$K_FORM_NAME);
  387. X`09dynd.dsc$w_length = 0;`09`09/* get dyamic string */
  388. X`09dynd.dsc$a_pointer = 0;
  389. X`09len = strlen(cp);`09`09`09/* pointer to form name */
  390. X`09str$copy_r(&dynd, &len, cp);
  391. X`09item`5Bourindex`5D.item_size = dynd.dsc$w_length;`09/* complete forge */
  392. X`09item`5Bourindex`5D.buffer = dynd.dsc$a_pointer;
  393. X`09
  394. X/*  now check to see if there are parameters */
  395. X
  396. X`09cp = ++pp;`09`09`09`09/* set extension address */
  397. X`09if (pp = strchr(cp,';')) *pp = 0;`09/* terminate at ";" */
  398. X`09
  399. X`09for (i = 0; i < 8; i++) `7B
  400. X`09`09if (*cp != '_') return;`09`09/* check next char */
  401. X`09`09cp++;`09`09`09`09/* advance over it */
  402. X
  403. X`09`09/* if there is another _, point to it, else point to the */
  404. X`09`09/* end of the string `09`09`09`09`09 */
  405. X`09`09if ((pp = strchr(cp,'_')) == 0) pp = cp + strlen(cp);
  406. X
  407. X`09`09len = pp - cp;`09`09`09/* find length of string */
  408. X`09`09if (len == 0) continue;`09`09/* if null parameter */
  409. X
  410. X`09`09/*  forge the item */
  411. X`09`09ourindex = findandclritem(SMBMSG$K_PARAMETER_1+i);
  412. X`09`09dynd.dsc$w_length = 0;`09`09/* get dynamic string */
  413. X`09`09dynd.dsc$a_pointer = 0;
  414. X`09`09str$copy_r(&dynd, &len, cp);
  415. X`09`09item`5Bourindex`5D.item_size = dynd.dsc$w_length;
  416. X`09`09item`5Bourindex`5D.buffer = dynd.dsc$a_pointer;
  417. X`09`09
  418. X`09`09cp = pp;
  419. X`09`7D
  420. X`7D
  421. X`09`09
  422. X`09
  423. X/**`09findandclritem - find and clear item.
  424. X*
  425. X*`09Finds an item in the item list. Releases the dynamic string
  426. X*`09for that item. If the item doesn't exist in the item list,
  427. X*`09create it.
  428. X*
  429. X*`09return:`09index to item in item list
  430. X*/
  431. Xfindandclritem(whichitem)
  432. Xint whichitem;
  433. X`7B
  434. X`09int i;
  435. X`09struct dsc$descriptor_d temp = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0`7D;
  436. X
  437. X`09for (i = 0; i < ii; i++) `7B`09`09/* search item list */
  438. X`09`09if (whichitem == item`5Bi`5D.item_code) break;
  439. X`09`7D
  440. X`09
  441. X`09if (i == ii) `7B`09`09`09`09/* if end of list */
  442. X`09`09if (++ii > MAXITEMS) exit(LASER$_MAXITEMS);`09/* new item */
  443. X`09`09item`5Bi`5D.item_code = whichitem;
  444. X`09`09item`5Bi`5D.item_size = 0;
  445. X`09`09item`5Bi`5D.buffer = 0;
  446. X`09`09return i;`09`09`09/* return index */
  447. X`09`7D
  448. X
  449. X`09temp.dsc$w_length = item`5Bi`5D.item_size;`09/* release string */
  450. X`09temp.dsc$a_pointer = item`5Bi`5D.buffer;
  451. X`09str$free1_dx(&temp);
  452. X`09item`5Bi`5D.buffer = 0;
  453. X`09return i;
  454. X`7D
  455. X
  456. X
  457. X/**`09checkstat - check value of system service return.
  458. X*/
  459. Xcheckstat(stat, string_dummy)
  460. Xint stat;
  461. Xchar *string_dummy;
  462. X`7B`09
  463. X`09if (!(stat & 1)) `7B
  464. X`09`09strcpy(&msg`5B5`5D, "Printer symbiont crashed due to error in ");
  465. X`09`09strcpy(&msg`5Bstrlen(msg)`5D, string_dummy);
  466. X`09`09errmsg_dsc.dsc$w_length = strlen(msg) ;
  467. X`09`09errmsg_dsc.dsc$a_pointer = &msg`5B0`5D;
  468. X`09`09msg`5Berrmsg_dsc.dsc$w_length-2`5D = '\r';
  469. X`09`09msg`5Berrmsg_dsc.dsc$w_length-1`5D = '\n';
  470. X`09`09sys$getmsg(stat, &msglen, &msgd, 15, 0);
  471. X`09`09strncpy(&msg`5Berrmsg_dsc.dsc$w_length`5D,message,msglen);
  472. X`09`09errmsg_dsc.dsc$w_length += msglen;
  473. X`09`09sndmsg(1);
  474. X`09`09if (lta_device && jobnum)
  475. X`09`09`09sys$qio(0, laserchan,IO$_TTY_PORT+IO$M_LT_DISCON, 0, 0, 0,
  476. X`09`09`090, 0, 0, 0, 0, 0);
  477. X`09  `09exit(stat);
  478. X        `7D
  479. X`7D
  480. X
  481. X
  482. X/**`09closefile - close main file.
  483. X*/
  484. Xclosefile()
  485. X`7B
  486. X`09int stat;
  487. X
  488. X`09stat = sys$close(&main_fab, 0, 0);
  489. X`09/*  ignore error */
  490. X
  491. X`09notify = FALSE;
  492. X`7D
  493. X
  494. X
  495. X/**`09closeuserlog - close user log file.
  496. X*/
  497. Xcloseuserlog()
  498. X`7B
  499. X`09int stat;
  500. X`09static int privs`5B2`5D = `7BPRV$M_BYPASS,0`7D;
  501. X
  502. X`09if (userlog < 0) return;`09`09/* if no log */
  503. X
  504. X/*  If no records written, set for delete on close */
  505. X`09
  506. X`09if (userlog == 0) log_fab.fab$l_fop `7C= FAB$M_DLT;
  507. X
  508. X`09stat = sys$close(&log_fab);
  509. X
  510. X`09stat = sys$setprv(1, privs, 0, 0);
  511. X`09checkstat(stat,"close log");
  512. X`09stat = sys$setprv(0, privs, 0, 0);
  513. X`09
  514. X`09str$free1_dx(&savelog);`09`09`09/* release saved log */
  515. X
  516. X`09userlog = -1;
  517. X`7D
  518. X`09
  519. X
  520. X/**`09expand_cc - expand PRN carriage control byte.
  521. X*
  522. X*`09Entry:`09ccb = fab$v_prn byte
  523. X*`09Exit:`09commands output to printer
  524. X*/
  525. Xexpand_cc(ccb)
  526. Xchar ccb;`09`09`09`09/* carriage control byte */
  527. X`7B
  528. X`09int ic, stat;
  529. X`09char obuf`5B40`5D;
  530. X
  531. X`09if (ccb == 0) `7B
  532. X`09`09return;
  533. X`09`7D
  534. X
  535. X`09if ((ccb & 0x80) == 0) `7B`09`09/* output (n) LF, 1 CR */
  536. X`09`09if ((ccb & 0x7f) == 1) `7B`09/* 1 LF, output short form */
  537. X`09`09`09WRITELASER("XLF XCR\r\n", 9);
  538. X`09`09`7D
  539. X`09`09else `7B
  540. X`09`09`09sprintf(obuf, "%d`7BXLF`7Drepeat XCR\r\n",(ccb & 0x7f));
  541. X`09`09`09WRITELASERBUF(obuf, strlen(obuf));
  542. X`09`09`7D
  543. X`09`7D
  544. X`09else `7B
  545. X`09`09if ((ccb & 0xe0) != 0xe0) `7B`09/* output single character */
  546. X`09`09`09ic = ccb & 0x7f;
  547. X`09`09`09expand_line(&ic, obuf, 1);
  548. X`09`09`7D
  549. X`09`7D
  550. X`7D
  551. X
  552. X
  553. X/**`09expand_hex - expand buffer into hex bytes.
  554. X*/
  555. Xexpand_hex(ibuf, obuf, rsz)
  556. Xunsigned char *ibuf;`09`09`09/* pointer to input buffer */
  557. Xchar *obuf;`09`09`09`09/* pointer to output buffer */
  558. Xint rsz;`09`09`09`09/* buffer size */
  559. X`7B
  560. X`09int i, c, stat;
  561. X`09static char hexnums`5B`5D = "0123456789ABCDEF";
  562. X`09
  563. X`09for (i = 0; i < rsz; i++) `7B
  564. X`09`09obuf`5Bi*2`5D = hexnums`5B(ibuf`5Bi`5D & 0xF0) >> 4`5D;
  565. X`09`09obuf`5Bi*2+1`5D = hexnums`5Bibuf`5Bi`5D & 0xF`5D;
  566. X`09`7D
  567. X`09WRITELASERBUF(obuf,rsz*2)
  568. X`7D
  569. X
  570. X`09
  571. X/**`09expand_line - expand input buffer and output result to printer.
  572. X*
  573. X*`09The ()pop sequences are an obscure hack to fix an obscure bug
  574. X*`09with XON/XOFF.  It just works.
  575. X*/
  576. Xexpand_line(ibuf, obuf, rsz)
  577. Xchar *ibuf;`09`09`09`09`09/* input buffer */
  578. Xchar *obuf;
  579. Xint rsz;`09`09`09`09`09/* buffer size */
  580. X`7B
  581. X`09int i, d, col, stat;
  582. X`09static int popcount = 0;`09`09/* XON kludge counter */
  583. X`09
  584. X`09d = 0;`09`09`09`09`09/* preset destination index */
  585. X`09col = 0;`09`09`09`09/* preset column */
  586. X
  587. X`09for (i = 0; i < rsz; i++) `7B
  588. X`09`09if (ibuf`5Bi`5D == 9) `09`09`7B`09/* if tab */
  589. X`09`09`09if (d == 0) obuf`5Bd++`5D = '(';/* if first */
  590. X`09`09`09do `7B
  591. X`09`09`09`09obuf`5Bd++`5D = ' ';`09/* fill spaces */
  592. X`09`09`09`09col++;
  593. X`09`09`09`7D while (col & 7);
  594. X`09`09`7D
  595. X`09`09else if (ibuf`5Bi`5D == 8 && col > 0) `7B`09/* if backspace */
  596. X`09`09`09obuf`5Bd++`5D = 8;`09/* insert backspace */
  597. X`09`09`09col--;
  598. X`09`09`7D
  599. X`09`09else if (ibuf`5Bi`5D == '(') `7B`09/* ( */
  600. X`09`09`09if (d == 0) obuf`5Bd++`5D = '(';/* if first */
  601. X`09`09`09obuf`5Bd++`5D = '\\';
  602. X`09`09`09obuf`5Bd++`5D = '(';
  603. X`09`09`09col++;
  604. X`09`09`7D
  605. X`09`09else if (ibuf`5Bi`5D == ')') `7B`09/* ) */
  606. X`09`09`09if (d == 0) obuf`5Bd++`5D = '(';/* if first */
  607. X`09`09`09obuf`5Bd++`5D = '\\';
  608. X`09`09`09obuf`5Bd++`5D = ')';
  609. X`09`09`09col++;
  610. X`09`09`7D
  611. X`09`09else if (ibuf`5Bi`5D == '\\') `7B`09/* \ */
  612. X`09`09`09if (d == 0) obuf`5Bd++`5D = '(';/* if first */
  613. X`09`09`09obuf`5Bd++`5D = '\\';
  614. X`09`09`09obuf`5Bd++`5D = '\\';
  615. X`09`09`09col++;
  616. X`09`09`7D
  617. X`09`09else if (ibuf`5Bi`5D == 0x0d) `7B /* CR */
  618. X`09`09`09if (d) `7B`09`09/* if string to terminate */
  619. X`09`09`09`09WRITELASERBUF(obuf,d)
  620. X`09`09`09`09if (++popcount == 20) `7B
  621. X`09`09`09`09`09popcount = 0;
  622. X`09`09`09`09`09WRITELASER(")XSTR()pop\r\n",12)
  623. X`09`09`09`09`7D
  624. X`09`09`09`09else `7B
  625. X`09`09`09`09`09WRITELASER(")XSTR\r\n",7)
  626. X`09`09`09`09`7D
  627. X`09`09`09`09d = 0;
  628. X`09`09`09`7D
  629. X`09`09`09WRITELASER("XCR\r\n",5)
  630. X`09`09`7D
  631. X `09`09else if (ibuf`5Bi`5D == 0x0a) `7B /* LF */
  632. X`09`09`09if (d) `7B`09`09/* if string to terminate */
  633. X`09`09`09`09WRITELASERBUF(obuf,d)
  634. X`09`09`09`09if (++popcount == 20) `7B
  635. X`09`09`09`09`09popcount = 0;
  636. X`09`09`09`09`09WRITELASER(")XSTR()pop\r\n",12)
  637. X`09`09`09`09`7D
  638. X`09`09`09`09else `7B
  639. X`09`09`09`09`09WRITELASER(")XSTR\r\n",7)
  640. X`09`09`09`09`7D
  641. X`09`09`09`09d = 0;
  642. X`09`09`09`7D
  643. X`09`09`09WRITELASER("XLF\r\n",5)
  644. X`09`09`7D
  645. X `09`09else if (ibuf`5Bi`5D == 0x0c) `7B /* FF */
  646. X`09`09`09if (d) `7B`09`09/* if string to terminate */
  647. X`09`09`09`09WRITELASERBUF(obuf,d)
  648. X`09`09`09`09if (++popcount == 20) `7B
  649. X`09`09`09`09`09popcount = 0;
  650. X`09`09`09`09`09WRITELASER(")XSTR()pop\r\n",12)
  651. X`09`09`09`09`7D
  652. X`09`09`09`09else `7B
  653. X`09`09`09`09`09WRITELASER(")XSTR\r\n",7)
  654. X`09`09`09`09`7D
  655. X`09`09`09`09d = 0;
  656. X`09`09`09`7D
  657. X`09`09`09WRITELASER("XFF\r\n",5)
  658. X`09`09`7D
  659. X`09`09else `7B
  660. X`09`09`09if (d == 0) obuf`5Bd++`5D = '(';/* if first */
  661. X`09`09`09obuf`5Bd++`5D = ibuf`5Bi`5D;`09/* move char */
  662. X`09`09`09col++;
  663. X`09`09`7D
  664. X`09`7D
  665. X`09if (d) `7B
  666. X`09`09obuf`5Bd++`5D = ')';
  667. X`09`09obuf`5Bd++`5D = 'X';
  668. X`09`09obuf`5Bd++`5D = 'S';
  669. X`09`09obuf`5Bd++`5D = 'T';
  670. X`09`09obuf`5Bd++`5D = 'R';
  671. X`09`09obuf`5Bd++`5D = '\r';
  672. X`09`09obuf`5Bd++`5D = '\n';
  673. X`09`7D
  674. X`09WRITELASERBUF(obuf,d)
  675. X`7D
  676. X
  677. X
  678. X/**`09getitems - get item list from job controller.
  679. X*/
  680. Xgetitems()
  681. X`7B
  682. X`09int stat;
  683. X`09int`09context;`09`09`09/* read_message_item context */
  684. X`09int`09item_code;`09`09`09/* item code */
  685. X`09unsigned short item_size;`09`09/* item size */
  686. X`09struct dsc$descriptor_d item_buffer =
  687. X`09`09`09`09`7B0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0`7D;
  688. X
  689. X`09context = 0;`09`09`09`09/* init context */
  690. X
  691. X/*  Save each item in a list */
  692. X`09
  693. X`09do `7B
  694. X`09`09item_buffer.dsc$a_pointer = 0;`09/* force d string allocation */
  695. X
  696. X`09`09stat = smb$read_message_item(&buffer_des, &context,
  697. X`09`09&item_code, &item_buffer, &item_size);
  698. X
  699. X`09`09item`5Bii`5D.item_code = item_code;
  700. X`09`09item`5Bii`5D.item_size = item_size;
  701. X`09`09item`5Bii`5D.buffer = item_buffer.dsc$a_pointer;
  702. X`09`09if (++ii > MAXITEMS) exit(LASER$_MAXITEMS);
  703. X`09`7D while (stat == SS$_NORMAL);
  704. X`7D
  705. X
  706. X
  707. X/**`09getitemdescrip - return item descriptor.
  708. X*
  709. X*`09return:`09TRUE if item found
  710. X*`09`09FALSE if (item not found) && NOT FATAL
  711. X*`09`09exit if (item not found) && FATAL
  712. X*/
  713. Xgetitemdescrip(code, descrip, fatal)
  714. Xint code;`09`09`09`09`09/* item code to search for */
  715. Xstruct dsc$descriptor_s *descrip;`09`09/* pointer to descriptor */
  716. Xint fatal;`09`09`09`09`09/* error severity */
  717. X`7B
  718. X`09int`09i;
  719. X
  720. X`09for (i = 0; i < ii; i++) `7B
  721. X`09`09if (item`5Bi`5D.item_code == code) `7B`09/* if found */
  722. X`09`09`09descrip->dsc$w_length = item`5Bi`5D.item_size;
  723. X`09`09`09descrip->dsc$a_pointer = item`5Bi`5D.buffer;
  724. X`09`09`09return TRUE;
  725. X`09`09`7D
  726. X`09`7D
  727. X`09if (fatal) exit(LASER$_ITEMNOTFOUND);`09/* item not in list */
  728. X`09else return FALSE;
  729. X`7D
  730. X
  731. X
  732. X/**`09getcopies - send copy count to laserwriter.
  733. X*
  734. X*`09Leave this here for now, but unfortunately, if you specify
  735. X*`09/copies=n to the print command, the job contoller sends
  736. X*`09the file that many times.  Not what we want.
  737. X*/
  738. Xgetcopies()
  739. X`7B
  740. X`09int stat, n;
  741. X`09struct dsc$descriptor_s temp = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0`7D;
  742. X`09char defcopy`5B80`5D;
  743. X
  744. X`09if (!getitemdescrip(SMBMSG$K_FILE_COPIES, &temp, FALSE))
  745. X`09`09if (!getitemdescrip(SMBMSG$K_JOB_COPIES, &temp, FALSE))
  746. X`09`09`09return;`09`09`09/* if no copies */
  747. X
  748. X`09n = * (long*) temp.dsc$a_pointer;
  749. X`09if (n == 1) return;`09`09`09/* if only 1 copy */
  750. X`09sprintf(defcopy, "/#copies %d def\r\n", n);
  751. X
  752. X`09WRITELASER(defcopy,strlen(defcopy))
  753. X`7D
  754. X
  755. X
  756. X/**`09getnote - get /note=<Text> to laserwriter.
  757. X*/
  758. Xgetnote()
  759. X`7B
  760. X`09int stat;
  761. X`09struct dsc$descriptor_s temp = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0`7D;
  762. X`09
  763. X`09if (!getitemdescrip(SMBMSG$K_NOTE, &temp, FALSE)) return; /* none */
  764. X   `20
  765. X/*
  766. X* KLUDGE ALERT: Multinet LPD puts a /note on its jobs.
  767. X*               Don't send it to the printer.
  768. X*/
  769. X`09if (strncmp(temp.dsc$a_pointer, "Remote LPD request", 18)==0)
  770. X`09`09return;
  771. X`09
  772. X`09WRITELASER(temp.dsc$a_pointer,temp.dsc$w_length)
  773. X`09WRITELASER(&0x0A0D,2)`09`09`09/* cr-lf */
  774. X`7D
  775. X
  776. X
  777. X/**`09getparams - get user parameters.
  778. X*/
  779. Xgetparams()
  780. X`7B
  781. X`09int stat;
  782. X`09int i, j, ctl;
  783. X`09int first=TRUE,startend=FALSE,border=TRUE;
  784. X`09struct dsc$descriptor_s temp = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0`7D;
  785. X`09char param`5B255`5D, str`5B255+15`5D, *eq, start`5B8`5D,end`5B8`5D,num`5B
  786. V6`5D;
  787. X`09static $DESCRIPTOR(number_up, "NUMBER_UP");
  788. X`09static $DESCRIPTOR(start_end, "STARTEND");
  789. X`09static $DESCRIPTOR(sides, "SIDES");
  790. X`09static $DESCRIPTOR(parser,"PARSER");
  791. X
  792. X`09for (i = 0; i < 8; i++) `7B`09`09/* loop for 8  parameters */
  793. X`09`09if (!getitemdescrip(SMBMSG$K_PARAMETER_1+i, &temp, FALSE))
  794. X`09`09`09continue;`09`09/* if no parameter */
  795. X
  796. X`09`09if (temp.dsc$w_length == 0) continue;`09/* if null string */
  797. X
  798. X`09`09strncpy(param, temp.dsc$a_pointer, temp.dsc$w_length);
  799. X`09`09param`5Btemp.dsc$w_length`5D = 0;
  800. X`09`09
  801. X                eq = strchr(param, '=');
  802. X                if (eq && !strncmp(param,"DATA_TYPE",(int)eq-(int)param)) `7
  803. VB
  804. X                        *eq++;
  805. X                        if (!strncmp(eq,"TEK4014",strlen(eq))) `7B
  806. X                        `09tek = TRUE;
  807. X                                ascii = FALSE;
  808. X                        `7D else if (!strncmp(eq,"ANSI",strlen(eq)) `7C`7C`2
  809. V0
  810. X`09`09`09`09 !strncmp(eq,"ASCII",strlen(eq))) `7B
  811. X                                ansi = TRUE;
  812. X                        `7D else if (!strncmp(eq,"PS",strlen(eq)) `7C`7C`20
  813. X`09`09`09`09 !strncmp(eq,"POSTSCRIPT",strlen(eq))) `7B
  814. X                                ps = TRUE;
  815. X                        `7D else `7B
  816. X`09`09`09`09stop_reason = LASER$_INVPARAM;
  817. X`09`09`09`09return FALSE;
  818. X`09`09`09`7D
  819. X                `7D else if (eq &&
  820. X`09`09`09!strncmp(param,"PAGE_ORIENTATION",(int)eq-(int)param)) `7B
  821. X                        *eq++;
  822. X                        if (!strncmp(eq,"LANDSCAPE",strlen(eq))) `7B
  823. X                                land = TRUE;
  824. X                                port = FALSE;
  825. X                        `7D else if (!strncmp(eq,"PORTRAIT",strlen(eq))) `7B
  826. X                                land = FALSE;
  827. X                                port = TRUE;
  828. X                        `7D else `7B
  829. X`09`09`09`09stop_reason = LASER$_INVPARAM;
  830. X`09`09`09`09return FALSE;
  831. X`09`09`09`7D
  832. X                `7D else if (eq &&
  833. X`09`09`09!strncmp(param,"SIDES",(int)eq-(int)param)) `7B
  834. X                        *eq++;
  835. X                        if (!strncmp(eq,"2",strlen(eq)) `7C`7C`20
  836. X`09`09`09    !strncmp(eq,"TWO",strlen(eq)) `7C`7C`20
  837. X`09`09`09    !strncmp(eq,"TWO_SIDED_DUPLEX",strlen(eq))) `7B
  838. X                                WRITESTRING("false true\r\n")
  839. X                        `7D else if (!strncmp(eq,"TUMBLE",strlen(eq)) `7C`7C
  840. V`20
  841. X`09`09`09   `09   !strncmp(eq,"TWO_SIDED_TUMBLE",strlen(eq))) `7B
  842. X                                WRITESTRING("true true\r\n")
  843. X                        `7D else `7B
  844. X`09`09`09`09stop_reason = LASER$_INVPARAM;
  845. X`09`09`09`09return FALSE;
  846. X`09`09`09`7D
  847. X `09`09`09if (!writemodule(sides)) `7B
  848. X`09`09`09`09stop_reason = LASER$_SETUPNOTFOUND;
  849. X`09`09`09`09return FALSE;
  850. X`09`09`09`7D
  851. X`09`09`7D else if (eq &&
  852. X`09`09`09!strncmp(param,"PAGE_LIMIT",(int)eq-(int)param)) `7B
  853. X`09`09`09int i = 0;
  854. X`09`09`09startend = TRUE;
  855. X                        *eq++;
  856. X`09`09`09if (*eq == '(') *eq++;
  857. X`09`09`09while (i < 5 && isdigit(*eq)) start`5Bi++`5D = *eq++;
  858. X`09`09`09if (*eq++ != ',') `7B
  859. X`09`09`09`09strncpy(end,start,i);
  860. X`09`09`09`09strncpy(start,"1\r\n\000",4);
  861. X`09`09`09`7D else `7B
  862. X`09`09`09`09strncpy(&start`5Bi`5D,"\r\n\000",3);
  863. X`09`09`09`09i = 0;
  864. X`09`09`09`09while (i < 5 && isdigit(*eq)) end`5Bi++`5D = *eq++;
  865. X`09`09`09`7D
  866. X`09`09`09if (!i)`20
  867. X`09`09`09`09strncpy(end,"10000\r\n\000",8);
  868. X`09`09`09else
  869. X                                strncpy(&end`5Bi`5D,"\r\n\000",3);`20
  870. X`09`09`7D else if (eq &&
  871. X`09`09`09!strncmp(param,"LW",(int)eq-(int)param)) `7B
  872. X                        *eq++;
  873. X`09`09`09WRITESTRING("/lw ")
  874. X`09`09`09WRITESTRING(eq)
  875. X`09`09`09WRITESTRING(" def\r\n")
  876. X                `7D else if (eq &&
  877. X`09`09`09!strncmp(param,"NUMBER_UP",(int)eq-(int)param)) `7B
  878. X`09`09`09int i = 0;
  879. X`09`09`09nup = TRUE;
  880. X                        *eq++;
  881. X`09`09`09if (*eq == '(') *eq++;
  882. X`09`09`09while (i < 3 && isdigit(*eq)) num`5Bi++`5D = *eq++;
  883. X`09`09`09if (!i) num`5Bi++`5D = '1';
  884. X                        strncpy(&num`5Bi`5D,"\r\n\000",3);`20
  885. X                `7D else if (!strncmp(param,"BORDER",strlen(param))) `7B
  886. X`09`09`09border = TRUE;
  887. X                `7D else if (eq &&
  888. X`09`09`09!strncmp(param,"BORDER",(int)eq-(int)param)) `7B
  889. X                        *eq++;
  890. X`09`09`09if (!strncmp(eq,"NONE",strlen(eq)))
  891. X`09`09`09`09border = FALSE;
  892. X                        else `7B
  893. X                                stop_reason = LASER$_INVPARAM;
  894. X                                return FALSE;
  895. X                        `7D
  896. X                `7D else if (eq &&
  897. X`09`09`09!strncmp(param,"MESSAGES",(int)eq-(int)param)) `7B
  898. X                        *eq++;
  899. X                        if (!strncmp(eq,"KEEP",strlen(eq)))`20
  900. X`09`09`09`09openuserlog();`09`09/* open user log file */
  901. X                        else `7B
  902. X                                stop_reason = LASER$_INVPARAM;
  903. X                                return FALSE;
  904. X                        `7D
  905. X`09`09`7D
  906. X`09`7D
  907. X
  908. X`09for (i = 0; i < 8; i++) `7B`09`09/* loop for 8  parameters */
  909. X`09`09if (!getitemdescrip(SMBMSG$K_PARAMETER_1+i, &temp, FALSE))
  910. X`09`09`09continue;`09`09/* if no parameter */
  911. X
  912. X`09`09if (temp.dsc$w_length == 0) continue;`09/* if null string */
  913. X
  914. X`09`09strncpy(param, temp.dsc$a_pointer, temp.dsc$w_length);
  915. X`09`09param`5Btemp.dsc$w_length`5D = 0;
  916. X`09`09
  917. X`09`09eq = strchr(param, '=');
  918. X`09`09if (!eq) eq = strchr(param, '\000');
  919. X                if (!strncmp(param,"DATA_TYPE",(int)eq-(int)param)
  920. X `09`09 `7C`7C !strncmp(param,"LW",(int)eq-(int)param)
  921. X`09`09 `7C`7C !strncmp(param,"PAGE_ORIENTATION",(int)eq-(int)param)
  922. X`09`09 `7C`7C !strncmp(param,"SIDES",(int)eq-(int)param)
  923. X`09`09 `7C`7C !strncmp(param,"PAGE_LIMIT",(int)eq-(int)param)
  924. X`09`09 `7C`7C !strncmp(param,"NUMBER_UP",(int)eq-(int)param)
  925. X`09`09 `7C`7C !strncmp(param,"BORDER",(int)eq-(int)param)
  926. X`09`09 `7C`7C !strncmp(param,"MESSAGES",(int)eq-(int)param)) `7B
  927. X`09`09`7D else `7B
  928. X`09`09`09if (first) `7B`09`09`09/* if first one */
  929. X`09`09`09`09first = FALSE;
  930. X`09`09`09`09WRITELASER("/params `5B\r\n",11)
  931. X`09`09`09`7D
  932. X
  933. X`09`09`09for (j= 0; (j < strlen(param)) && (param`5Bj`5D != '(');
  934. X`09`09`09`09 j++) `7B`09/* lowercase string */
  935. X`09`09`09`09if (isupper(param`5Bj`5D)) param`5Bj`5D `5E= 0x20;
  936. X`09`09`09`7D      `20
  937. X`09`09
  938. X/*  if there is an = separator (or - for spooled files), use it */
  939. X`09`09
  940. X`09`09`09if ((eq = strchr(param, '='))
  941. X`09`09`09`09`7C`7C (eq = strchr(param, '-'))
  942. X`09`09`09`09`7C`7C (eq = strchr(param, ':'))) `7B
  943. X`09`09`09`09*eq++ = 0;`09`09/* bust string in 2 */
  944. X`09`09`09`09sprintf(str, "(%s) %s\r\n", param, eq);
  945. X`09`09`09`7D
  946. X`09`09`09else sprintf(str, "(param%d) %s\r\n", i+1, param);
  947. X
  948. X`09`09`09WRITELASER(str,strlen(str))
  949. X`09`09`7D
  950. X`09`7D
  951. X       `20
  952. X        getitemdescrip(SMBMSG$K_PRINT_CONTROL, &temp, TRUE);
  953. X        ctl = * (long*) temp.dsc$a_pointer;
  954. X
  955. X`09if (ctl & SMBMSG$M_PAGE_HEADER) `7B
  956. X`09`09if (first) `7B`09`09`09`09/* if first one */
  957. X`09`09`09first = FALSE;
  958. X`09`09`09WRITELASER("/params `5B\r\n",11)
  959. X`09`09`7D
  960. X
  961. X`09`09WRITESTRING("(title) true\r\n")
  962. X`09`7D
  963. X`09
  964. X`09if (!first) `7B`09`09`09`09/* if some params found */
  965. X`09`09WRITELASER("`5D def\r\n",7)
  966. X`09`09writemodule(parser);`09`09/* write the parser module */
  967. X`09`7D
  968. X
  969. X`09if (nup) `7B
  970. X`09`09if (!writemodule(number_up)) `7B
  971. X`09`09`09stop_reason = LASER$_SETUPNOTFOUND;
  972. X`09`09`09return FALSE;
  973. X`09`09`7D
  974. X`09`09WRITELASER(num,strlen(num))
  975. X`09`09WRITELASER("false\r\n",7)  /* true to transpose row/col order */
  976. X`09`09if (port)
  977. X`09       `09`09WRITELASER("false\r\n",7)
  978. X`09`09else
  979. X`09       `09`09WRITELASER("true\r\n",6)
  980. X`09       `09WRITELASER("false\r\n",7)  /* true for Mac landscape */
  981. X`09       `09WRITELASER("false\r\n",7)  /* true to disable clipping */
  982. X`09`09if (border)`20
  983. X`09       `09`09WRITELASER("0\r\n",3)
  984. X`09`09else
  985. X`09       `09`09WRITELASER("-1\r\n",4)
  986. X`09`09if (startend) `7B
  987. X`09`09       `09WRITELASER(start,strlen(start))
  988. X`09`09       `09WRITELASER(end,strlen(end))
  989. X`09`09`7D else `7B
  990. X`09`09`09WRITELASER("1\r\n",3)
  991. X`09`09`09WRITELASER("10000\r\n",7)
  992. X`09`09`7D
  993. X`09`09WRITELASER("DMM-nup-pre\r\n",13)
  994. X        `7D else if (startend) `7B
  995. X`09`09WRITELASER(start,strlen(start))
  996. X`09`09WRITELASER(end,strlen(end))
  997. X`09`09if (!writemodule(start_end)) `7B
  998. X`09`09`09stop_reason = LASER$_SETUPNOTFOUND;
  999. X`09`09`09return FALSE;
  1000. X`09`09`7D
  1001. X`09`7D
  1002. X
  1003. X`09return TRUE;
  1004. X`7D
  1005. X
  1006. X
  1007. X/**`09getsetup - get setup module to laserwriter.
  1008. X*
  1009. X*`09return:`09TRUE if no problems with setup module.
  1010. X*`09        FALSE if setup module nonexistant
  1011. X*/
  1012. Xgetsetup()
  1013. X`7B
  1014. X`09int stat, len;
  1015. X`09int library_index;
  1016. X`09long txtrfa`5B2`5D;
  1017. X`09char inbuf`5B255`5D;
  1018. X`09struct dsc$descriptor_s inbufdes = `7Bsizeof(inbuf), DSC$K_DTYPE_T, DSC$K
  1019. V_CLASS_S, inbuf`7D;
  1020. X`09struct dsc$descriptor_s outbufdes;
  1021. X`09struct dsc$descriptor_s key = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0`7D;
  1022. X`09struct dsc$descriptor_s temp = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0`7D;
  1023. X
  1024. X/*  Try for a file setup module first, then a form setup module.  For now,
  1025. X    we only support one setup module, the first found. We should support
  1026. X    lists of setup modules, and all found. */
  1027. X`09
  1028. X`09if (!getitemdescrip(SMBMSG$K_FILE_SETUP_MODULES, &key, FALSE))
  1029. X`09`09if (!getitemdescrip(SMBMSG$K_FORM_SETUP_MODULES, &key, FALSE))
  1030. X`09`09`09return TRUE;`09`09/* if no setup */
  1031. X
  1032. X`09if (key.dsc$w_length == 0) return TRUE;`09/* if no setup */
  1033. X`09
  1034. X`09if (!getparams()) return FALSE;`09`09/* get user parameters */
  1035. X
  1036. X`09if (ps) return TRUE;
  1037. X
  1038. X/*  Get out if no library. Error because the user specified a setup. */
  1039. X
  1040. X`09if (library_spec.dsc$a_pointer == 0) `7B
  1041. +-+-+-+-+-+-+-+-  END  OF PART 2 +-+-+-+-+-+-+-+-
  1042.  
  1043.