Debian Codegraph @

exp/prj/amd/src/app/exp-amd-utils.als

raw
1 # ----------------------------------------------------------------------------
2 # - exp-amd-utils -
3 # - afnxi:amd utility functions module -
4 # ----------------------------------------------------------------------------
5 # - This program is free software; you can redistribute it and/or modify -
6 # - it provided that this copyright notice is kept intact. -
7 # - -
8 # - This program is distributed in the hope that it will be useful, but -
9 # - without any warranty; without even the implied warranty of -
10 # - merchantability or fitness for a particular purpose. In not event shall -
11 # - the copyright holder be liable for any direct, indirect, incidental or -
12 # - special damages arising in any way out of the use of this software. -
13 # ----------------------------------------------------------------------------
14 # - copyright (c) 1999-2023 amaury darsch -
15 # ----------------------------------------------------------------------------
16
17 # ----------------------------------------------------------------------------
18 # - type section -
19 # ----------------------------------------------------------------------------
20
21 # map an argument to a literal
22 # @param value the value to map
23
24 const afnix:amd:to-literal (value) (
25 if (literal-p value) (value:to-literal) "nil"
26 )
27
28 # ----------------------------------------------------------------------------
29 # - copyright section -
30 # ----------------------------------------------------------------------------
31
32 # @return the copyright message
33
34 const afnix:amd:get-copyright-message nil {
35 # format the copyright message
36 + (+ AFNIX:AMD:TITLE " - ") AFNIX:AMD:HOLDER
37 }
38
39 # @return the full system version
40
41 const afnix:amd:get-revision-message nil {
42 # get the revision info
43 const major (afnix:amd:to-literal AFNIX:AMD:MAJOR)
44 const minor (afnix:amd:to-literal AFNIX:AMD:MINOR)
45 const patch (afnix:amd:to-literal AFNIX:AMD:PATCH)
46 # format the revision message
47 const mesg (+ (+ (+ (+ (+ "revision " major) '.') minor) '.') patch)
48 # add system info
49 mesg:+= (+ ", afnix " interp:version)
50 mesg:+= (+ ", " interp:os-name)
51 # here it is
52 eval mesg
53 }
54
55 # ----------------------------------------------------------------------------
56 # - uri section -
57 # ----------------------------------------------------------------------------
58
59 # normalize a uri name with a http scheme
60 # @param name the name to normalize
61
62 const afnix:amd:get-uri-name (name) {
63 # cerate a uri with a normalized name
64 const uri (afnix:nwg:Uri (afnix:nwg:normalize-uri-name name))
65 # get the hierarchical name
66 uri:get-hname
67 }
68
69 # compute the output name by uri and requested name
70 # @param uri the uri to process
71
72 const afnix:amd:get-output-name (uri) {
73 # check if the file name has been set
74 if afnix:amd:system-oflg (return afnix:amd:system-onam)
75 # make sure we have a uri
76 assert true (afnix:nwg:uri-p uri)
77 # get the uri path target
78 const ptnm (uri:get-path-target)
79 # make sure we have something
80 if (ptnm:nil-p) afnix:amd:system-onam ptnm
81 }
82
83 # create a new media controler by uri
84 # @param uri the uri to parse
85
86 const afnix:amd:newmc (uri) {
87 # make sure we have a uri
88 assert true (afnix:nwg:uri-p uri)
89 # create a media controller from the scheme
90 switch (uri:get-scheme) (
91 ("http" (afnix:amd:htmmc uri))
92 (else {
93 const msg "invalid media scheme "
94 throw "uri-error" (+ msg (uri:get-name))
95 }
96 )
97 )
98 }