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