Production Ready Macros for SAS Application Developers
mm_getwebappsrvprops.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Retrieves properties of the SAS web app server
4  @description usage:
5 
6  %mm_getwebappsrvprops(outds= some_ds)
7  data _null_;
8  set some_ds(where=(name='webappsrv.server.url'));
9  put value=;
10  run;
11 
12  @param outds the dataset to create that contains the list of properties
13 
14  @returns outds dataset containing all properties
15 
16  @warning The following filenames are created and then de-assigned:
17 
18  filename __in clear;
19  filename __out clear;
20  libname __shake clear;
21 
22  @version 9.4
23  @author Allan Bowe
24 
25 **/
26 
27 %macro mm_getwebappsrvprops(
28  outds= mm_getwebappsrvprops
29 )/*/STORE SOURCE*/;
30 
31 filename __in temp lrecl=10000;
32 filename __out temp lrecl=10000;
33 filename __shake temp lrecl=10000;
34 data _null_ ;
35  file __in ;
36  put '<GetMetadataObjects>' ;
37  put '<Reposid>$METAREPOSITORY</Reposid>' ;
38  put '<Type>TextStore</Type>' ;
39  put '<NS>SAS</NS>' ;
40  put '<Flags>388</Flags>' ;
41  put '<Options>' ;
42  put '<XMLSelect search="TextStore[@Name='@@;
43  put "'Public Configuration Properties']" @@;
44  put '[Objects/SoftwareComponent[@ClassIdentifier=''webappsrv'']]' ;
45  put '"/>';
46  put '<Templates>' ;
47  put '<TextStore StoredText="">' ;
48  put '</TextStore>' ;
49  put '</Templates>' ;
50  put '</Options>' ;
51  put '</GetMetadataObjects>' ;
52 run ;
53 proc metadata in=__in out=__out verbose;run;
54 
55 /* find the beginning of the text */
56 data _null_;
57  infile __out lrecl=10000;
58  input;
59  length cleartemplate $32000;
60  cleartemplate=tranwrd(_infile_,'StoredText=""','');
61  start=index(cleartemplate,'StoredText="');
62  if start then do;
63  call symputx("start",start+11+length('StoredText=""')-1);
64  putlog cleartemplate ;
65  end;
66  stop;
67 run;
68 %put &=start;
69 /* read the content, byte by byte, resolving escaped chars */
70 data _null_;
71  length filein 8 fileid 8;
72  filein = fopen("__out","I",1,"B");
73  fileid = fopen("__shake","O",1,"B");
74  rec = "20"x;
75  length entity $6;
76  do while(fread(filein)=0);
77  x+1;
78  if x>&start then do;
79  rc = fget(filein,rec,1);
80  if rec='"' then leave;
81  else if rec="&" then do;
82  entity=rec;
83  do until (rec=";");
84  if fread(filein) ne 0 then goto getout;
85  rc = fget(filein,rec,1);
86  entity=cats(entity,rec);
87  end;
88  select (entity);
89  when ('&amp;' ) rec='&' ;
90  when ('&lt;' ) rec='<' ;
91  when ('&gt;' ) rec='>' ;
92  when ('&apos;') rec="'" ;
93  when ('&quot;') rec='"' ;
94  when ('&#x0a;') rec='0A'x;
95  when ('&#x0d;') rec='0D'x;
96  when ('&#36;' ) rec='$' ;
97  otherwise putlog "WARNING: missing value for " entity=;
98  end;
99  rc =fput(fileid, substr(rec,1,1));
100  rc =fwrite(fileid);
101  end;
102  else do;
103  rc =fput(fileid,rec);
104  rc =fwrite(fileid);
105  end;
106  end;
107  end;
108  getout:
109  rc=fclose(filein);
110  rc=fclose(fileid);
111 run;
112 
113 data &outds ;
114  infile __shake dlm='=' missover;
115  length name $50 value $500;
116  input name $ value $;
117 run;
118 
119 /* clear references */
120 filename __in clear;
121 filename __out clear;
122 filename __shake clear;
123 
124 %mend;