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