%!PS-Adobe-3.1 % Attempted Distiller-GoogleDrive-GhostScript snooper snoop1a.psl % ================================================================ % Copyright c 2019 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.1 % some ongoing experiments in reading ps internals. % This uses a simplified text presenter. Use Gonzo for anything fancier { systemdict begin .distillerparamkeys {} forall } pop %%%%%%%%%% Some Gonzo Utility Excerpts %%%%%%%%%%% /thingridlines {0} def % simplified grid modules /setgrid { /blocksize exch def translate blocksize dup scale} def /showgrid {gsave /vblocks exch def /hblocks exch def thingridlines setlinewidth [{0 0 moveto 0 vblocks rlineto stroke} 1 hblocks 1 add] xrpt [{0 0 moveto hblocks 0 rlineto stroke} 1 vblocks 1 add] yrpt fatterborder { gsave newpath 0 0.96 blocksize div dtransform round idtransform setlinewidth pop 2 setlinecap 0 0 moveto hblocks 0 rlineto 0 vblocks rlineto hblocks neg 0 rlineto closepath stroke grestore} if fat5 { gsave newpath 0 0.48 blocksize div setlinewidth pop mark {5 0 moveto 0 vblocks rlineto stroke} 5 hblocks 5 div cvi] xrpt mark {0 5 moveto hblocks 0 rlineto stroke} 5 vblocks 5 div cvi] yrpt grestore} if fatter10 { gsave 18 setwebtint % emphasize here newpath 0 0.96 blocksize div setlinewidth pop mark {10 0 moveto 0 vblocks rlineto stroke} 10 hblocks 10 div cvi] xrpt mark {0 10 moveto hblocks 0 rlineto stroke} 10 vblocks 10 div cvi] yrpt grestore} if grestore} def /fatterborder true store /fat5 true store /fatter10 true store % repeats [ proc distance trips] xrpt /xrpt{gsave aload pop /trips exch def /dist exch def /rproc exch def trips { gsave rproc grestore dist 0 translate } repeat grestore} def /yrpt{gsave aload pop /trips exch def /dist exch def /rproc exch def trips { gsave rproc grestore 0 dist translate } repeat grestore} def % gonzofont accepts either % /font1 /Helvetica 12 gonzofont -- or else -- % /font1 /Helvetica [wide climb slant high xshift yshift] gonzofont /gonzofont { dup type cvlit /arraytype eq {exch findfont exch makefont} {exch findfont exch scalefont} ifelse setfont mark /spacewidth ( ) stringwidth pop /cstretch cvx /add cvx /sstretch cvx /add cvx /def cvx currentfont dup backcdict exch (F?) dup 1 14 index (xxxxx) cvs 4 get put put /setfont cvx ] cvx def} def % mergestr merges the two top stack strings into one top stack string /mergestr {2 copy length exch length add string dup dup 4 3 roll 4 index length exch putinterval 3 1 roll exch 0 exch putinterval} def % ///////// WEB FRIENDLY COLOR UTILITIES ///////////// % tintmat is a self-generating list of 216 triple color % values. Not presently in the classic Gonzo Utilities /webtintmat [ 0 1 5 { /a exch store 0 1 5 { /b exch store 0 1 5 { 5 div b 5 div a 5 div }for } for } for ] def % setwebtint accepts a color number 0 to 215 and then % sets the PostScript color generator for later use... /setwebtint { abs cvi 216 cvi mod % restrict range webtintmat exch 3 mul 3 getinterval % get values from table aload pop setrgbcolor} def % and set them % The blocks are arranged as red to the right, green % up in order of increasing blue. % Some "pure color" sequences are % red: 0 1 2 3 4 5 % orange: 0 7 8 15 16 23 (sort of) % yellow: 0 7 14 21 28 35 % green: 0 6 12 18 24 30 % aqua: 0 42 84 126 168 210 % blue: 0 36 72 108 144 180 % magenta: 0 37 74 111 148 185 % purple 0 73 73 110 147 183 (sort of) % gray 0 43 86 129 172 215 % Array bubble sort utility. Insert near beginning of your PostScript code... % sorts counts on an array of [(string1)(string2)...(stringn)]] % additional inside array elements or even subarrays permitted. /bubsort2s {/curmat1 exch store curmat1 length 1 sub -1 1 % start outer loop {/done true store % short exit marker /maxposition exch store 0 1 maxposition 1 sub {/posn exch store % inner loop curmat1 posn get % find current count curmat1 posn 1 add get % compare to next higher gt % lt {curmat1 posn get % swap only if needed curmat1 posn 1 add get curmat1 exch posn exch put curmat1 exch posn 1 add exch put /done false store % a swap was needed }if } for % inner loop done {exit} if % stop on no swaps } for % outer loop curmat1 % update sorted array } bind store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % //////// this does it ///////// /gridhigh 69 store /gridwide 52 store /viewgrid {true} store /xmar 1 store /xpos xmar store /ytop 65 store /ypos ytop store /ybot 2 store /yinc 1 store /xtab 18 store /StoneSans-Bold findfont 1.1 scalefont setfont /placename {xpos ypos moveto 50 string cvs show % for three column display ypos ybot gt {/ypos ypos yinc sub store} {/xpos xpos xtab add store xpos xtab 3 mul gt {showpage 31 setwebtint 50 50 10 setgrid % image grid on following page viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store} if /ypos ytop store} ifelse } store /placename2 {xpos ypos moveto 50 string cvs show % for two column display ypos ybot gt {/ypos ypos yinc sub store} {/xpos xpos xtab add 9 add store xpos xtab 3 mul gt {showpage 31 setwebtint 50 50 10 setgrid % image grid on following page viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store} if /ypos ytop store} ifelse } store { %%% currentdistillerparams1 /snoopcurrentdistillerparams1zzz { % only in Distiller; GhostScript uses 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store systemdict /currentdistillerparams known { 11 67 moveto (currentdistillerparams has a total of ) currentdistillerparams length 50 string cvs mergestr ( name entries.) mergestr show mark currentdistillerparams {pop dup type (nametype) eq {50 string cvs}{pop }ifelse } forall ] /curarray exch store curarray bubsort2s curarray { (/)exch mergestr placename2} forall } { 11 67 moveto (currentdistillerparams is not known ) (in this version.) mergestr show } ifelse showpage } store } pop %%% currentdistillerparams %%% /snoopcurrentdistillerparams1 { 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (currentdistillerparams has a total of ) currentdistillerparams length 50 string cvs mergestr ( name entries.) mergestr show mark currentdistillerparams {pop dup type (nametype) eq {50 string cvs}{pop }ifelse } forall ] /curarray exch store curarray bubsort2s curarray { (/)exch mergestr placename2} forall showpage } store %%% systemdict %%% /snoopsystemdict1 { 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (systemdict has a total of ) systemdict length 50 string cvs mergestr ( name entries.) mergestr show mark systemdict {pop dup type (nametype) eq {50 string cvs}{pop }ifelse } forall ] /curarray exch store curarray bubsort2s curarray { (/)exch mergestr placename} forall showpage } store %%% userdict %%% /snoopuserdict1 { 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (userdict has a total of ) userdict length 30 string cvs mergestr ( name entries.) mergestr show mark userdict {pop dup type (nametype) eq {35 string cvs}{pop }ifelse } forall ] /curarray exch store curarray bubsort2s curarray { (/) exch mergestr placename} forall showpage } store %%%% errordict %%%% /snooperrordict1 { 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (errordict has a total of ) errordict length 30 string cvs mergestr ( name entries.) mergestr show mark errordict {pop dup type (nametype) eq {35 string cvs}{pop }ifelse } forall ] /curarray exch store curarray bubsort2s /curarray exch store curarray {(/) exch mergestr placename} forall showpage } store %%%% execdict %%%% /snoopexecdict1 { 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (execdict has a total of ) execdict length 30 string cvs mergestr ( name entries.) mergestr show mark execdict {pop dup type (nametype) eq {35 string cvs}{pop }ifelse } forall ] /curarray exch store curarray bubsort2s curarray {(/) exch mergestr placename}forall showpage } store %%%% globaldict %%%% /snoopglobaldict1 { 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (globaldict has a total of ) globaldict length 30 string cvs mergestr ( name entries.) mergestr show mark globaldict {pop dup type (nametype) eq {35 string cvs}{pop }ifelse } forall ] /curarray exch store curarray bubsort2s curarray { (/) exch mergestr placename}forall showpage } store %%%% statusdict %%%% /snoopstatusdict1 { 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (statusdict has a total of ) statusdict length 30 string cvs mergestr ( name entries.) mergestr show mark statusdict {pop dup type (nametype) eq {35 string cvs}{pop }ifelse } forall ] /curarray exch store curarray bubsort2s curarray { (/) exch mergestr placename}forall showpage} store %%%% serverdict %%%% /snoopserverdict1 { 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (serverdictdict has a total of ) serverdict length 30 string cvs mergestr ( name entries.) mergestr show mark serverdict {pop dup type (nametype) eq {35 string cvs}{pop }ifelse } forall ] /curarray exch store curarray bubsort2s curarray { (/) exch mergestr placename} forall showpage }store %%%% shareddict %%%% /snoopshareddict1 { 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (shareddict has a total of ) shareddict length 30 string cvs mergestr ( name entries.) mergestr show mark shareddict {pop dup type (nametype) eq {35 string cvs}{pop }ifelse } forall ] /curarray exch store curarray bubsort2s curarray { (/) exch mergestr placename} forall showpage }store %%%% pdfmark in internaldict ( needs usual password ) %%%% %%%% distillerdict in internaldict ( needs usual password ) %%%% /snoopdistillerdict1 { 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (distillerdict has a total of ) 1183615869 internaldict begin {distillerdict length} superexec 50 string cvs mergestr ( name entries.) mergestr show mark 1183615869 internaldict begin distillerdict { {pop dup type (nametype)eq {50 string cvs}{pop} ifelse }forall } superexec ] /curarray exch store curarray bubsort2s/curarray exch store curarray curarray { (/) exch mergestr placename} forall showpage }store %%%% internaldict ( needs usual password ) %%%% /snoopinternaldict1 { 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (internaldict has a total of ) 1183615869 internaldict length 30 string cvs mergestr ( name entries.) mergestr show mark 1183615869 internaldict {pop dup type (nametype) eq {35 string cvs}{pop }ifelse } forall ] /curarray exch store curarray bubsort2s curarray { (/) exch mergestr placename} forall showpage } store /snoopexecdict1 { % only in Distiller; not in ghostscr4ipt 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store systemdict /execdict known { 11 67 moveto (execdict has a total of ) execdict length 50 string cvs mergestr ( name entries.) mergestr show mark execdict {pop dup type (nametype) eq {50 string cvs}{pop }ifelse } forall ] /curarray exch store curarray bubsort2s curarray { (/)exch mergestr placename2} forall } { 11 67 moveto (execdict is not known ) (in this implementation .) mergestr show } ifelse showpage } store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % snoopcurrentdistillerparams1 now in systemdict with /. % snoopdistillerdict1 /snooppdfmarkInternalDict1 { %Note: Distiller uses Internaldict, GS yet to be found. 1183615869 internaldict /pdfmarkInternalDict known { 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (pdfmarkInternalDict has a total of ) 1183615869 internaldict begin {pdfmarkInternalDict length} superexec 50 string cvs mergestr ( name entries.) mergestr show mark 1183615869 internaldict begin pdfmarkInternalDict { {pop dup type (nametype)eq {50 string cvs}{pop} ifelse }forall } superexec ] /curarray exch store curarray bubsort2s/curarray exch store curarray curarray { (/) exch mergestr placename} forall showpage } if systemdict /pdfdict known { % GS only 31 setwebtint 50 50 10 setgrid viewgrid {gridwide gridhigh showgrid} if 0 setwebtint /ypos ytop store /xpos xmar store 11 67 moveto (pdfdict has a total of ) pdfdict length 50 string cvs mergestr ( name entries.) mergestr show mark pdfdict { {pop dup type (nametype)eq {50 string cvs}{pop} ifelse }forall } superexec ] /curarray exch store curarray bubsort2s/curarray exch store curarray curarray { (/) exch mergestr placename} forall showpage } if }store /showdicts { snoopcurrentdistillerparams1 % ok snooperrordict1 % ok snoopexecdict1 % only on Distiller; not on GhostScript snoopglobaldict1 % present but empty snoopinternaldict1 % ok but sparce on gd snooppdfmarkInternalDict1 % only in internaldict in distiller % snooppdfDict % only in systemdict in GhostScript snoopserverdict1 % ok snoopshareddict1 % present but empty snoopstatusdict1 % ok snoopsystemdict1 % ok snoopuserdict1 % ok } store % //////// this does it ///////// showdicts % showpage % duplicate last page unneeded %% EOF