#This awk script, when invoked against the client.lyt file for OpenMind setup
#will strip out all viewer files that are not part of the bundled OM.
#This is for the 16 bit viewer files

BEGIN { c = 0; bundle = 0}

/vs70cgm\.dll/ {c=c+1; continue}
/vs70dez\.dll/ {c=c+1; continue}
/vs70dif\.dll/ {c=c+1; continue}
/vs70drw\.dll/ {c=c+1; continue}
/vs70dx\.dll/ {c=c+1; continue}
/vs70en4\.dll/ {c=c+1; continue}
/vs70ens\.dll/ {c=c+1; continue}
/vs70enw\.dll/ {c=c+1; continue}
/vs70fax\.dll/ {c=c+1; continue}
/vs70fcd\.dll/ {c=c+1; continue}
/vs70fcs\.dll/ {c=c+1; continue}
/vs70fft\.dll/ {c=c+1; continue}
/vs70fwk\.dll/ {c=c+1; continue}
/vs70hgs\.dll/ {c=c+1; continue}
/vs70img\.dll/ {c=c+1; continue}
/vs70iwp\.dll/ {c=c+1; continue}
/vs70jw\.dll/ {c=c+1; continue}
/vs70leg\.dll/ {c=c+1; continue}
/vs70m11\.dll/ {c=c+1; continue}
/vs70manu\.dll/ {c=c+1; continue}
/vs70mcw\.dll/ {c=c+1; continue}
/vs70mm\.dll/ {c=c+1; continue}
/vs70mm4\.dll/ {c=c+1; continue}
/vs70mmfn\.dll/ {c=c+1; continue}
/vs70mp\.dll/ {c=c+1; continue}
/vs70mwkd\.dll/ {c=c+1; continue}
/vs70mwks\.dll/ {c=c+1; continue}
/vs70mwpf\.dll/ {c=c+1; continue}
/vs70mwrk\.dll/ {c=c+1; continue}
/vs70ow\.dll/ {c=c+1; continue}
/vs70pcl\.dll/ {c=c+1; continue}
/vs70pfs\.dll/ {c=c+1; continue}
/vs70pntg\.dll/ {c=c+1; continue}
/vs70ppl\.dll/ {c=c+1; continue}
/vs70qa\.dll/ {c=c+1; continue}
/vs70qad\.dll/ {c=c+1; continue}
/vs70rbs\.dll/ {c=c+1; continue}
/vs70rft\.dll/ {c=c+1; continue}
/vs70rfx\.dll/ {c=c+1; continue}
/vs70sam\.dll/ {c=c+1; continue}
/vs70sc5\.dll/ {c=c+1; continue}
/vs70sdw\.dll/ {c=c+1; continue}
/vs70smd\.dll/ {c=c+1; continue}
/vs70sms\.dll/ {c=c+1; continue}
/vs70smt\.dll/ {c=c+1; continue}
/vs70snap\.dll/ {c=c+1; continue}
/vs70spt\.dll/ {c=c+1; continue}
/vs70tga\.dll/ {c=c+1; continue}
/vs70tw\.dll/ {c=c+1; continue}
/vs70txt\.dll/ {c=c+1; continue}
/vs70vw3\.dll/ {c=c+1; continue}
/vs70wg2\.dll/ {c=c+1; continue}
/vs70wm\.dll/ {c=c+1; continue}
/vs70wpg\.dll/ {c=c+1; continue}
/vs70wpg2\.dll/ {c=c+1; continue}
/vs70ws\.dll/ {c=c+1; continue}
/vs70ws2\.dll/ {c=c+1; continue}
/vs70xy\.dll/ {c=c+1; continue}
/vs70mwp2\.dll/ {c=c+1; continue}
/vs70mwrd\.dll/ {c=c+1; continue}
/vs70wk3\.dll/ {c=c+1; continue}


#Count the number of viewer files
/vs.+\.dll/ { bundle = bundle + 1} #count bundled viewers

#print all lines except non-bundled viewers
/./ {print $0}

END {if (bundle < 30) 
			{
			print "There are only " bundle " viewers present!";
         exit 1;
         }
         
	  if (bundle > 30)
	  		{
	  		print "The viewer license only allows 30 viewers. There are " bundle " viewers present!";
         exit 2;
         }
#    print "Count = " c #used for debugging. Counts non-bundled viewers
	  exit 0;
	  }

 
