diff --git a/3ano/1semestre/so/practice-exam/so+fso-1920-epnm-v2.pdf b/3ano/1semestre/so/practice-exam/so+fso-1920-epnm-v2.pdf new file mode 100644 index 0000000..812305c Binary files /dev/null and b/3ano/1semestre/so/practice-exam/so+fso-1920-epnm-v2.pdf differ diff --git a/3ano/1semestre/so/practice-exam/src/Makefile b/3ano/1semestre/so/practice-exam/src/Makefile new file mode 100644 index 0000000..f45931a --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/Makefile @@ -0,0 +1,21 @@ +CXX = g++ +CPPFLAGS=-Wall -Wfatal-errors -Wno-write-strings -Wno-unused-function -ggdb -pthread -Iinclude # -DEXCEPTION_POLICY or -DEXIT_POLICY +LDFLAGS = -Llib -lsoconcur + +OBJS=pfifo.o urgency.o + +TARGET = urgency + +.PHONY: all clean cleanall + +all: $(TARGET) + +urgency: $(OBJS) + $(CXX) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) + +clean: + rm -fv *.o core + +cleanall: clean + rm -f $(TARGET) + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/bc_s.png b/3ano/1semestre/so/practice-exam/src/doc/html/bc_s.png new file mode 100644 index 0000000..224b29a Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/bc_s.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/bdwn.png b/3ano/1semestre/so/practice-exam/src/doc/html/bdwn.png new file mode 100644 index 0000000..940a0b9 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/bdwn.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/closed.png b/3ano/1semestre/so/practice-exam/src/doc/html/closed.png new file mode 100644 index 0000000..98cc2c9 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/closed.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/dbc_8h.html b/3ano/1semestre/so/practice-exam/src/doc/html/dbc_8h.html new file mode 100644 index 0000000..f8495c8 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/dbc_8h.html @@ -0,0 +1,108 @@ + + + + + + + +C++ Library, mos@ua: dbc.h File Reference + + + + + + + + + + +
+
+ + + + + + +
+
C++ Library, mos@ua +  0.9 +
+
cpplib-mos
+
+
+ + + + + + +
+
+ +
+
+
+ +
+
+ +
+
dbc.h File Reference
+
+
+ +

Design-by-Contract module. +More...

+
#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include "utils.h"
+
+

Go to the source code of this file.

+ + + + + + + + + + + + + + +

+Macros

#define check(condition, message)
 Checks the verification of an general algorithm assertion. More...
 
#define require(condition, message)
 Checks the verification of a precondition. More...
 
#define ensure(condition, message)
 Checks the verification of a postcondition. More...
 
#define invariant(condition, message)
 Checks the verification of an invariant. More...
 
+

Detailed Description

+

Design-by-Contract module.

+
+
+ + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/dbc_8h.js b/3ano/1semestre/so/practice-exam/src/doc/html/dbc_8h.js new file mode 100644 index 0000000..8d4c28c --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/dbc_8h.js @@ -0,0 +1,7 @@ +var dbc_8h = +[ + [ "check", "group___db_c.html#gac101c8ba449f6f8c71b3789a9c489221", null ], + [ "require", "group___db_c.html#ga5bf1825f80465097d4b753a001cf1af8", null ], + [ "ensure", "group___db_c.html#ga5d17c602c4f191371a5fec5af7adc3cf", null ], + [ "invariant", "group___db_c.html#gaf9d59b04beef1bf139e10fc44c6f9725", null ] +]; \ No newline at end of file diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/dbc_8h_source.html b/3ano/1semestre/so/practice-exam/src/doc/html/dbc_8h_source.html new file mode 100644 index 0000000..1e46f7e --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/dbc_8h_source.html @@ -0,0 +1,203 @@ + + + + + + + +C++ Library, mos@ua: dbc.h Source File + + + + + + + + + + +
+
+ + + + + + +
+
C++ Library, mos@ua +  0.9 +
+
cpplib-mos
+
+
+ + + + + + +
+
+ +
+
+
+ +
+
+
+
dbc.h
+
+
+Go to the documentation of this file.
1 
+
34 #ifndef DBC_H
+
35 #define DBC_H
+
36 
+
37 #include <stdio.h>
+
38 #include <stdlib.h>
+
39 #include <assert.h>
+
40 #include "utils.h"
+
41 
+
42 #ifdef NDEBUG
+
43 #define NDEBUG_CHECKS
+
44 #define NDEBUG_PRECONDITIONS
+
45 #define NDEBUG_POSTCONDITIONS
+
46 #define NDEBUG_INVARIANTS
+
47 #endif
+
48 
+
49 #ifdef DEBUG_ONLY_PRECONDITIONS
+
50 #ifdef NDEBUG_PRECONDITIONS
+
51 #undef NDEBUG_PRECONDITIONS
+
52 #endif
+
53 #ifndef NDEBUG_CHECKS
+
54 #define NDEBUG_CHECKS
+
55 #endif
+
56 #ifndef NDEBUG_POSTCONDITIONS
+
57 #define NDEBUG_POSTCONDITIONS
+
58 #endif
+
59 #ifndef NDEBUG_INVARIANTS
+
60 #define NDEBUG_INVARIANTS
+
61 #endif
+
62 #endif
+
63 
+
64 // check:
+
65 #ifdef NDEBUG_CHECKS
+
66 #define check(condition, message)
+
67 #else
+
68 #if defined __cplusplus && defined EXCEPTION_POLICY
+
69 #define check(condition, message) \
+
70  if (!(condition)) \
+
71  throw string_concat(NULL, 0, (char*)"Assertion fail", message[0] ? (char*)": " : (char*)"", message, (char*)", assertion: \"", #condition, (char*)"\", function: \"", __FUNCTION__, (char*)"\":", int2str(__LINE__), (char*)", file: \"", __FILE__, (char*)"\"\n", NULL)
+
72 #else // EXIT_POLICY (default)
+
73 
+
81 #define check(condition, message) \
+
82  if (!(condition)) \
+
83  do { \
+
84  fprintf (stderr, "Assertion fail%s%s, assertion: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \
+
85  message[0] ? ": " : "", message, #condition, __FUNCTION__, __LINE__ , __FILE__); \
+
86  *((int*)0) = 0; \
+
87  abort (); \
+
88  } while (0)
+
89 #endif
+
90 #endif
+
91 
+
92 
+
93 // precondition:
+
94 #ifdef NDEBUG_PRECONDITIONS
+
95 #define require(condition, message)
+
96 #else
+
97 #if defined __cplusplus && defined EXCEPTION_POLICY
+
98 #define require(condition, message) \
+
99  if (!(condition)) \
+
100  throw string_concat(NULL, 0, (char*)"Precondition fail", message[0] ? (char*)": " : (char*)"", message, (char*)", assertion: \"", #condition, (char*)"\", function: \"", __FUNCTION__, (char*)"\":", int2str(__LINE__), (char*)", file: \"", __FILE__, (char*)"\"\n", NULL)
+
101 #else // EXIT_POLICY (default)
+
102 
+
110 #define require(condition, message) \
+
111  if (!(condition)) \
+
112  do { \
+
113  fprintf (stderr, "Precondition fail%s%s, assertion: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \
+
114  message[0] ? ": " : "", message, #condition, __FUNCTION__, __LINE__ , __FILE__); \
+
115  *((int*)0) = 0; \
+
116  abort (); \
+
117  } while (0)
+
118 #endif
+
119 #endif
+
120 
+
121 
+
122 // postcondition:
+
123 #ifdef NDEBUG_POSTCONDITIONS
+
124 #define ensure(condition, message)
+
125 #else
+
126 #if defined __cplusplus && defined EXCEPTION_POLICY
+
127 #define ensure(condition, message) \
+
128  if (!(condition)) \
+
129  throw string_concat(NULL, 0, (char*)"Postcondition fail", message[0] ? (char*)": " : (char*)"", message, (char*)", assertion: \"", #condition, (char*)"\", function: \"", __FUNCTION__, (char*)"\":", int2str(__LINE__), (char*)", file: \"", __FILE__, (char*)"\"\n", NULL)
+
130 #else // EXIT_POLICY (default)
+
131 
+
139 #define ensure(condition, message) \
+
140  if (!(condition)) \
+
141  do { \
+
142  fprintf (stderr, "Postcondition fail%s%s, assertion: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \
+
143  message[0] ? ": " : "", message, #condition, __FUNCTION__, __LINE__ , __FILE__); \
+
144  *((int*)0) = 0; \
+
145  abort (); \
+
146  } while (0)
+
147 #endif
+
148 #endif
+
149 
+
150 //
+
151 // invariant:
+
152 #ifdef NDEBUG_INVARIANTS
+
153 #define invariant(condition, message)
+
154 #else
+
155 #if defined __cplusplus && defined EXCEPTION_POLICY
+
156 #define invariant(condition, message) \
+
157  if (!(condition)) \
+
158  throw string_concat(NULL, 0, (char*)"Invariant fail", message[0] ? (char*)": " : (char*)"", message, (char*)", assertion: \"", #condition, (char*)"\", function: \"", __FUNCTION__, (char*)"\":", int2str(__LINE__), (char*)", file: \"", __FILE__, (char*)"\"\n", NULL)
+
159 #else // EXIT_POLICY (default)
+
160 
+
168 #define invariant(condition, message) \
+
169  if (!(condition)) \
+
170  do { \
+
171  fprintf (stderr, "Invariant fail%s%s, assertion: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \
+
172  message[0] ? ": " : "", message, #condition, __FUNCTION__, __LINE__ , __FILE__); \
+
173  *((int*)0) = 0; \
+
174  abort (); \
+
175  } while (0)
+
176 #endif
+
177 #endif
+
178 
+
179 #endif
+
180 
+
181 /* ************************************************** */
+
185 /* ************************************************** */
+
186 
+
+
+
utils.h
Useful common functions and macros.
+ + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/3ano/1semestre/so/practice-exam/src/doc/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html new file mode 100644 index 0000000..ba0809c --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -0,0 +1,95 @@ + + + + + + + +C++ Library, mos@ua: src Directory Reference + + + + + + + + + + +
+
+ + + + + + +
+
C++ Library, mos@ua +  0.9 +
+
cpplib-mos
+
+
+ + + + + + +
+
+ +
+
+
+ +
+
+
+
src Directory Reference
+
+
+ + + + + + + + + + + + + + +

+Files

file  dbc.h [code]
 Design-by-Contract module.
 
file  process.h [code]
 Process, System-V, and POSIX libraries wrapper module.
 
file  thread.h [code]
 POSIX threads library wrapper module.
 
file  utils.h [code]
 Useful common functions and macros.
 
+
+
+ + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/doc.png b/3ano/1semestre/so/practice-exam/src/doc/html/doc.png new file mode 100644 index 0000000..17edabf Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/doc.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/doxygen.css b/3ano/1semestre/so/practice-exam/src/doc/html/doxygen.css new file mode 100644 index 0000000..73ecbb2 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/doxygen.css @@ -0,0 +1,1771 @@ +/* The standard CSS for doxygen 1.8.17 */ + +body, table, div, p, dl { + font: 400 14px/22px Roboto,sans-serif; +} + +p.reference, p.definition { + font: 400 14px/22px Roboto,sans-serif; +} + +/* @group Heading Levels */ + +h1.groupheader { + font-size: 150%; +} + +.title { + font: 400 14px/28px Roboto,sans-serif; + font-size: 150%; + font-weight: bold; + margin: 10px 2px; +} + +h2.groupheader { + border-bottom: 1px solid #879ECB; + color: #354C7B; + font-size: 150%; + font-weight: normal; + margin-top: 1.75em; + padding-top: 8px; + padding-bottom: 4px; + width: 100%; +} + +h3.groupheader { + font-size: 100%; +} + +h1, h2, h3, h4, h5, h6 { + -webkit-transition: text-shadow 0.5s linear; + -moz-transition: text-shadow 0.5s linear; + -ms-transition: text-shadow 0.5s linear; + -o-transition: text-shadow 0.5s linear; + transition: text-shadow 0.5s linear; + margin-right: 15px; +} + +h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { + text-shadow: 0 0 15px cyan; +} + +dt { + font-weight: bold; +} + +ul.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; + column-count: 3; +} + +p.startli, p.startdd { + margin-top: 2px; +} + +th p.starttd, p.intertd, p.endtd { + font-size: 100%; + font-weight: 700; +} + +p.starttd { + margin-top: 0px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +p.interli { +} + +p.interdd { +} + +p.intertd { +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab{ + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #4665A2; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #9CAFD4; + color: #FFFFFF; + border: 1px double #869DCA; +} + +.contents a.qindexHL:visited { + color: #FFFFFF; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code, a.code:visited, a.line, a.line:visited { + color: #4665A2; +} + +a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { + color: #4665A2; +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +ul { + overflow: hidden; /*Fixed: list item bullets overlap floating elements*/ +} + +#side-nav ul { + overflow: visible; /* reset ul rule for scroll bar in GENERATE_TREEVIEW window */ +} + +#main-nav ul { + overflow: visible; /* reset ul rule for the navigation bar drop down lists */ +} + +.fragment { + text-align: left; + direction: ltr; + overflow-x: auto; /*Fixed: fragment lines overlap floating elements*/ + overflow-y: hidden; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; + font-family: monospace, fixed; + font-size: 105%; +} + +div.fragment { + padding: 0 0 1px 0; /*Fixed: last line underline overlap border*/ + margin: 4px 8px 4px 2px; + background-color: #FBFCFD; + border: 1px solid #C4CFE5; +} + +div.line { + font-family: monospace, fixed; + font-size: 13px; + min-height: 13px; + line-height: 1.0; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; /* Moz */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + white-space: pre-wrap; /* CSS3 */ + word-wrap: break-word; /* IE 5.5+ */ + text-indent: -53px; + padding-left: 53px; + padding-bottom: 0px; + margin: 0px; + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +div.line:after { + content:"\000A"; + white-space: pre; +} + +div.line.glow { + background-color: cyan; + box-shadow: 0 0 10px cyan; +} + + +span.lineno { + padding-right: 4px; + text-align: right; + border-right: 2px solid #0F0; + background-color: #E8E8E8; + white-space: pre; +} +span.lineno a { + background-color: #D8D8D8; +} + +span.lineno a:hover { + background-color: #C8C8C8; +} + +.lineno { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +div.ah, span.ah { + background-color: black; + font-weight: bold; + color: #FFFFFF; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + box-shadow: 2px 2px 3px #999; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000 110%); +} + +div.classindex ul { + list-style: none; + padding-left: 0; +} + +div.classindex span.ai { + display: inline-block; +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background-color: white; + color: black; + margin: 0; +} + +div.contents { + margin-top: 10px; + margin-left: 12px; + margin-right: 8px; +} + +td.indexkey { + background-color: #EBEFF6; + font-weight: bold; + border: 1px solid #C4CFE5; + margin: 2px 0px 2px 0; + padding: 2px 10px; + white-space: nowrap; + vertical-align: top; +} + +td.indexvalue { + background-color: #EBEFF6; + border: 1px solid #C4CFE5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #EEF1F7; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { + +} + +img.formulaInl, img.inline { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ + +span.keyword { + color: #008000 +} + +span.keywordtype { + color: #604020 +} + +span.keywordflow { + color: #e08000 +} + +span.comment { + color: #800000 +} + +span.preprocessor { + color: #806020 +} + +span.stringliteral { + color: #002080 +} + +span.charliteral { + color: #008080 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +blockquote { + background-color: #F7F8FB; + border-left: 2px solid #9CAFD4; + margin: 0 24px 0 4px; + padding: 0 12px 0 16px; +} + +blockquote.DocNodeRTL { + border-left: 0; + border-right: 2px solid #9CAFD4; + margin: 0 4px 0 24px; + padding: 0 16px 0 12px; +} + +/* @end */ + +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #A3B4D7; +} + +th.dirtab { + background: #EBEFF6; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.memberdecls td, .fieldtable tr { + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +.memberdecls td.glow, .fieldtable tr.glow { + background-color: cyan; + box-shadow: 0 0 15px cyan; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #F9FAFC; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memSeparator { + border-bottom: 1px solid #DEE4F0; + line-height: 1px; + margin: 0px; + padding: 0px; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memItemRight, .memTemplItemRight { + width: 100%; +} + +.memTemplParams { + color: #4665A2; + white-space: nowrap; + font-size: 80%; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtitle { + padding: 8px; + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + border-top-right-radius: 4px; + border-top-left-radius: 4px; + margin-bottom: -1px; + background-image: url('nav_f.png'); + background-repeat: repeat-x; + background-color: #E2E8F2; + line-height: 1.25; + font-weight: 300; + float:left; +} + +.permalink +{ + font-size: 65%; + display: inline-block; + vertical-align: middle; +} + +.memtemplate { + font-size: 80%; + color: #4665A2; + font-weight: normal; + margin-left: 9px; +} + +.memnav { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.mempage { + width: 100%; +} + +.memitem { + padding: 0; + margin-bottom: 10px; + margin-right: 5px; + -webkit-transition: box-shadow 0.5s linear; + -moz-transition: box-shadow 0.5s linear; + -ms-transition: box-shadow 0.5s linear; + -o-transition: box-shadow 0.5s linear; + transition: box-shadow 0.5s linear; + display: table !important; + width: 100%; +} + +.memitem.glow { + box-shadow: 0 0 15px cyan; +} + +.memname { + font-weight: 400; + margin-left: 6px; +} + +.memname td { + vertical-align: bottom; +} + +.memproto, dl.reflist dt { + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 0px 6px 0px; + color: #253555; + font-weight: bold; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + background-color: #DFE5F1; + /* opera specific markup */ + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + border-top-right-radius: 4px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + -moz-border-radius-topright: 4px; + /* webkit specific markup */ + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 4px; + +} + +.overload { + font-family: "courier new",courier,monospace; + font-size: 65%; +} + +.memdoc, dl.reflist dd { + border-bottom: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 10px 2px 10px; + background-color: #FBFCFD; + border-top-width: 0; + background-image:url('nav_g.png'); + background-repeat:repeat-x; + background-color: #FFFFFF; + /* opera specific markup */ + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + /* firefox specific markup */ + -moz-border-radius-bottomleft: 4px; + -moz-border-radius-bottomright: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); +} + +dl.reflist dt { + padding: 5px; +} + +dl.reflist dd { + margin: 0px 0px 10px 0px; + padding: 5px; +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} +.paramname code { + line-height: 14px; +} + +.params, .retval, .exception, .tparams { + margin-left: 0px; + padding-left: 0px; +} + +.params .paramname, .retval .paramname, .tparams .paramname, .exception .paramname { + font-weight: bold; + vertical-align: top; +} + +.params .paramtype, .tparams .paramtype { + font-style: italic; + vertical-align: top; +} + +.params .paramdir, .tparams .paramdir { + font-family: "courier new",courier,monospace; + vertical-align: top; +} + +table.mlabels { + border-spacing: 0px; +} + +td.mlabels-left { + width: 100%; + padding: 0px; +} + +td.mlabels-right { + vertical-align: bottom; + padding: 0px; + white-space: nowrap; +} + +span.mlabels { + margin-left: 8px; +} + +span.mlabel { + background-color: #728DC1; + border-top:1px solid #5373B4; + border-left:1px solid #5373B4; + border-right:1px solid #C4CFE5; + border-bottom:1px solid #C4CFE5; + text-shadow: none; + color: white; + margin-right: 4px; + padding: 2px 3px; + border-radius: 3px; + font-size: 7pt; + white-space: nowrap; + vertical-align: middle; +} + + + +/* @end */ + +/* these are for tree view inside a (index) page */ + +div.directory { + margin: 10px 0px; + border-top: 1px solid #9CAFD4; + border-bottom: 1px solid #9CAFD4; + width: 100%; +} + +.directory table { + border-collapse:collapse; +} + +.directory td { + margin: 0px; + padding: 0px; + vertical-align: top; +} + +.directory td.entry { + white-space: nowrap; + padding-right: 6px; + padding-top: 3px; +} + +.directory td.entry a { + outline:none; +} + +.directory td.entry a img { + border: none; +} + +.directory td.desc { + width: 100%; + padding-left: 6px; + padding-right: 6px; + padding-top: 3px; + border-left: 1px solid rgba(0,0,0,0.05); +} + +.directory tr.even { + padding-left: 6px; + background-color: #F7F8FB; +} + +.directory img { + vertical-align: -30%; +} + +.directory .levels { + white-space: nowrap; + width: 100%; + text-align: right; + font-size: 9pt; +} + +.directory .levels span { + cursor: pointer; + padding-left: 2px; + padding-right: 2px; + color: #3D578C; +} + +.arrow { + color: #9CAFD4; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + cursor: pointer; + font-size: 80%; + display: inline-block; + width: 16px; + height: 22px; +} + +.icon { + font-family: Arial, Helvetica; + font-weight: bold; + font-size: 12px; + height: 14px; + width: 16px; + display: inline-block; + background-color: #728DC1; + color: white; + text-align: center; + border-radius: 4px; + margin-left: 2px; + margin-right: 2px; +} + +.icona { + width: 24px; + height: 22px; + display: inline-block; +} + +.iconfopen { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('folderopen.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +.iconfclosed { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('folderclosed.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +.icondoc { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('doc.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +table.directory { + font: 400 14px Roboto,sans-serif; +} + +/* @end */ + +div.dynheader { + margin-top: 8px; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +address { + font-style: normal; + color: #2A3D61; +} + +table.doxtable caption { + caption-side: top; +} + +table.doxtable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +table.fieldtable { + /*width: 100%;*/ + margin-bottom: 10px; + border: 1px solid #A8B8D9; + border-spacing: 0px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); + box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); +} + +.fieldtable td, .fieldtable th { + padding: 3px 7px 2px; +} + +.fieldtable td.fieldtype, .fieldtable td.fieldname { + white-space: nowrap; + border-right: 1px solid #A8B8D9; + border-bottom: 1px solid #A8B8D9; + vertical-align: top; +} + +.fieldtable td.fieldname { + padding-top: 3px; +} + +.fieldtable td.fielddoc { + border-bottom: 1px solid #A8B8D9; + /*width: 100%;*/ +} + +.fieldtable td.fielddoc p:first-child { + margin-top: 0px; +} + +.fieldtable td.fielddoc p:last-child { + margin-bottom: 2px; +} + +.fieldtable tr:last-child td { + border-bottom: none; +} + +.fieldtable th { + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + font-size: 90%; + color: #253555; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; + font-weight: 400; + -moz-border-radius-topleft: 4px; + -moz-border-radius-topright: 4px; + -webkit-border-top-left-radius: 4px; + -webkit-border-top-right-radius: 4px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-bottom: 1px solid #A8B8D9; +} + + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image:url('tab_b.png'); + background-repeat:repeat-x; + background-position: 0 -5px; + height:30px; + line-height:30px; + color:#8AA0CC; + border:solid 1px #C2CDE4; + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right:15px; + background-image:url('bc_s.png'); + background-repeat:no-repeat; + background-position:right; + color:#364D7C; +} + +.navpath li.navelem a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; + color: #283A5D; + font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + text-decoration: none; +} + +.navpath li.navelem a:hover +{ + color:#6884BD; +} + +.navpath li.footer +{ + list-style-type:none; + float:right; + padding-left:10px; + padding-right:15px; + background-image:none; + background-repeat:no-repeat; + background-position:right; + color:#364D7C; + font-size: 8pt; +} + + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +table.classindex +{ + margin: 10px; + white-space: nowrap; + margin-left: 3%; + margin-right: 3%; + width: 94%; + border: 0; + border-spacing: 0; + padding: 0; +} + +div.ingroups +{ + font-size: 8pt; + width: 50%; + text-align: left; +} + +div.ingroups a +{ + white-space: nowrap; +} + +div.header +{ + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} + +div.headertitle +{ + padding: 5px 5px 5px 10px; +} + +.PageDocRTL-title div.headertitle { + text-align: right; + direction: rtl; +} + +dl { + padding: 0 0 0 0; +} + +/* dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug, dl.examples */ +dl.section { + margin-left: 0px; + padding-left: 0px; +} + +dl.section.DocNodeRTL { + margin-right: 0px; + padding-right: 0px; +} + +dl.note { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #D0C000; +} + +dl.note.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #D0C000; +} + +dl.warning, dl.attention { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #FF0000; +} + +dl.warning.DocNodeRTL, dl.attention.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #FF0000; +} + +dl.pre, dl.post, dl.invariant { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #00D000; +} + +dl.pre.DocNodeRTL, dl.post.DocNodeRTL, dl.invariant.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #00D000; +} + +dl.deprecated { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #505050; +} + +dl.deprecated.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #505050; +} + +dl.todo { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #00C0E0; +} + +dl.todo.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #00C0E0; +} + +dl.test { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #3030E0; +} + +dl.test.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #3030E0; +} + +dl.bug { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #C08050; +} + +dl.bug.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #C08050; +} + +dl.section dd { + margin-bottom: 6px; +} + + +#projectlogo +{ + text-align: center; + vertical-align: bottom; + border-collapse: separate; +} + +#projectlogo img +{ + border: 0px none; +} + +#projectalign +{ + vertical-align: middle; +} + +#projectname +{ + font: 300% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 2px 0px; +} + +#projectbrief +{ + font: 120% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#projectnumber +{ + font: 50% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#titlearea +{ + padding: 0px; + margin: 0px; + width: 100%; + border-bottom: 1px solid #5373B4; +} + +.image +{ + text-align: center; +} + +.dotgraph +{ + text-align: center; +} + +.mscgraph +{ + text-align: center; +} + +.plantumlgraph +{ + text-align: center; +} + +.diagraph +{ + text-align: center; +} + +.caption +{ + font-weight: bold; +} + +div.zoom +{ + border: 1px solid #90A5CE; +} + +dl.citelist { + margin-bottom:50px; +} + +dl.citelist dt { + color:#334975; + float:left; + font-weight:bold; + margin-right:10px; + padding:5px; +} + +dl.citelist dd { + margin:2px 0; + padding:5px 0; +} + +div.toc { + padding: 14px 25px; + background-color: #F4F6FA; + border: 1px solid #D8DFEE; + border-radius: 7px 7px 7px 7px; + float: right; + height: auto; + margin: 0 8px 10px 10px; + width: 200px; +} + +.PageDocRTL-title div.toc { + float: left !important; + text-align: right; +} + +div.toc li { + background: url("bdwn.png") no-repeat scroll 0 5px transparent; + font: 10px/1.2 Verdana,DejaVu Sans,Geneva,sans-serif; + margin-top: 5px; + padding-left: 10px; + padding-top: 2px; +} + +.PageDocRTL-title div.toc li { + background-position-x: right !important; + padding-left: 0 !important; + padding-right: 10px; +} + +div.toc h3 { + font: bold 12px/1.2 Arial,FreeSans,sans-serif; + color: #4665A2; + border-bottom: 0 none; + margin: 0; +} + +div.toc ul { + list-style: none outside none; + border: medium none; + padding: 0px; +} + +div.toc li.level1 { + margin-left: 0px; +} + +div.toc li.level2 { + margin-left: 15px; +} + +div.toc li.level3 { + margin-left: 30px; +} + +div.toc li.level4 { + margin-left: 45px; +} + +.PageDocRTL-title div.toc li.level1 { + margin-left: 0 !important; + margin-right: 0; +} + +.PageDocRTL-title div.toc li.level2 { + margin-left: 0 !important; + margin-right: 15px; +} + +.PageDocRTL-title div.toc li.level3 { + margin-left: 0 !important; + margin-right: 30px; +} + +.PageDocRTL-title div.toc li.level4 { + margin-left: 0 !important; + margin-right: 45px; +} + +.inherit_header { + font-weight: bold; + color: gray; + cursor: pointer; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.inherit_header td { + padding: 6px 0px 2px 5px; +} + +.inherit { + display: none; +} + +tr.heading h2 { + margin-top: 12px; + margin-bottom: 4px; +} + +/* tooltip related style info */ + +.ttc { + position: absolute; + display: none; +} + +#powerTip { + cursor: default; + white-space: nowrap; + background-color: white; + border: 1px solid gray; + border-radius: 4px 4px 4px 4px; + box-shadow: 1px 1px 7px gray; + display: none; + font-size: smaller; + max-width: 80%; + opacity: 0.9; + padding: 1ex 1em 1em; + position: absolute; + z-index: 2147483647; +} + +#powerTip div.ttdoc { + color: grey; + font-style: italic; +} + +#powerTip div.ttname a { + font-weight: bold; +} + +#powerTip div.ttname { + font-weight: bold; +} + +#powerTip div.ttdeci { + color: #006318; +} + +#powerTip div { + margin: 0px; + padding: 0px; + font: 12px/16px Roboto,sans-serif; +} + +#powerTip:before, #powerTip:after { + content: ""; + position: absolute; + margin: 0px; +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.s:after, #powerTip.s:before, +#powerTip.w:after, #powerTip.w:before, +#powerTip.e:after, #powerTip.e:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.nw:after, #powerTip.nw:before, +#powerTip.sw:after, #powerTip.sw:before { + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; +} + +#powerTip.n:after, #powerTip.s:after, +#powerTip.w:after, #powerTip.e:after, +#powerTip.nw:after, #powerTip.ne:after, +#powerTip.sw:after, #powerTip.se:after { + border-color: rgba(255, 255, 255, 0); +} + +#powerTip.n:before, #powerTip.s:before, +#powerTip.w:before, #powerTip.e:before, +#powerTip.nw:before, #powerTip.ne:before, +#powerTip.sw:before, #powerTip.se:before { + border-color: rgba(128, 128, 128, 0); +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.nw:after, #powerTip.nw:before { + top: 100%; +} + +#powerTip.n:after, #powerTip.ne:after, #powerTip.nw:after { + border-top-color: #FFFFFF; + border-width: 10px; + margin: 0px -10px; +} +#powerTip.n:before { + border-top-color: #808080; + border-width: 11px; + margin: 0px -11px; +} +#powerTip.n:after, #powerTip.n:before { + left: 50%; +} + +#powerTip.nw:after, #powerTip.nw:before { + right: 14px; +} + +#powerTip.ne:after, #powerTip.ne:before { + left: 14px; +} + +#powerTip.s:after, #powerTip.s:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.sw:after, #powerTip.sw:before { + bottom: 100%; +} + +#powerTip.s:after, #powerTip.se:after, #powerTip.sw:after { + border-bottom-color: #FFFFFF; + border-width: 10px; + margin: 0px -10px; +} + +#powerTip.s:before, #powerTip.se:before, #powerTip.sw:before { + border-bottom-color: #808080; + border-width: 11px; + margin: 0px -11px; +} + +#powerTip.s:after, #powerTip.s:before { + left: 50%; +} + +#powerTip.sw:after, #powerTip.sw:before { + right: 14px; +} + +#powerTip.se:after, #powerTip.se:before { + left: 14px; +} + +#powerTip.e:after, #powerTip.e:before { + left: 100%; +} +#powerTip.e:after { + border-left-color: #FFFFFF; + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.e:before { + border-left-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +#powerTip.w:after, #powerTip.w:before { + right: 100%; +} +#powerTip.w:after { + border-right-color: #FFFFFF; + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.w:before { + border-right-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +@media print +{ + #top { display: none; } + #side-nav { display: none; } + #nav-path { display: none; } + body { overflow:visible; } + h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } + .summary { display: none; } + .memitem { page-break-inside: avoid; } + #doc-content + { + margin-left:0 !important; + height:auto !important; + width:auto !important; + overflow:inherit; + display:inline; + } +} + +/* @group Markdown */ + +/* +table.markdownTable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.markdownTable td, table.markdownTable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.markdownTableHead tr { +} + +table.markdownTableBodyLeft td, table.markdownTable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +th.markdownTableHeadLeft th.markdownTableHeadRight th.markdownTableHeadCenter th.markdownTableHeadNone { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +th.markdownTableHeadLeft { + text-align: left +} + +th.markdownTableHeadRight { + text-align: right +} + +th.markdownTableHeadCenter { + text-align: center +} +*/ + +table.markdownTable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.markdownTable td, table.markdownTable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.markdownTable tr { +} + +th.markdownTableHeadLeft, th.markdownTableHeadRight, th.markdownTableHeadCenter, th.markdownTableHeadNone { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +th.markdownTableHeadLeft, td.markdownTableBodyLeft { + text-align: left +} + +th.markdownTableHeadRight, td.markdownTableBodyRight { + text-align: right +} + +th.markdownTableHeadCenter, td.markdownTableBodyCenter { + text-align: center +} + +.DocNodeRTL { + text-align: right; + direction: rtl; +} + +.DocNodeLTR { + text-align: left; + direction: ltr; +} + +table.DocNodeRTL { + width: auto; + margin-right: 0; + margin-left: auto; +} + +table.DocNodeLTR { + width: auto; + margin-right: auto; + margin-left: 0; +} + +tt, code, kbd, samp +{ + display: inline-block; + direction:ltr; +} +/* @end */ + +u { + text-decoration: underline; +} + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/doxygen.png b/3ano/1semestre/so/practice-exam/src/doc/html/doxygen.png new file mode 100644 index 0000000..3ff17d8 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/doxygen.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/dynsections.js b/3ano/1semestre/so/practice-exam/src/doc/html/dynsections.js new file mode 100644 index 0000000..ea0a7b3 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/dynsections.js @@ -0,0 +1,120 @@ +/* + @licstart The following is the entire license notice for the + JavaScript code in this file. + + Copyright (C) 1997-2017 by Dimitri van Heesch + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + @licend The above is the entire license notice + for the JavaScript code in this file + */ +function toggleVisibility(linkObj) +{ + var base = $(linkObj).attr('id'); + var summary = $('#'+base+'-summary'); + var content = $('#'+base+'-content'); + var trigger = $('#'+base+'-trigger'); + var src=$(trigger).attr('src'); + if (content.is(':visible')===true) { + content.hide(); + summary.show(); + $(linkObj).addClass('closed').removeClass('opened'); + $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); + } else { + content.show(); + summary.hide(); + $(linkObj).removeClass('closed').addClass('opened'); + $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); + } + return false; +} + +function updateStripes() +{ + $('table.directory tr'). + removeClass('even').filter(':visible:even').addClass('even'); +} + +function toggleLevel(level) +{ + $('table.directory tr').each(function() { + var l = this.id.split('_').length-1; + var i = $('#img'+this.id.substring(3)); + var a = $('#arr'+this.id.substring(3)); + if (l + + + + + + +C++ Library, mos@ua: File List + + + + + + + + + + +
+
+ + + + + + +
+
C++ Library, mos@ua +  0.9 +
+
cpplib-mos
+
+
+ + + + + + +
+
+ +
+
+
+ +
+
+
+
File List
+
+
+
Here is a list of all documented files with brief descriptions:
+ + + + + +
 dbc.hDesign-by-Contract module
 process.hProcess, System-V, and POSIX libraries wrapper module
 thread.hPOSIX threads library wrapper module
 utils.hUseful common functions and macros
+
+
+
+ + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/files_dup.js b/3ano/1semestre/so/practice-exam/src/doc/html/files_dup.js new file mode 100644 index 0000000..fa08b09 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/files_dup.js @@ -0,0 +1,7 @@ +var files_dup = +[ + [ "dbc.h", "dbc_8h.html", "dbc_8h" ], + [ "process.h", "process_8h.html", "process_8h" ], + [ "thread.h", "thread_8h.html", "thread_8h" ], + [ "utils.h", "utils_8h.html", "utils_8h" ] +]; \ No newline at end of file diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/folderclosed.png b/3ano/1semestre/so/practice-exam/src/doc/html/folderclosed.png new file mode 100644 index 0000000..bb8ab35 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/folderclosed.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/folderopen.png b/3ano/1semestre/so/practice-exam/src/doc/html/folderopen.png new file mode 100644 index 0000000..d6c7f67 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/folderopen.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/globals.html b/3ano/1semestre/so/practice-exam/src/doc/html/globals.html new file mode 100644 index 0000000..73e09d1 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/globals.html @@ -0,0 +1,439 @@ + + + + + + + +C++ Library, mos@ua: Globals + + + + + + + + + + +
+
+ + + + + + +
+
C++ Library, mos@ua +  0.9 +
+
cpplib-mos
+
+
+ + + + + + +
+
+ +
+
+
+ +
+
+
Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation:
+ +

- c -

+ + +

- e -

+ + +

- h -

+ + +

- i -

+ + +

- l -

+ + +

- m -

+ + +

- n -

+ + +

- p -

+ + +

- r -

+ + +

- s -

+ + +

- t -

+
+
+ + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/globals_defs.html b/3ano/1semestre/so/practice-exam/src/doc/html/globals_defs.html new file mode 100644 index 0000000..5a31dc1 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/globals_defs.html @@ -0,0 +1,127 @@ + + + + + + + +C++ Library, mos@ua: Globals + + + + + + + + + + +
+
+ + + + + + +
+
C++ Library, mos@ua +  0.9 +
+
cpplib-mos
+
+
+ + + + + + +
+
+ +
+
+
+ +
+
+
+
+ + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/globals_func.html b/3ano/1semestre/so/practice-exam/src/doc/html/globals_func.html new file mode 100644 index 0000000..49ef70b --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/globals_func.html @@ -0,0 +1,376 @@ + + + + + + + +C++ Library, mos@ua: Globals + + + + + + + + + + +
+
+ + + + + + +
+
C++ Library, mos@ua +  0.9 +
+
cpplib-mos
+
+
+ + + + + + +
+
+ +
+
+
+ +
+
+  + +

- c -

+ + +

- h -

+ + +

- i -

+ + +

- m -

+ + +

- p -

+ + +

- r -

+ + +

- s -

+ + +

- t -

+
+
+ + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/group___db_c.html b/3ano/1semestre/so/practice-exam/src/doc/html/group___db_c.html new file mode 100644 index 0000000..0796ad0 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/group___db_c.html @@ -0,0 +1,305 @@ + + + + + + + +C++ Library, mos@ua: DbC + + + + + + + + + + +
+
+ + + + + + +
+
C++ Library, mos@ua +  0.9 +
+
cpplib-mos
+
+
+ + + + + + +
+
+ +
+
+
+ +
+
+ +
+
DbC
+
+
+ +

Design-by-Contract module. +More...

+ + + + + +

+Files

file  dbc.h
 Design-by-Contract module.
 
+ + + + + + + + + + + + + +

+Macros

#define check(condition, message)
 Checks the verification of an general algorithm assertion. More...
 
#define require(condition, message)
 Checks the verification of a precondition. More...
 
#define ensure(condition, message)
 Checks the verification of a postcondition. More...
 
#define invariant(condition, message)
 Checks the verification of an invariant. More...
 
+

Detailed Description

+

Design-by-Contract module.

+

This module gives a better support for DbC in C++.

+

When compared with assert.h this module offers the following functionalities:

    +
  • separates different assertion types (preconditions, postconditions, invariants, and others);
  • +
  • augments assert with error message strings;
  • +
  • implements two error handling policies:
      +
    1. EXIT_POLICY (default): describes the failed assertion in stderr (with the identification and the precise location of the assertion), generates a segmentation fault (enabling a stack trace within a debugger like gdb), and exits program execution;
    2. +
    3. EXCEPTION_POLICY: throws a char* exception with the description of the failed assertion.
    4. +
    +
  • +
+

Debug settings:

    +
  • As happens with assert.h, this module accepts NDEBUG macro definition to disable all assertion run-time verification.
  • +
  • Also, each assertion type verification can be disabled with macros: NDEBUG_CHECKS, NDEBUG_PRECONDITIONS, NDEBUG_POSTCONDITIONS, and NDEBUG_INVARIANTS.
  • +
  • A special (high priority) macro named DEBUG_ONLY_PRECONDITIONS ensures that only precondition debugging remains active (regardless of other debug definitions).
  • +
+
Author
Miguel Oliveira e Silva, 2018
+

Macro Definition Documentation

+ +

◆ check

+ +
+
+ + + + + + + + + + + + + + + + + + +
#define check( condition,
 message 
)
+
+Value:
if (!(condition)) \
+
do { \
+
fprintf (stderr, "Assertion fail%s%s, assertion: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \
+
message[0] ? ": " : "", message, #condition, __FUNCTION__, __LINE__ , __FILE__); \
+
*((int*)0) = 0; \
+
abort (); \
+
} while (0)
+
+

Checks the verification of an general algorithm assertion.

+

This assertion verification can be disabled at compile time by defining the macro NDEBUG_CHECKS.

+
Parameters
+ + + +
[in]conditionexpression to assert its truthness
[in]messagetext to be presented with error information when the assertion fails
+
+
+ +
+
+ +

◆ require

+ +
+
+ + + + + + + + + + + + + + + + + + +
#define require( condition,
 message 
)
+
+Value:
if (!(condition)) \
+
do { \
+
fprintf (stderr, "Precondition fail%s%s, assertion: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \
+
message[0] ? ": " : "", message, #condition, __FUNCTION__, __LINE__ , __FILE__); \
+
*((int*)0) = 0; \
+
abort (); \
+
} while (0)
+
+

Checks the verification of a precondition.

+

This assertion verification can be disabled at compile time by defining the macro NDEBUG_PRECONDITIONS.

+
Parameters
+ + + +
[in]conditionexpression to assert its truthness
[in]messagetext to be presented with error information when the assertion fails
+
+
+ +
+
+ +

◆ ensure

+ +
+
+ + + + + + + + + + + + + + + + + + +
#define ensure( condition,
 message 
)
+
+Value:
if (!(condition)) \
+
do { \
+
fprintf (stderr, "Postcondition fail%s%s, assertion: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \
+
message[0] ? ": " : "", message, #condition, __FUNCTION__, __LINE__ , __FILE__); \
+
*((int*)0) = 0; \
+
abort (); \
+
} while (0)
+
+

Checks the verification of a postcondition.

+

This assertion verification can be disabled at compile time by defining the macro NDEBUG_POSTCONDITIONS.

+
Parameters
+ + + +
[in]conditionexpression to assert its truthness
[in]messagetext to be presented with error information when the assertion fails
+
+
+ +
+
+ +

◆ invariant

+ +
+
+ + + + + + + + + + + + + + + + + + +
#define invariant( condition,
 message 
)
+
+Value:
if (!(condition)) \
+
do { \
+
fprintf (stderr, "Invariant fail%s%s, assertion: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \
+
message[0] ? ": " : "", message, #condition, __FUNCTION__, __LINE__ , __FILE__); \
+
*((int*)0) = 0; \
+
abort (); \
+
} while (0)
+
+

Checks the verification of an invariant.

+

This assertion verification can be disabled at compile time by defining the macro NDEBUG_INVARIANTS.

+
Parameters
+ + + +
[in]conditionexpression to assert its truthness
[in]messagetext to be presented with error information when the assertion fails
+
+
+ +
+
+
+
+ + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/group___db_c.js b/3ano/1semestre/so/practice-exam/src/doc/html/group___db_c.js new file mode 100644 index 0000000..61e00c4 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/group___db_c.js @@ -0,0 +1,8 @@ +var group___db_c = +[ + [ "dbc.h", "dbc_8h.html", null ], + [ "check", "group___db_c.html#gac101c8ba449f6f8c71b3789a9c489221", null ], + [ "require", "group___db_c.html#ga5bf1825f80465097d4b753a001cf1af8", null ], + [ "ensure", "group___db_c.html#ga5d17c602c4f191371a5fec5af7adc3cf", null ], + [ "invariant", "group___db_c.html#gaf9d59b04beef1bf139e10fc44c6f9725", null ] +]; \ No newline at end of file diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/group__process.html b/3ano/1semestre/so/practice-exam/src/doc/html/group__process.html new file mode 100644 index 0000000..89d2fff --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/group__process.html @@ -0,0 +1,1255 @@ + + + + + + + +C++ Library, mos@ua: process + + + + + + + + + + +
+
+ + + + + + +
+
C++ Library, mos@ua +  0.9 +
+
cpplib-mos
+
+
+ + + + + + +
+
+ +
+
+
+ +
+
+ +
+
process
+
+
+ +

Process, System-V, and POSIX libraries wrapper module. +More...

+ + + + + +

+Files

file  process.h
 Process, System-V, and POSIX libraries wrapper module.
 
+ + + + + + + + + + + + + + + + + + + + +

+Process handling

+
pid_t pfork (void)
 fork wrapper function. More...
 
pid_t pwait (int *status)
 wait wrapper function. More...
 
pid_t pwaitpid (pid_t pid, int *status, int options)
 waitpid wrapper function. More...
 
void pkill (pid_t pid, int sig)
 kill wrapper function. More...
 
void pexecl (const char *pathname, const char *arg,...)
 execl wrapper function. More...
 
void psigaction (int signum, const struct sigaction *act, struct sigaction *oldact)
 sigaction wrapper function. More...
 
+ + + + + + + + + + + + + + +

+System V - shared memory

Example
#include <process.h> // #include <sys/shm.h>
+
...
+
int shmid;
+
// creation:
+
shmid = pshmget(key, size, 0600 | IPC_CREAT | IPC_EXCL);
+
// or, use existing:
+
shmid = pshmget(key, 0, 0);
+
...
+
// attach shm to pointer address:
+
void* p = pshmat(shmid, NULL, 0);
+
...
+
// detach shm from pointer address:
+
pshmdt(p);
+
...
+
// destroy shm:
+
pshmctl(shmid, IPC_RMID, NULL);
+
+
int pshmget (key_t key, size_t size, int shmflg)
 shmget wrapper function. More...
 
int pshmctl (int shmid, int cmd, struct shmid_ds *buf)
 shmctl wrapper function. More...
 
void * pshmat (int shmid, const void *shmaddr, int shmflg)
 shmat wrapper function. More...
 
void pshmdt (const void *shmaddr)
 shmdt wrapper function. More...
 
+ + + + + + + + + + + + + + + + + + + + + + +

+System V - semaphores

Example
#include <process.h> // #include <sys/sem.h>
+
...
+
int semid;
+
// creation:
+
semid = psemget(key, 1, 0600 | IPC_CREAT | IPC_EXCL); // 1 semaphore!
+
// or, use existing:
+
semid = psemget(key, 0, 0);
+
...
+
// decrement:
+
struct sembuf down = {0, -1, 0};
+
psemop(semid, &down, 1);
+
// or, simply use provided function:
+
psem_down(semid, 0); // NOTE: there is no sem_down in default library!
+
...
+
// increment:
+
struct sembuf up = {0, 1, 0};
+
psemop(semid, &up, 1);
+
// or, simply use provided function:
+
psem_up(semid, 0); // NOTE: there is no sem_up in default library!
+
...
+
// destroy sem 0:
+
psemctl(semid, 0, IPC_RMID, NULL);
+
+
int psemget (key_t key, int nsems, int semflg)
 semget wrapper function. More...
 
int psemctl (int semid, int semnum, int cmd)
 semctl wrapper function. More...
 
+int psemctl (int semid, int semnum, int cmd, void *u)
 
void psemop (int semid, struct sembuf *sops, size_t nsops)
 semop wrapper function. More...
 
+void psem_up (int semid, short unsigned int index)
 Increment a semaphore (uses psemop()).
 
+void psem_down (int semid, short unsigned int index)
 Decrements a semaphore (uses psemop()).
 
+void psem_down2 (int semid, short unsigned int index1, unsigned int index2)
 Decrements atomically two semaphores in a System V semaphore array (uses psemop()).
 
+ + + + + + + + + + + + + + +

+System V - message queues

Example
#include <process.h> // #include <sys/msg.h>
+
...
+
typedef struct Item
+
{
+
...
+
} Item;
+
typedef struct Message
+
{
+
long type;
+
Item item;
+
} Message;
+
...
+
int msgid;
+
// creation:
+
msgid = pmsgget(key, 0600 | IPC_CREAT | IPC_EXCL);
+
// or, use existing:
+
msgid = pmsgget(key, 0);
+
...
+
Message msg;
+
// send msg:
+
msg = ...;
+
pmsgsnd(msgid, &msg, sizeof(Item), 0);
+
...
+
// receive msg:
+
pmsgrcv(msgid, &msg, sizeof(Item), type, 0);
+
...
+
// destroy msg:
+
pmsgctl(msgid, IPC_RMID, NULL);
+
+
int pmsgget (key_t key, int msgflg)
 msgget wrapper function. More...
 
int pmsgctl (int msqid, int cmd, struct msqid_ds *buf)
 msgctl wrapper function. More...
 
void pmsgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
 msgsnd wrapper function. More...
 
size_t pmsgrcv (int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
 msgrcv wrapper function. More...
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+POSIX semaphores

+
sem_t * psem_open (const char *name, int oflag)
 sem_open wrapper function. More...
 
+sem_t * psem_open (const char *name, int oflag, mode_t mode, unsigned int value)
 
void psem_close (sem_t *sem)
 sem_close wrapper function. More...
 
void psem_unlink (const char *name)
 sem_unlink wrapper function. More...
 
void psem_init (sem_t *sem, int pshared, unsigned int value)
 sem_init wrapper function. More...
 
void psem_destroy (sem_t *sem)
 sem_destroy wrapper function. More...
 
void psem_wait (sem_t *sem)
 sem_wait wrapper function. More...
 
int psem_trywait (sem_t *sem)
 sem_trywait wrapper function. More...
 
int psem_timedwait (sem_t *sem, const struct timespec *abs_timeout)
 sem_timedwait wrapper function. More...
 
void psem_post (sem_t *sem)
 sem_post wrapper function. More...
 
+ + + + + + + + + + + +

+UNIX pipes

+
void ppipe (int pipefd[2])
 pipe wrapper function. More...
 
FILE * ppopen (const char *command, const char *type)
 popen wrapper function. More...
 
void ppclose (FILE *stream)
 pclose wrapper function. More...
 
+

Detailed Description

+

Process, System-V, and POSIX libraries wrapper module.

+

This module removes defensive programming approach of native libraries.

+

All implemented functions, have exactly the same arguments and/or result of the original function, with the exception of returning an error indication.

+

Errors are handled by the implementation of two policies:

    +
  1. EXIT_POLICY (default): describes the failed call in stderr (with the identification of the errno error, and the precise location the call), generates a segmentation fault (enabling a stack trace within a debugger like gdb), and exits program execution;
  2. +
  3. EXCEPTION_POLICY: throws a int exception with the (errno) status error returned by the original function.
  4. +
+

System V group of IPC mechanisms

+

There are three resources for IPC: shared memory, semaphores, and message queues.

+

Common to all, is resource handling through a non-negative integer identifier. After proper creation and initialization, different processes can establish communication using the same integer identifier.

+

A key (key_t) is used to establish this common identifier. There are three possibilities to define a key:

+
    +
  1. IPC_PRIVATE: In this case an alternative channel to communicate the identifier between processes is necessary (parent/child fork, file system, ...).
  2. +
  3. A fixed predetermined key number (may collide with other existing keys).
  4. +
  5. ftok function to generate a key from a path and a byte integer.
  6. +
+

Usage:

+
    +
  • create new identifier: msgget/semget/shmget with a key and IPC_CREAT and IPC_EXCL flags
  • +
  • get existing identifier: msgget/semget/shmget with a key and other arguments as zero
  • +
+
Author
Miguel Oliveira e Silva, 2017-2018
+

Function Documentation

+ +

◆ pfork()

+ +
+
+ + + + + + + + +
pid_t pfork (void )
+
+ +

fork wrapper function.

+

Other documentation in

man 2 fork 
See also
https://man.cx/fork(2)
+ +
+
+ +

◆ pwait()

+ +
+
+ + + + + + + + +
pid_t pwait (int * status)
+
+ +

wait wrapper function.

+

Other documentation in

man 2 wait 
See also
https://man.cx/wait(2)
+ +
+
+ +

◆ pwaitpid()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
pid_t pwaitpid (pid_t pid,
int * status,
int options 
)
+
+ +

waitpid wrapper function.

+

Other documentation in

man 2 waitpid 
See also
https://man.cx/waitpid(2)
+ +
+
+ +

◆ pkill()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void pkill (pid_t pid,
int sig 
)
+
+ +

kill wrapper function.

+

Other documentation in

man 2 kill 
See also
https://man.cx/kill(2)
+ +
+
+ +

◆ pexecl()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void pexecl (const char * pathname,
const char * arg,
 ... 
)
+
+ +

execl wrapper function.

+

Other documentation in

man 3 execl 
See also
https://man.cx/execl(3)
+ +
+
+ +

◆ psigaction()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void psigaction (int signum,
const struct sigaction * act,
struct sigaction * oldact 
)
+
+ +

sigaction wrapper function.

+

Other documentation in

man 2 sigaction 
See also
https://man.cx/sigaction(2)
+ +
+
+ +

◆ pshmget()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
int pshmget (key_t key,
size_t size,
int shmflg 
)
+
+ +

shmget wrapper function.

+
+
Precondition:
+
(size > 0) || !(shmflg & IPC_CREAT)
+
+

Other documentation in

man 2 shmget 
See also
https://man.cx/shmget(2)
+ +
+
+ +

◆ pshmctl()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
int pshmctl (int shmid,
int cmd,
struct shmid_ds * buf 
)
+
+ +

shmctl wrapper function.

+

Other documentation in

man 2 shmctl 
See also
https://man.cx/shmctl(2)
+ +
+
+ +

◆ pshmat()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void* pshmat (int shmid,
const void * shmaddr,
int shmflg 
)
+
+ +

shmat wrapper function.

+

Other documentation in

man 2 shmat 
See also
https://man.cx/shmat(2)
+ +
+
+ +

◆ pshmdt()

+ +
+
+ + + + + + + + +
void pshmdt (const void * shmaddr)
+
+ +

shmdt wrapper function.

+

Other documentation in

man 2 shmdt 
See also
https://man.cx/shmdt(2)
+ +
+
+ +

◆ psemget()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
int psemget (key_t key,
int nsems,
int semflg 
)
+
+ +

semget wrapper function.

+
+
Precondition:
+
nsems > 0
+
+

Other documentation in

man 2 semget 
See also
https://man.cx/semget(2)
+ +
+
+ +

◆ psemctl()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
int psemctl (int semid,
int semnum,
int cmd 
)
+
+ +

semctl wrapper function.

+

Other documentation in

man 2 semctl 
See also
https://man.cx/semctl(2)
+ +
+
+ +

◆ psemop()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void psemop (int semid,
struct sembuf * sops,
size_t nsops 
)
+
+ +

semop wrapper function.

+

Other documentation in

man 2 semop 
See also
https://man.cx/semop(2)
+ +
+
+ +

◆ pmsgget()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int pmsgget (key_t key,
int msgflg 
)
+
+ +

msgget wrapper function.

+

Other documentation in

man 2 msgget 
See also
https://man.cx/msgget(2)
+ +
+
+ +

◆ pmsgctl()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
int pmsgctl (int msqid,
int cmd,
struct msqid_ds * buf 
)
+
+ +

msgctl wrapper function.

+

Other documentation in

man 2 msgctl 
See also
https://man.cx/msgctl(2)
+ +
+
+ +

◆ pmsgsnd()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void pmsgsnd (int msqid,
const void * msgp,
size_t msgsz,
int msgflg 
)
+
+ +

msgsnd wrapper function.

+

Other documentation in

man 2 msgsnd 
See also
https://man.cx/msgsnd(2)
+ +
+
+ +

◆ pmsgrcv()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
size_t pmsgrcv (int msqid,
void * msgp,
size_t msgsz,
long msgtyp,
int msgflg 
)
+
+ +

msgrcv wrapper function.

+

Other documentation in

man 2 msgrcv 
See also
https://man.cx/msgrcv(2)
+ +
+
+ +

◆ psem_open()

+ +
+
+ + + + + + + + + + + + + + + + + + +
sem_t* psem_open (const char * name,
int oflag 
)
+
+ +

sem_open wrapper function.

+

Other documentation in

man 3 sem_open 
See also
https://man.cx/sem_open(3)
+ +
+
+ +

◆ psem_close()

+ +
+
+ + + + + + + + +
void psem_close (sem_t * sem)
+
+ +

sem_close wrapper function.

+
+
Precondition:
+
sem != NULL
+
+

Other documentation in

man 3 sem_close 
See also
https://man.cx/sem_close(3)
+ +
+
+ +

◆ psem_unlink()

+ +
+
+ + + + + + + + +
void psem_unlink (const char * name)
+
+ +

sem_unlink wrapper function.

+

Other documentation in

man 3 sem_unlink 
See also
https://man.cx/sem_unlink(3)
+ +
+
+ +

◆ psem_init()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void psem_init (sem_t * sem,
int pshared,
unsigned int value 
)
+
+ +

sem_init wrapper function.

+
+
Precondition:
+
sem != NULL
+
+

Other documentation in

man 3 sem_init 
See also
https://man.cx/sem_init(3)
+ +
+
+ +

◆ psem_destroy()

+ +
+
+ + + + + + + + +
void psem_destroy (sem_t * sem)
+
+ +

sem_destroy wrapper function.

+
+
Precondition:
+
sem != NULL
+
+

Other documentation in

man 3 sem_destroy 
See also
https://man.cx/sem_destroy(3)
+ +
+
+ +

◆ psem_wait()

+ +
+
+ + + + + + + + +
void psem_wait (sem_t * sem)
+
+ +

sem_wait wrapper function.

+
+
Precondition:
+
sem != NULL
+
+

Other documentation in

man 3 sem_wait 
See also
https://man.cx/sem_wait(3)
+ +
+
+ +

◆ psem_trywait()

+ +
+
+ + + + + + + + +
int psem_trywait (sem_t * sem)
+
+ +

sem_trywait wrapper function.

+
+
Precondition:
+
sem != NULL
+
+

Other documentation in

man 3 sem_trywait 
See also
https://man.cx/sem_trywait(3)
+
Returns
true (!=0) on success, false (0) if semaphore is zero
+ +
+
+ +

◆ psem_timedwait()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int psem_timedwait (sem_t * sem,
const struct timespec * abs_timeout 
)
+
+ +

sem_timedwait wrapper function.

+
+
Precondition:
+
sem != NULL
+
+

Other documentation in

man 3 sem_timedwait 
See also
https://man.cx/sem_timedwait(3)
+
Returns
true (!=0) on success, false (0) if timeout has expired before being able to decrement the semaphore
+ +
+
+ +

◆ psem_post()

+ +
+
+ + + + + + + + +
void psem_post (sem_t * sem)
+
+ +

sem_post wrapper function.

+
+
Precondition:
+
sem != NULL
+
+

Other documentation in

man 3 sem_post 
See also
https://man.cx/sem_post(3)
+ +
+
+ +

◆ ppipe()

+ +
+
+ + + + + + + + +
void ppipe (int pipefd[2])
+
+ +

pipe wrapper function.

+

Other documentation in

man 3 pipe 
See also
https://man.cx/pipe
+ +
+
+ +

◆ ppopen()

+ +
+
+ + + + + + + + + + + + + + + + + + +
FILE* ppopen (const char * command,
const char * type 
)
+
+ +

popen wrapper function.

+
+
Precondition:
+
command != NULL type != NULL
+
+

Other documentation in

man 3 popen 
See also
https://man.cx/popen
+ +
+
+ +

◆ ppclose()

+ +
+
+ + + + + + + + +
void ppclose (FILE * stream)
+
+ +

pclose wrapper function.

+
+
Precondition:
+
stream != NULL
+
+

Other documentation in

man 3 pclose 
See also
https://man.cx/pclose
+ +
+
+
+
+
void * pshmat(int shmid, const void *shmaddr, int shmflg)
shmat wrapper function.
+
Process, System-V, and POSIX libraries wrapper module.
+
int psemget(key_t key, int nsems, int semflg)
semget wrapper function.
+
int pshmget(key_t key, size_t size, int shmflg)
shmget wrapper function.
+
void pmsgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg)
msgsnd wrapper function.
+
int pmsgget(key_t key, int msgflg)
msgget wrapper function.
+
void psem_down(int semid, short unsigned int index)
Decrements a semaphore (uses psemop()).
+
void psem_up(int semid, short unsigned int index)
Increment a semaphore (uses psemop()).
+
void psemop(int semid, struct sembuf *sops, size_t nsops)
semop wrapper function.
+ + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/group__process.js b/3ano/1semestre/so/practice-exam/src/doc/html/group__process.js new file mode 100644 index 0000000..efd6fbb --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/group__process.js @@ -0,0 +1,36 @@ +var group__process = +[ + [ "process.h", "process_8h.html", null ], + [ "pfork", "group__process.html#ga67e00aff1839b1ba68c83947593f625b", null ], + [ "pwait", "group__process.html#gad27b81fee9a0f792c4ba29fd95c967e1", null ], + [ "pwaitpid", "group__process.html#gac926bd7ccd173f742b5d58f51cabcb48", null ], + [ "pkill", "group__process.html#gab546ccee89e3159ea7c23aa3a463a0d8", null ], + [ "pexecl", "group__process.html#gae5d3e8ac00f0e788f21020699bac758a", null ], + [ "psigaction", "group__process.html#ga7c7f6de68bd3dea8a702668090a65854", null ], + [ "pshmget", "group__process.html#gaff71624be0fc9c76e0c72295721875e6", null ], + [ "pshmctl", "group__process.html#ga3119bdf5486059aee6ec3ed65a01b319", null ], + [ "pshmat", "group__process.html#ga0cdba7faa458e7fb57c31d3cd8788480", null ], + [ "pshmdt", "group__process.html#ga1682328cd34b592404ff030779b0428f", null ], + [ "psemget", "group__process.html#gaada159a0fe725ed843ac358be6e6a9d3", null ], + [ "psemctl", "group__process.html#gac42e869afba098ec9bdd77444ba790c5", null ], + [ "psemop", "group__process.html#ga0e2534c82b54573590d913c297cc4840", null ], + [ "psem_up", "group__process.html#gaa00610fec639ef123819ceee2ef00da3", null ], + [ "psem_down", "group__process.html#gac2b930e9aceda9ef276b21ae8e839c16", null ], + [ "psem_down2", "group__process.html#ga47891b55ba91af98c5b45cbcf154bc20", null ], + [ "pmsgget", "group__process.html#gad426e03bc9b8dae5f1fbf889ce2dd8f7", null ], + [ "pmsgctl", "group__process.html#ga13bfac41329ec74b2aa4950f9586ae9f", null ], + [ "pmsgsnd", "group__process.html#gaeeb6cd0ab585a7769cd17405f600e56a", null ], + [ "pmsgrcv", "group__process.html#gacd4e4161a46bfa2e1f23eb1d49aaa07b", null ], + [ "psem_open", "group__process.html#ga7bf7fce2d1f344e7dfeeb1b46a9ee7ba", null ], + [ "psem_close", "group__process.html#ga41a884c3a9d9ac6a31fc6ab27ae1d668", null ], + [ "psem_unlink", "group__process.html#ga0415c9c4fab4baafef6cd2d40becd05e", null ], + [ "psem_init", "group__process.html#gac49ddb266cec5493ebd756cd9382f99d", null ], + [ "psem_destroy", "group__process.html#ga82e3d1015521711a2a6374d6c3771491", null ], + [ "psem_wait", "group__process.html#gae2c867f9f66e74fad44df3f32f87a8c6", null ], + [ "psem_trywait", "group__process.html#ga04cb3c84545fe7707c63578e1d59b689", null ], + [ "psem_timedwait", "group__process.html#gac8b2b3d1e18b385f10b389ce2ea734ef", null ], + [ "psem_post", "group__process.html#gad63921c4ec6f0845b752eb59a8935b8e", null ], + [ "ppipe", "group__process.html#ga013466fa89ac97a0db0ccd78168a8456", null ], + [ "ppopen", "group__process.html#ga2d9df322812707050312aa24d15a4360", null ], + [ "ppclose", "group__process.html#ga1490f6e0ca0ebf607d1f5ff431c79b68", null ] +]; \ No newline at end of file diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/group__thread.html b/3ano/1semestre/so/practice-exam/src/doc/html/group__thread.html new file mode 100644 index 0000000..b86770c --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/group__thread.html @@ -0,0 +1,1417 @@ + + + + + + + +C++ Library, mos@ua: thread + + + + + + + + + + +
+
+ + + + + + +
+
C++ Library, mos@ua +  0.9 +
+
cpplib-mos
+
+
+ + + + + + +
+
+ +
+
+
+ +
+
+ +
+
thread
+
+
+ +

POSIX threads library wrapper module. +More...

+ + + + + +

+Files

file  thread.h
 POSIX threads library wrapper module.
 
+ + + + + + + + + + + + + + + + + + + + + + + +

+Thread handling

Variable type: pthread_t

+

+
int thread_equal (pthread_t t1, pthread_t t2)
 pthread_equal wrapper function. More...
 
void thread_create (pthread_t *t, pthread_attr_t *attr, void *(*thread_main)(void *), void *arg)
 pthread_create wrapper function. More...
 
pthread_t thread_self ()
 pthread_self wrapper function. More...
 
void thread_sched_yield (void)
 sched_yield wrapper function. More...
 
void thread_exit (void *retval)
 pthread_exit wrapper function. More...
 
void thread_detach (pthread_t thread)
 pthread_detach wrapper function. More...
 
void thread_join (pthread_t t, void **result)
 pthread_join wrapper function. More...
 
+ + + + + + + + + + + + + + + + + +

+Mutexes

Variable type: pthread_mutex_t

+

Initialization of mutexes can be static or dynamic.

+

In static initialization the following initialization macros are suggested:

    +
  • PTHREAD_MUTEX_INITIALIZER - standard initializer
  • +
  • PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP - initializer that ensures error checking
  • +
  • PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP - for recursive mutexes (note that recursive mutexes should be avoid)
  • +
+

Dynamic initialization is done by mutex_init() and mutex_destroy().

+

+
void mutex_init (pthread_mutex_t *pmtx, pthread_mutexattr_t *attr)
 pthread_mutex_init wrapper function. More...
 
void mutex_destroy (pthread_mutex_t *pmtx)
 pthread_mutex_destroy wrapper function. More...
 
void mutex_lock (pthread_mutex_t *pmtx)
 pthread_mutex_lock wrapper function. More...
 
int mutex_trylock (pthread_mutex_t *pmtx)
 pthread_mutex_trylock wrapper function. More...
 
void mutex_unlock (pthread_mutex_t *pmtx)
 pthread_mutex_unlock wrapper function. More...
 
+ + + + + + + + + + + + + + + + + + + + + + + +

+Condition variables

Variable type: pthread_cond_t

+

Initialization of condition variables can be static or dynamic.

+

In static initialization the following initialization macros should be used:

    +
  • PTHREAD_COND_INITIALIZER - standard initializer
  • +
+

Dynamic initialization is done by cond_init() and cond_destroy().

+

+
void cond_init (pthread_cond_t *pcvar, pthread_condattr_t *attr)
 pthread_cond_init wrapper function. More...
 
void cond_destroy (pthread_cond_t *pcvar)
 pthread_cond_destroy wrapper function. More...
 
void cond_wait (pthread_cond_t *pcvar, pthread_mutex_t *pmtx)
 pthread_cond_wait wrapper function. More...
 
int cond_timedwait (pthread_cond_t *pcvar, pthread_mutex_t *pmtx, const struct timespec *abstime)
 pthread_cond_timedwait wrapper function. More...
 
int cond_timedwait (pthread_cond_t *pcvar, pthread_mutex_t *pmtx, long relative_time_us)
 pthread_cond_timedwait wrapper function accepting relative time (in microseconds) instead of absolute time. More...
 
void cond_signal (pthread_cond_t *pcvar)
 pthread_cond_signal wrapper function. More...
 
void cond_broadcast (pthread_cond_t *pcvar)
 pthread_cond_broadcast wrapper function. More...
 
+ + + + + +

+One-time initialization

Variable type: pthread_once_t

+

POSIX thread library support a mechanism that ensures a one-time execution of a function. It does it through pthread_once_t variables, and by passing a callback function (in C/C++ is simply a function pointer).

+
Example
   void once_init_routine(void) { ... }
+   ...
+   pthread_once_t once_control = PTHREAD_ONCE_INIT;
+   thread_once(&once_control, &once_init_routine); // one time execution over pthread_once_t
+                                                   // variable is guaranteed, regardless of the
+                                                   // number of threads that execute over that
+                                                   // variable.
+
+

+
void thread_once (pthread_once_t *once_control, void(*init_routine)(void))
 pthread_once wrapper function. More...
 
+ + + + + + + + + + + + + + +

+Thread-specific data

Variable type: pthread_key_t

+

Thread-specific data allows the definition of variable whose scope is limited to each thread. In practice, we will have a common variable, with a common access, but with different values for each thread.

+

+
void thread_key_create (pthread_key_t *key, void(*destr_function)(void *))
 pthread_key_create wrapper function. More...
 
void thread_key_delete (pthread_key_t key)
 pthread_key_delete wrapper function. More...
 
void thread_setspecific (pthread_key_t key, void *pointer)
 pthread_setspecific wrapper function. More...
 
void * thread_getspecific (pthread_key_t key)
 pthread_getspecific wrapper function. More...
 
+ + + + + + + + + + + + + + +

+Mutex attributes

Variable type: pthread_mutexattr_t

+

+
void mutexattr_init (pthread_mutexattr_t *attr)
 pthread_mutexattr_init wrapper function. More...
 
void mutexattr_destroy (pthread_mutexattr_t *attr)
 pthread_mutexattr_destroy wrapper function. More...
 
void mutexattr_settype (pthread_mutexattr_t *attr, int type)
 pthread_mutexattr_settype wrapper function. More...
 
void mutexattr_gettype (const pthread_mutexattr_t *attr, int *kind)
 pthread_mutexattr_gettype wrapper function. More...
 
+ + + + + + + + +

+Condition variables attributes

Variable type: pthread_condattr_t

+

+
void condattr_init (pthread_condattr_t *attr)
 pthread_condattr_init wrapper function. More...
 
void condattr_destroy (pthread_condattr_t *attr)
 pthread_condattr_destroy wrapper function. More...
 
+ + + + + + + + + + + + + + +

+Thread attributes

Variable type: pthread_attr_t

+

+
void thread_attr_init (pthread_attr_t *attr)
 pthread_attr_init wrapper function. More...
 
void thread_attr_destroy (pthread_attr_t *attr)
 pthread_attr_destroy wrapper function. More...
 
void thread_attr_setdetachstate (pthread_attr_t *attr, int detachstate)
 pthread_attr_setdetachstate wrapper function. More...
 
void thread_attr_getdetachstate (const pthread_attr_t *attr, int *pdetachstate)
 pthread_attr_getdetachstate wrapper function. More...
 
+ + + + + + + + + + + + + + +

+Cancellation

+
void thread_cancel (pthread_t thread)
 pthread_cancel wrapper function. More...
 
void thread_setcancelstate (int state, int *oldstate)
 pthread_setcancelstate wrapper function. More...
 
void thread_setcanceltype (int type, int *oldtype)
 pthread_setcanceltype wrapper function. More...
 
void thread_testcancel (void)
 pthread_testcancel wrapper function. More...
 
+

Detailed Description

+

POSIX threads library wrapper module.

+

This module removes defensive programming approach of native POSIX threads library.

+

All implemented functions, have exactly the same arguments and/or result of the original function, with the exception of returning an error indication.

+

Errors are handled by the implementation of two policies:

    +
  1. EXIT_POLICY (default): describes the failed call in stderr (with the identification of the errno error, and the precise location the call), generates a segmentation fault (enabling a stack trace within a debugger like gdb), and exits program execution;
  2. +
  3. EXCEPTION_POLICY: throws a int exception with the (errno) status error returned by the original function.
  4. +
+
Author
Miguel Oliveira e Silva, 2017-2018
+

Function Documentation

+ +

◆ thread_equal()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int thread_equal (pthread_t t1,
pthread_t t2 
)
+
+ +

pthread_equal wrapper function.

+

Other documentation in

man 3 pthread_equal 
See also
https://man.cx/pthread_equal(3)
+ +
+
+ +

◆ thread_create()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void thread_create (pthread_t * t,
pthread_attr_t * attr,
void *(*)(void *) thread_main,
void * arg 
)
+
+ +

pthread_create wrapper function.

+
+
Precondition:
+
t != NULL
+ thread_main != NULL
+
+

Other documentation in

man 3 pthread_create 
See also
https://man.cx/pthread_create(3)
+ +
+
+ +

◆ thread_self()

+ +
+
+ + + + + + + +
pthread_t thread_self ()
+
+ +

pthread_self wrapper function.

+

Other documentation in

man 3 pthread_self 
See also
https://man.cx/pthread_self(3)
+ +
+
+ +

◆ thread_sched_yield()

+ +
+
+ + + + + + + + +
void thread_sched_yield (void )
+
+ +

sched_yield wrapper function.

+

Other documentation in

man 3 sched_yield 
See also
https://man.cx/sched_yield(3)
+ +
+
+ +

◆ thread_exit()

+ +
+
+ + + + + + + + +
void thread_exit (void * retval)
+
+ +

pthread_exit wrapper function.

+

Other documentation in

man 3 pthread_exit 
See also
https://man.cx/pthread_exit(3)
+ +
+
+ +

◆ thread_detach()

+ +
+
+ + + + + + + + +
void thread_detach (pthread_t thread)
+
+ +

pthread_detach wrapper function.

+

Other documentation in

man 3 pthread_detach 
See also
https://man.cx/pthread_detach(3)
+ +
+
+ +

◆ thread_join()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void thread_join (pthread_t t,
void ** result 
)
+
+ +

pthread_join wrapper function.

+

Other documentation in

man 3 pthread_join 
See also
https://man.cx/pthread_join(3)
+ +
+
+ +

◆ mutex_init()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void mutex_init (pthread_mutex_t * pmtx,
pthread_mutexattr_t * attr 
)
+
+ +

pthread_mutex_init wrapper function.

+
+
Precondition:
+
pmtx != NULL
+
+

Other documentation in

man 3 pthread_mutex_init 
See also
https://man.cx/pthread_mutex_init(3)
+ +
+
+ +

◆ mutex_destroy()

+ +
+
+ + + + + + + + +
void mutex_destroy (pthread_mutex_t * pmtx)
+
+ +

pthread_mutex_destroy wrapper function.

+
+
Precondition:
+
pmtx != NULL
+
+

Other documentation in

man 3 pthread_mutex_destroy 
See also
https://man.cx/pthread_mutex_destroy(3)
+ +
+
+ +

◆ mutex_lock()

+ +
+
+ + + + + + + + +
void mutex_lock (pthread_mutex_t * pmtx)
+
+ +

pthread_mutex_lock wrapper function.

+
+
Precondition:
+
pmtx != NULL
+
+

Other documentation in

man 3 pthread_mutex_lock 
See also
https://man.cx/pthread_mutex_lock(3)
+ +
+
+ +

◆ mutex_trylock()

+ +
+
+ + + + + + + + +
int mutex_trylock (pthread_mutex_t * pmtx)
+
+ +

pthread_mutex_trylock wrapper function.

+
+
Precondition:
+
pmtx != NULL
+
+

Other documentation in

man 3 pthread_mutex_trylock 
See also
https://man.cx/pthread_mutex_trylock(3)
+
Returns
true (!=0) if lock succeeds, false (0) otherwise
+ +
+
+ +

◆ mutex_unlock()

+ +
+
+ + + + + + + + +
void mutex_unlock (pthread_mutex_t * pmtx)
+
+ +

pthread_mutex_unlock wrapper function.

+
+
Precondition:
+
pmtx != NULL
+
+

Other documentation in

man 3 pthread_mutex_unlock 
See also
https://man.cx/pthread_mutex_unlock(3)
+ +
+
+ +

◆ cond_init()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void cond_init (pthread_cond_t * pcvar,
pthread_condattr_t * attr 
)
+
+ +

pthread_cond_init wrapper function.

+
+
Precondition:
+
pcvar != NULL
+
+

Other documentation in

man 3 pthread_cond_init 
See also
https://man.cx/pthread_cond_init(3)
+ +
+
+ +

◆ cond_destroy()

+ +
+
+ + + + + + + + +
void cond_destroy (pthread_cond_t * pcvar)
+
+ +

pthread_cond_destroy wrapper function.

+
+
Precondition:
+
pcvar != NULL
+
+

Other documentation in

man 3 pthread_cond_destroy 
See also
https://man.cx/pthread_cond_destroy(3)
+ +
+
+ +

◆ cond_wait()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void cond_wait (pthread_cond_t * pcvar,
pthread_mutex_t * pmtx 
)
+
+ +

pthread_cond_wait wrapper function.

+
+
Precondition:
+
pcvar != NULL
+ pmtx != NULL
+
+

Other documentation in

man 3 pthread_cond_wait 
See also
https://man.cx/pthread_cond_wait(3)
+ +
+
+ +

◆ cond_timedwait() [1/2]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
int cond_timedwait (pthread_cond_t * pcvar,
pthread_mutex_t * pmtx,
const struct timespec * abstime 
)
+
+ +

pthread_cond_timedwait wrapper function.

+
+
Precondition:
+
pcvar != NULL
+ pmtx != NULL
+ abstime != NULL
+
+
Returns
true (!=0) if condition variable was signaled, false (0) it time out has expired.
+

Other documentation in

man 3 pthread_cond_timedwait 
See also
https://man.cx/pthread_cond_wait(3)
+ +
+
+ +

◆ cond_timedwait() [2/2]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
int cond_timedwait (pthread_cond_t * pcvar,
pthread_mutex_t * pmtx,
long relative_time_us 
)
+
+ +

pthread_cond_timedwait wrapper function accepting relative time (in microseconds) instead of absolute time.

+
+
Precondition:
+
pcvar != NULL
+ pmtx != NULL
+ relative_time_us > 0L
+
+
Returns
true (!=0) if condition variable was signaled, false (0) it time out has expired.
+

Documentation in

man 3 pthread_cond_timedwait 
See also
https://man.cx/pthread_cond_wait(3)
+ +
+
+ +

◆ cond_signal()

+ +
+
+ + + + + + + + +
void cond_signal (pthread_cond_t * pcvar)
+
+ +

pthread_cond_signal wrapper function.

+
+
Precondition:
+
pcvar != NULL
+
+

Other documentation in

man 3 pthread_cond_signal 
See also
https://man.cx/pthread_cond_signal(3)
+ +
+
+ +

◆ cond_broadcast()

+ +
+
+ + + + + + + + +
void cond_broadcast (pthread_cond_t * pcvar)
+
+ +

pthread_cond_broadcast wrapper function.

+
+
Precondition:
+
pcvar != NULL
+
+

Other documentation in

man 3 pthread_cond_broadcast 
See also
https://man.cx/pthread_cond_broadcast(3)
+ +
+
+ +

◆ thread_once()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void thread_once (pthread_once_t * once_control,
void(*)(void) init_routine 
)
+
+ +

pthread_once wrapper function.

+
+
Precondition:
+
once_control != NULL
+ init_routine != NULL
+
+

Other documentation in

man 3 pthread_once 
See also
https://man.cx/pthread_once(3)
+ +
+
+ +

◆ thread_key_create()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void thread_key_create (pthread_key_t * key,
void(*)(void *) destr_function 
)
+
+ +

pthread_key_create wrapper function.

+

This function should be executed once for each key (use thread_once()).

+
+
Precondition:
+
key != NULL
+
+

Other documentation in

man 3 pthread_key_create 
See also
https://man.cx/pthread_key_create(3)
+ +
+
+ +

◆ thread_key_delete()

+ +
+
+ + + + + + + + +
void thread_key_delete (pthread_key_t key)
+
+ +

pthread_key_delete wrapper function.

+

This function should be executed once for each key (use thread_once()).

+
+
Precondition:
+
key != NULL
+
+

Other documentation in

man 3 pthread_key_delete 
See also
https://man.cx/pthread_key_delete(3)
+ +
+
+ +

◆ thread_setspecific()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void thread_setspecific (pthread_key_t key,
void * pointer 
)
+
+ +

pthread_setspecific wrapper function.

+
+
Precondition:
+
pointer != NULL
+
+

Other documentation in

man 3 pthread_setspecific 
See also
https://man.cx/pthread_setspecific(3)
+ +
+
+ +

◆ thread_getspecific()

+ +
+
+ + + + + + + + +
void* thread_getspecific (pthread_key_t key)
+
+ +

pthread_getspecific wrapper function.

+
+
Precondition:
+
key != NULL
+
+

Other documentation in

man 3 pthread_getspecific 
See also
https://man.cx/pthread_getspecific(3)
+ +
+
+ +

◆ mutexattr_init()

+ +
+
+ + + + + + + + +
void mutexattr_init (pthread_mutexattr_t * attr)
+
+ +

pthread_mutexattr_init wrapper function.

+
+
Precondition:
+
attr != NULL
+
+

Other documentation in

man 3 pthread_mutexattr_init 
See also
https://man.cx/pthread_mutexattr_init(3)
+ +
+
+ +

◆ mutexattr_destroy()

+ +
+
+ + + + + + + + +
void mutexattr_destroy (pthread_mutexattr_t * attr)
+
+ +

pthread_mutexattr_destroy wrapper function.

+
+
Precondition:
+
attr != NULL
+
+

Other documentation in

man 3 pthread_mutexattr_destroy 
See also
https://man.cx/pthread_mutexattr_destroy(3)
+ +
+
+ +

◆ mutexattr_settype()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void mutexattr_settype (pthread_mutexattr_t * attr,
int type 
)
+
+ +

pthread_mutexattr_settype wrapper function.

+
+
Precondition:
+
attr != NULL
+
+

Other documentation in

man 3 pthread_mutexattr_settype 
See also
https://man.cx/pthread_mutexattr_settype(3)
+ +
+
+ +

◆ mutexattr_gettype()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void mutexattr_gettype (const pthread_mutexattr_t * attr,
int * kind 
)
+
+ +

pthread_mutexattr_gettype wrapper function.

+
+
Precondition:
+
attr != NULL
+ kind != NULL
+
+

Other documentation in

man 3 pthread_mutexattr_gettype 
See also
https://man.cx/pthread_mutexattr_gettype(3)
+ +
+
+ +

◆ condattr_init()

+ +
+
+ + + + + + + + +
void condattr_init (pthread_condattr_t * attr)
+
+ +

pthread_condattr_init wrapper function.

+
+
Precondition:
+
attr != NULL
+
+

Other documentation in

man 3 pthread_condattr_init 
See also
https://man.cx/pthread_condattr_init(3)
+ +
+
+ +

◆ condattr_destroy()

+ +
+
+ + + + + + + + +
void condattr_destroy (pthread_condattr_t * attr)
+
+ +

pthread_condattr_destroy wrapper function.

+
+
Precondition:
+
attr != NULL
+
+

Other documentation in

man 3 pthread_condattr_destroy 
See also
https://man.cx/pthread_condattr_destroy(3)
+ +
+
+ +

◆ thread_attr_init()

+ +
+
+ + + + + + + + +
void thread_attr_init (pthread_attr_t * attr)
+
+ +

pthread_attr_init wrapper function.

+
+
Precondition:
+
attr != NULL
+
+

Other documentation in

man 3 pthread_attr_init 
See also
https://man.cx/pthread_attr_init(3)
+ +
+
+ +

◆ thread_attr_destroy()

+ +
+
+ + + + + + + + +
void thread_attr_destroy (pthread_attr_t * attr)
+
+ +

pthread_attr_destroy wrapper function.

+
+
Precondition:
+
attr != NULL
+
+

Other documentation in

man 3 pthread_attr_destroy 
See also
https://man.cx/pthread_attr_destroy(3)
+ +
+
+ +

◆ thread_attr_setdetachstate()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void thread_attr_setdetachstate (pthread_attr_t * attr,
int detachstate 
)
+
+ +

pthread_attr_setdetachstate wrapper function.

+
+
Precondition:
+
attr != NULL
+ detachstate == PTHREAD_CREATE_DETACHED || detachstate == PTHREAD_CREATE_JOINABLE
+
+

Other documentation in

man 3 pthread_attr_setdetachstate 
See also
https://man.cx/pthread_attr_setdetachstate(3)
+ +
+
+ +

◆ thread_attr_getdetachstate()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void thread_attr_getdetachstate (const pthread_attr_t * attr,
int * pdetachstate 
)
+
+ +

pthread_attr_getdetachstate wrapper function.

+
+
Precondition:
+
attr != NULL
+ pdetachstate != NULL
+
+

Other documentation in

man 3 pthread_attr_getdetachstate 
See also
https://man.cx/pthread_attr_getdetachstate(3)
+ +
+
+ +

◆ thread_cancel()

+ +
+
+ + + + + + + + +
void thread_cancel (pthread_t thread)
+
+ +

pthread_cancel wrapper function.

+

Other documentation in

man 3 pthread_cancel 
See also
https://man.cx/pthread_cancel(3)
+ +
+
+ +

◆ thread_setcancelstate()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void thread_setcancelstate (int state,
int * oldstate 
)
+
+ +

pthread_setcancelstate wrapper function.

+
+
Precondition:
+
state == PTHREAD_CANCEL_ENABLE || state == PTHREAD_CANCEL_DISABLE
+ oldstate != NULL
+
+

Other documentation in

man 3 pthread_setcancelstate 
See also
https://man.cx/pthread_setcancelstate(3)
+ +
+
+ +

◆ thread_setcanceltype()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void thread_setcanceltype (int type,
int * oldtype 
)
+
+ +

pthread_setcanceltype wrapper function.

+
+
Precondition:
+
type == PTHREAD_CANCEL_DEFERRED || type == PTHREAD_CANCEL_ASYNCHRONOUS
+ oldtype != NULL
+
+

Other documentation in

man 3 pthread_setcanceltype 
See also
https://man.cx/pthread_setcanceltype(3)
+ +
+
+ +

◆ thread_testcancel()

+ +
+
+ + + + + + + + +
void thread_testcancel (void )
+
+ +

pthread_testcancel wrapper function.

+

Other documentation in

man 3 pthread_testcancel 
See also
https://man.cx/pthread_testcancel(3)
+ +
+
+
+
+ + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/group__thread.js b/3ano/1semestre/so/practice-exam/src/doc/html/group__thread.js new file mode 100644 index 0000000..c5ad3e5 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/group__thread.js @@ -0,0 +1,42 @@ +var group__thread = +[ + [ "thread.h", "thread_8h.html", null ], + [ "thread_equal", "group__thread.html#gadca8bdcec91b8985370d904591d342b8", null ], + [ "thread_create", "group__thread.html#ga3a0f9920a321b54c41c098d3461d3889", null ], + [ "thread_self", "group__thread.html#ga606fdef53f997c231e0e1e9e54b350d4", null ], + [ "thread_sched_yield", "group__thread.html#ga952c63101c667d247f0923b609710c72", null ], + [ "thread_exit", "group__thread.html#ga19b16adf05364471bae2840aa564329a", null ], + [ "thread_detach", "group__thread.html#ga86aa7989874009c886bea9d41700e25c", null ], + [ "thread_join", "group__thread.html#ga2b2370a45c1518f777493526b2e4f46d", null ], + [ "mutex_init", "group__thread.html#ga3f227a19d6a339ce0aeda15775e5e6e6", null ], + [ "mutex_destroy", "group__thread.html#ga5ebb836d0f83eac719f2cdd336497b01", null ], + [ "mutex_lock", "group__thread.html#ga87086ba0f13f6ddc479a6bc803a10c39", null ], + [ "mutex_trylock", "group__thread.html#ga8bd074884e1c92e88ca8ea0552d9a928", null ], + [ "mutex_unlock", "group__thread.html#ga95235231165ebda870afa10ba5fd6c41", null ], + [ "cond_init", "group__thread.html#ga31e5eaf158d118d0e4ef7fd47368eaad", null ], + [ "cond_destroy", "group__thread.html#gad663c43fbfbb4f660d48b07e110c8f80", null ], + [ "cond_wait", "group__thread.html#ga1123643838d5174ccd41f52f4169e896", null ], + [ "cond_timedwait", "group__thread.html#ga8cd2040836c30e4f0ea17abe4f66b8e2", null ], + [ "cond_timedwait", "group__thread.html#ga4b41089ba3cd8ad0a539b42bc8b95d6b", null ], + [ "cond_signal", "group__thread.html#ga9624688b577fb653af7a528848cc53d5", null ], + [ "cond_broadcast", "group__thread.html#ga6459039ab27da7237dda2bbc866eb2d0", null ], + [ "thread_once", "group__thread.html#gad0428e8a0809704f4b3d682f26d3ef1c", null ], + [ "thread_key_create", "group__thread.html#ga7df1983f57dca40a86a55d215d13d42b", null ], + [ "thread_key_delete", "group__thread.html#ga65a50dfc97c087a28cb916e0f30f760e", null ], + [ "thread_setspecific", "group__thread.html#ga3008b033f2830e79179a882a2b74c8ba", null ], + [ "thread_getspecific", "group__thread.html#ga0d207f1bb2e1d493b68a026b8650cb16", null ], + [ "mutexattr_init", "group__thread.html#ga9fb2733a01e8d668a2022005ea5dbebd", null ], + [ "mutexattr_destroy", "group__thread.html#ga07bf0e49b1f2cb99d3a2955641c676d5", null ], + [ "mutexattr_settype", "group__thread.html#ga601a6a9527d7d5ee2ca2870cddc4afc2", null ], + [ "mutexattr_gettype", "group__thread.html#gadf741e1818d53c5b7d71cd68e161b215", null ], + [ "condattr_init", "group__thread.html#gab8073c72be896ba9d711d887a5405a74", null ], + [ "condattr_destroy", "group__thread.html#ga4644f4989b30ccfb2e908017c43bd0d0", null ], + [ "thread_attr_init", "group__thread.html#gaaf2db7012069f0006e7ffaf257d8ccc6", null ], + [ "thread_attr_destroy", "group__thread.html#gaf3a9c2c051deee01e21c75f0fa8b2e9c", null ], + [ "thread_attr_setdetachstate", "group__thread.html#gabc82fea1785fc82aeb2f43cdd77b9b0f", null ], + [ "thread_attr_getdetachstate", "group__thread.html#gaae83c8617612c1bb481fec2b382ac9c4", null ], + [ "thread_cancel", "group__thread.html#ga1b3cb53565eabe02a36e000e5244dfd1", null ], + [ "thread_setcancelstate", "group__thread.html#ga98baffe08beec792f3428ae9ddad966e", null ], + [ "thread_setcanceltype", "group__thread.html#gab4ec114c7b59f8f4185bac648b256d0c", null ], + [ "thread_testcancel", "group__thread.html#ga81bdb13d62e16ad7cb3cbd263c9a5671", null ] +]; \ No newline at end of file diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/group__utils.html b/3ano/1semestre/so/practice-exam/src/doc/html/group__utils.html new file mode 100644 index 0000000..ed6d68c --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/group__utils.html @@ -0,0 +1,1619 @@ + + + + + + + +C++ Library, mos@ua: utils + + + + + + + + + + +
+
+ + + + + + +
+
C++ Library, mos@ua +  0.9 +
+
cpplib-mos
+
+
+ + + + + + +
+
+ +
+
+
+ +
+
+ +
+
utils
+
+
+ +

Useful common functions and macros. +More...

+ + + + + +

+Files

file  utils.h
 Useful common functions and macros.
 
+ + + + + + + + + + + + + + + + + + + + + + +

+Macros

#define int2str(num)
 Converts an int value to a stack allocated string. More...
 
#define int2nstr(num, len)
 Converts an int value to a stack allocated string. More...
 
#define long2str(num)
 Converts an long value to a stack allocated string. More...
 
#define long2nstr(num, len)
 Converts an long value to a stack allocated string. More...
 
#define perc2str(percentage)
 Converts an int percentage to a stack allocated string. More...
 
#define length_vargs_string_list(first)
 Determines the length of all strings passed as a NULL terminated variable list of arguments (vargs). More...
 
#define not_null(pnt)
 Checks if address is not NULL, before its application. More...
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Functions

void * mem_alloc (int size)
 A replacement for malloc function. More...
 
void mem_free (void *pnt)
 A replacement for free function. More...
 
char * string_clone (char *str)
 Replicates a string. More...
 
int string_num_lines (char *text)
 Number of lines of a string. More...
 
int string_num_columns (char *text)
 Maximum number of columns of a string (not counting character ‘’\n'`). More...
 
int string_count_char (char *text, char *ch)
 Counts the number of occurrences of an UTF8 character in a text. More...
 
int string_starts_with (char *text, char *prefix)
 Tests if a string starts with a prefix. More...
 
int string_ends_with (char *text, char *suffix)
 Tests if a string ends with a suffix. More...
 
char * string_concat (char *res, int max_length, char *text,...)
 Concatenates a NULL terminated list of string arguments. More...
 
int random_boolean (int trueProb)
 Generates a random boolean value. More...
 
int random_int (int min, int max)
 Generates a random integer value within a given interval. More...
 
char * random_string (char **list, int *used, int length)
 Returns a random string from a given string list. More...
 
+void clear_console ()
 Clears the terminal.
 
void move_cursor (int line, int column)
 Moves the cursor to a position in terminal. More...
 
+void hide_cursor ()
 Hides the terminal cursor.
 
+void show_cursor ()
 Shows the terminal cursor.
 
int string_list_length (char **list)
 Number of elements of a NULL terminated list of strings. More...
 
char ** string_list_clone (char **list)
 Replicates a NULL terminated list of strings. More...
 
char ** string_list_free (char **list)
 Frees the memory allocated to a NULL terminated list of strings. More...
 
char * int2nstring (char *res, int num, int len)
 Converts an int value to a string. More...
 
char * percentage2string (char *res, int percentage)
 Converts an int percentage to a string. More...
 
+ + + + + + + + + + + + + + + + + + + + +

+String concatenation in stack memory

+
#define concat_2str(str1, str2)
 Concatenates two strings in the stack memory (thus it cannot be implemented in a function). More...
 
#define concat_3str(str1, str2, str3)
 Concatenates three strings in the stack memory (thus it cannot be implemented in a function). More...
 
#define concat_4str(str1, str2, str3, str4)
 Concatenates four strings in the stack memory (thus it cannot be implemented in a function). More...
 
#define concat_5str(str1, str2, str3, str4, str5)
 Concatenates five strings in the stack memory (thus it cannot be implemented in a function). More...
 
#define concat_6str(str1, str2, str3, str4, str5, str6)
 Concatenates six strings in the stack memory (thus it cannot be implemented in a function). More...
 
#define concat_7str(str1, str2, str3, str4, str5, str6, str7)
 Concatenates seven strings in the stack memory (thus it cannot be implemented in a function). More...
 
+

Detailed Description

+

Useful common functions and macros.

+
Author
Miguel Oliveira e Silva, 2017-2018
+

Macro Definition Documentation

+ +

◆ concat_2str

+ +
+
+ + + + + + + + + + + + + + + + + + +
#define concat_2str( str1,
 str2 
)
+
+Value:
({ \
+
char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \
+
char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \
+
char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+1); \
+
strcpy(__res__, s1); \
+
strcat(__res__, s2); \
+
__res__; \
+
})
+
+

Concatenates two strings in the stack memory (thus it cannot be implemented in a function).

+

A NULL reference is treated as an empty string.

+
Parameters
+ + + +
[in]str1string 1
[in]str2string 2
+
+
+
Returns
the concatenated string
+ +
+
+ +

◆ concat_3str

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
#define concat_3str( str1,
 str2,
 str3 
)
+
+Value:
({ \
+
char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \
+
char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \
+
char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \
+
char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+1); \
+
strcpy(__res__, s1); \
+
strcat(__res__, s2); \
+
strcat(__res__, s3); \
+
__res__; \
+
})
+
+

Concatenates three strings in the stack memory (thus it cannot be implemented in a function).

+

A NULL reference is treated as an empty string.

+
Parameters
+ + + + +
[in]str1string 1
[in]str2string 2
[in]str3string 3
+
+
+
Returns
the concatenated string
+ +
+
+ +

◆ concat_4str

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define concat_4str( str1,
 str2,
 str3,
 str4 
)
+
+Value:
({ \
+
char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \
+
char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \
+
char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \
+
char* s4 = (str4) == NULL ? (char*)"" : (char*)(str4); \
+
char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+strlen(s4)+1); \
+
strcpy(__res__, s1); \
+
strcat(__res__, s2); \
+
strcat(__res__, s3); \
+
strcat(__res__, s4); \
+
__res__; \
+
})
+
+

Concatenates four strings in the stack memory (thus it cannot be implemented in a function).

+

A NULL reference is treated as an empty string.

+
Parameters
+ + + + + +
[in]str1string 1
[in]str2string 2
[in]str3string 3
[in]str4string 4
+
+
+
Returns
the concatenated string
+ +
+
+ +

◆ concat_5str

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define concat_5str( str1,
 str2,
 str3,
 str4,
 str5 
)
+
+Value:
({ \
+
char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \
+
char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \
+
char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \
+
char* s4 = (str4) == NULL ? (char*)"" : (char*)(str4); \
+
char* s5 = (str5) == NULL ? (char*)"" : (char*)(str5); \
+
char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+strlen(s4)+strlen(s5)+1); \
+
strcpy(__res__, s1); \
+
strcat(__res__, s2); \
+
strcat(__res__, s3); \
+
strcat(__res__, s4); \
+
strcat(__res__, s5); \
+
__res__; \
+
})
+
+

Concatenates five strings in the stack memory (thus it cannot be implemented in a function).

+

A NULL reference is treated as an empty string.

+
Parameters
+ + + + + + +
[in]str1string 1
[in]str2string 2
[in]str3string 3
[in]str4string 4
[in]str5string 5
+
+
+
Returns
the concatenated string
+ +
+
+ +

◆ concat_6str

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define concat_6str( str1,
 str2,
 str3,
 str4,
 str5,
 str6 
)
+
+Value:
({ \
+
char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \
+
char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \
+
char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \
+
char* s4 = (str4) == NULL ? (char*)"" : (char*)(str4); \
+
char* s5 = (str5) == NULL ? (char*)"" : (char*)(str5); \
+
char* s6 = (str6) == NULL ? (char*)"" : (char*)(str6); \
+
char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+strlen(s4)+strlen(s5)+strlen(s6)+1); \
+
strcpy(__res__, s1); \
+
strcat(__res__, s2); \
+
strcat(__res__, s3); \
+
strcat(__res__, s4); \
+
strcat(__res__, s5); \
+
strcat(__res__, s6); \
+
__res__; \
+
})
+
+

Concatenates six strings in the stack memory (thus it cannot be implemented in a function).

+

A NULL reference is treated as an empty string.

+
Parameters
+ + + + + + + +
[in]str1string 1
[in]str2string 2
[in]str3string 3
[in]str4string 4
[in]str5string 5
[in]str6string 6
+
+
+
Returns
the concatenated string
+ +
+
+ +

◆ concat_7str

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define concat_7str( str1,
 str2,
 str3,
 str4,
 str5,
 str6,
 str7 
)
+
+Value:
({ \
+
char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \
+
char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \
+
char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \
+
char* s4 = (str4) == NULL ? (char*)"" : (char*)(str4); \
+
char* s5 = (str5) == NULL ? (char*)"" : (char*)(str5); \
+
char* s6 = (str6) == NULL ? (char*)"" : (char*)(str6); \
+
char* s7 = (str7) == NULL ? (char*)"" : (char*)(str7); \
+
char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+strlen(s4)+strlen(s5)+strlen(s6)+strlen(s7)+1); \
+
strcpy(__res__, s1); \
+
strcat(__res__, s2); \
+
strcat(__res__, s3); \
+
strcat(__res__, s4); \
+
strcat(__res__, s5); \
+
strcat(__res__, s6); \
+
strcat(__res__, s7); \
+
__res__; \
+
})
+
+

Concatenates seven strings in the stack memory (thus it cannot be implemented in a function).

+

A NULL reference is treated as an empty string.

+
Parameters
+ + + + + + + + +
[in]str1string 1
[in]str2string 2
[in]str3string 3
[in]str4string 4
[in]str5string 5
[in]str6string 6
[in]str7string 7
+
+
+
Returns
the concatenated string
+ +
+
+ +

◆ int2str

+ +
+
+ + + + + + + + +
#define int2str( num)
+
+Value:
({ \
+
char* __res__ = (char*)alloca(numDigits((int)num)+1); \
+
sprintf(__res__, "%d", (int)num); \
+
__res__; \
+
})
+
+

Converts an int value to a stack allocated string.

+
Parameters
+ + +
[in]numinteger number
+
+
+
Returns
the converted string
+ +
+
+ +

◆ int2nstr

+ +
+
+ + + + + + + + + + + + + + + + + + +
#define int2nstr( num,
 len 
)
+
+Value:
({ \
+
require (len > 0, concat_3str("invalid length value (", int2str(len), ")")); \
+
int d = numDigits((int)num); \
+
if (len > d) \
+
d = len; \
+
char* __res__ = (char*)alloca(d+1); \
+
sprintf(__res__, "%0*d", d, (int)num); \
+
__res__; \
+
})
+
+

Converts an int value to a stack allocated string.

+

If necessary, fills the result string with left zeros.

+
Parameters
+ + + +
[in]numinteger number
[in]lenminimum length of result string
+
+
+
+
Precondition:
+
len > 0
+
+
Returns
the converted string
+ +
+
+ +

◆ long2str

+ +
+
+ + + + + + + + +
#define long2str( num)
+
+Value:
({ \
+
char* __res__ = (char*)alloca(numDigits((long)num)+1); \
+
sprintf(__res__, "%ld", (long)num); \
+
__res__; \
+
})
+
+

Converts an long value to a stack allocated string.

+
Parameters
+ + +
[in]numlong integer number
+
+
+
Returns
the converted string
+ +
+
+ +

◆ long2nstr

+ +
+
+ + + + + + + + + + + + + + + + + + +
#define long2nstr( num,
 len 
)
+
+Value:
({ \
+
require (len > 0, concat_3str("invalid length value (", int2str(len), ")")); \
+
int d = numDigits((int)num); \
+
if (len > d) \
+
d = len; \
+
char* __res__ = (char*)alloca(d+1); \
+
sprintf(__res__, "%0*ld", d, (long)num); \
+
__res__; \
+
})
+
+

Converts an long value to a stack allocated string.

+

If necessary, fills the result string with left zeros.

+
Parameters
+ + + +
[in]numlong integer number
[in]lenminimum length of result string
+
+
+
+
Precondition:
+
len > 0
+
+
Returns
the converted string
+ +
+
+ +

◆ perc2str

+ +
+
+ + + + + + + + +
#define perc2str( percentage)
+
+Value:
({ \
+
require (percentage >= 0 && percentage <= 100, concat_3str("invalid percentage value (", int2str(percentage), ")")); \
+
char* __res__ = (char*)alloca(4+1); \
+
sprintf(__res__, "%3d%%", (int)percentage); \
+
__res__; \
+
})
+
+

Converts an int percentage to a stack allocated string.

+
Parameters
+ + +
[in]percentagean integer number with a percentage value
+
+
+
+
Precondition:
+
percentage >= 0 && percentage <= 100
+
+
Returns
the converted string
+ +
+
+ +

◆ length_vargs_string_list

+ +
+
+ + + + + + + + +
#define length_vargs_string_list( first)
+
+Value:
({ \
+
int __res__ = 0; \
+
va_list ap; \
+
va_start(ap, first); \
+
char* t = first; \
+
while (t != NULL) \
+
{ \
+
__res__ += strlen(t); \
+
t = va_arg(ap, char*); \
+
} \
+
va_end(ap); \
+
__res__; \
+
})
+
+

Determines the length of all strings passed as a NULL terminated variable list of arguments (vargs).

+
Parameters
+ + +
[in]firstthe argument that precedes the vargs argument list.
+
+
+
Returns
the sum of the length of all strings (not counting terminator ‘’\0'`)
+ +
+
+ +

◆ not_null

+ +
+
+ + + + + + + + +
#define not_null( pnt)
+
+Value:
({ \
+
if ((pnt) == NULL) \
+
{ \
+
fprintf (stderr, "Null pointer error, pointer: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \
+
#pnt, __FUNCTION__, __LINE__ , __FILE__); \
+
*((int*)0) = 0; \
+
abort (); \
+
} \
+
pnt; \
+
})
+
+

Checks if address is not NULL, before its application.

+

This macro is a non-defensive implementation of a null pointer verification. It implements two error handling policies:

    +
  • EXIT_POLICY (default): describes the error in stderr (with the identification and the precise location of the failure), generates a segmentation fault (enabling a stack trace within a debugger like gdb), and exits program execution;
  • +
  • EXCEPTION_POLICY: throws a char* exception with the description of the failure.
  • +
+
Example
not_null(pnt)->something();
+
Parameters
+ + +
[in]pntmemory address
+
+
+ +
+
+

Function Documentation

+ +

◆ mem_alloc()

+ +
+
+ + + + + + + + +
void* mem_alloc (int size)
+
+ +

A replacement for malloc function.

+

This function is a non-defensive implementation of malloc error verification. It implements two error handling policies:

    +
  • EXIT_POLICY (default): describes the error in stderr (with the identification and the precise location of the failure), generates a segmentation fault (enabling a stack trace within a debugger like gdb), and exits program execution;
  • +
  • EXCEPTION_POLICY: throws a char* exception with the description of the failure.
  • +
+
Parameters
+ + +
[in]sizenumber of bytes to be allocated
+
+
+
+
Precondition:
+
size >= 0
+
+
Returns
address of the allocated memory
+ +
+
+ +

◆ mem_free()

+ +
+
+ + + + + + + + +
void mem_free (void * pnt)
+
+ +

A replacement for free function.

+
Parameters
+ + +
[in]pntmemory address to be freed
+
+
+
+
Precondition:
+
pnt != NULL
+
+ +
+
+ +

◆ string_clone()

+ +
+
+ + + + + + + + +
char* string_clone (char * str)
+
+ +

Replicates a string.

+

The memory is allocated in the heap (using mem_alloc()).

+
Parameters
+ + +
[in]strstring to be replicated
+
+
+
+
Precondition:
+
str != NULL
+
+
Returns
pointer to the replicated string
+ +
+
+ +

◆ string_num_lines()

+ +
+
+ + + + + + + + +
int string_num_lines (char * text)
+
+ +

Number of lines of a string.

+
Parameters
+ + +
[in]textstring text to process
+
+
+
+
Precondition:
+
text != NULL
+
+
Returns
number of counted lines
+ +
+
+ +

◆ string_num_columns()

+ +
+
+ + + + + + + + +
int string_num_columns (char * text)
+
+ +

Maximum number of columns of a string (not counting character ‘’\n'`).

+
Parameters
+ + +
[in]textstring text to process
+
+
+
+
Precondition:
+
text != NULL
+
+
Returns
maximum number of counted columns
+ +
+
+ +

◆ string_count_char()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int string_count_char (char * text,
char * ch 
)
+
+ +

Counts the number of occurrences of an UTF8 character in a text.

+
Parameters
+ + + +
[in]textstring text to process
[in]chstring containing the sequence of bytes (one or more) of an UTF8 single character
+
+
+
+
Precondition:
+
text != NULL
+ ch != NULL && num_chars_utf8(ch) == 1
+
+
Returns
number of counted occurrences
+ +
+
+ +

◆ string_starts_with()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int string_starts_with (char * text,
char * prefix 
)
+
+ +

Tests if a string starts with a prefix.

+
Parameters
+ + + +
[in]textstring text to process
[in]prefixstring to test if is a prefix
+
+
+
+
Precondition:
+
text != NULL
+ prefix != NULL
+
+
Returns
true (!=0) if prefix starts text, false (0) otherwise
+ +
+
+ +

◆ string_ends_with()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int string_ends_with (char * text,
char * suffix 
)
+
+ +

Tests if a string ends with a suffix.

+
Parameters
+ + + +
[in]textstring text to process
[in]suffixstring to test if is a suffix
+
+
+
+
Precondition:
+
text != NULL
+ suffix != NULL
+
+
Returns
true (!=0) if suffix ends text, false (0) otherwise
+ +
+
+ +

◆ string_concat()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
char* string_concat (char * res,
int max_length,
char * text,
 ... 
)
+
+ +

Concatenates a NULL terminated list of string arguments.

+

This function treats all vargs arguments as strings (char*), and requires that the list is terminated with a NULL argument.

+

It allocates memory in heap (using mem_alloc()) if NULL is passed in the res argument.

+
Parameters
+ + + + +
[in,out]resaddress of result string (if not NULL)
[in]max_lengthres input argument maximum length (not counting terminator ‘’\0'), only applies if(res != NULL)`
[in]textthe first string to be used in concatenation
+
+
+
+
Precondition:
+
text != NULL
+ res == NULL || (max_length > 0 && length_vargs_string_list(text) <= max_length)
+
+
Returns
the concatenated string
+ +
+
+ +

◆ random_boolean()

+ +
+
+ + + + + + + + +
int random_boolean (int trueProb)
+
+ +

Generates a random boolean value.

+

This function generates boolean values with defined probabilities for true (!=0) and false (0) values.

+
Parameters
+ + +
[in]trueProbprobability (in interval [0;100]).
+
+
+
+
Precondition:
+
trueProb >= 0 && trueProb <= 100
+
+
Returns
the random boolean value
+ +
+
+ +

◆ random_int()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int random_int (int min,
int max 
)
+
+ +

Generates a random integer value within a given interval.

+

This function generates integer values in the interval [min;max]with an uniform distribution for all values.

+
Parameters
+ + + +
[in]minlower value of interval
[in]maxhigher value of interval
+
+
+
+
Precondition:
+
max >= min
+
+
Returns
the random integer value
+ +
+
+ +

◆ random_string()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
char* random_string (char ** list,
int * used,
int length 
)
+
+ +

Returns a random string from a given string list.

+

This function stores the previous randomly selected string's (using the integer indexes of the string list) to disallow its repeated generation.

+
Parameters
+ + + + +
[in]listlist of strings to be selected (NULL terminated)
[in,out]usedindexes of strings already selected
[in]lengthnumber of elements of lists list (not counting NULL entry) and used
+
+
+
+
Precondition:
+
list != NULL
+ used != NULL
+
+
Returns
the random string
+ +
+
+ +

◆ move_cursor()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void move_cursor (int line,
int column 
)
+
+ +

Moves the cursor to a position in terminal.

+
Parameters
+ + + +
[in]lineposition in the terminal
[in]columnposition in the terminal
+
+
+
+
Precondition:
+
line >= 0 && column >= 0
+
+ +
+
+ +

◆ string_list_length()

+ +
+
+ + + + + + + + +
int string_list_length (char ** list)
+
+ +

Number of elements of a NULL terminated list of strings.

+
Parameters
+ + +
[in]listNULL terminated array of strings
+
+
+
+
Precondition:
+
list != NULL
+
+
Returns
number of elements of list (not counting NULL)
+ +
+
+ +

◆ string_list_clone()

+ +
+
+ + + + + + + + +
char** string_list_clone (char ** list)
+
+ +

Replicates a NULL terminated list of strings.

+

The memory is allocated in the heap (using mem_alloc()).

+
Parameters
+ + +
[in]listNULL terminated array of strings
+
+
+
+
Precondition:
+
list != NULL
+
+
Returns
pointer to the replicated list
+ +
+
+ +

◆ string_list_free()

+ +
+
+ + + + + + + + +
char** string_list_free (char ** list)
+
+ +

Frees the memory allocated to a NULL terminated list of strings.

+

This function is totally compatible with string_list_clone(), and always returns NULL.

+
Parameters
+ + +
[in]listNULL terminated array of strings
+
+
+
+
Precondition:
+
list != NULL
+
+
Returns
NULL
+ +
+
+ +

◆ int2nstring()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
char* int2nstring (char * res,
int num,
int len 
)
+
+ +

Converts an int value to a string.

+

If necessary, fills the result string with left zeros. It allocates memory in heap (using mem_alloc()) if NULL is passed in the res argument.

+
Parameters
+ + + + +
[in,out]resaddress of result string (if not NULL)
[in]numinteger number
[in]lenminimum length of result string (not counting terminator ‘’\0'`)
+
+
+
+
Precondition:
+
len >= numDigits(num)
+
+
Returns
the converted string
+ +
+
+ +

◆ percentage2string()

+ +
+
+ + + + + + + + + + + + + + + + + + +
char* percentage2string (char * res,
int percentage 
)
+
+ +

Converts an int percentage to a string.

+

It allocates memory in heap (using mem_alloc()) if NULL is passed in the res argument.

+
Parameters
+ + + +
[in,out]resaddress of result string (if not NULL)
[in]percentagean integer number with a percentage value
+
+
+
+
Precondition:
+
percentage >= 0 && percentage <= 100
+
+
Returns
the converted string (if not NULL, it returns res)
+ +
+
+
+
+
#define concat_3str(str1, str2, str3)
Concatenates three strings in the stack memory (thus it cannot be implemented in a function).
Definition: utils.h:57
+
#define int2str(num)
Converts an int value to a stack allocated string.
Definition: utils.h:199
+ + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/group__utils.js b/3ano/1semestre/so/practice-exam/src/doc/html/group__utils.js new file mode 100644 index 0000000..324e2fb --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/group__utils.js @@ -0,0 +1,38 @@ +var group__utils = +[ + [ "utils.h", "utils_8h.html", null ], + [ "concat_2str", "group__utils.html#ga22347cbf977a0300726f06257edd79d6", null ], + [ "concat_3str", "group__utils.html#ga123e40006d54612c48c2660432dfeb23", null ], + [ "concat_4str", "group__utils.html#ga69037999e65cdb42d39988e0fec48af4", null ], + [ "concat_5str", "group__utils.html#ga580d1897bc7a8cef16d5a16a2373b876", null ], + [ "concat_6str", "group__utils.html#ga34f8c2fcee597a99c5f4c66f2119bca9", null ], + [ "concat_7str", "group__utils.html#ga01d1ea65eb6780d91705484dd46833bf", null ], + [ "int2str", "group__utils.html#ga3c545b669dff7d67e5ed3c58233ccf4b", null ], + [ "int2nstr", "group__utils.html#ga858ece77e79fb78d3db0f1851bf7fe09", null ], + [ "long2str", "group__utils.html#ga69373a612a7b4d264371f727217f9954", null ], + [ "long2nstr", "group__utils.html#ga50cea1f8154c7c7d2abd68f1ddb33086", null ], + [ "perc2str", "group__utils.html#ga59cd66180162d107cf86a51c21d7e6f5", null ], + [ "length_vargs_string_list", "group__utils.html#ga7bffda236a079c26302722c7d155f7a5", null ], + [ "not_null", "group__utils.html#gadfa0375f8178c737deae23ffa8d152f4", null ], + [ "mem_alloc", "group__utils.html#gadce4d1c428f979bf1cf8e1582d2f4052", null ], + [ "mem_free", "group__utils.html#gabe60e8350f3e3b07ed5002ee3449a6ae", null ], + [ "string_clone", "group__utils.html#ga825354891d287cc86d2b4ed1b600175a", null ], + [ "string_num_lines", "group__utils.html#ga15630ddb64e977c8243892556feedfd8", null ], + [ "string_num_columns", "group__utils.html#ga0ca31b2a579b6ef7c75c41324ed5367c", null ], + [ "string_count_char", "group__utils.html#gad643e0fcac9e59c1a171c460633e8637", null ], + [ "string_starts_with", "group__utils.html#ga3ec2b60d1636397119c5e0c21987f791", null ], + [ "string_ends_with", "group__utils.html#ga1c5ba308f71c323fbbd7eb9bb34285d4", null ], + [ "string_concat", "group__utils.html#gaa23a827164f7039b9770379cbf008905", null ], + [ "random_boolean", "group__utils.html#gabe3e28fe49daaf3530e203c4aed1d15f", null ], + [ "random_int", "group__utils.html#gad7954e6a1b9ea073c7bc894dc5af85a9", null ], + [ "random_string", "group__utils.html#gaa820c93c2f719401b4b1ca54f6ea5c75", null ], + [ "clear_console", "group__utils.html#ga3cffe15b7e5d10a108f1734a9640a2c7", null ], + [ "move_cursor", "group__utils.html#gad3d324aed0ec686314cb0f68dfde9853", null ], + [ "hide_cursor", "group__utils.html#ga42702791e6da9510e4f44f33d2dad8f1", null ], + [ "show_cursor", "group__utils.html#ga1bdd62a6bef7cfd6522dc1412e162559", null ], + [ "string_list_length", "group__utils.html#gab8050db5b87bfdee91ee92e67b063478", null ], + [ "string_list_clone", "group__utils.html#ga41163cf3a95e702f12506cd54ba3c70c", null ], + [ "string_list_free", "group__utils.html#gaacf77b3345bbca43767b08ec0583fe3c", null ], + [ "int2nstring", "group__utils.html#ga824373ca8e0b2fdfe3f5c4805cf2ab7e", null ], + [ "percentage2string", "group__utils.html#gacf6edf10cb84412b6bfb431ef87b56d6", null ] +]; \ No newline at end of file diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/index.html b/3ano/1semestre/so/practice-exam/src/doc/html/index.html new file mode 100644 index 0000000..eed0bec --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/index.html @@ -0,0 +1,78 @@ + + + + + + + +C++ Library, mos@ua: Main Page + + + + + + + + + + +
+
+ + + + + + +
+
C++ Library, mos@ua +  0.9 +
+
cpplib-mos
+
+
+ + + + + + +
+
+ +
+
+
+ +
+
+
+
C++ Library, mos@ua Documentation
+
+
+
+
+ + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/jquery.js b/3ano/1semestre/so/practice-exam/src/doc/html/jquery.js new file mode 100644 index 0000000..103c32d --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/jquery.js @@ -0,0 +1,35 @@ +/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.4.1",k=function(e,t){return new k.fn.init(e,t)},p=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function d(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp($),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+$),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ne=function(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(m.childNodes),m.childNodes),t[m.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&((e?e.ownerDocument||e:m)!==C&&T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!A[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&U.test(t)){(s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=k),o=(l=h(t)).length;while(o--)l[o]="#"+s+" "+xe(l[o]);c=l.join(","),f=ee.test(t)&&ye(e.parentNode)||e}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){A(t,!0)}finally{s===k&&e.removeAttribute("id")}}}return g(t.replace(B,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[k]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:m;return r!==C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),m!==C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=k,!C.getElementsByName||!C.getElementsByName(k).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+k+"-]").length||v.push("~="),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+k+"+*").length||v.push(".#.+[+~]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",$)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e===C||e.ownerDocument===m&&y(m,e)?-1:t===C||t.ownerDocument===m&&y(m,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===C?-1:t===C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]===m?-1:s[r]===m?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==C&&T(e),d.matchesSelector&&E&&!A[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){A(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=p[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&p(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?k.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?k.grep(e,function(e){return e===n!==r}):"string"!=typeof n?k.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(k.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:L.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof k?t[0]:t,k.merge(this,k.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),D.test(r[1])&&k.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(k):k.makeArray(e,this)}).prototype=k.fn,q=k(E);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}k.fn.extend({has:function(e){var t=k(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?k.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;nx",y.noCloneChecked=!!me.cloneNode(!0).lastChild.defaultValue;var Te=/^key/,Ce=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ee=/^([^.]*)(?:\.(.+)|)/;function ke(){return!0}function Se(){return!1}function Ne(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function Ae(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)Ae(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Se;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return k().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=k.guid++)),e.each(function(){k.event.add(this,t,i,r,n)})}function De(e,i,o){o?(Q.set(e,i,!1),k.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Q.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(k.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Q.set(this,i,r),t=o(this,i),this[i](),r!==(n=Q.get(this,i))||t?Q.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n.value}else r.length&&(Q.set(this,i,{value:k.event.trigger(k.extend(r[0],k.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===Q.get(e,i)&&k.event.add(e,i,ke)}k.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.get(t);if(v){n.handler&&(n=(o=n).handler,i=o.selector),i&&k.find.matchesSelector(ie,i),n.guid||(n.guid=k.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof k&&k.event.triggered!==e.type?k.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(R)||[""]).length;while(l--)d=g=(s=Ee.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=k.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=k.event.special[d]||{},c=k.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&k.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),k.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.hasData(e)&&Q.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(R)||[""]).length;while(l--)if(d=g=(s=Ee.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=k.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||k.removeEvent(e,d,v.handle),delete u[d])}else for(d in u)k.event.remove(e,d+t[l],n,r,!0);k.isEmptyObject(u)&&Q.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=k.event.fix(e),u=new Array(arguments.length),l=(Q.get(this,"events")||{})[s.type]||[],c=k.event.special[s.type]||{};for(u[0]=s,t=1;t\x20\t\r\n\f]*)[^>]*)\/>/gi,qe=/\s*$/g;function Oe(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&k(e).children("tbody")[0]||e}function Pe(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Re(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Me(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(Q.hasData(e)&&(o=Q.access(e),a=Q.set(t,o),l=o.events))for(i in delete a.handle,a.events={},l)for(n=0,r=l[i].length;n")},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=oe(e);if(!(y.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||k.isXMLDoc(e)))for(a=ve(c),r=0,i=(o=ve(e)).length;r").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Vt,Gt=[],Yt=/(=)\?(?=&|$)|\?\?/;k.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Gt.pop()||k.expando+"_"+kt++;return this[e]=!0,e}}),k.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Yt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Yt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Yt,"$1"+r):!1!==e.jsonp&&(e.url+=(St.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||k.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?k(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Gt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((Vt=E.implementation.createHTMLDocument("").body).innerHTML="
",2===Vt.childNodes.length),k.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=D.exec(e))?[t.createElement(i[1])]:(i=we([e],t,o),o&&o.length&&k(o).remove(),k.merge([],i.childNodes)));var r,i,o},k.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(k.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},k.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){k.fn[t]=function(e){return this.on(t,e)}}),k.expr.pseudos.animated=function(t){return k.grep(k.timers,function(e){return t===e.elem}).length},k.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=k.css(e,"position"),c=k(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=k.css(e,"top"),u=k.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,k.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},k.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){k.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===k.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===k.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=k(e).offset()).top+=k.css(e,"borderTopWidth",!0),i.left+=k.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-k.css(r,"marginTop",!0),left:t.left-i.left-k.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===k.css(e,"position"))e=e.offsetParent;return e||ie})}}),k.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;k.fn[t]=function(e){return _(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),k.each(["top","left"],function(e,n){k.cssHooks[n]=ze(y.pixelPosition,function(e,t){if(t)return t=_e(e,n),$e.test(t)?k(e).position()[n]+"px":t})}),k.each({Height:"height",Width:"width"},function(a,s){k.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){k.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return _(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?k.css(e,t,i):k.style(e,t,n,i)},s,n?e:void 0,n)}})}),k.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){k.fn[n]=function(e,t){return 0a;a++)for(i in o[a])n=o[a][i],o[a].hasOwnProperty(i)&&void 0!==n&&(e[i]=t.isPlainObject(n)?t.isPlainObject(e[i])?t.widget.extend({},e[i],n):t.widget.extend({},n):n);return e},t.widget.bridge=function(e,i){var n=i.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,r=s.call(arguments,1),h=this;return a?this.length||"instance"!==o?this.each(function(){var i,s=t.data(this,n);return"instance"===o?(h=s,!1):s?t.isFunction(s[o])&&"_"!==o.charAt(0)?(i=s[o].apply(s,r),i!==s&&void 0!==i?(h=i&&i.jquery?h.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+o+"'")}):h=void 0:(r.length&&(o=t.widget.extend.apply(null,[o].concat(r))),this.each(function(){var e=t.data(this,n);e?(e.option(o||{}),e._init&&e._init()):t.data(this,n,new i(o,this))})),h}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{classes:{},disabled:!1,create:null},_createWidget:function(e,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),this.classesElementLookup={},s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){var e=this;this._destroy(),t.each(this.classesElementLookup,function(t,i){e._removeClass(i,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(e){var i,s,n;for(i in e)n=this.classesElementLookup[i],e[i]!==this.options.classes[i]&&n&&n.length&&(s=t(n.get()),this._removeClass(n,i),s.addClass(this._classes({element:s,keys:i,classes:e,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(e){function i(i,o){var a,r;for(r=0;i.length>r;r++)a=n.classesElementLookup[i[r]]||t(),a=e.add?t(t.unique(a.get().concat(e.element.get()))):t(a.not(e.element).get()),n.classesElementLookup[i[r]]=a,s.push(i[r]),o&&e.classes[i[r]]&&s.push(e.classes[i[r]])}var s=[],n=this;return e=t.extend({element:this.element,classes:this.options.classes||{}},e),this._on(e.element,{remove:"_untrackClassesElement"}),e.keys&&i(e.keys.match(/\S+/g)||[],!0),e.extra&&i(e.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(e){var i=this;t.each(i.classesElementLookup,function(s,n){-1!==t.inArray(e.target,n)&&(i.classesElementLookup[s]=t(n.not(e.target).get()))})},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){s="boolean"==typeof s?s:i;var n="string"==typeof t||null===t,o={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s};return o.element.toggleClass(this._classes(o),s),this},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+o.eventNamespace,c=h[2];c?n.on(l,c,r):i.on(l,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.off(i).off(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){this._addClass(t(e.currentTarget),null,"ui-state-hover")},mouseleave:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){this._addClass(t(e.currentTarget),null,"ui-state-focus")},focusout:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget,function(){function e(t,e,i){return[parseFloat(t[0])*(u.test(t[0])?e/100:1),parseFloat(t[1])*(u.test(t[1])?i/100:1)]}function i(e,i){return parseInt(t.css(e,i),10)||0}function s(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}var n,o=Math.max,a=Math.abs,r=/left|center|right/,h=/top|center|bottom/,l=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,u=/%$/,d=t.fn.position;t.position={scrollbarWidth:function(){if(void 0!==n)return n;var e,i,s=t("
"),o=s.children()[0];return t("body").append(s),e=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,e===i&&(i=s[0].clientWidth),s.remove(),n=e-i},getScrollInfo:function(e){var i=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),s=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.widthi?"left":e>0?"right":"center",vertical:0>r?"top":s>0?"bottom":"middle"};l>p&&p>a(e+i)&&(u.horizontal="center"),c>f&&f>a(s+r)&&(u.vertical="middle"),u.important=o(a(e),a(i))>o(a(s),a(r))?"horizontal":"vertical",n.using.call(this,t,u)}),h.offset(t.extend(D,{using:r}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=t.left-e.collisionPosition.marginLeft,h=n-r,l=r+e.collisionWidth-a-n;e.collisionWidth>a?h>0&&0>=l?(i=t.left+h+e.collisionWidth-a-n,t.left+=h-i):t.left=l>0&&0>=h?n:h>l?n+a-e.collisionWidth:n:h>0?t.left+=h:l>0?t.left-=l:t.left=o(t.left-r,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,h=n-r,l=r+e.collisionHeight-a-n;e.collisionHeight>a?h>0&&0>=l?(i=t.top+h+e.collisionHeight-a-n,t.top+=h-i):t.top=l>0&&0>=h?n:h>l?n+a-e.collisionHeight:n:h>0?t.top+=h:l>0?t.top-=l:t.top=o(t.top-r,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,o=n.offset.left+n.scrollLeft,r=n.width,h=n.isWindow?n.scrollLeft:n.offset.left,l=t.left-e.collisionPosition.marginLeft,c=l-h,u=l+e.collisionWidth-r-h,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];0>c?(i=t.left+d+p+f+e.collisionWidth-r-o,(0>i||a(c)>i)&&(t.left+=d+p+f)):u>0&&(s=t.left-e.collisionPosition.marginLeft+d+p+f-h,(s>0||u>a(s))&&(t.left+=d+p+f))},top:function(t,e){var i,s,n=e.within,o=n.offset.top+n.scrollTop,r=n.height,h=n.isWindow?n.scrollTop:n.offset.top,l=t.top-e.collisionPosition.marginTop,c=l-h,u=l+e.collisionHeight-r-h,d="top"===e.my[1],p=d?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,f="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,m=-2*e.offset[1];0>c?(s=t.top+p+f+m+e.collisionHeight-r-o,(0>s||a(c)>s)&&(t.top+=p+f+m)):u>0&&(i=t.top-e.collisionPosition.marginTop+p+f+m-h,(i>0||u>a(i))&&(t.top+=p+f+m))}},flipfit:{left:function(){t.ui.position.flip.left.apply(this,arguments),t.ui.position.fit.left.apply(this,arguments)},top:function(){t.ui.position.flip.top.apply(this,arguments),t.ui.position.fit.top.apply(this,arguments)}}}}(),t.ui.position,t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,s){return!!t.data(e,s[3])}}),t.fn.extend({disableSelection:function(){var t="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.on(t+".ui-disableSelection",function(t){t.preventDefault()})}}(),enableSelection:function(){return this.off(".ui-disableSelection")}}),t.ui.focusable=function(i,s){var n,o,a,r,h,l=i.nodeName.toLowerCase();return"area"===l?(n=i.parentNode,o=n.name,i.href&&o&&"map"===n.nodeName.toLowerCase()?(a=t("img[usemap='#"+o+"']"),a.length>0&&a.is(":visible")):!1):(/^(input|select|textarea|button|object)$/.test(l)?(r=!i.disabled,r&&(h=t(i).closest("fieldset")[0],h&&(r=!h.disabled))):r="a"===l?i.href||s:s,r&&t(i).is(":visible")&&e(t(i)))},t.extend(t.expr[":"],{focusable:function(e){return t.ui.focusable(e,null!=t.attr(e,"tabindex"))}}),t.ui.focusable,t.fn.form=function(){return"string"==typeof this[0].form?this.closest("form"):t(this[0].form)},t.ui.formResetMixin={_formResetHandler:function(){var e=t(this);setTimeout(function(){var i=e.data("ui-form-reset-instances");t.each(i,function(){this.refresh()})})},_bindFormResetHandler:function(){if(this.form=this.element.form(),this.form.length){var t=this.form.data("ui-form-reset-instances")||[];t.length||this.form.on("reset.ui-form-reset",this._formResetHandler),t.push(this),this.form.data("ui-form-reset-instances",t)}},_unbindFormResetHandler:function(){if(this.form.length){var e=this.form.data("ui-form-reset-instances");e.splice(t.inArray(this,e),1),e.length?this.form.data("ui-form-reset-instances",e):this.form.removeData("ui-form-reset-instances").off("reset.ui-form-reset")}}},"1.7"===t.fn.jquery.substring(0,3)&&(t.each(["Width","Height"],function(e,i){function s(e,i,s,o){return t.each(n,function(){i-=parseFloat(t.css(e,"padding"+this))||0,s&&(i-=parseFloat(t.css(e,"border"+this+"Width"))||0),o&&(i-=parseFloat(t.css(e,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],o=i.toLowerCase(),a={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+i]=function(e){return void 0===e?a["inner"+i].call(this):this.each(function(){t(this).css(o,s(this,e)+"px")})},t.fn["outer"+i]=function(e,n){return"number"!=typeof e?a["outer"+i].call(this,e):this.each(function(){t(this).css(o,s(this,e,!0,n)+"px")})}}),t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},t.ui.escapeSelector=function(){var t=/([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;return function(e){return e.replace(t,"\\$1")}}(),t.fn.labels=function(){var e,i,s,n,o;return this[0].labels&&this[0].labels.length?this.pushStack(this[0].labels):(n=this.eq(0).parents("label"),s=this.attr("id"),s&&(e=this.eq(0).parents().last(),o=e.add(e.length?e.siblings():this.siblings()),i="label[for='"+t.ui.escapeSelector(s)+"']",n=n.add(o.find(i).addBack(i))),this.pushStack(n))},t.fn.scrollParent=function(e){var i=this.css("position"),s="absolute"===i,n=e?/(auto|scroll|hidden)/:/(auto|scroll)/,o=this.parents().filter(function(){var e=t(this);return s&&"static"===e.css("position")?!1:n.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==i&&o.length?o:t(this[0].ownerDocument||document)},t.extend(t.expr[":"],{tabbable:function(e){var i=t.attr(e,"tabindex"),s=null!=i;return(!s||i>=0)&&t.ui.focusable(e,s)}}),t.fn.extend({uniqueId:function(){var t=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++t)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&t(this).removeAttr("id")})}}),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());var n=!1;t(document).on("mouseup",function(){n=!1}),t.widget("ui.mouse",{version:"1.12.1",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.on("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).on("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){if(!n){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var i=this,s=1===e.which,o="string"==typeof this.options.cancel&&e.target.nodeName?t(e.target).closest(this.options.cancel).length:!1;return s&&!o&&this._mouseCapture(e)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(e)!==!1,!this._mouseStarted)?(e.preventDefault(),!0):(!0===t.data(e.target,this.widgetName+".preventClickEvent")&&t.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return i._mouseMove(t)},this._mouseUpDelegate=function(t){return i._mouseUp(t)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),n=!0,!0)):!0}},_mouseMove:function(e){if(this._mouseMoved){if(t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button)return this._mouseUp(e);if(!e.which)if(e.originalEvent.altKey||e.originalEvent.ctrlKey||e.originalEvent.metaKey||e.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,n=!1,e.preventDefault()},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),t.ui.plugin={add:function(e,i,s){var n,o=t.ui[e].prototype;for(n in s)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([i,s[n]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;o.length>n;n++)t.options[o[n][0]]&&o[n][1].apply(t.element,i)}},t.widget("ui.resizable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,classes:{"ui-resizable-se":"ui-icon ui-icon-gripsmall-diagonal-se"},containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(t){return parseFloat(t)||0},_isNumber:function(t){return!isNaN(parseFloat(t))},_hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return e[s]>0?!0:(e[s]=1,n=e[s]>0,e[s]=0,n)},_create:function(){var e,i=this.options,s=this;this._addClass("ui-resizable"),t.extend(this,{_aspectRatio:!!i.aspectRatio,aspectRatio:i.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:i.helper||i.ghost||i.animate?i.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)&&(this.element.wrap(t("
").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,e={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(e),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(e),this._proportionallyResize()),this._setupHandles(),i.autoHide&&t(this.element).on("mouseenter",function(){i.disabled||(s._removeClass("ui-resizable-autohide"),s._handles.show())}).on("mouseleave",function(){i.disabled||s.resizing||(s._addClass("ui-resizable-autohide"),s._handles.hide())}),this._mouseInit()},_destroy:function(){this._mouseDestroy();var e,i=function(e){t(e).removeData("resizable").removeData("ui-resizable").off(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_setOption:function(t,e){switch(this._super(t,e),t){case"handles":this._removeHandles(),this._setupHandles();break;default:}},_setupHandles:function(){var e,i,s,n,o,a=this.options,r=this;if(this.handles=a.handles||(t(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=t(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),s=this.handles.split(","),this.handles={},i=0;s.length>i;i++)e=t.trim(s[i]),n="ui-resizable-"+e,o=t("
"),this._addClass(o,"ui-resizable-handle "+n),o.css({zIndex:a.zIndex}),this.handles[e]=".ui-resizable-"+e,this.element.append(o);this._renderAxis=function(e){var i,s,n,o;e=e||this.element;for(i in this.handles)this.handles[i].constructor===String?this.handles[i]=this.element.children(this.handles[i]).first().show():(this.handles[i].jquery||this.handles[i].nodeType)&&(this.handles[i]=t(this.handles[i]),this._on(this.handles[i],{mousedown:r._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(s=t(this.handles[i],this.element),o=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),e.css(n,o),this._proportionallyResize()),this._handles=this._handles.add(this.handles[i])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",function(){r.resizing||(this.className&&(o=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),r.axis=o&&o[1]?o[1]:"se")}),a.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._handles.remove()},_mouseCapture:function(e){var i,s,n=!1;for(i in this.handles)s=t(this.handles[i])[0],(s===e.target||t.contains(s,e.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(e){var i,s,n,o=this.options,a=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),o.containment&&(i+=t(o.containment).scrollLeft()||0,s+=t(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:a.width(),height:a.height()},this.originalSize=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.sizeDiff={width:a.outerWidth()-a.width(),height:a.outerHeight()-a.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:e.pageX,top:e.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=t(".ui-resizable-"+this.axis).css("cursor"),t("body").css("cursor","auto"===n?this.axis+"-resize":n),this._addClass("ui-resizable-resizing"),this._propagate("start",e),!0},_mouseDrag:function(e){var i,s,n=this.originalMousePosition,o=this.axis,a=e.pageX-n.left||0,r=e.pageY-n.top||0,h=this._change[o];return this._updatePrevProperties(),h?(i=h.apply(this,[e,a,r]),this._updateVirtualBoundaries(e.shiftKey),(this._aspectRatio||e.shiftKey)&&(i=this._updateRatio(i,e)),i=this._respectSize(i,e),this._updateCache(i),this._propagate("resize",e),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),t.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",e,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(e){this.resizing=!1;var i,s,n,o,a,r,h,l=this.options,c=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:c.sizeDiff.height,o=s?0:c.sizeDiff.width,a={width:c.helper.width()-o,height:c.helper.height()-n},r=parseFloat(c.element.css("left"))+(c.position.left-c.originalPosition.left)||null,h=parseFloat(c.element.css("top"))+(c.position.top-c.originalPosition.top)||null,l.animate||this.element.css(t.extend(a,{top:h,left:r})),c.helper.height(c.size.height),c.helper.width(c.size.width),this._helper&&!l.animate&&this._proportionallyResize()),t("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",e),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s,n,o,a=this.options;o={minWidth:this._isNumber(a.minWidth)?a.minWidth:0,maxWidth:this._isNumber(a.maxWidth)?a.maxWidth:1/0,minHeight:this._isNumber(a.minHeight)?a.minHeight:0,maxHeight:this._isNumber(a.maxHeight)?a.maxHeight:1/0},(this._aspectRatio||t)&&(e=o.minHeight*this.aspectRatio,s=o.minWidth/this.aspectRatio,i=o.maxHeight*this.aspectRatio,n=o.maxWidth/this.aspectRatio,e>o.minWidth&&(o.minWidth=e),s>o.minHeight&&(o.minHeight=s),o.maxWidth>i&&(o.maxWidth=i),o.maxHeight>n&&(o.maxHeight=n)),this._vBoundaries=o},_updateCache:function(t){this.offset=this.helper.offset(),this._isNumber(t.left)&&(this.position.left=t.left),this._isNumber(t.top)&&(this.position.top=t.top),this._isNumber(t.height)&&(this.size.height=t.height),this._isNumber(t.width)&&(this.size.width=t.width)},_updateRatio:function(t){var e=this.position,i=this.size,s=this.axis;return this._isNumber(t.height)?t.width=t.height*this.aspectRatio:this._isNumber(t.width)&&(t.height=t.width/this.aspectRatio),"sw"===s&&(t.left=e.left+(i.width-t.width),t.top=null),"nw"===s&&(t.top=e.top+(i.height-t.height),t.left=e.left+(i.width-t.width)),t},_respectSize:function(t){var e=this._vBoundaries,i=this.axis,s=this._isNumber(t.width)&&e.maxWidth&&e.maxWidtht.width,a=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,r=this.originalPosition.left+this.originalSize.width,h=this.originalPosition.top+this.originalSize.height,l=/sw|nw|w/.test(i),c=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),a&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&l&&(t.left=r-e.minWidth),s&&l&&(t.left=r-e.maxWidth),a&&c&&(t.top=h-e.minHeight),n&&c&&(t.top=h-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];4>e;e++)i[e]=parseFloat(s[e])||0,i[e]+=parseFloat(n[e])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;this._proportionallyResizeElements.length>e;e++)t=this._proportionallyResizeElements[e],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(t)),t.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var e=this.element,i=this.options;this.elementOffset=e.offset(),this._helper?(this.helper=this.helper||t("
"),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element +},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize,s=this.originalPosition;return{left:s.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},sw:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,i,s]))},ne:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},nw:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,i,s]))}},_propagate:function(e,i){t.ui.plugin.call(this,e,[i,this.ui()]),"resize"!==e&&this._trigger(e,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),t.ui.plugin.add("resizable","animate",{stop:function(e){var i=t(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,o=n.length&&/textarea/i.test(n[0].nodeName),a=o&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=o?0:i.sizeDiff.width,h={width:i.size.width-r,height:i.size.height-a},l=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,c=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(t.extend(h,c&&l?{top:c,left:l}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};n&&n.length&&t(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",e)}})}}),t.ui.plugin.add("resizable","containment",{start:function(){var e,i,s,n,o,a,r,h=t(this).resizable("instance"),l=h.options,c=h.element,u=l.containment,d=u instanceof t?u.get(0):/parent/.test(u)?c.parent().get(0):u;d&&(h.containerElement=t(d),/document/.test(u)||u===document?(h.containerOffset={left:0,top:0},h.containerPosition={left:0,top:0},h.parentData={element:t(document),left:0,top:0,width:t(document).width(),height:t(document).height()||document.body.parentNode.scrollHeight}):(e=t(d),i=[],t(["Top","Right","Left","Bottom"]).each(function(t,s){i[t]=h._num(e.css("padding"+s))}),h.containerOffset=e.offset(),h.containerPosition=e.position(),h.containerSize={height:e.innerHeight()-i[3],width:e.innerWidth()-i[1]},s=h.containerOffset,n=h.containerSize.height,o=h.containerSize.width,a=h._hasScroll(d,"left")?d.scrollWidth:o,r=h._hasScroll(d)?d.scrollHeight:n,h.parentData={element:d,left:s.left,top:s.top,width:a,height:r}))},resize:function(e){var i,s,n,o,a=t(this).resizable("instance"),r=a.options,h=a.containerOffset,l=a.position,c=a._aspectRatio||e.shiftKey,u={top:0,left:0},d=a.containerElement,p=!0;d[0]!==document&&/static/.test(d.css("position"))&&(u=h),l.left<(a._helper?h.left:0)&&(a.size.width=a.size.width+(a._helper?a.position.left-h.left:a.position.left-u.left),c&&(a.size.height=a.size.width/a.aspectRatio,p=!1),a.position.left=r.helper?h.left:0),l.top<(a._helper?h.top:0)&&(a.size.height=a.size.height+(a._helper?a.position.top-h.top:a.position.top),c&&(a.size.width=a.size.height*a.aspectRatio,p=!1),a.position.top=a._helper?h.top:0),n=a.containerElement.get(0)===a.element.parent().get(0),o=/relative|absolute/.test(a.containerElement.css("position")),n&&o?(a.offset.left=a.parentData.left+a.position.left,a.offset.top=a.parentData.top+a.position.top):(a.offset.left=a.element.offset().left,a.offset.top=a.element.offset().top),i=Math.abs(a.sizeDiff.width+(a._helper?a.offset.left-u.left:a.offset.left-h.left)),s=Math.abs(a.sizeDiff.height+(a._helper?a.offset.top-u.top:a.offset.top-h.top)),i+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-i,c&&(a.size.height=a.size.width/a.aspectRatio,p=!1)),s+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-s,c&&(a.size.width=a.size.height*a.aspectRatio,p=!1)),p||(a.position.left=a.prevPosition.left,a.position.top=a.prevPosition.top,a.size.width=a.prevSize.width,a.size.height=a.prevSize.height)},stop:function(){var e=t(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.containerPosition,o=e.containerElement,a=t(e.helper),r=a.offset(),h=a.outerWidth()-e.sizeDiff.width,l=a.outerHeight()-e.sizeDiff.height;e._helper&&!i.animate&&/relative/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:h,height:l}),e._helper&&!i.animate&&/static/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:h,height:l})}}),t.ui.plugin.add("resizable","alsoResize",{start:function(){var e=t(this).resizable("instance"),i=e.options;t(i.alsoResize).each(function(){var e=t(this);e.data("ui-resizable-alsoresize",{width:parseFloat(e.width()),height:parseFloat(e.height()),left:parseFloat(e.css("left")),top:parseFloat(e.css("top"))})})},resize:function(e,i){var s=t(this).resizable("instance"),n=s.options,o=s.originalSize,a=s.originalPosition,r={height:s.size.height-o.height||0,width:s.size.width-o.width||0,top:s.position.top-a.top||0,left:s.position.left-a.left||0};t(n.alsoResize).each(function(){var e=t(this),s=t(this).data("ui-resizable-alsoresize"),n={},o=e.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];t.each(o,function(t,e){var i=(s[e]||0)+(r[e]||0);i&&i>=0&&(n[e]=i||null)}),e.css(n)})},stop:function(){t(this).removeData("ui-resizable-alsoresize")}}),t.ui.plugin.add("resizable","ghost",{start:function(){var e=t(this).resizable("instance"),i=e.size;e.ghost=e.originalElement.clone(),e.ghost.css({opacity:.25,display:"block",position:"relative",height:i.height,width:i.width,margin:0,left:0,top:0}),e._addClass(e.ghost,"ui-resizable-ghost"),t.uiBackCompat!==!1&&"string"==typeof e.options.ghost&&e.ghost.addClass(this.options.ghost),e.ghost.appendTo(e.helper)},resize:function(){var e=t(this).resizable("instance");e.ghost&&e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})},stop:function(){var e=t(this).resizable("instance");e.ghost&&e.helper&&e.helper.get(0).removeChild(e.ghost.get(0))}}),t.ui.plugin.add("resizable","grid",{resize:function(){var e,i=t(this).resizable("instance"),s=i.options,n=i.size,o=i.originalSize,a=i.originalPosition,r=i.axis,h="number"==typeof s.grid?[s.grid,s.grid]:s.grid,l=h[0]||1,c=h[1]||1,u=Math.round((n.width-o.width)/l)*l,d=Math.round((n.height-o.height)/c)*c,p=o.width+u,f=o.height+d,m=s.maxWidth&&p>s.maxWidth,g=s.maxHeight&&f>s.maxHeight,_=s.minWidth&&s.minWidth>p,v=s.minHeight&&s.minHeight>f;s.grid=h,_&&(p+=l),v&&(f+=c),m&&(p-=l),g&&(f-=c),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=a.top-d):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=a.left-u):((0>=f-c||0>=p-l)&&(e=i._getPaddingPlusBorderDimensions(this)),f-c>0?(i.size.height=f,i.position.top=a.top-d):(f=c-e.height,i.size.height=f,i.position.top=a.top+o.height-f),p-l>0?(i.size.width=p,i.position.left=a.left-u):(p=l-e.width,i.size.width=p,i.position.left=a.left+o.width-p))}}),t.ui.resizable});/** + * Copyright (c) 2007 Ariel Flesler - aflesler ○ gmail • com | https://github.com/flesler + * Licensed under MIT + * @author Ariel Flesler + * @version 2.1.2 + */ +;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1=f[g]?0:Math.min(f[g],n));!a&&1-1){targetElements.on(evt+EVENT_NAMESPACE,function elementToggle(event){$.powerTip.toggle(this,event)})}else{targetElements.on(evt+EVENT_NAMESPACE,function elementOpen(event){$.powerTip.show(this,event)})}});$.each(options.closeEvents,function(idx,evt){if($.inArray(evt,options.openEvents)<0){targetElements.on(evt+EVENT_NAMESPACE,function elementClose(event){$.powerTip.hide(this,!isMouseEvent(event))})}});targetElements.on("keydown"+EVENT_NAMESPACE,function elementKeyDown(event){if(event.keyCode===27){$.powerTip.hide(this,true)}})}return targetElements};$.fn.powerTip.defaults={fadeInTime:200,fadeOutTime:100,followMouse:false,popupId:"powerTip",popupClass:null,intentSensitivity:7,intentPollInterval:100,closeDelay:100,placement:"n",smartPlacement:false,offset:10,mouseOnToPopup:false,manual:false,openEvents:["mouseenter","focus"],closeEvents:["mouseleave","blur"]};$.fn.powerTip.smartPlacementLists={n:["n","ne","nw","s"],e:["e","ne","se","w","nw","sw","n","s","e"],s:["s","se","sw","n"],w:["w","nw","sw","e","ne","se","n","s","w"],nw:["nw","w","sw","n","s","se","nw"],ne:["ne","e","se","n","s","sw","ne"],sw:["sw","w","nw","s","n","ne","sw"],se:["se","e","ne","s","n","nw","se"],"nw-alt":["nw-alt","n","ne-alt","sw-alt","s","se-alt","w","e"],"ne-alt":["ne-alt","n","nw-alt","se-alt","s","sw-alt","e","w"],"sw-alt":["sw-alt","s","se-alt","nw-alt","n","ne-alt","w","e"],"se-alt":["se-alt","s","sw-alt","ne-alt","n","nw-alt","e","w"]};$.powerTip={show:function apiShowTip(element,event){if(isMouseEvent(event)){trackMouse(event);session.previousX=event.pageX;session.previousY=event.pageY;$(element).data(DATA_DISPLAYCONTROLLER).show()}else{$(element).first().data(DATA_DISPLAYCONTROLLER).show(true,true)}return element},reposition:function apiResetPosition(element){$(element).first().data(DATA_DISPLAYCONTROLLER).resetPosition();return element},hide:function apiCloseTip(element,immediate){var displayController;immediate=element?immediate:true;if(element){displayController=$(element).first().data(DATA_DISPLAYCONTROLLER)}else if(session.activeHover){displayController=session.activeHover.data(DATA_DISPLAYCONTROLLER)}if(displayController){displayController.hide(immediate)}return element},toggle:function apiToggle(element,event){if(session.activeHover&&session.activeHover.is(element)){$.powerTip.hide(element,!isMouseEvent(event))}else{$.powerTip.show(element,event)}return element}};$.powerTip.showTip=$.powerTip.show;$.powerTip.closeTip=$.powerTip.hide;function CSSCoordinates(){var me=this;me.top="auto";me.left="auto";me.right="auto";me.bottom="auto";me.set=function(property,value){if($.isNumeric(value)){me[property]=Math.round(value)}}}function DisplayController(element,options,tipController){var hoverTimer=null,myCloseDelay=null;function openTooltip(immediate,forceOpen){cancelTimer();if(!element.data(DATA_HASACTIVEHOVER)){if(!immediate){session.tipOpenImminent=true;hoverTimer=setTimeout(function intentDelay(){hoverTimer=null;checkForIntent()},options.intentPollInterval)}else{if(forceOpen){element.data(DATA_FORCEDOPEN,true)}closeAnyDelayed();tipController.showTip(element)}}else{cancelClose()}}function closeTooltip(disableDelay){if(myCloseDelay){myCloseDelay=session.closeDelayTimeout=clearTimeout(myCloseDelay);session.delayInProgress=false}cancelTimer();session.tipOpenImminent=false;if(element.data(DATA_HASACTIVEHOVER)){element.data(DATA_FORCEDOPEN,false);if(!disableDelay){session.delayInProgress=true;session.closeDelayTimeout=setTimeout(function closeDelay(){session.closeDelayTimeout=null;tipController.hideTip(element);session.delayInProgress=false;myCloseDelay=null},options.closeDelay);myCloseDelay=session.closeDelayTimeout}else{tipController.hideTip(element)}}}function checkForIntent(){var xDifference=Math.abs(session.previousX-session.currentX),yDifference=Math.abs(session.previousY-session.currentY),totalDifference=xDifference+yDifference;if(totalDifference",{id:options.popupId});if($body.length===0){$body=$("body")}$body.append(tipElement);session.tooltips=session.tooltips?session.tooltips.add(tipElement):tipElement}if(options.followMouse){if(!tipElement.data(DATA_HASMOUSEMOVE)){$document.on("mousemove"+EVENT_NAMESPACE,positionTipOnCursor);$window.on("scroll"+EVENT_NAMESPACE,positionTipOnCursor);tipElement.data(DATA_HASMOUSEMOVE,true)}}function beginShowTip(element){element.data(DATA_HASACTIVEHOVER,true);tipElement.queue(function queueTipInit(next){showTip(element);next()})}function showTip(element){var tipContent;if(!element.data(DATA_HASACTIVEHOVER)){return}if(session.isTipOpen){if(!session.isClosing){hideTip(session.activeHover)}tipElement.delay(100).queue(function queueTipAgain(next){showTip(element);next()});return}element.trigger("powerTipPreRender");tipContent=getTooltipContent(element);if(tipContent){tipElement.empty().append(tipContent)}else{return}element.trigger("powerTipRender");session.activeHover=element;session.isTipOpen=true;tipElement.data(DATA_MOUSEONTOTIP,options.mouseOnToPopup);tipElement.addClass(options.popupClass);if(!options.followMouse||element.data(DATA_FORCEDOPEN)){positionTipOnElement(element);session.isFixedTipOpen=true}else{positionTipOnCursor()}if(!element.data(DATA_FORCEDOPEN)&&!options.followMouse){$document.on("click"+EVENT_NAMESPACE,function documentClick(event){var target=event.target;if(target!==element[0]){if(options.mouseOnToPopup){if(target!==tipElement[0]&&!$.contains(tipElement[0],target)){$.powerTip.hide()}}else{$.powerTip.hide()}}})}if(options.mouseOnToPopup&&!options.manual){tipElement.on("mouseenter"+EVENT_NAMESPACE,function tipMouseEnter(){if(session.activeHover){session.activeHover.data(DATA_DISPLAYCONTROLLER).cancel()}});tipElement.on("mouseleave"+EVENT_NAMESPACE,function tipMouseLeave(){if(session.activeHover){session.activeHover.data(DATA_DISPLAYCONTROLLER).hide()}})}tipElement.fadeIn(options.fadeInTime,function fadeInCallback(){if(!session.desyncTimeout){session.desyncTimeout=setInterval(closeDesyncedTip,500)}element.trigger("powerTipOpen")})}function hideTip(element){session.isClosing=true;session.isTipOpen=false;session.desyncTimeout=clearInterval(session.desyncTimeout);element.data(DATA_HASACTIVEHOVER,false);element.data(DATA_FORCEDOPEN,false);$document.off("click"+EVENT_NAMESPACE);tipElement.off(EVENT_NAMESPACE);tipElement.fadeOut(options.fadeOutTime,function fadeOutCallback(){var coords=new CSSCoordinates;session.activeHover=null;session.isClosing=false;session.isFixedTipOpen=false;tipElement.removeClass();coords.set("top",session.currentY+options.offset);coords.set("left",session.currentX+options.offset);tipElement.css(coords);element.trigger("powerTipClose")})}function positionTipOnCursor(){var tipWidth,tipHeight,coords,collisions,collisionCount;if(!session.isFixedTipOpen&&(session.isTipOpen||session.tipOpenImminent&&tipElement.data(DATA_HASMOUSEMOVE))){tipWidth=tipElement.outerWidth();tipHeight=tipElement.outerHeight();coords=new CSSCoordinates;coords.set("top",session.currentY+options.offset);coords.set("left",session.currentX+options.offset);collisions=getViewportCollisions(coords,tipWidth,tipHeight);if(collisions!==Collision.none){collisionCount=countFlags(collisions);if(collisionCount===1){if(collisions===Collision.right){coords.set("left",session.scrollLeft+session.windowWidth-tipWidth)}else if(collisions===Collision.bottom){coords.set("top",session.scrollTop+session.windowHeight-tipHeight)}}else{coords.set("left",session.currentX-tipWidth-options.offset);coords.set("top",session.currentY-tipHeight-options.offset)}}tipElement.css(coords)}}function positionTipOnElement(element){var priorityList,finalPlacement;if(options.smartPlacement||options.followMouse&&element.data(DATA_FORCEDOPEN)){priorityList=$.fn.powerTip.smartPlacementLists[options.placement];$.each(priorityList,function(idx,pos){var collisions=getViewportCollisions(placeTooltip(element,pos),tipElement.outerWidth(),tipElement.outerHeight());finalPlacement=pos;return collisions!==Collision.none})}else{placeTooltip(element,options.placement);finalPlacement=options.placement}tipElement.removeClass("w nw sw e ne se n s w se-alt sw-alt ne-alt nw-alt");tipElement.addClass(finalPlacement)}function placeTooltip(element,placement){var iterationCount=0,tipWidth,tipHeight,coords=new CSSCoordinates;coords.set("top",0);coords.set("left",0);tipElement.css(coords);do{tipWidth=tipElement.outerWidth();tipHeight=tipElement.outerHeight();coords=placementCalculator.compute(element,placement,tipWidth,tipHeight,options.offset);tipElement.css(coords)}while(++iterationCount<=5&&(tipWidth!==tipElement.outerWidth()||tipHeight!==tipElement.outerHeight()));return coords}function closeDesyncedTip(){var isDesynced=false,hasDesyncableCloseEvent=$.grep(["mouseleave","mouseout","blur","focusout"],function(eventType){return $.inArray(eventType,options.closeEvents)!==-1}).length>0;if(session.isTipOpen&&!session.isClosing&&!session.delayInProgress&&hasDesyncableCloseEvent){if(session.activeHover.data(DATA_HASACTIVEHOVER)===false||session.activeHover.is(":disabled")){isDesynced=true}else if(!isMouseOver(session.activeHover)&&!session.activeHover.is(":focus")&&!session.activeHover.data(DATA_FORCEDOPEN)){if(tipElement.data(DATA_MOUSEONTOTIP)){if(!isMouseOver(tipElement)){isDesynced=true}}else{isDesynced=true}}if(isDesynced){hideTip(session.activeHover)}}}this.showTip=beginShowTip;this.hideTip=hideTip;this.resetPosition=positionTipOnElement}function isSvgElement(element){return Boolean(window.SVGElement&&element[0]instanceof SVGElement)}function isMouseEvent(event){return Boolean(event&&$.inArray(event.type,MOUSE_EVENTS)>-1&&typeof event.pageX==="number")}function initTracking(){if(!session.mouseTrackingActive){session.mouseTrackingActive=true;getViewportDimensions();$(getViewportDimensions);$document.on("mousemove"+EVENT_NAMESPACE,trackMouse);$window.on("resize"+EVENT_NAMESPACE,trackResize);$window.on("scroll"+EVENT_NAMESPACE,trackScroll)}}function getViewportDimensions(){session.scrollLeft=$window.scrollLeft();session.scrollTop=$window.scrollTop();session.windowWidth=$window.width();session.windowHeight=$window.height()}function trackResize(){session.windowWidth=$window.width();session.windowHeight=$window.height()}function trackScroll(){var x=$window.scrollLeft(),y=$window.scrollTop();if(x!==session.scrollLeft){session.currentX+=x-session.scrollLeft;session.scrollLeft=x}if(y!==session.scrollTop){session.currentY+=y-session.scrollTop;session.scrollTop=y}}function trackMouse(event){session.currentX=event.pageX;session.currentY=event.pageY}function isMouseOver(element){var elementPosition=element.offset(),elementBox=element[0].getBoundingClientRect(),elementWidth=elementBox.right-elementBox.left,elementHeight=elementBox.bottom-elementBox.top;return session.currentX>=elementPosition.left&&session.currentX<=elementPosition.left+elementWidth&&session.currentY>=elementPosition.top&&session.currentY<=elementPosition.top+elementHeight}function getTooltipContent(element){var tipText=element.data(DATA_POWERTIP),tipObject=element.data(DATA_POWERTIPJQ),tipTarget=element.data(DATA_POWERTIPTARGET),targetElement,content;if(tipText){if($.isFunction(tipText)){tipText=tipText.call(element[0])}content=tipText}else if(tipObject){if($.isFunction(tipObject)){tipObject=tipObject.call(element[0])}if(tipObject.length>0){content=tipObject.clone(true,true)}}else if(tipTarget){targetElement=$("#"+tipTarget);if(targetElement.length>0){content=targetElement.html()}}return content}function getViewportCollisions(coords,elementWidth,elementHeight){var viewportTop=session.scrollTop,viewportLeft=session.scrollLeft,viewportBottom=viewportTop+session.windowHeight,viewportRight=viewportLeft+session.windowWidth,collisions=Collision.none;if(coords.topviewportBottom||Math.abs(coords.bottom-session.windowHeight)>viewportBottom){collisions|=Collision.bottom}if(coords.leftviewportRight){collisions|=Collision.left}if(coords.left+elementWidth>viewportRight||coords.right1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);/*! SmartMenus jQuery Plugin - v1.1.0 - September 17, 2017 + * http://www.smartmenus.org/ + * Copyright Vasil Dinkov, Vadikom Web Ltd. http://vadikom.com; Licensed MIT */(function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&"object"==typeof module.exports?module.exports=t(require("jquery")):t(jQuery)})(function($){function initMouseDetection(t){var e=".smartmenus_mouse";if(mouseDetectionEnabled||t)mouseDetectionEnabled&&t&&($(document).off(e),mouseDetectionEnabled=!1);else{var i=!0,s=null,o={mousemove:function(t){var e={x:t.pageX,y:t.pageY,timeStamp:(new Date).getTime()};if(s){var o=Math.abs(s.x-e.x),a=Math.abs(s.y-e.y);if((o>0||a>0)&&2>=o&&2>=a&&300>=e.timeStamp-s.timeStamp&&(mouse=!0,i)){var n=$(t.target).closest("a");n.is("a")&&$.each(menuTrees,function(){return $.contains(this.$root[0],n[0])?(this.itemEnter({currentTarget:n[0]}),!1):void 0}),i=!1}}s=e}};o[touchEvents?"touchstart":"pointerover pointermove pointerout MSPointerOver MSPointerMove MSPointerOut"]=function(t){isTouchEvent(t.originalEvent)&&(mouse=!1)},$(document).on(getEventsNS(o,e)),mouseDetectionEnabled=!0}}function isTouchEvent(t){return!/^(4|mouse)$/.test(t.pointerType)}function getEventsNS(t,e){e||(e="");var i={};for(var s in t)i[s.split(" ").join(e+" ")+e]=t[s];return i}var menuTrees=[],mouse=!1,touchEvents="ontouchstart"in window,mouseDetectionEnabled=!1,requestAnimationFrame=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},cancelAnimationFrame=window.cancelAnimationFrame||function(t){clearTimeout(t)},canAnimate=!!$.fn.animate;return $.SmartMenus=function(t,e){this.$root=$(t),this.opts=e,this.rootId="",this.accessIdPrefix="",this.$subArrow=null,this.activatedItems=[],this.visibleSubMenus=[],this.showTimeout=0,this.hideTimeout=0,this.scrollTimeout=0,this.clickActivated=!1,this.focusActivated=!1,this.zIndexInc=0,this.idInc=0,this.$firstLink=null,this.$firstSub=null,this.disabled=!1,this.$disableOverlay=null,this.$touchScrollingSub=null,this.cssTransforms3d="perspective"in t.style||"webkitPerspective"in t.style,this.wasCollapsible=!1,this.init()},$.extend($.SmartMenus,{hideAll:function(){$.each(menuTrees,function(){this.menuHideAll()})},destroy:function(){for(;menuTrees.length;)menuTrees[0].destroy();initMouseDetection(!0)},prototype:{init:function(t){var e=this;if(!t){menuTrees.push(this),this.rootId=((new Date).getTime()+Math.random()+"").replace(/\D/g,""),this.accessIdPrefix="sm-"+this.rootId+"-",this.$root.hasClass("sm-rtl")&&(this.opts.rightToLeftSubMenus=!0);var i=".smartmenus";this.$root.data("smartmenus",this).attr("data-smartmenus-id",this.rootId).dataSM("level",1).on(getEventsNS({"mouseover focusin":$.proxy(this.rootOver,this),"mouseout focusout":$.proxy(this.rootOut,this),keydown:$.proxy(this.rootKeyDown,this)},i)).on(getEventsNS({mouseenter:$.proxy(this.itemEnter,this),mouseleave:$.proxy(this.itemLeave,this),mousedown:$.proxy(this.itemDown,this),focus:$.proxy(this.itemFocus,this),blur:$.proxy(this.itemBlur,this),click:$.proxy(this.itemClick,this)},i),"a"),i+=this.rootId,this.opts.hideOnClick&&$(document).on(getEventsNS({touchstart:$.proxy(this.docTouchStart,this),touchmove:$.proxy(this.docTouchMove,this),touchend:$.proxy(this.docTouchEnd,this),click:$.proxy(this.docClick,this)},i)),$(window).on(getEventsNS({"resize orientationchange":$.proxy(this.winResize,this)},i)),this.opts.subIndicators&&(this.$subArrow=$("").addClass("sub-arrow"),this.opts.subIndicatorsText&&this.$subArrow.html(this.opts.subIndicatorsText)),initMouseDetection()}if(this.$firstSub=this.$root.find("ul").each(function(){e.menuInit($(this))}).eq(0),this.$firstLink=this.$root.find("a").eq(0),this.opts.markCurrentItem){var s=/(index|default)\.[^#\?\/]*/i,o=/#.*/,a=window.location.href.replace(s,""),n=a.replace(o,"");this.$root.find("a").each(function(){var t=this.href.replace(s,""),i=$(this);(t==a||t==n)&&(i.addClass("current"),e.opts.markCurrentTree&&i.parentsUntil("[data-smartmenus-id]","ul").each(function(){$(this).dataSM("parent-a").addClass("current")}))})}this.wasCollapsible=this.isCollapsible()},destroy:function(t){if(!t){var e=".smartmenus";this.$root.removeData("smartmenus").removeAttr("data-smartmenus-id").removeDataSM("level").off(e),e+=this.rootId,$(document).off(e),$(window).off(e),this.opts.subIndicators&&(this.$subArrow=null)}this.menuHideAll();var i=this;this.$root.find("ul").each(function(){var t=$(this);t.dataSM("scroll-arrows")&&t.dataSM("scroll-arrows").remove(),t.dataSM("shown-before")&&((i.opts.subMenusMinWidth||i.opts.subMenusMaxWidth)&&t.css({width:"",minWidth:"",maxWidth:""}).removeClass("sm-nowrap"),t.dataSM("scroll-arrows")&&t.dataSM("scroll-arrows").remove(),t.css({zIndex:"",top:"",left:"",marginLeft:"",marginTop:"",display:""})),0==(t.attr("id")||"").indexOf(i.accessIdPrefix)&&t.removeAttr("id")}).removeDataSM("in-mega").removeDataSM("shown-before").removeDataSM("scroll-arrows").removeDataSM("parent-a").removeDataSM("level").removeDataSM("beforefirstshowfired").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeAttr("aria-expanded"),this.$root.find("a.has-submenu").each(function(){var t=$(this);0==t.attr("id").indexOf(i.accessIdPrefix)&&t.removeAttr("id")}).removeClass("has-submenu").removeDataSM("sub").removeAttr("aria-haspopup").removeAttr("aria-controls").removeAttr("aria-expanded").closest("li").removeDataSM("sub"),this.opts.subIndicators&&this.$root.find("span.sub-arrow").remove(),this.opts.markCurrentItem&&this.$root.find("a.current").removeClass("current"),t||(this.$root=null,this.$firstLink=null,this.$firstSub=null,this.$disableOverlay&&(this.$disableOverlay.remove(),this.$disableOverlay=null),menuTrees.splice($.inArray(this,menuTrees),1))},disable:function(t){if(!this.disabled){if(this.menuHideAll(),!t&&!this.opts.isPopup&&this.$root.is(":visible")){var e=this.$root.offset();this.$disableOverlay=$('
').css({position:"absolute",top:e.top,left:e.left,width:this.$root.outerWidth(),height:this.$root.outerHeight(),zIndex:this.getStartZIndex(!0),opacity:0}).appendTo(document.body)}this.disabled=!0}},docClick:function(t){return this.$touchScrollingSub?(this.$touchScrollingSub=null,void 0):((this.visibleSubMenus.length&&!$.contains(this.$root[0],t.target)||$(t.target).closest("a").length)&&this.menuHideAll(),void 0)},docTouchEnd:function(){if(this.lastTouch){if(!(!this.visibleSubMenus.length||void 0!==this.lastTouch.x2&&this.lastTouch.x1!=this.lastTouch.x2||void 0!==this.lastTouch.y2&&this.lastTouch.y1!=this.lastTouch.y2||this.lastTouch.target&&$.contains(this.$root[0],this.lastTouch.target))){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0);var t=this;this.hideTimeout=setTimeout(function(){t.menuHideAll()},350)}this.lastTouch=null}},docTouchMove:function(t){if(this.lastTouch){var e=t.originalEvent.touches[0];this.lastTouch.x2=e.pageX,this.lastTouch.y2=e.pageY}},docTouchStart:function(t){var e=t.originalEvent.touches[0];this.lastTouch={x1:e.pageX,y1:e.pageY,target:e.target}},enable:function(){this.disabled&&(this.$disableOverlay&&(this.$disableOverlay.remove(),this.$disableOverlay=null),this.disabled=!1)},getClosestMenu:function(t){for(var e=$(t).closest("ul");e.dataSM("in-mega");)e=e.parent().closest("ul");return e[0]||null},getHeight:function(t){return this.getOffset(t,!0)},getOffset:function(t,e){var i;"none"==t.css("display")&&(i={position:t[0].style.position,visibility:t[0].style.visibility},t.css({position:"absolute",visibility:"hidden"}).show());var s=t[0].getBoundingClientRect&&t[0].getBoundingClientRect(),o=s&&(e?s.height||s.bottom-s.top:s.width||s.right-s.left);return o||0===o||(o=e?t[0].offsetHeight:t[0].offsetWidth),i&&t.hide().css(i),o},getStartZIndex:function(t){var e=parseInt(this[t?"$root":"$firstSub"].css("z-index"));return!t&&isNaN(e)&&(e=parseInt(this.$root.css("z-index"))),isNaN(e)?1:e},getTouchPoint:function(t){return t.touches&&t.touches[0]||t.changedTouches&&t.changedTouches[0]||t},getViewport:function(t){var e=t?"Height":"Width",i=document.documentElement["client"+e],s=window["inner"+e];return s&&(i=Math.min(i,s)),i},getViewportHeight:function(){return this.getViewport(!0)},getViewportWidth:function(){return this.getViewport()},getWidth:function(t){return this.getOffset(t)},handleEvents:function(){return!this.disabled&&this.isCSSOn()},handleItemEvents:function(t){return this.handleEvents()&&!this.isLinkInMegaMenu(t)},isCollapsible:function(){return"static"==this.$firstSub.css("position")},isCSSOn:function(){return"inline"!=this.$firstLink.css("display")},isFixed:function(){var t="fixed"==this.$root.css("position");return t||this.$root.parentsUntil("body").each(function(){return"fixed"==$(this).css("position")?(t=!0,!1):void 0}),t},isLinkInMegaMenu:function(t){return $(this.getClosestMenu(t[0])).hasClass("mega-menu")},isTouchMode:function(){return!mouse||this.opts.noMouseOver||this.isCollapsible()},itemActivate:function(t,e){var i=t.closest("ul"),s=i.dataSM("level");if(s>1&&(!this.activatedItems[s-2]||this.activatedItems[s-2][0]!=i.dataSM("parent-a")[0])){var o=this;$(i.parentsUntil("[data-smartmenus-id]","ul").get().reverse()).add(i).each(function(){o.itemActivate($(this).dataSM("parent-a"))})}if((!this.isCollapsible()||e)&&this.menuHideSubMenus(this.activatedItems[s-1]&&this.activatedItems[s-1][0]==t[0]?s:s-1),this.activatedItems[s-1]=t,this.$root.triggerHandler("activate.smapi",t[0])!==!1){var a=t.dataSM("sub");a&&(this.isTouchMode()||!this.opts.showOnClick||this.clickActivated)&&this.menuShow(a)}},itemBlur:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&this.$root.triggerHandler("blur.smapi",e[0])},itemClick:function(t){var e=$(t.currentTarget);if(this.handleItemEvents(e)){if(this.$touchScrollingSub&&this.$touchScrollingSub[0]==e.closest("ul")[0])return this.$touchScrollingSub=null,t.stopPropagation(),!1;if(this.$root.triggerHandler("click.smapi",e[0])===!1)return!1;var i=$(t.target).is(".sub-arrow"),s=e.dataSM("sub"),o=s?2==s.dataSM("level"):!1,a=this.isCollapsible(),n=/toggle$/.test(this.opts.collapsibleBehavior),r=/link$/.test(this.opts.collapsibleBehavior),h=/^accordion/.test(this.opts.collapsibleBehavior);if(s&&!s.is(":visible")){if((!r||!a||i)&&(this.opts.showOnClick&&o&&(this.clickActivated=!0),this.itemActivate(e,h),s.is(":visible")))return this.focusActivated=!0,!1}else if(a&&(n||i))return this.itemActivate(e,h),this.menuHide(s),n&&(this.focusActivated=!1),!1;return this.opts.showOnClick&&o||e.hasClass("disabled")||this.$root.triggerHandler("select.smapi",e[0])===!1?!1:void 0}},itemDown:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&e.dataSM("mousedown",!0)},itemEnter:function(t){var e=$(t.currentTarget);if(this.handleItemEvents(e)){if(!this.isTouchMode()){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0);var i=this;this.showTimeout=setTimeout(function(){i.itemActivate(e)},this.opts.showOnClick&&1==e.closest("ul").dataSM("level")?1:this.opts.showTimeout)}this.$root.triggerHandler("mouseenter.smapi",e[0])}},itemFocus:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&(!this.focusActivated||this.isTouchMode()&&e.dataSM("mousedown")||this.activatedItems.length&&this.activatedItems[this.activatedItems.length-1][0]==e[0]||this.itemActivate(e,!0),this.$root.triggerHandler("focus.smapi",e[0]))},itemLeave:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&(this.isTouchMode()||(e[0].blur(),this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0)),e.removeDataSM("mousedown"),this.$root.triggerHandler("mouseleave.smapi",e[0]))},menuHide:function(t){if(this.$root.triggerHandler("beforehide.smapi",t[0])!==!1&&(canAnimate&&t.stop(!0,!0),"none"!=t.css("display"))){var e=function(){t.css("z-index","")};this.isCollapsible()?canAnimate&&this.opts.collapsibleHideFunction?this.opts.collapsibleHideFunction.call(this,t,e):t.hide(this.opts.collapsibleHideDuration,e):canAnimate&&this.opts.hideFunction?this.opts.hideFunction.call(this,t,e):t.hide(this.opts.hideDuration,e),t.dataSM("scroll")&&(this.menuScrollStop(t),t.css({"touch-action":"","-ms-touch-action":"","-webkit-transform":"",transform:""}).off(".smartmenus_scroll").removeDataSM("scroll").dataSM("scroll-arrows").hide()),t.dataSM("parent-a").removeClass("highlighted").attr("aria-expanded","false"),t.attr({"aria-expanded":"false","aria-hidden":"true"});var i=t.dataSM("level");this.activatedItems.splice(i-1,1),this.visibleSubMenus.splice($.inArray(t,this.visibleSubMenus),1),this.$root.triggerHandler("hide.smapi",t[0])}},menuHideAll:function(){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0);for(var t=this.opts.isPopup?1:0,e=this.visibleSubMenus.length-1;e>=t;e--)this.menuHide(this.visibleSubMenus[e]);this.opts.isPopup&&(canAnimate&&this.$root.stop(!0,!0),this.$root.is(":visible")&&(canAnimate&&this.opts.hideFunction?this.opts.hideFunction.call(this,this.$root):this.$root.hide(this.opts.hideDuration))),this.activatedItems=[],this.visibleSubMenus=[],this.clickActivated=!1,this.focusActivated=!1,this.zIndexInc=0,this.$root.triggerHandler("hideAll.smapi")},menuHideSubMenus:function(t){for(var e=this.activatedItems.length-1;e>=t;e--){var i=this.activatedItems[e].dataSM("sub");i&&this.menuHide(i)}},menuInit:function(t){if(!t.dataSM("in-mega")){t.hasClass("mega-menu")&&t.find("ul").dataSM("in-mega",!0);for(var e=2,i=t[0];(i=i.parentNode.parentNode)!=this.$root[0];)e++;var s=t.prevAll("a").eq(-1);s.length||(s=t.prevAll().find("a").eq(-1)),s.addClass("has-submenu").dataSM("sub",t),t.dataSM("parent-a",s).dataSM("level",e).parent().dataSM("sub",t);var o=s.attr("id")||this.accessIdPrefix+ ++this.idInc,a=t.attr("id")||this.accessIdPrefix+ ++this.idInc;s.attr({id:o,"aria-haspopup":"true","aria-controls":a,"aria-expanded":"false"}),t.attr({id:a,role:"group","aria-hidden":"true","aria-labelledby":o,"aria-expanded":"false"}),this.opts.subIndicators&&s[this.opts.subIndicatorsPos](this.$subArrow.clone())}},menuPosition:function(t){var e,i,s=t.dataSM("parent-a"),o=s.closest("li"),a=o.parent(),n=t.dataSM("level"),r=this.getWidth(t),h=this.getHeight(t),u=s.offset(),l=u.left,c=u.top,d=this.getWidth(s),m=this.getHeight(s),p=$(window),f=p.scrollLeft(),v=p.scrollTop(),b=this.getViewportWidth(),S=this.getViewportHeight(),g=a.parent().is("[data-sm-horizontal-sub]")||2==n&&!a.hasClass("sm-vertical"),M=this.opts.rightToLeftSubMenus&&!o.is("[data-sm-reverse]")||!this.opts.rightToLeftSubMenus&&o.is("[data-sm-reverse]"),w=2==n?this.opts.mainMenuSubOffsetX:this.opts.subMenusSubOffsetX,T=2==n?this.opts.mainMenuSubOffsetY:this.opts.subMenusSubOffsetY;if(g?(e=M?d-r-w:w,i=this.opts.bottomToTopSubMenus?-h-T:m+T):(e=M?w-r:d-w,i=this.opts.bottomToTopSubMenus?m-T-h:T),this.opts.keepInViewport){var y=l+e,I=c+i;if(M&&f>y?e=g?f-y+e:d-w:!M&&y+r>f+b&&(e=g?f+b-r-y+e:w-r),g||(S>h&&I+h>v+S?i+=v+S-h-I:(h>=S||v>I)&&(i+=v-I)),g&&(I+h>v+S+.49||v>I)||!g&&h>S+.49){var x=this;t.dataSM("scroll-arrows")||t.dataSM("scroll-arrows",$([$('')[0],$('')[0]]).on({mouseenter:function(){t.dataSM("scroll").up=$(this).hasClass("scroll-up"),x.menuScroll(t)},mouseleave:function(e){x.menuScrollStop(t),x.menuScrollOut(t,e)},"mousewheel DOMMouseScroll":function(t){t.preventDefault()}}).insertAfter(t));var A=".smartmenus_scroll";if(t.dataSM("scroll",{y:this.cssTransforms3d?0:i-m,step:1,itemH:m,subH:h,arrowDownH:this.getHeight(t.dataSM("scroll-arrows").eq(1))}).on(getEventsNS({mouseover:function(e){x.menuScrollOver(t,e)},mouseout:function(e){x.menuScrollOut(t,e)},"mousewheel DOMMouseScroll":function(e){x.menuScrollMousewheel(t,e)}},A)).dataSM("scroll-arrows").css({top:"auto",left:"0",marginLeft:e+(parseInt(t.css("border-left-width"))||0),width:r-(parseInt(t.css("border-left-width"))||0)-(parseInt(t.css("border-right-width"))||0),zIndex:t.css("z-index")}).eq(g&&this.opts.bottomToTopSubMenus?0:1).show(),this.isFixed()){var C={};C[touchEvents?"touchstart touchmove touchend":"pointerdown pointermove pointerup MSPointerDown MSPointerMove MSPointerUp"]=function(e){x.menuScrollTouch(t,e)},t.css({"touch-action":"none","-ms-touch-action":"none"}).on(getEventsNS(C,A))}}}t.css({top:"auto",left:"0",marginLeft:e,marginTop:i-m})},menuScroll:function(t,e,i){var s,o=t.dataSM("scroll"),a=t.dataSM("scroll-arrows"),n=o.up?o.upEnd:o.downEnd;if(!e&&o.momentum){if(o.momentum*=.92,s=o.momentum,.5>s)return this.menuScrollStop(t),void 0}else s=i||(e||!this.opts.scrollAccelerate?this.opts.scrollStep:Math.floor(o.step));var r=t.dataSM("level");if(this.activatedItems[r-1]&&this.activatedItems[r-1].dataSM("sub")&&this.activatedItems[r-1].dataSM("sub").is(":visible")&&this.menuHideSubMenus(r-1),o.y=o.up&&o.y>=n||!o.up&&n>=o.y?o.y:Math.abs(n-o.y)>s?o.y+(o.up?s:-s):n,t.css(this.cssTransforms3d?{"-webkit-transform":"translate3d(0, "+o.y+"px, 0)",transform:"translate3d(0, "+o.y+"px, 0)"}:{marginTop:o.y}),mouse&&(o.up&&o.y>o.downEnd||!o.up&&o.y0;t.dataSM("scroll-arrows").eq(i?0:1).is(":visible")&&(t.dataSM("scroll").up=i,this.menuScroll(t,!0))}e.preventDefault()},menuScrollOut:function(t,e){mouse&&(/^scroll-(up|down)/.test((e.relatedTarget||"").className)||(t[0]==e.relatedTarget||$.contains(t[0],e.relatedTarget))&&this.getClosestMenu(e.relatedTarget)==t[0]||t.dataSM("scroll-arrows").css("visibility","hidden"))},menuScrollOver:function(t,e){if(mouse&&!/^scroll-(up|down)/.test(e.target.className)&&this.getClosestMenu(e.target)==t[0]){this.menuScrollRefreshData(t);var i=t.dataSM("scroll"),s=$(window).scrollTop()-t.dataSM("parent-a").offset().top-i.itemH;t.dataSM("scroll-arrows").eq(0).css("margin-top",s).end().eq(1).css("margin-top",s+this.getViewportHeight()-i.arrowDownH).end().css("visibility","visible")}},menuScrollRefreshData:function(t){var e=t.dataSM("scroll"),i=$(window).scrollTop()-t.dataSM("parent-a").offset().top-e.itemH;this.cssTransforms3d&&(i=-(parseFloat(t.css("margin-top"))-i)),$.extend(e,{upEnd:i,downEnd:i+this.getViewportHeight()-e.subH})},menuScrollStop:function(t){return this.scrollTimeout?(cancelAnimationFrame(this.scrollTimeout),this.scrollTimeout=0,t.dataSM("scroll").step=1,!0):void 0},menuScrollTouch:function(t,e){if(e=e.originalEvent,isTouchEvent(e)){var i=this.getTouchPoint(e);if(this.getClosestMenu(i.target)==t[0]){var s=t.dataSM("scroll");if(/(start|down)$/i.test(e.type))this.menuScrollStop(t)?(e.preventDefault(),this.$touchScrollingSub=t):this.$touchScrollingSub=null,this.menuScrollRefreshData(t),$.extend(s,{touchStartY:i.pageY,touchStartTime:e.timeStamp});else if(/move$/i.test(e.type)){var o=void 0!==s.touchY?s.touchY:s.touchStartY;if(void 0!==o&&o!=i.pageY){this.$touchScrollingSub=t;var a=i.pageY>o;void 0!==s.up&&s.up!=a&&$.extend(s,{touchStartY:i.pageY,touchStartTime:e.timeStamp}),$.extend(s,{up:a,touchY:i.pageY}),this.menuScroll(t,!0,Math.abs(i.pageY-o))}e.preventDefault()}else void 0!==s.touchY&&((s.momentum=15*Math.pow(Math.abs(i.pageY-s.touchStartY)/(e.timeStamp-s.touchStartTime),2))&&(this.menuScrollStop(t),this.menuScroll(t),e.preventDefault()),delete s.touchY)}}},menuShow:function(t){if((t.dataSM("beforefirstshowfired")||(t.dataSM("beforefirstshowfired",!0),this.$root.triggerHandler("beforefirstshow.smapi",t[0])!==!1))&&this.$root.triggerHandler("beforeshow.smapi",t[0])!==!1&&(t.dataSM("shown-before",!0),canAnimate&&t.stop(!0,!0),!t.is(":visible"))){var e=t.dataSM("parent-a"),i=this.isCollapsible();if((this.opts.keepHighlighted||i)&&e.addClass("highlighted"),i)t.removeClass("sm-nowrap").css({zIndex:"",width:"auto",minWidth:"",maxWidth:"",top:"",left:"",marginLeft:"",marginTop:""});else{if(t.css("z-index",this.zIndexInc=(this.zIndexInc||this.getStartZIndex())+1),(this.opts.subMenusMinWidth||this.opts.subMenusMaxWidth)&&(t.css({width:"auto",minWidth:"",maxWidth:""}).addClass("sm-nowrap"),this.opts.subMenusMinWidth&&t.css("min-width",this.opts.subMenusMinWidth),this.opts.subMenusMaxWidth)){var s=this.getWidth(t);t.css("max-width",this.opts.subMenusMaxWidth),s>this.getWidth(t)&&t.removeClass("sm-nowrap").css("width",this.opts.subMenusMaxWidth)}this.menuPosition(t)}var o=function(){t.css("overflow","")};i?canAnimate&&this.opts.collapsibleShowFunction?this.opts.collapsibleShowFunction.call(this,t,o):t.show(this.opts.collapsibleShowDuration,o):canAnimate&&this.opts.showFunction?this.opts.showFunction.call(this,t,o):t.show(this.opts.showDuration,o),e.attr("aria-expanded","true"),t.attr({"aria-expanded":"true","aria-hidden":"false"}),this.visibleSubMenus.push(t),this.$root.triggerHandler("show.smapi",t[0])}},popupHide:function(t){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0);var e=this;this.hideTimeout=setTimeout(function(){e.menuHideAll()},t?1:this.opts.hideTimeout)},popupShow:function(t,e){if(!this.opts.isPopup)return alert('SmartMenus jQuery Error:\n\nIf you want to show this menu via the "popupShow" method, set the isPopup:true option.'),void 0;if(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0),this.$root.dataSM("shown-before",!0),canAnimate&&this.$root.stop(!0,!0),!this.$root.is(":visible")){this.$root.css({left:t,top:e});var i=this,s=function(){i.$root.css("overflow","")};canAnimate&&this.opts.showFunction?this.opts.showFunction.call(this,this.$root,s):this.$root.show(this.opts.showDuration,s),this.visibleSubMenus[0]=this.$root}},refresh:function(){this.destroy(!0),this.init(!0)},rootKeyDown:function(t){if(this.handleEvents())switch(t.keyCode){case 27:var e=this.activatedItems[0];if(e){this.menuHideAll(),e[0].focus();var i=e.dataSM("sub");i&&this.menuHide(i)}break;case 32:var s=$(t.target);if(s.is("a")&&this.handleItemEvents(s)){var i=s.dataSM("sub");i&&!i.is(":visible")&&(this.itemClick({currentTarget:t.target}),t.preventDefault())}}},rootOut:function(t){if(this.handleEvents()&&!this.isTouchMode()&&t.target!=this.$root[0]&&(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0),!this.opts.showOnClick||!this.opts.hideOnClick)){var e=this;this.hideTimeout=setTimeout(function(){e.menuHideAll()},this.opts.hideTimeout)}},rootOver:function(t){this.handleEvents()&&!this.isTouchMode()&&t.target!=this.$root[0]&&this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0)},winResize:function(t){if(this.handleEvents()){if(!("onorientationchange"in window)||"orientationchange"==t.type){var e=this.isCollapsible();this.wasCollapsible&&e||(this.activatedItems.length&&this.activatedItems[this.activatedItems.length-1][0].blur(),this.menuHideAll()),this.wasCollapsible=e}}else if(this.$disableOverlay){var i=this.$root.offset();this.$disableOverlay.css({top:i.top,left:i.left,width:this.$root.outerWidth(),height:this.$root.outerHeight()})}}}}),$.fn.dataSM=function(t,e){return e?this.data(t+"_smartmenus",e):this.data(t+"_smartmenus")},$.fn.removeDataSM=function(t){return this.removeData(t+"_smartmenus")},$.fn.smartmenus=function(options){if("string"==typeof options){var args=arguments,method=options;return Array.prototype.shift.call(args),this.each(function(){var t=$(this).data("smartmenus");t&&t[method]&&t[method].apply(t,args)})}return this.each(function(){var dataOpts=$(this).data("sm-options")||null;if(dataOpts)try{dataOpts=eval("("+dataOpts+")")}catch(e){dataOpts=null,alert('ERROR\n\nSmartMenus jQuery init:\nInvalid "data-sm-options" attribute value syntax.')}new $.SmartMenus(this,$.extend({},$.fn.smartmenus.defaults,options,dataOpts))})},$.fn.smartmenus.defaults={isPopup:!1,mainMenuSubOffsetX:0,mainMenuSubOffsetY:0,subMenusSubOffsetX:0,subMenusSubOffsetY:0,subMenusMinWidth:"10em",subMenusMaxWidth:"20em",subIndicators:!0,subIndicatorsPos:"append",subIndicatorsText:"",scrollStep:30,scrollAccelerate:!0,showTimeout:250,hideTimeout:500,showDuration:0,showFunction:null,hideDuration:0,hideFunction:function(t,e){t.fadeOut(200,e)},collapsibleShowDuration:0,collapsibleShowFunction:function(t,e){t.slideDown(200,e)},collapsibleHideDuration:0,collapsibleHideFunction:function(t,e){t.slideUp(200,e)},showOnClick:!1,hideOnClick:!0,noMouseOver:!1,keepInViewport:!0,keepHighlighted:!0,markCurrentItem:!1,markCurrentTree:!0,rightToLeftSubMenus:!1,bottomToTopSubMenus:!1,collapsibleBehavior:"default"},$}); \ No newline at end of file diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/menu.js b/3ano/1semestre/so/practice-exam/src/doc/html/menu.js new file mode 100644 index 0000000..433c15b --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/menu.js @@ -0,0 +1,50 @@ +/* + @licstart The following is the entire license notice for the + JavaScript code in this file. + + Copyright (C) 1997-2017 by Dimitri van Heesch + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + @licend The above is the entire license notice + for the JavaScript code in this file + */ +function initMenu(relPath,searchEnabled,serverSide,searchPage,search) { + function makeTree(data,relPath) { + var result=''; + if ('children' in data) { + result+=''; + } + return result; + } + + $('#main-nav').append(makeTree(menudata,relPath)); + $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu'); + if (searchEnabled) { + if (serverSide) { + $('#main-menu').append('
  • '); + } else { + $('#main-menu').append('
  • '); + } + } + $('#main-menu').smartmenus(); +} +/* @license-end */ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/menudata.js b/3ano/1semestre/so/practice-exam/src/doc/html/menudata.js new file mode 100644 index 0000000..749943c --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/menudata.js @@ -0,0 +1,50 @@ +/* +@licstart The following is the entire license notice for the +JavaScript code in this file. + +Copyright (C) 1997-2019 by Dimitri van Heesch + +This program is free software; you can redistribute it and/or modify +it under the terms of version 2 of the GNU General Public License as published by +the Free Software Foundation + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +@licend The above is the entire license notice +for the JavaScript code in this file +*/ +var menudata={children:[ +{text:"Main Page",url:"index.html"}, +{text:"Modules",url:"modules.html"}, +{text:"Files",url:"files.html",children:[ +{text:"File List",url:"files.html"}, +{text:"Globals",url:"globals.html",children:[ +{text:"All",url:"globals.html",children:[ +{text:"c",url:"globals.html#index_c"}, +{text:"e",url:"globals.html#index_e"}, +{text:"h",url:"globals.html#index_h"}, +{text:"i",url:"globals.html#index_i"}, +{text:"l",url:"globals.html#index_l"}, +{text:"m",url:"globals.html#index_m"}, +{text:"n",url:"globals.html#index_n"}, +{text:"p",url:"globals.html#index_p"}, +{text:"r",url:"globals.html#index_r"}, +{text:"s",url:"globals.html#index_s"}, +{text:"t",url:"globals.html#index_t"}]}, +{text:"Functions",url:"globals_func.html",children:[ +{text:"c",url:"globals_func.html#index_c"}, +{text:"h",url:"globals_func.html#index_h"}, +{text:"i",url:"globals_func.html#index_i"}, +{text:"m",url:"globals_func.html#index_m"}, +{text:"p",url:"globals_func.html#index_p"}, +{text:"r",url:"globals_func.html#index_r"}, +{text:"s",url:"globals_func.html#index_s"}, +{text:"t",url:"globals_func.html#index_t"}]}, +{text:"Macros",url:"globals_defs.html"}]}]}]} diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/modules.html b/3ano/1semestre/so/practice-exam/src/doc/html/modules.html new file mode 100644 index 0000000..ffdac9c --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/modules.html @@ -0,0 +1,86 @@ + + + + + + + +C++ Library, mos@ua: Modules + + + + + + + + + + +
    +
    + + + + + + +
    +
    C++ Library, mos@ua +  0.9 +
    +
    cpplib-mos
    +
    +
    + + + + + + +
    +
    + +
    +
    +
    + +
    +
    +
    +
    Modules
    +
    +
    +
    Here is a list of all modules:
    + + + + + +
     DbCDesign-by-Contract module
     processProcess, System-V, and POSIX libraries wrapper module
     threadPOSIX threads library wrapper module
     utilsUseful common functions and macros
    +
    +
    +
    + + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/modules.js b/3ano/1semestre/so/practice-exam/src/doc/html/modules.js new file mode 100644 index 0000000..6341813 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/modules.js @@ -0,0 +1,7 @@ +var modules = +[ + [ "DbC", "group___db_c.html", "group___db_c" ], + [ "process", "group__process.html", "group__process" ], + [ "thread", "group__thread.html", "group__thread" ], + [ "utils", "group__utils.html", "group__utils" ] +]; \ No newline at end of file diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/nav_f.png b/3ano/1semestre/so/practice-exam/src/doc/html/nav_f.png new file mode 100644 index 0000000..72a58a5 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/nav_f.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/nav_g.png b/3ano/1semestre/so/practice-exam/src/doc/html/nav_g.png new file mode 100644 index 0000000..2093a23 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/nav_g.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/nav_h.png b/3ano/1semestre/so/practice-exam/src/doc/html/nav_h.png new file mode 100644 index 0000000..33389b1 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/nav_h.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/navtree.css b/3ano/1semestre/so/practice-exam/src/doc/html/navtree.css new file mode 100644 index 0000000..33341a6 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/navtree.css @@ -0,0 +1,146 @@ +#nav-tree .children_ul { + margin:0; + padding:4px; +} + +#nav-tree ul { + list-style:none outside none; + margin:0px; + padding:0px; +} + +#nav-tree li { + white-space:nowrap; + margin:0px; + padding:0px; +} + +#nav-tree .plus { + margin:0px; +} + +#nav-tree .selected { + background-image: url('tab_a.png'); + background-repeat:repeat-x; + color: #fff; + text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); +} + +#nav-tree img { + margin:0px; + padding:0px; + border:0px; + vertical-align: middle; +} + +#nav-tree a { + text-decoration:none; + padding:0px; + margin:0px; + outline:none; +} + +#nav-tree .label { + margin:0px; + padding:0px; + font: 12px 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; +} + +#nav-tree .label a { + padding:2px; +} + +#nav-tree .selected a { + text-decoration:none; + color:#fff; +} + +#nav-tree .children_ul { + margin:0px; + padding:0px; +} + +#nav-tree .item { + margin:0px; + padding:0px; +} + +#nav-tree { + padding: 0px 0px; + background-color: #FAFAFF; + font-size:14px; + overflow:auto; +} + +#doc-content { + overflow:auto; + display:block; + padding:0px; + margin:0px; + -webkit-overflow-scrolling : touch; /* iOS 5+ */ +} + +#side-nav { + padding:0 6px 0 0; + margin: 0px; + display:block; + position: absolute; + left: 0px; + width: 250px; +} + +.ui-resizable .ui-resizable-handle { + display:block; +} + +.ui-resizable-e { + background-image:url("splitbar.png"); + background-size:100%; + background-repeat:repeat-y; + background-attachment: scroll; + cursor:ew-resize; + height:100%; + right:0; + top:0; + width:6px; +} + +.ui-resizable-handle { + display:none; + font-size:0.1px; + position:absolute; + z-index:1; +} + +#nav-tree-contents { + margin: 6px 0px 0px 0px; +} + +#nav-tree { + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + -webkit-overflow-scrolling : touch; /* iOS 5+ */ +} + +#nav-sync { + position:absolute; + top:5px; + right:24px; + z-index:0; +} + +#nav-sync img { + opacity:0.3; +} + +#nav-sync img:hover { + opacity:0.9; +} + +@media print +{ + #nav-tree { display: none; } + div.ui-resizable-handle { display: none; position: relative; } +} + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/navtree.js b/3ano/1semestre/so/practice-exam/src/doc/html/navtree.js new file mode 100644 index 0000000..edc31ef --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/navtree.js @@ -0,0 +1,544 @@ +/* + @licstart The following is the entire license notice for the + JavaScript code in this file. + + Copyright (C) 1997-2019 by Dimitri van Heesch + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + @licend The above is the entire license notice + for the JavaScript code in this file + */ +var navTreeSubIndices = new Array(); +var arrowDown = '▼'; +var arrowRight = '►'; + +function getData(varName) +{ + var i = varName.lastIndexOf('/'); + var n = i>=0 ? varName.substring(i+1) : varName; + return eval(n.replace(/\-/g,'_')); +} + +function stripPath(uri) +{ + return uri.substring(uri.lastIndexOf('/')+1); +} + +function stripPath2(uri) +{ + var i = uri.lastIndexOf('/'); + var s = uri.substring(i+1); + var m = uri.substring(0,i+1).match(/\/d\w\/d\w\w\/$/); + return m ? uri.substring(i-6) : s; +} + +function hashValue() +{ + return $(location).attr('hash').substring(1).replace(/[^\w\-]/g,''); +} + +function hashUrl() +{ + return '#'+hashValue(); +} + +function pathName() +{ + return $(location).attr('pathname').replace(/[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]/g, ''); +} + +function localStorageSupported() +{ + try { + return 'localStorage' in window && window['localStorage'] !== null && window.localStorage.getItem; + } + catch(e) { + return false; + } +} + +function storeLink(link) +{ + if (!$("#nav-sync").hasClass('sync') && localStorageSupported()) { + window.localStorage.setItem('navpath',link); + } +} + +function deleteLink() +{ + if (localStorageSupported()) { + window.localStorage.setItem('navpath',''); + } +} + +function cachedLink() +{ + if (localStorageSupported()) { + return window.localStorage.getItem('navpath'); + } else { + return ''; + } +} + +function getScript(scriptName,func,show) +{ + var head = document.getElementsByTagName("head")[0]; + var script = document.createElement('script'); + script.id = scriptName; + script.type = 'text/javascript'; + script.onload = func; + script.src = scriptName+'.js'; + head.appendChild(script); +} + +function createIndent(o,domNode,node,level) +{ + var level=-1; + var n = node; + while (n.parentNode) { level++; n=n.parentNode; } + if (node.childrenData) { + var imgNode = document.createElement("span"); + imgNode.className = 'arrow'; + imgNode.style.paddingLeft=(16*level).toString()+'px'; + imgNode.innerHTML=arrowRight; + node.plus_img = imgNode; + node.expandToggle = document.createElement("a"); + node.expandToggle.href = "javascript:void(0)"; + node.expandToggle.onclick = function() { + if (node.expanded) { + $(node.getChildrenUL()).slideUp("fast"); + node.plus_img.innerHTML=arrowRight; + node.expanded = false; + } else { + expandNode(o, node, false, false); + } + } + node.expandToggle.appendChild(imgNode); + domNode.appendChild(node.expandToggle); + } else { + var span = document.createElement("span"); + span.className = 'arrow'; + span.style.width = 16*(level+1)+'px'; + span.innerHTML = ' '; + domNode.appendChild(span); + } +} + +var animationInProgress = false; + +function gotoAnchor(anchor,aname,updateLocation) +{ + var pos, docContent = $('#doc-content'); + var ancParent = $(anchor.parent()); + if (ancParent.hasClass('memItemLeft') || + ancParent.hasClass('memtitle') || + ancParent.hasClass('fieldname') || + ancParent.hasClass('fieldtype') || + ancParent.is(':header')) + { + pos = ancParent.position().top; + } else if (anchor.position()) { + pos = anchor.position().top; + } + if (pos) { + var dist = Math.abs(Math.min( + pos-docContent.offset().top, + docContent[0].scrollHeight- + docContent.height()-docContent.scrollTop())); + animationInProgress=true; + docContent.animate({ + scrollTop: pos + docContent.scrollTop() - docContent.offset().top + },Math.max(50,Math.min(500,dist)),function(){ + if (updateLocation) window.location.href=aname; + animationInProgress=false; + }); + } +} + +function newNode(o, po, text, link, childrenData, lastNode) +{ + var node = new Object(); + node.children = Array(); + node.childrenData = childrenData; + node.depth = po.depth + 1; + node.relpath = po.relpath; + node.isLast = lastNode; + + node.li = document.createElement("li"); + po.getChildrenUL().appendChild(node.li); + node.parentNode = po; + + node.itemDiv = document.createElement("div"); + node.itemDiv.className = "item"; + + node.labelSpan = document.createElement("span"); + node.labelSpan.className = "label"; + + createIndent(o,node.itemDiv,node,0); + node.itemDiv.appendChild(node.labelSpan); + node.li.appendChild(node.itemDiv); + + var a = document.createElement("a"); + node.labelSpan.appendChild(a); + node.label = document.createTextNode(text); + node.expanded = false; + a.appendChild(node.label); + if (link) { + var url; + if (link.substring(0,1)=='^') { + url = link.substring(1); + link = url; + } else { + url = node.relpath+link; + } + a.className = stripPath(link.replace('#',':')); + if (link.indexOf('#')!=-1) { + var aname = '#'+link.split('#')[1]; + var srcPage = stripPath(pathName()); + var targetPage = stripPath(link.split('#')[0]); + a.href = srcPage!=targetPage ? url : "javascript:void(0)"; + a.onclick = function(){ + storeLink(link); + if (!$(a).parent().parent().hasClass('selected')) + { + $('.item').removeClass('selected'); + $('.item').removeAttr('id'); + $(a).parent().parent().addClass('selected'); + $(a).parent().parent().attr('id','selected'); + } + var anchor = $(aname); + gotoAnchor(anchor,aname,true); + }; + } else { + a.href = url; + a.onclick = function() { storeLink(link); } + } + } else { + if (childrenData != null) + { + a.className = "nolink"; + a.href = "javascript:void(0)"; + a.onclick = node.expandToggle.onclick; + } + } + + node.childrenUL = null; + node.getChildrenUL = function() { + if (!node.childrenUL) { + node.childrenUL = document.createElement("ul"); + node.childrenUL.className = "children_ul"; + node.childrenUL.style.display = "none"; + node.li.appendChild(node.childrenUL); + } + return node.childrenUL; + }; + + return node; +} + +function showRoot() +{ + var headerHeight = $("#top").height(); + var footerHeight = $("#nav-path").height(); + var windowHeight = $(window).height() - headerHeight - footerHeight; + (function (){ // retry until we can scroll to the selected item + try { + var navtree=$('#nav-tree'); + navtree.scrollTo('#selected',100,{offset:-windowHeight/2}); + } catch (err) { + setTimeout(arguments.callee, 0); + } + })(); +} + +function expandNode(o, node, imm, showRoot) +{ + if (node.childrenData && !node.expanded) { + if (typeof(node.childrenData)==='string') { + var varName = node.childrenData; + getScript(node.relpath+varName,function(){ + node.childrenData = getData(varName); + expandNode(o, node, imm, showRoot); + }, showRoot); + } else { + if (!node.childrenVisited) { + getNode(o, node); + } + $(node.getChildrenUL()).slideDown("fast"); + node.plus_img.innerHTML = arrowDown; + node.expanded = true; + } + } +} + +function glowEffect(n,duration) +{ + n.addClass('glow').delay(duration).queue(function(next){ + $(this).removeClass('glow');next(); + }); +} + +function highlightAnchor() +{ + var aname = hashUrl(); + var anchor = $(aname); + if (anchor.parent().attr('class')=='memItemLeft'){ + var rows = $('.memberdecls tr[class$="'+hashValue()+'"]'); + glowEffect(rows.children(),300); // member without details + } else if (anchor.parent().attr('class')=='fieldname'){ + glowEffect(anchor.parent().parent(),1000); // enum value + } else if (anchor.parent().attr('class')=='fieldtype'){ + glowEffect(anchor.parent().parent(),1000); // struct field + } else if (anchor.parent().is(":header")) { + glowEffect(anchor.parent(),1000); // section header + } else { + glowEffect(anchor.next(),1000); // normal member + } +} + +function selectAndHighlight(hash,n) +{ + var a; + if (hash) { + var link=stripPath(pathName())+':'+hash.substring(1); + a=$('.item a[class$="'+link+'"]'); + } + if (a && a.length) { + a.parent().parent().addClass('selected'); + a.parent().parent().attr('id','selected'); + highlightAnchor(); + } else if (n) { + $(n.itemDiv).addClass('selected'); + $(n.itemDiv).attr('id','selected'); + } + if ($('#nav-tree-contents .item:first').hasClass('selected')) { + $('#nav-sync').css('top','30px'); + } else { + $('#nav-sync').css('top','5px'); + } + showRoot(); +} + +function showNode(o, node, index, hash) +{ + if (node && node.childrenData) { + if (typeof(node.childrenData)==='string') { + var varName = node.childrenData; + getScript(node.relpath+varName,function(){ + node.childrenData = getData(varName); + showNode(o,node,index,hash); + },true); + } else { + if (!node.childrenVisited) { + getNode(o, node); + } + $(node.getChildrenUL()).css({'display':'block'}); + node.plus_img.innerHTML = arrowDown; + node.expanded = true; + var n = node.children[o.breadcrumbs[index]]; + if (index+11) hash = '#'+parts[1].replace(/[^\w\-]/g,''); + else hash=''; + } + if (hash.match(/^#l\d+$/)) { + var anchor=$('a[name='+hash.substring(1)+']'); + glowEffect(anchor.parent(),1000); // line number + hash=''; // strip line number anchors + } + var url=root+hash; + var i=-1; + while (NAVTREEINDEX[i+1]<=url) i++; + if (i==-1) { i=0; root=NAVTREE[0][1]; } // fallback: show index + if (navTreeSubIndices[i]) { + gotoNode(o,i,root,hash,relpath) + } else { + getScript(relpath+'navtreeindex'+i,function(){ + navTreeSubIndices[i] = eval('NAVTREEINDEX'+i); + if (navTreeSubIndices[i]) { + gotoNode(o,i,root,hash,relpath); + } + },true); + } +} + +function showSyncOff(n,relpath) +{ + n.html(''); +} + +function showSyncOn(n,relpath) +{ + n.html(''); +} + +function toggleSyncButton(relpath) +{ + var navSync = $('#nav-sync'); + if (navSync.hasClass('sync')) { + navSync.removeClass('sync'); + showSyncOff(navSync,relpath); + storeLink(stripPath2(pathName())+hashUrl()); + } else { + navSync.addClass('sync'); + showSyncOn(navSync,relpath); + deleteLink(); + } +} + +var loadTriggered = false; +var readyTriggered = false; +var loadObject,loadToRoot,loadUrl,loadRelPath; + +$(window).on('load',function(){ + if (readyTriggered) { // ready first + navTo(loadObject,loadToRoot,loadUrl,loadRelPath); + showRoot(); + } + loadTriggered=true; +}); + +function initNavTree(toroot,relpath) +{ + var o = new Object(); + o.toroot = toroot; + o.node = new Object(); + o.node.li = document.getElementById("nav-tree-contents"); + o.node.childrenData = NAVTREE; + o.node.children = new Array(); + o.node.childrenUL = document.createElement("ul"); + o.node.getChildrenUL = function() { return o.node.childrenUL; }; + o.node.li.appendChild(o.node.childrenUL); + o.node.depth = 0; + o.node.relpath = relpath; + o.node.expanded = false; + o.node.isLast = true; + o.node.plus_img = document.createElement("span"); + o.node.plus_img.className = 'arrow'; + o.node.plus_img.innerHTML = arrowRight; + + if (localStorageSupported()) { + var navSync = $('#nav-sync'); + if (cachedLink()) { + showSyncOff(navSync,relpath); + navSync.removeClass('sync'); + } else { + showSyncOn(navSync,relpath); + } + navSync.click(function(){ toggleSyncButton(relpath); }); + } + + if (loadTriggered) { // load before ready + navTo(o,toroot,hashUrl(),relpath); + showRoot(); + } else { // ready before load + loadObject = o; + loadToRoot = toroot; + loadUrl = hashUrl(); + loadRelPath = relpath; + readyTriggered=true; + } + + $(window).bind('hashchange', function(){ + if (window.location.hash && window.location.hash.length>1){ + var a; + if ($(location).attr('hash')){ + var clslink=stripPath(pathName())+':'+hashValue(); + a=$('.item a[class$="'+clslink.replace(/ + + + + + + +C++ Library, mos@ua: process.h File Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    C++ Library, mos@ua +  0.9 +
    +
    cpplib-mos
    +
    +
    + + + + + + +
    +
    + +
    +
    +
    + +
    +
    +
    +
    process.h File Reference
    +
    +
    + +

    Process, System-V, and POSIX libraries wrapper module. +More...

    +
    #include <stdio.h>
    +#include <unistd.h>
    +#include <sys/ipc.h>
    +#include <sys/shm.h>
    +#include <sys/sem.h>
    +#include <semaphore.h>
    +#include <signal.h>
    +
    +

    Go to the source code of this file.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Functions

    Process handling

    +
    pid_t pfork (void)
     fork wrapper function. More...
     
    pid_t pwait (int *status)
     wait wrapper function. More...
     
    pid_t pwaitpid (pid_t pid, int *status, int options)
     waitpid wrapper function. More...
     
    void pkill (pid_t pid, int sig)
     kill wrapper function. More...
     
    void pexecl (const char *pathname, const char *arg,...)
     execl wrapper function. More...
     
    void psigaction (int signum, const struct sigaction *act, struct sigaction *oldact)
     sigaction wrapper function. More...
     
    System V - shared memory

    Example
    #include <process.h> // #include <sys/shm.h>
    +
    ...
    +
    int shmid;
    +
    // creation:
    +
    shmid = pshmget(key, size, 0600 | IPC_CREAT | IPC_EXCL);
    +
    // or, use existing:
    +
    shmid = pshmget(key, 0, 0);
    +
    ...
    +
    // attach shm to pointer address:
    +
    void* p = pshmat(shmid, NULL, 0);
    +
    ...
    +
    // detach shm from pointer address:
    +
    pshmdt(p);
    +
    ...
    +
    // destroy shm:
    +
    pshmctl(shmid, IPC_RMID, NULL);
    +
    +
    int pshmget (key_t key, size_t size, int shmflg)
     shmget wrapper function. More...
     
    int pshmctl (int shmid, int cmd, struct shmid_ds *buf)
     shmctl wrapper function. More...
     
    void * pshmat (int shmid, const void *shmaddr, int shmflg)
     shmat wrapper function. More...
     
    void pshmdt (const void *shmaddr)
     shmdt wrapper function. More...
     
    System V - semaphores

    Example
    #include <process.h> // #include <sys/sem.h>
    +
    ...
    +
    int semid;
    +
    // creation:
    +
    semid = psemget(key, 1, 0600 | IPC_CREAT | IPC_EXCL); // 1 semaphore!
    +
    // or, use existing:
    +
    semid = psemget(key, 0, 0);
    +
    ...
    +
    // decrement:
    +
    struct sembuf down = {0, -1, 0};
    +
    psemop(semid, &down, 1);
    +
    // or, simply use provided function:
    +
    psem_down(semid, 0); // NOTE: there is no sem_down in default library!
    +
    ...
    +
    // increment:
    +
    struct sembuf up = {0, 1, 0};
    +
    psemop(semid, &up, 1);
    +
    // or, simply use provided function:
    +
    psem_up(semid, 0); // NOTE: there is no sem_up in default library!
    +
    ...
    +
    // destroy sem 0:
    +
    psemctl(semid, 0, IPC_RMID, NULL);
    +
    +
    int psemget (key_t key, int nsems, int semflg)
     semget wrapper function. More...
     
    int psemctl (int semid, int semnum, int cmd)
     semctl wrapper function. More...
     
    +int psemctl (int semid, int semnum, int cmd, void *u)
     
    void psemop (int semid, struct sembuf *sops, size_t nsops)
     semop wrapper function. More...
     
    +void psem_up (int semid, short unsigned int index)
     Increment a semaphore (uses psemop()).
     
    +void psem_down (int semid, short unsigned int index)
     Decrements a semaphore (uses psemop()).
     
    +void psem_down2 (int semid, short unsigned int index1, unsigned int index2)
     Decrements atomically two semaphores in a System V semaphore array (uses psemop()).
     
    System V - message queues

    Example
    #include <process.h> // #include <sys/msg.h>
    +
    ...
    +
    typedef struct Item
    +
    {
    +
    ...
    +
    } Item;
    +
    typedef struct Message
    +
    {
    +
    long type;
    +
    Item item;
    +
    } Message;
    +
    ...
    +
    int msgid;
    +
    // creation:
    +
    msgid = pmsgget(key, 0600 | IPC_CREAT | IPC_EXCL);
    +
    // or, use existing:
    +
    msgid = pmsgget(key, 0);
    +
    ...
    +
    Message msg;
    +
    // send msg:
    +
    msg = ...;
    +
    pmsgsnd(msgid, &msg, sizeof(Item), 0);
    +
    ...
    +
    // receive msg:
    +
    pmsgrcv(msgid, &msg, sizeof(Item), type, 0);
    +
    ...
    +
    // destroy msg:
    +
    pmsgctl(msgid, IPC_RMID, NULL);
    +
    +
    int pmsgget (key_t key, int msgflg)
     msgget wrapper function. More...
     
    int pmsgctl (int msqid, int cmd, struct msqid_ds *buf)
     msgctl wrapper function. More...
     
    void pmsgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
     msgsnd wrapper function. More...
     
    size_t pmsgrcv (int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
     msgrcv wrapper function. More...
     
    POSIX semaphores

    +
    sem_t * psem_open (const char *name, int oflag)
     sem_open wrapper function. More...
     
    +sem_t * psem_open (const char *name, int oflag, mode_t mode, unsigned int value)
     
    void psem_close (sem_t *sem)
     sem_close wrapper function. More...
     
    void psem_unlink (const char *name)
     sem_unlink wrapper function. More...
     
    void psem_init (sem_t *sem, int pshared, unsigned int value)
     sem_init wrapper function. More...
     
    void psem_destroy (sem_t *sem)
     sem_destroy wrapper function. More...
     
    void psem_wait (sem_t *sem)
     sem_wait wrapper function. More...
     
    int psem_trywait (sem_t *sem)
     sem_trywait wrapper function. More...
     
    int psem_timedwait (sem_t *sem, const struct timespec *abs_timeout)
     sem_timedwait wrapper function. More...
     
    void psem_post (sem_t *sem)
     sem_post wrapper function. More...
     
    UNIX pipes

    +
    void ppipe (int pipefd[2])
     pipe wrapper function. More...
     
    FILE * ppopen (const char *command, const char *type)
     popen wrapper function. More...
     
    void ppclose (FILE *stream)
     pclose wrapper function. More...
     
    +

    Detailed Description

    +

    Process, System-V, and POSIX libraries wrapper module.

    +
    Remarks
    Removes defensive programming from native libraries
    +
    +
    +
    void * pshmat(int shmid, const void *shmaddr, int shmflg)
    shmat wrapper function.
    +
    Process, System-V, and POSIX libraries wrapper module.
    +
    int psemget(key_t key, int nsems, int semflg)
    semget wrapper function.
    +
    int pshmget(key_t key, size_t size, int shmflg)
    shmget wrapper function.
    +
    void pmsgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg)
    msgsnd wrapper function.
    +
    int pmsgget(key_t key, int msgflg)
    msgget wrapper function.
    +
    void psem_down(int semid, short unsigned int index)
    Decrements a semaphore (uses psemop()).
    +
    void psem_up(int semid, short unsigned int index)
    Increment a semaphore (uses psemop()).
    +
    void psemop(int semid, struct sembuf *sops, size_t nsops)
    semop wrapper function.
    + + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/process_8h.js b/3ano/1semestre/so/practice-exam/src/doc/html/process_8h.js new file mode 100644 index 0000000..9a0053b --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/process_8h.js @@ -0,0 +1,35 @@ +var process_8h = +[ + [ "pfork", "group__process.html#ga67e00aff1839b1ba68c83947593f625b", null ], + [ "pwait", "group__process.html#gad27b81fee9a0f792c4ba29fd95c967e1", null ], + [ "pwaitpid", "group__process.html#gac926bd7ccd173f742b5d58f51cabcb48", null ], + [ "pkill", "group__process.html#gab546ccee89e3159ea7c23aa3a463a0d8", null ], + [ "pexecl", "group__process.html#gae5d3e8ac00f0e788f21020699bac758a", null ], + [ "psigaction", "group__process.html#ga7c7f6de68bd3dea8a702668090a65854", null ], + [ "pshmget", "group__process.html#gaff71624be0fc9c76e0c72295721875e6", null ], + [ "pshmctl", "group__process.html#ga3119bdf5486059aee6ec3ed65a01b319", null ], + [ "pshmat", "group__process.html#ga0cdba7faa458e7fb57c31d3cd8788480", null ], + [ "pshmdt", "group__process.html#ga1682328cd34b592404ff030779b0428f", null ], + [ "psemget", "group__process.html#gaada159a0fe725ed843ac358be6e6a9d3", null ], + [ "psemctl", "group__process.html#gac42e869afba098ec9bdd77444ba790c5", null ], + [ "psemop", "group__process.html#ga0e2534c82b54573590d913c297cc4840", null ], + [ "psem_up", "group__process.html#gaa00610fec639ef123819ceee2ef00da3", null ], + [ "psem_down", "group__process.html#gac2b930e9aceda9ef276b21ae8e839c16", null ], + [ "psem_down2", "group__process.html#ga47891b55ba91af98c5b45cbcf154bc20", null ], + [ "pmsgget", "group__process.html#gad426e03bc9b8dae5f1fbf889ce2dd8f7", null ], + [ "pmsgctl", "group__process.html#ga13bfac41329ec74b2aa4950f9586ae9f", null ], + [ "pmsgsnd", "group__process.html#gaeeb6cd0ab585a7769cd17405f600e56a", null ], + [ "pmsgrcv", "group__process.html#gacd4e4161a46bfa2e1f23eb1d49aaa07b", null ], + [ "psem_open", "group__process.html#ga7bf7fce2d1f344e7dfeeb1b46a9ee7ba", null ], + [ "psem_close", "group__process.html#ga41a884c3a9d9ac6a31fc6ab27ae1d668", null ], + [ "psem_unlink", "group__process.html#ga0415c9c4fab4baafef6cd2d40becd05e", null ], + [ "psem_init", "group__process.html#gac49ddb266cec5493ebd756cd9382f99d", null ], + [ "psem_destroy", "group__process.html#ga82e3d1015521711a2a6374d6c3771491", null ], + [ "psem_wait", "group__process.html#gae2c867f9f66e74fad44df3f32f87a8c6", null ], + [ "psem_trywait", "group__process.html#ga04cb3c84545fe7707c63578e1d59b689", null ], + [ "psem_timedwait", "group__process.html#gac8b2b3d1e18b385f10b389ce2ea734ef", null ], + [ "psem_post", "group__process.html#gad63921c4ec6f0845b752eb59a8935b8e", null ], + [ "ppipe", "group__process.html#ga013466fa89ac97a0db0ccd78168a8456", null ], + [ "ppopen", "group__process.html#ga2d9df322812707050312aa24d15a4360", null ], + [ "ppclose", "group__process.html#ga1490f6e0ca0ebf607d1f5ff431c79b68", null ] +]; \ No newline at end of file diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/process_8h_source.html b/3ano/1semestre/so/practice-exam/src/doc/html/process_8h_source.html new file mode 100644 index 0000000..d4429d3 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/process_8h_source.html @@ -0,0 +1,201 @@ + + + + + + + +C++ Library, mos@ua: process.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    C++ Library, mos@ua +  0.9 +
    +
    cpplib-mos
    +
    +
    + + + + + + +
    +
    + +
    +
    +
    + +
    +
    +
    +
    process.h
    +
    +
    +Go to the documentation of this file.
    1 
    +
    54 #ifndef PROCESS_H
    +
    55 #define PROCESS_H
    +
    56 
    +
    57 #include <stdio.h>
    +
    58 #include <unistd.h>
    +
    59 #include <sys/ipc.h>
    +
    60 #include <sys/shm.h>
    +
    61 #include <sys/sem.h>
    +
    62 #include <semaphore.h>
    +
    63 #include <signal.h>
    +
    64 
    +
    65 //#define EXCEPTION_POLICY
    +
    66 //#define EXIT_POLICY // DEFAULT
    +
    67 
    +
    68 
    +
    80 pid_t pfork(void);
    +
    81 
    +
    89 pid_t pwait(int *status);
    +
    90 
    +
    98 pid_t pwaitpid(pid_t pid, int *status, int options);
    +
    99 
    +
    107 void pkill(pid_t pid, int sig);
    +
    108 
    +
    116 void pexecl(const char *pathname, const char *arg, ... /* (char *) NULL */);
    +
    117 
    +
    125 void psigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
    +
    126 
    +
    167 int pshmget(key_t key, size_t size, int shmflg);
    +
    168 
    +
    176 int pshmctl(int shmid, int cmd, struct shmid_ds *buf);
    +
    177 
    +
    185 void *pshmat(int shmid, const void *shmaddr, int shmflg);
    +
    186 
    +
    194 void pshmdt(const void *shmaddr);
    +
    195 
    +
    242 int psemget(key_t key, int nsems, int semflg);
    +
    243 
    +
    251 int psemctl(int semid, int semnum, int cmd);
    +
    252 int psemctl(int semid, int semnum, int cmd, void *u);
    +
    253 
    +
    261 void psemop(int semid, struct sembuf *sops, size_t nsops);
    +
    262 
    +
    266 void psem_up(int semid, short unsigned int index);
    +
    267 
    +
    271 void psem_down(int semid, short unsigned int index);
    +
    272 
    +
    276 void psem_down2(int semid, short unsigned int index1, unsigned int index2);
    +
    277 
    +
    326 int pmsgget(key_t key, int msgflg);
    +
    327 
    +
    335 int pmsgctl(int msqid, int cmd, struct msqid_ds *buf);
    +
    336 
    +
    344 void pmsgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);
    +
    345 
    +
    353 size_t pmsgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg);
    +
    354 
    +
    362 // named:
    +
    370 sem_t *psem_open(const char *name, int oflag);
    +
    371 sem_t *psem_open(const char *name, int oflag, mode_t mode, unsigned int value);
    +
    372 
    +
    384 void psem_close(sem_t *sem);
    +
    385 
    +
    393 void psem_unlink(const char *name);
    +
    394 
    +
    395 // unnamed:
    +
    407 void psem_init(sem_t *sem, int pshared, unsigned int value);
    +
    408 
    +
    420 void psem_destroy(sem_t *sem);
    +
    421 
    +
    422 // named and unnamed:
    +
    434 void psem_wait(sem_t *sem);
    +
    435 
    +
    449 int psem_trywait(sem_t *sem);
    +
    450 
    +
    464 int psem_timedwait(sem_t *sem, const struct timespec *abs_timeout);
    +
    465 
    +
    477 void psem_post(sem_t *sem);
    +
    478 
    +
    492 void ppipe(int pipefd[2]);
    +
    493 
    +
    506 FILE *ppopen(const char *command, const char *type);
    +
    507 
    +
    519 void ppclose(FILE *stream);
    +
    520 
    +
    524 #endif
    +
    525 
    +
    526 /* ************************************************** */
    +
    530 /* ************************************************** */
    +
    531 
    +
    +
    +
    int psem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
    sem_timedwait wrapper function.
    +
    void pkill(pid_t pid, int sig)
    kill wrapper function.
    +
    void psem_init(sem_t *sem, int pshared, unsigned int value)
    sem_init wrapper function.
    +
    void psem_down2(int semid, short unsigned int index1, unsigned int index2)
    Decrements atomically two semaphores in a System V semaphore array (uses psemop()).
    +
    int psem_trywait(sem_t *sem)
    sem_trywait wrapper function.
    +
    int psemctl(int semid, int semnum, int cmd)
    semctl wrapper function.
    +
    void psem_wait(sem_t *sem)
    sem_wait wrapper function.
    +
    void psem_unlink(const char *name)
    sem_unlink wrapper function.
    +
    void * pshmat(int shmid, const void *shmaddr, int shmflg)
    shmat wrapper function.
    +
    void ppclose(FILE *stream)
    pclose wrapper function.
    +
    int psemget(key_t key, int nsems, int semflg)
    semget wrapper function.
    +
    void psem_destroy(sem_t *sem)
    sem_destroy wrapper function.
    +
    void ppipe(int pipefd[2])
    pipe wrapper function.
    +
    sem_t * psem_open(const char *name, int oflag)
    sem_open wrapper function.
    +
    void pexecl(const char *pathname, const char *arg,...)
    execl wrapper function.
    +
    pid_t pfork(void)
    fork wrapper function.
    +
    FILE * ppopen(const char *command, const char *type)
    popen wrapper function.
    +
    void psem_post(sem_t *sem)
    sem_post wrapper function.
    +
    int pshmget(key_t key, size_t size, int shmflg)
    shmget wrapper function.
    +
    pid_t pwaitpid(pid_t pid, int *status, int options)
    waitpid wrapper function.
    +
    void pmsgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg)
    msgsnd wrapper function.
    +
    int pmsgget(key_t key, int msgflg)
    msgget wrapper function.
    +
    void psem_down(int semid, short unsigned int index)
    Decrements a semaphore (uses psemop()).
    +
    int pshmctl(int shmid, int cmd, struct shmid_ds *buf)
    shmctl wrapper function.
    +
    void pshmdt(const void *shmaddr)
    shmdt wrapper function.
    +
    void psem_close(sem_t *sem)
    sem_close wrapper function.
    +
    void psigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
    sigaction wrapper function.
    +
    size_t pmsgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
    msgrcv wrapper function.
    +
    void psem_up(int semid, short unsigned int index)
    Increment a semaphore (uses psemop()).
    +
    int pmsgctl(int msqid, int cmd, struct msqid_ds *buf)
    msgctl wrapper function.
    +
    pid_t pwait(int *status)
    wait wrapper function.
    +
    void psemop(int semid, struct sembuf *sops, size_t nsops)
    semop wrapper function.
    + + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/resize.js b/3ano/1semestre/so/practice-exam/src/doc/html/resize.js new file mode 100644 index 0000000..a0bb5f4 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/resize.js @@ -0,0 +1,137 @@ +/* + @licstart The following is the entire license notice for the + JavaScript code in this file. + + Copyright (C) 1997-2017 by Dimitri van Heesch + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + @licend The above is the entire license notice + for the JavaScript code in this file + */ +function initResizable() +{ + var cookie_namespace = 'doxygen'; + var sidenav,navtree,content,header,collapsed,collapsedWidth=0,barWidth=6,desktop_vp=768,titleHeight; + + function readCookie(cookie) + { + var myCookie = cookie_namespace+"_"+cookie+"="; + if (document.cookie) { + var index = document.cookie.indexOf(myCookie); + if (index != -1) { + var valStart = index + myCookie.length; + var valEnd = document.cookie.indexOf(";", valStart); + if (valEnd == -1) { + valEnd = document.cookie.length; + } + var val = document.cookie.substring(valStart, valEnd); + return val; + } + } + return 0; + } + + function writeCookie(cookie, val, expiration) + { + if (val==undefined) return; + if (expiration == null) { + var date = new Date(); + date.setTime(date.getTime()+(10*365*24*60*60*1000)); // default expiration is one week + expiration = date.toGMTString(); + } + document.cookie = cookie_namespace + "_" + cookie + "=" + val + "; expires=" + expiration+"; path=/"; + } + + function resizeWidth() + { + var windowWidth = $(window).width() + "px"; + var sidenavWidth = $(sidenav).outerWidth(); + content.css({marginLeft:parseInt(sidenavWidth)+"px"}); + writeCookie('width',sidenavWidth-barWidth, null); + } + + function restoreWidth(navWidth) + { + var windowWidth = $(window).width() + "px"; + content.css({marginLeft:parseInt(navWidth)+barWidth+"px"}); + sidenav.css({width:navWidth + "px"}); + } + + function resizeHeight() + { + var headerHeight = header.outerHeight(); + var footerHeight = footer.outerHeight(); + var windowHeight = $(window).height() - headerHeight - footerHeight; + content.css({height:windowHeight + "px"}); + navtree.css({height:windowHeight + "px"}); + sidenav.css({height:windowHeight + "px"}); + var width=$(window).width(); + if (width!=collapsedWidth) { + if (width=desktop_vp) { + if (!collapsed) { + collapseExpand(); + } + } else if (width>desktop_vp && collapsedWidth0) { + restoreWidth(0); + collapsed=true; + } + else { + var width = readCookie('width'); + if (width>200 && width<$(window).width()) { restoreWidth(width); } else { restoreWidth(200); } + collapsed=false; + } + } + + header = $("#top"); + sidenav = $("#side-nav"); + content = $("#doc-content"); + navtree = $("#nav-tree"); + footer = $("#nav-path"); + $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } }); + $(sidenav).resizable({ minWidth: 0 }); + $(window).resize(function() { resizeHeight(); }); + var device = navigator.userAgent.toLowerCase(); + var touch_device = device.match(/(iphone|ipod|ipad|android)/); + if (touch_device) { /* wider split bar for touch only devices */ + $(sidenav).css({ paddingRight:'20px' }); + $('.ui-resizable-e').css({ width:'20px' }); + $('#nav-sync').css({ right:'34px' }); + barWidth=20; + } + var width = readCookie('width'); + if (width) { restoreWidth(width); } else { resizeWidth(); } + resizeHeight(); + var url = location.href; + var i=url.indexOf("#"); + if (i>=0) window.location.hash=url.substr(i); + var _preventDefault = function(evt) { evt.preventDefault(); }; + $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault); + $(".ui-resizable-handle").dblclick(collapseExpand); + $(window).on('load',resizeHeight); +} +/* @license-end */ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/splitbar.png b/3ano/1semestre/so/practice-exam/src/doc/html/splitbar.png new file mode 100644 index 0000000..fe895f2 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/splitbar.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/sync_off.png b/3ano/1semestre/so/practice-exam/src/doc/html/sync_off.png new file mode 100644 index 0000000..3b443fc Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/sync_off.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/sync_on.png b/3ano/1semestre/so/practice-exam/src/doc/html/sync_on.png new file mode 100644 index 0000000..e08320f Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/sync_on.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/tab_a.png b/3ano/1semestre/so/practice-exam/src/doc/html/tab_a.png new file mode 100644 index 0000000..3b725c4 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/tab_a.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/tab_b.png b/3ano/1semestre/so/practice-exam/src/doc/html/tab_b.png new file mode 100644 index 0000000..e2b4a86 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/tab_b.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/tab_h.png b/3ano/1semestre/so/practice-exam/src/doc/html/tab_h.png new file mode 100644 index 0000000..fd5cb70 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/tab_h.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/tab_s.png b/3ano/1semestre/so/practice-exam/src/doc/html/tab_s.png new file mode 100644 index 0000000..ab478c9 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/doc/html/tab_s.png differ diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/tabs.css b/3ano/1semestre/so/practice-exam/src/doc/html/tabs.css new file mode 100644 index 0000000..7d45d36 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/tabs.css @@ -0,0 +1 @@ +.sm{position:relative;z-index:9999}.sm,.sm ul,.sm li{display:block;list-style:none;margin:0;padding:0;line-height:normal;direction:ltr;text-align:left;-webkit-tap-highlight-color:rgba(0,0,0,0)}.sm-rtl,.sm-rtl ul,.sm-rtl li{direction:rtl;text-align:right}.sm>li>h1,.sm>li>h2,.sm>li>h3,.sm>li>h4,.sm>li>h5,.sm>li>h6{margin:0;padding:0}.sm ul{display:none}.sm li,.sm a{position:relative}.sm a{display:block}.sm a.disabled{cursor:not-allowed}.sm:after{content:"\00a0";display:block;height:0;font:0px/0 serif;clear:both;visibility:hidden;overflow:hidden}.sm,.sm *,.sm *:before,.sm *:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.sm-dox{background-image:url("tab_b.png")}.sm-dox a,.sm-dox a:focus,.sm-dox a:hover,.sm-dox a:active{padding:0px 12px;padding-right:43px;font-family:"Lucida Grande","Geneva","Helvetica",Arial,sans-serif;font-size:13px;font-weight:bold;line-height:36px;text-decoration:none;text-shadow:0px 1px 1px rgba(255,255,255,0.9);color:#283A5D;outline:none}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:#fff;text-shadow:0px 1px 1px #000}.sm-dox a.current{color:#D23600}.sm-dox a.disabled{color:#bbb}.sm-dox a span.sub-arrow{position:absolute;top:50%;margin-top:-14px;left:auto;right:3px;width:28px;height:28px;overflow:hidden;font:bold 12px/28px monospace !important;text-align:center;text-shadow:none;background:rgba(255,255,255,0.5);border-radius:5px}.sm-dox a.highlighted span.sub-arrow:before{display:block;content:'-'}.sm-dox>li:first-child>a,.sm-dox>li:first-child>:not(ul) a{border-radius:5px 5px 0 0}.sm-dox>li:last-child>a,.sm-dox>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul{border-radius:0 0 5px 5px}.sm-dox>li:last-child>a.highlighted,.sm-dox>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted{border-radius:0}.sm-dox ul{background:rgba(162,162,162,0.1)}.sm-dox ul a,.sm-dox ul a:focus,.sm-dox ul a:hover,.sm-dox ul a:active{font-size:12px;border-left:8px solid transparent;line-height:36px;text-shadow:none;background-color:white;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:#fff;text-shadow:0px 1px 1px #000}.sm-dox ul ul a,.sm-dox ul ul a:hover,.sm-dox ul ul a:focus,.sm-dox ul ul a:active{border-left:16px solid transparent}.sm-dox ul ul ul a,.sm-dox ul ul ul a:hover,.sm-dox ul ul ul a:focus,.sm-dox ul ul ul a:active{border-left:24px solid transparent}.sm-dox ul ul ul ul a,.sm-dox ul ul ul ul a:hover,.sm-dox ul ul ul ul a:focus,.sm-dox ul ul ul ul a:active{border-left:32px solid transparent}.sm-dox ul ul ul ul ul a,.sm-dox ul ul ul ul ul a:hover,.sm-dox ul ul ul ul ul a:focus,.sm-dox ul ul ul ul ul a:active{border-left:40px solid transparent}@media (min-width: 768px){.sm-dox ul{position:absolute;width:12em}.sm-dox li{float:left}.sm-dox.sm-rtl li{float:right}.sm-dox ul li,.sm-dox.sm-rtl ul li,.sm-dox.sm-vertical li{float:none}.sm-dox a{white-space:nowrap}.sm-dox ul a,.sm-dox.sm-vertical a{white-space:normal}.sm-dox .sm-nowrap>li>a,.sm-dox .sm-nowrap>li>:not(ul) a{white-space:nowrap}.sm-dox{padding:0 10px;background-image:url("tab_b.png");line-height:36px}.sm-dox a span.sub-arrow{top:50%;margin-top:-2px;right:12px;width:0;height:0;border-width:4px;border-style:solid dashed dashed dashed;border-color:#283A5D transparent transparent transparent;background:transparent;border-radius:0}.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted{padding:0px 12px;background-image:url("tab_s.png");background-repeat:no-repeat;background-position:right;border-radius:0 !important}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:#fff;text-shadow:0px 1px 1px #000}.sm-dox a:hover span.sub-arrow{border-color:#fff transparent transparent transparent}.sm-dox a.has-submenu{padding-right:24px}.sm-dox li{border-top:0}.sm-dox>li>ul:before,.sm-dox>li>ul:after{content:'';position:absolute;top:-18px;left:30px;width:0;height:0;overflow:hidden;border-width:9px;border-style:dashed dashed solid dashed;border-color:transparent transparent #bbb transparent}.sm-dox>li>ul:after{top:-16px;left:31px;border-width:8px;border-color:transparent transparent #fff transparent}.sm-dox ul{border:1px solid #bbb;padding:5px 0;background:#fff;border-radius:5px !important;box-shadow:0 5px 9px rgba(0,0,0,0.2)}.sm-dox ul a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-color:transparent transparent transparent #555;border-style:dashed dashed dashed solid}.sm-dox ul a,.sm-dox ul a:hover,.sm-dox ul a:focus,.sm-dox ul a:active,.sm-dox ul a.highlighted{color:#555;background-image:none;border:0 !important;color:#555;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:#fff;text-shadow:0px 1px 1px #000}.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent #fff}.sm-dox span.scroll-up,.sm-dox span.scroll-down{position:absolute;display:none;visibility:hidden;overflow:hidden;background:#fff;height:36px}.sm-dox span.scroll-up:hover,.sm-dox span.scroll-down:hover{background:#eee}.sm-dox span.scroll-up:hover span.scroll-up-arrow,.sm-dox span.scroll-up:hover span.scroll-down-arrow{border-color:transparent transparent #D23600 transparent}.sm-dox span.scroll-down:hover span.scroll-down-arrow{border-color:#D23600 transparent transparent transparent}.sm-dox span.scroll-up-arrow,.sm-dox span.scroll-down-arrow{position:absolute;top:0;left:50%;margin-left:-6px;width:0;height:0;overflow:hidden;border-width:6px;border-style:dashed dashed solid dashed;border-color:transparent transparent #555 transparent}.sm-dox span.scroll-down-arrow{top:8px;border-style:solid dashed dashed dashed;border-color:#555 transparent transparent transparent}.sm-dox.sm-rtl a.has-submenu{padding-right:12px;padding-left:24px}.sm-dox.sm-rtl a span.sub-arrow{right:auto;left:12px}.sm-dox.sm-rtl.sm-vertical a.has-submenu{padding:10px 20px}.sm-dox.sm-rtl.sm-vertical a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-rtl>li>ul:before{left:auto;right:30px}.sm-dox.sm-rtl>li>ul:after{left:auto;right:31px}.sm-dox.sm-rtl ul a.has-submenu{padding:10px 20px !important}.sm-dox.sm-rtl ul a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-vertical{padding:10px 0;border-radius:5px}.sm-dox.sm-vertical a{padding:10px 20px}.sm-dox.sm-vertical a:hover,.sm-dox.sm-vertical a:focus,.sm-dox.sm-vertical a:active,.sm-dox.sm-vertical a.highlighted{background:#fff}.sm-dox.sm-vertical a.disabled{background-image:url("tab_b.png")}.sm-dox.sm-vertical a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-style:dashed dashed dashed solid;border-color:transparent transparent transparent #555}.sm-dox.sm-vertical>li>ul:before,.sm-dox.sm-vertical>li>ul:after{display:none}.sm-dox.sm-vertical ul a{padding:10px 20px}.sm-dox.sm-vertical ul a:hover,.sm-dox.sm-vertical ul a:focus,.sm-dox.sm-vertical ul a:active,.sm-dox.sm-vertical ul a.highlighted{background:#eee}.sm-dox.sm-vertical ul a.disabled{background:#fff}} diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/thread_8h.html b/3ano/1semestre/so/practice-exam/src/doc/html/thread_8h.html new file mode 100644 index 0000000..805fef9 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/thread_8h.html @@ -0,0 +1,263 @@ + + + + + + + +C++ Library, mos@ua: thread.h File Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    C++ Library, mos@ua +  0.9 +
    +
    cpplib-mos
    +
    +
    + + + + + + +
    +
    + +
    +
    +
    + +
    +
    +
    +
    thread.h File Reference
    +
    +
    + +

    POSIX threads library wrapper module. +More...

    +
    #include <pthread.h>
    +
    +

    Go to the source code of this file.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Functions

    Thread handling

    Variable type: pthread_t

    +

    +
    int thread_equal (pthread_t t1, pthread_t t2)
     pthread_equal wrapper function. More...
     
    void thread_create (pthread_t *t, pthread_attr_t *attr, void *(*thread_main)(void *), void *arg)
     pthread_create wrapper function. More...
     
    pthread_t thread_self ()
     pthread_self wrapper function. More...
     
    void thread_sched_yield (void)
     sched_yield wrapper function. More...
     
    void thread_exit (void *retval)
     pthread_exit wrapper function. More...
     
    void thread_detach (pthread_t thread)
     pthread_detach wrapper function. More...
     
    void thread_join (pthread_t t, void **result)
     pthread_join wrapper function. More...
     
    Mutexes

    Variable type: pthread_mutex_t

    +

    Initialization of mutexes can be static or dynamic.

    +

    In static initialization the following initialization macros are suggested:

      +
    • PTHREAD_MUTEX_INITIALIZER - standard initializer
    • +
    • PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP - initializer that ensures error checking
    • +
    • PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP - for recursive mutexes (note that recursive mutexes should be avoid)
    • +
    +

    Dynamic initialization is done by mutex_init() and mutex_destroy().

    +

    +
    void mutex_init (pthread_mutex_t *pmtx, pthread_mutexattr_t *attr)
     pthread_mutex_init wrapper function. More...
     
    void mutex_destroy (pthread_mutex_t *pmtx)
     pthread_mutex_destroy wrapper function. More...
     
    void mutex_lock (pthread_mutex_t *pmtx)
     pthread_mutex_lock wrapper function. More...
     
    int mutex_trylock (pthread_mutex_t *pmtx)
     pthread_mutex_trylock wrapper function. More...
     
    void mutex_unlock (pthread_mutex_t *pmtx)
     pthread_mutex_unlock wrapper function. More...
     
    Condition variables

    Variable type: pthread_cond_t

    +

    Initialization of condition variables can be static or dynamic.

    +

    In static initialization the following initialization macros should be used:

      +
    • PTHREAD_COND_INITIALIZER - standard initializer
    • +
    +

    Dynamic initialization is done by cond_init() and cond_destroy().

    +

    +
    void cond_init (pthread_cond_t *pcvar, pthread_condattr_t *attr)
     pthread_cond_init wrapper function. More...
     
    void cond_destroy (pthread_cond_t *pcvar)
     pthread_cond_destroy wrapper function. More...
     
    void cond_wait (pthread_cond_t *pcvar, pthread_mutex_t *pmtx)
     pthread_cond_wait wrapper function. More...
     
    int cond_timedwait (pthread_cond_t *pcvar, pthread_mutex_t *pmtx, const struct timespec *abstime)
     pthread_cond_timedwait wrapper function. More...
     
    int cond_timedwait (pthread_cond_t *pcvar, pthread_mutex_t *pmtx, long relative_time_us)
     pthread_cond_timedwait wrapper function accepting relative time (in microseconds) instead of absolute time. More...
     
    void cond_signal (pthread_cond_t *pcvar)
     pthread_cond_signal wrapper function. More...
     
    void cond_broadcast (pthread_cond_t *pcvar)
     pthread_cond_broadcast wrapper function. More...
     
    One-time initialization

    Variable type: pthread_once_t

    +

    POSIX thread library support a mechanism that ensures a one-time execution of a function. It does it through pthread_once_t variables, and by passing a callback function (in C/C++ is simply a function pointer).

    +
    Example
       void once_init_routine(void) { ... }
    +   ...
    +   pthread_once_t once_control = PTHREAD_ONCE_INIT;
    +   thread_once(&once_control, &once_init_routine); // one time execution over pthread_once_t
    +                                                   // variable is guaranteed, regardless of the
    +                                                   // number of threads that execute over that
    +                                                   // variable.
    +
    +

    +
    void thread_once (pthread_once_t *once_control, void(*init_routine)(void))
     pthread_once wrapper function. More...
     
    Thread-specific data

    Variable type: pthread_key_t

    +

    Thread-specific data allows the definition of variable whose scope is limited to each thread. In practice, we will have a common variable, with a common access, but with different values for each thread.

    +

    +
    void thread_key_create (pthread_key_t *key, void(*destr_function)(void *))
     pthread_key_create wrapper function. More...
     
    void thread_key_delete (pthread_key_t key)
     pthread_key_delete wrapper function. More...
     
    void thread_setspecific (pthread_key_t key, void *pointer)
     pthread_setspecific wrapper function. More...
     
    void * thread_getspecific (pthread_key_t key)
     pthread_getspecific wrapper function. More...
     
    Mutex attributes

    Variable type: pthread_mutexattr_t

    +

    +
    void mutexattr_init (pthread_mutexattr_t *attr)
     pthread_mutexattr_init wrapper function. More...
     
    void mutexattr_destroy (pthread_mutexattr_t *attr)
     pthread_mutexattr_destroy wrapper function. More...
     
    void mutexattr_settype (pthread_mutexattr_t *attr, int type)
     pthread_mutexattr_settype wrapper function. More...
     
    void mutexattr_gettype (const pthread_mutexattr_t *attr, int *kind)
     pthread_mutexattr_gettype wrapper function. More...
     
    Condition variables attributes

    Variable type: pthread_condattr_t

    +

    +
    void condattr_init (pthread_condattr_t *attr)
     pthread_condattr_init wrapper function. More...
     
    void condattr_destroy (pthread_condattr_t *attr)
     pthread_condattr_destroy wrapper function. More...
     
    Thread attributes

    Variable type: pthread_attr_t

    +

    +
    void thread_attr_init (pthread_attr_t *attr)
     pthread_attr_init wrapper function. More...
     
    void thread_attr_destroy (pthread_attr_t *attr)
     pthread_attr_destroy wrapper function. More...
     
    void thread_attr_setdetachstate (pthread_attr_t *attr, int detachstate)
     pthread_attr_setdetachstate wrapper function. More...
     
    void thread_attr_getdetachstate (const pthread_attr_t *attr, int *pdetachstate)
     pthread_attr_getdetachstate wrapper function. More...
     
    Cancellation

    +
    void thread_cancel (pthread_t thread)
     pthread_cancel wrapper function. More...
     
    void thread_setcancelstate (int state, int *oldstate)
     pthread_setcancelstate wrapper function. More...
     
    void thread_setcanceltype (int type, int *oldtype)
     pthread_setcanceltype wrapper function. More...
     
    void thread_testcancel (void)
     pthread_testcancel wrapper function. More...
     
    +

    Detailed Description

    +

    POSIX threads library wrapper module.

    +
    Remarks
    Removes defensive programming from native libraries
    +
    +
    + + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/thread_8h.js b/3ano/1semestre/so/practice-exam/src/doc/html/thread_8h.js new file mode 100644 index 0000000..afcfcb2 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/thread_8h.js @@ -0,0 +1,41 @@ +var thread_8h = +[ + [ "thread_equal", "group__thread.html#gadca8bdcec91b8985370d904591d342b8", null ], + [ "thread_create", "group__thread.html#ga3a0f9920a321b54c41c098d3461d3889", null ], + [ "thread_self", "group__thread.html#ga606fdef53f997c231e0e1e9e54b350d4", null ], + [ "thread_sched_yield", "group__thread.html#ga952c63101c667d247f0923b609710c72", null ], + [ "thread_exit", "group__thread.html#ga19b16adf05364471bae2840aa564329a", null ], + [ "thread_detach", "group__thread.html#ga86aa7989874009c886bea9d41700e25c", null ], + [ "thread_join", "group__thread.html#ga2b2370a45c1518f777493526b2e4f46d", null ], + [ "mutex_init", "group__thread.html#ga3f227a19d6a339ce0aeda15775e5e6e6", null ], + [ "mutex_destroy", "group__thread.html#ga5ebb836d0f83eac719f2cdd336497b01", null ], + [ "mutex_lock", "group__thread.html#ga87086ba0f13f6ddc479a6bc803a10c39", null ], + [ "mutex_trylock", "group__thread.html#ga8bd074884e1c92e88ca8ea0552d9a928", null ], + [ "mutex_unlock", "group__thread.html#ga95235231165ebda870afa10ba5fd6c41", null ], + [ "cond_init", "group__thread.html#ga31e5eaf158d118d0e4ef7fd47368eaad", null ], + [ "cond_destroy", "group__thread.html#gad663c43fbfbb4f660d48b07e110c8f80", null ], + [ "cond_wait", "group__thread.html#ga1123643838d5174ccd41f52f4169e896", null ], + [ "cond_timedwait", "group__thread.html#ga8cd2040836c30e4f0ea17abe4f66b8e2", null ], + [ "cond_timedwait", "group__thread.html#ga4b41089ba3cd8ad0a539b42bc8b95d6b", null ], + [ "cond_signal", "group__thread.html#ga9624688b577fb653af7a528848cc53d5", null ], + [ "cond_broadcast", "group__thread.html#ga6459039ab27da7237dda2bbc866eb2d0", null ], + [ "thread_once", "group__thread.html#gad0428e8a0809704f4b3d682f26d3ef1c", null ], + [ "thread_key_create", "group__thread.html#ga7df1983f57dca40a86a55d215d13d42b", null ], + [ "thread_key_delete", "group__thread.html#ga65a50dfc97c087a28cb916e0f30f760e", null ], + [ "thread_setspecific", "group__thread.html#ga3008b033f2830e79179a882a2b74c8ba", null ], + [ "thread_getspecific", "group__thread.html#ga0d207f1bb2e1d493b68a026b8650cb16", null ], + [ "mutexattr_init", "group__thread.html#ga9fb2733a01e8d668a2022005ea5dbebd", null ], + [ "mutexattr_destroy", "group__thread.html#ga07bf0e49b1f2cb99d3a2955641c676d5", null ], + [ "mutexattr_settype", "group__thread.html#ga601a6a9527d7d5ee2ca2870cddc4afc2", null ], + [ "mutexattr_gettype", "group__thread.html#gadf741e1818d53c5b7d71cd68e161b215", null ], + [ "condattr_init", "group__thread.html#gab8073c72be896ba9d711d887a5405a74", null ], + [ "condattr_destroy", "group__thread.html#ga4644f4989b30ccfb2e908017c43bd0d0", null ], + [ "thread_attr_init", "group__thread.html#gaaf2db7012069f0006e7ffaf257d8ccc6", null ], + [ "thread_attr_destroy", "group__thread.html#gaf3a9c2c051deee01e21c75f0fa8b2e9c", null ], + [ "thread_attr_setdetachstate", "group__thread.html#gabc82fea1785fc82aeb2f43cdd77b9b0f", null ], + [ "thread_attr_getdetachstate", "group__thread.html#gaae83c8617612c1bb481fec2b382ac9c4", null ], + [ "thread_cancel", "group__thread.html#ga1b3cb53565eabe02a36e000e5244dfd1", null ], + [ "thread_setcancelstate", "group__thread.html#ga98baffe08beec792f3428ae9ddad966e", null ], + [ "thread_setcanceltype", "group__thread.html#gab4ec114c7b59f8f4185bac648b256d0c", null ], + [ "thread_testcancel", "group__thread.html#ga81bdb13d62e16ad7cb3cbd263c9a5671", null ] +]; \ No newline at end of file diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/thread_8h_source.html b/3ano/1semestre/so/practice-exam/src/doc/html/thread_8h_source.html new file mode 100644 index 0000000..c0e7fab --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/thread_8h_source.html @@ -0,0 +1,207 @@ + + + + + + + +C++ Library, mos@ua: thread.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    C++ Library, mos@ua +  0.9 +
    +
    cpplib-mos
    +
    +
    + + + + + + +
    +
    + +
    +
    +
    + +
    +
    +
    +
    thread.h
    +
    +
    +Go to the documentation of this file.
    1 
    +
    28 #ifndef THREAD_H
    +
    29 #define THREAD_H
    +
    30 
    +
    31 #include <pthread.h>
    +
    32 
    +
    33 //#define EXCEPTION_POLICY
    +
    34 //#define EXIT_POLICY // DEFAULT
    +
    35 
    +
    52 int thread_equal(pthread_t t1, pthread_t t2);
    +
    53 
    +
    66 void thread_create(pthread_t* t, pthread_attr_t* attr, void *(*thread_main)(void*), void* arg);
    +
    67 
    +
    75 pthread_t thread_self();
    +
    76 
    +
    84 void thread_sched_yield(void);
    +
    85 
    +
    93 void thread_exit(void *retval);
    +
    94 
    +
    102 void thread_detach(pthread_t thread);
    +
    103 
    +
    111 void thread_join(pthread_t t, void** result);
    +
    112 
    +
    145 void mutex_init(pthread_mutex_t* pmtx, pthread_mutexattr_t* attr);
    +
    146 
    +
    158 void mutex_destroy(pthread_mutex_t* pmtx);
    +
    159 
    +
    171 void mutex_lock(pthread_mutex_t* pmtx);
    +
    172 
    +
    186 int mutex_trylock(pthread_mutex_t* pmtx);
    +
    187 
    +
    199 void mutex_unlock(pthread_mutex_t* pmtx);
    +
    200 
    +
    231 void cond_init(pthread_cond_t* pcvar, pthread_condattr_t* attr);
    +
    232 
    +
    244 void cond_destroy(pthread_cond_t* pcvar);
    +
    245 
    +
    258 void cond_wait(pthread_cond_t* pcvar, pthread_mutex_t* pmtx);
    +
    259 
    +
    275 int cond_timedwait(pthread_cond_t* pcvar, pthread_mutex_t* pmtx, const struct timespec *abstime);
    +
    276 
    +
    292 int cond_timedwait(pthread_cond_t* pcvar, pthread_mutex_t* pmtx, long relative_time_us);
    +
    293 
    +
    305 void cond_signal(pthread_cond_t* pcvar);
    +
    306 
    +
    318 void cond_broadcast(pthread_cond_t* pcvar);
    +
    319 
    +
    359 void thread_once(pthread_once_t *once_control, void (*init_routine) (void));
    +
    360 
    +
    389 void thread_key_create(pthread_key_t *key, void (*destr_function) (void *));
    +
    390 
    +
    404 void thread_key_delete(pthread_key_t key);
    +
    405 
    +
    417 void thread_setspecific(pthread_key_t key, void* pointer);
    +
    418 
    +
    430 void* thread_getspecific(pthread_key_t key);
    +
    431 
    +
    455 void mutexattr_init(pthread_mutexattr_t *attr);
    +
    456 
    +
    468 void mutexattr_destroy(pthread_mutexattr_t *attr);
    +
    469 
    +
    481 void mutexattr_settype(pthread_mutexattr_t *attr, int type);
    +
    482 
    +
    495 void mutexattr_gettype(const pthread_mutexattr_t *attr, int *kind);
    +
    496 
    +
    520 void condattr_init(pthread_condattr_t *attr);
    +
    521 
    +
    533 void condattr_destroy(pthread_condattr_t *attr);
    +
    534 
    +
    558 void thread_attr_init(pthread_attr_t *attr);
    +
    559 
    +
    571 void thread_attr_destroy(pthread_attr_t *attr);
    +
    572 
    +
    585 void thread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
    +
    586 
    +
    599 void thread_attr_getdetachstate(const pthread_attr_t *attr, int *pdetachstate);
    +
    600 
    +
    616 void thread_cancel(pthread_t thread);
    +
    617 
    +
    630 void thread_setcancelstate(int state, int *oldstate);
    +
    631 
    +
    644 void thread_setcanceltype(int type, int *oldtype);
    +
    645 
    +
    653 void thread_testcancel(void);
    +
    654 
    +
    655 
    +
    658 #endif
    +
    659 
    +
    660 /* ************************************************** */
    +
    664 /* ************************************************** */
    +
    665 
    +
    +
    +
    void cond_init(pthread_cond_t *pcvar, pthread_condattr_t *attr)
    pthread_cond_init wrapper function.
    +
    void thread_setspecific(pthread_key_t key, void *pointer)
    pthread_setspecific wrapper function.
    +
    void cond_destroy(pthread_cond_t *pcvar)
    pthread_cond_destroy wrapper function.
    +
    void thread_key_create(pthread_key_t *key, void(*destr_function)(void *))
    pthread_key_create wrapper function.
    +
    void thread_exit(void *retval)
    pthread_exit wrapper function.
    +
    void mutexattr_destroy(pthread_mutexattr_t *attr)
    pthread_mutexattr_destroy wrapper function.
    +
    void thread_setcancelstate(int state, int *oldstate)
    pthread_setcancelstate wrapper function.
    +
    void thread_attr_getdetachstate(const pthread_attr_t *attr, int *pdetachstate)
    pthread_attr_getdetachstate wrapper function.
    +
    void thread_key_delete(pthread_key_t key)
    pthread_key_delete wrapper function.
    +
    void thread_testcancel(void)
    pthread_testcancel wrapper function.
    +
    void condattr_init(pthread_condattr_t *attr)
    pthread_condattr_init wrapper function.
    +
    void thread_join(pthread_t t, void **result)
    pthread_join wrapper function.
    +
    void condattr_destroy(pthread_condattr_t *attr)
    pthread_condattr_destroy wrapper function.
    +
    void cond_signal(pthread_cond_t *pcvar)
    pthread_cond_signal wrapper function.
    +
    void thread_attr_init(pthread_attr_t *attr)
    pthread_attr_init wrapper function.
    +
    void mutex_init(pthread_mutex_t *pmtx, pthread_mutexattr_t *attr)
    pthread_mutex_init wrapper function.
    +
    void cond_wait(pthread_cond_t *pcvar, pthread_mutex_t *pmtx)
    pthread_cond_wait wrapper function.
    +
    void thread_detach(pthread_t thread)
    pthread_detach wrapper function.
    +
    void cond_broadcast(pthread_cond_t *pcvar)
    pthread_cond_broadcast wrapper function.
    +
    void mutexattr_init(pthread_mutexattr_t *attr)
    pthread_mutexattr_init wrapper function.
    +
    void mutexattr_gettype(const pthread_mutexattr_t *attr, int *kind)
    pthread_mutexattr_gettype wrapper function.
    +
    void thread_attr_destroy(pthread_attr_t *attr)
    pthread_attr_destroy wrapper function.
    +
    void * thread_getspecific(pthread_key_t key)
    pthread_getspecific wrapper function.
    +
    void mutex_destroy(pthread_mutex_t *pmtx)
    pthread_mutex_destroy wrapper function.
    +
    void thread_once(pthread_once_t *once_control, void(*init_routine)(void))
    pthread_once wrapper function.
    +
    void thread_create(pthread_t *t, pthread_attr_t *attr, void *(*thread_main)(void *), void *arg)
    pthread_create wrapper function.
    +
    void thread_setcanceltype(int type, int *oldtype)
    pthread_setcanceltype wrapper function.
    +
    void thread_sched_yield(void)
    sched_yield wrapper function.
    +
    void mutexattr_settype(pthread_mutexattr_t *attr, int type)
    pthread_mutexattr_settype wrapper function.
    +
    int thread_equal(pthread_t t1, pthread_t t2)
    pthread_equal wrapper function.
    +
    void thread_cancel(pthread_t thread)
    pthread_cancel wrapper function.
    +
    pthread_t thread_self()
    pthread_self wrapper function.
    +
    void thread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
    pthread_attr_setdetachstate wrapper function.
    +
    void mutex_lock(pthread_mutex_t *pmtx)
    pthread_mutex_lock wrapper function.
    +
    int cond_timedwait(pthread_cond_t *pcvar, pthread_mutex_t *pmtx, const struct timespec *abstime)
    pthread_cond_timedwait wrapper function.
    +
    void mutex_unlock(pthread_mutex_t *pmtx)
    pthread_mutex_unlock wrapper function.
    +
    int mutex_trylock(pthread_mutex_t *pmtx)
    pthread_mutex_trylock wrapper function.
    + + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/utils_8h.html b/3ano/1semestre/so/practice-exam/src/doc/html/utils_8h.html new file mode 100644 index 0000000..acbf5ff --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/utils_8h.html @@ -0,0 +1,208 @@ + + + + + + + +C++ Library, mos@ua: utils.h File Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    C++ Library, mos@ua +  0.9 +
    +
    cpplib-mos
    +
    +
    + + + + + + +
    +
    + +
    +
    +
    + +
    +
    + +
    +
    utils.h File Reference
    +
    +
    + +

    Useful common functions and macros. +More...

    +
    #include <stdio.h>
    +#include <string.h>
    +#include <errno.h>
    +#include "dbc.h"
    +
    +

    Go to the source code of this file.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Macros

    #define int2str(num)
     Converts an int value to a stack allocated string. More...
     
    #define int2nstr(num, len)
     Converts an int value to a stack allocated string. More...
     
    #define long2str(num)
     Converts an long value to a stack allocated string. More...
     
    #define long2nstr(num, len)
     Converts an long value to a stack allocated string. More...
     
    #define perc2str(percentage)
     Converts an int percentage to a stack allocated string. More...
     
    #define length_vargs_string_list(first)
     Determines the length of all strings passed as a NULL terminated variable list of arguments (vargs). More...
     
    #define not_null(pnt)
     Checks if address is not NULL, before its application. More...
     
    String concatenation in stack memory

    +
    #define concat_2str(str1, str2)
     Concatenates two strings in the stack memory (thus it cannot be implemented in a function). More...
     
    #define concat_3str(str1, str2, str3)
     Concatenates three strings in the stack memory (thus it cannot be implemented in a function). More...
     
    #define concat_4str(str1, str2, str3, str4)
     Concatenates four strings in the stack memory (thus it cannot be implemented in a function). More...
     
    #define concat_5str(str1, str2, str3, str4, str5)
     Concatenates five strings in the stack memory (thus it cannot be implemented in a function). More...
     
    #define concat_6str(str1, str2, str3, str4, str5, str6)
     Concatenates six strings in the stack memory (thus it cannot be implemented in a function). More...
     
    #define concat_7str(str1, str2, str3, str4, str5, str6, str7)
     Concatenates seven strings in the stack memory (thus it cannot be implemented in a function). More...
     
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Functions

    void * mem_alloc (int size)
     A replacement for malloc function. More...
     
    void mem_free (void *pnt)
     A replacement for free function. More...
     
    char * string_clone (char *str)
     Replicates a string. More...
     
    int string_num_lines (char *text)
     Number of lines of a string. More...
     
    int string_num_columns (char *text)
     Maximum number of columns of a string (not counting character ‘’\n'`). More...
     
    int string_count_char (char *text, char *ch)
     Counts the number of occurrences of an UTF8 character in a text. More...
     
    int string_starts_with (char *text, char *prefix)
     Tests if a string starts with a prefix. More...
     
    int string_ends_with (char *text, char *suffix)
     Tests if a string ends with a suffix. More...
     
    char * string_concat (char *res, int max_length, char *text,...)
     Concatenates a NULL terminated list of string arguments. More...
     
    int random_boolean (int trueProb)
     Generates a random boolean value. More...
     
    int random_int (int min, int max)
     Generates a random integer value within a given interval. More...
     
    char * random_string (char **list, int *used, int length)
     Returns a random string from a given string list. More...
     
    +void clear_console ()
     Clears the terminal.
     
    void move_cursor (int line, int column)
     Moves the cursor to a position in terminal. More...
     
    +void hide_cursor ()
     Hides the terminal cursor.
     
    +void show_cursor ()
     Shows the terminal cursor.
     
    int string_list_length (char **list)
     Number of elements of a NULL terminated list of strings. More...
     
    char ** string_list_clone (char **list)
     Replicates a NULL terminated list of strings. More...
     
    char ** string_list_free (char **list)
     Frees the memory allocated to a NULL terminated list of strings. More...
     
    char * int2nstring (char *res, int num, int len)
     Converts an int value to a string. More...
     
    char * percentage2string (char *res, int percentage)
     Converts an int percentage to a string. More...
     
    +

    Detailed Description

    +

    Useful common functions and macros.

    +
    +
    + + + + diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/utils_8h.js b/3ano/1semestre/so/practice-exam/src/doc/html/utils_8h.js new file mode 100644 index 0000000..accef9d --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/utils_8h.js @@ -0,0 +1,37 @@ +var utils_8h = +[ + [ "concat_2str", "group__utils.html#ga22347cbf977a0300726f06257edd79d6", null ], + [ "concat_3str", "group__utils.html#ga123e40006d54612c48c2660432dfeb23", null ], + [ "concat_4str", "group__utils.html#ga69037999e65cdb42d39988e0fec48af4", null ], + [ "concat_5str", "group__utils.html#ga580d1897bc7a8cef16d5a16a2373b876", null ], + [ "concat_6str", "group__utils.html#ga34f8c2fcee597a99c5f4c66f2119bca9", null ], + [ "concat_7str", "group__utils.html#ga01d1ea65eb6780d91705484dd46833bf", null ], + [ "int2str", "group__utils.html#ga3c545b669dff7d67e5ed3c58233ccf4b", null ], + [ "int2nstr", "group__utils.html#ga858ece77e79fb78d3db0f1851bf7fe09", null ], + [ "long2str", "group__utils.html#ga69373a612a7b4d264371f727217f9954", null ], + [ "long2nstr", "group__utils.html#ga50cea1f8154c7c7d2abd68f1ddb33086", null ], + [ "perc2str", "group__utils.html#ga59cd66180162d107cf86a51c21d7e6f5", null ], + [ "length_vargs_string_list", "group__utils.html#ga7bffda236a079c26302722c7d155f7a5", null ], + [ "not_null", "group__utils.html#gadfa0375f8178c737deae23ffa8d152f4", null ], + [ "mem_alloc", "group__utils.html#gadce4d1c428f979bf1cf8e1582d2f4052", null ], + [ "mem_free", "group__utils.html#gabe60e8350f3e3b07ed5002ee3449a6ae", null ], + [ "string_clone", "group__utils.html#ga825354891d287cc86d2b4ed1b600175a", null ], + [ "string_num_lines", "group__utils.html#ga15630ddb64e977c8243892556feedfd8", null ], + [ "string_num_columns", "group__utils.html#ga0ca31b2a579b6ef7c75c41324ed5367c", null ], + [ "string_count_char", "group__utils.html#gad643e0fcac9e59c1a171c460633e8637", null ], + [ "string_starts_with", "group__utils.html#ga3ec2b60d1636397119c5e0c21987f791", null ], + [ "string_ends_with", "group__utils.html#ga1c5ba308f71c323fbbd7eb9bb34285d4", null ], + [ "string_concat", "group__utils.html#gaa23a827164f7039b9770379cbf008905", null ], + [ "random_boolean", "group__utils.html#gabe3e28fe49daaf3530e203c4aed1d15f", null ], + [ "random_int", "group__utils.html#gad7954e6a1b9ea073c7bc894dc5af85a9", null ], + [ "random_string", "group__utils.html#gaa820c93c2f719401b4b1ca54f6ea5c75", null ], + [ "clear_console", "group__utils.html#ga3cffe15b7e5d10a108f1734a9640a2c7", null ], + [ "move_cursor", "group__utils.html#gad3d324aed0ec686314cb0f68dfde9853", null ], + [ "hide_cursor", "group__utils.html#ga42702791e6da9510e4f44f33d2dad8f1", null ], + [ "show_cursor", "group__utils.html#ga1bdd62a6bef7cfd6522dc1412e162559", null ], + [ "string_list_length", "group__utils.html#gab8050db5b87bfdee91ee92e67b063478", null ], + [ "string_list_clone", "group__utils.html#ga41163cf3a95e702f12506cd54ba3c70c", null ], + [ "string_list_free", "group__utils.html#gaacf77b3345bbca43767b08ec0583fe3c", null ], + [ "int2nstring", "group__utils.html#ga824373ca8e0b2fdfe3f5c4805cf2ab7e", null ], + [ "percentage2string", "group__utils.html#gacf6edf10cb84412b6bfb431ef87b56d6", null ] +]; \ No newline at end of file diff --git a/3ano/1semestre/so/practice-exam/src/doc/html/utils_8h_source.html b/3ano/1semestre/so/practice-exam/src/doc/html/utils_8h_source.html new file mode 100644 index 0000000..822c7d0 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/doc/html/utils_8h_source.html @@ -0,0 +1,330 @@ + + + + + + + +C++ Library, mos@ua: utils.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    C++ Library, mos@ua +  0.9 +
    +
    cpplib-mos
    +
    +
    + + + + + + +
    +
    + +
    +
    +
    + +
    +
    +
    +
    utils.h
    +
    +
    +Go to the documentation of this file.
    1 
    +
    15 #ifndef UTILS_H
    +
    16 #define UTILS_H
    +
    17 
    +
    18 #include <stdio.h>
    +
    19 #include <string.h>
    +
    20 #include <errno.h>
    +
    21 #include "dbc.h"
    +
    22 
    +
    36 #define concat_2str(str1,str2) \
    +
    37  ({ \
    +
    38  char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \
    +
    39  char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \
    +
    40  char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+1); \
    +
    41  strcpy(__res__, s1); \
    +
    42  strcat(__res__, s2); \
    +
    43  __res__; \
    +
    44  })
    +
    45 
    +
    57 #define concat_3str(str1,str2,str3) \
    +
    58  ({ \
    +
    59  char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \
    +
    60  char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \
    +
    61  char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \
    +
    62  char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+1); \
    +
    63  strcpy(__res__, s1); \
    +
    64  strcat(__res__, s2); \
    +
    65  strcat(__res__, s3); \
    +
    66  __res__; \
    +
    67  })
    +
    68 
    +
    81 #define concat_4str(str1,str2,str3,str4) \
    +
    82  ({ \
    +
    83  char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \
    +
    84  char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \
    +
    85  char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \
    +
    86  char* s4 = (str4) == NULL ? (char*)"" : (char*)(str4); \
    +
    87  char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+strlen(s4)+1); \
    +
    88  strcpy(__res__, s1); \
    +
    89  strcat(__res__, s2); \
    +
    90  strcat(__res__, s3); \
    +
    91  strcat(__res__, s4); \
    +
    92  __res__; \
    +
    93  })
    +
    94 
    +
    108 #define concat_5str(str1,str2,str3,str4,str5) \
    +
    109  ({ \
    +
    110  char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \
    +
    111  char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \
    +
    112  char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \
    +
    113  char* s4 = (str4) == NULL ? (char*)"" : (char*)(str4); \
    +
    114  char* s5 = (str5) == NULL ? (char*)"" : (char*)(str5); \
    +
    115  char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+strlen(s4)+strlen(s5)+1); \
    +
    116  strcpy(__res__, s1); \
    +
    117  strcat(__res__, s2); \
    +
    118  strcat(__res__, s3); \
    +
    119  strcat(__res__, s4); \
    +
    120  strcat(__res__, s5); \
    +
    121  __res__; \
    +
    122  })
    +
    123 
    +
    138 #define concat_6str(str1,str2,str3,str4,str5,str6) \
    +
    139  ({ \
    +
    140  char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \
    +
    141  char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \
    +
    142  char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \
    +
    143  char* s4 = (str4) == NULL ? (char*)"" : (char*)(str4); \
    +
    144  char* s5 = (str5) == NULL ? (char*)"" : (char*)(str5); \
    +
    145  char* s6 = (str6) == NULL ? (char*)"" : (char*)(str6); \
    +
    146  char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+strlen(s4)+strlen(s5)+strlen(s6)+1); \
    +
    147  strcpy(__res__, s1); \
    +
    148  strcat(__res__, s2); \
    +
    149  strcat(__res__, s3); \
    +
    150  strcat(__res__, s4); \
    +
    151  strcat(__res__, s5); \
    +
    152  strcat(__res__, s6); \
    +
    153  __res__; \
    +
    154  })
    +
    155 
    +
    171 #define concat_7str(str1,str2,str3,str4,str5,str6,str7) \
    +
    172  ({ \
    +
    173  char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \
    +
    174  char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \
    +
    175  char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \
    +
    176  char* s4 = (str4) == NULL ? (char*)"" : (char*)(str4); \
    +
    177  char* s5 = (str5) == NULL ? (char*)"" : (char*)(str5); \
    +
    178  char* s6 = (str6) == NULL ? (char*)"" : (char*)(str6); \
    +
    179  char* s7 = (str7) == NULL ? (char*)"" : (char*)(str7); \
    +
    180  char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+strlen(s4)+strlen(s5)+strlen(s6)+strlen(s7)+1); \
    +
    181  strcpy(__res__, s1); \
    +
    182  strcat(__res__, s2); \
    +
    183  strcat(__res__, s3); \
    +
    184  strcat(__res__, s4); \
    +
    185  strcat(__res__, s5); \
    +
    186  strcat(__res__, s6); \
    +
    187  strcat(__res__, s7); \
    +
    188  __res__; \
    +
    189  })
    +
    190 
    +
    199 #define int2str(num) \
    +
    200  ({ \
    +
    201  char* __res__ = (char*)alloca(numDigits((int)num)+1); \
    +
    202  sprintf(__res__, "%d", (int)num); \
    +
    203  __res__; \
    +
    204  })
    +
    205 
    +
    220 #define int2nstr(num, len) \
    +
    221  ({ \
    +
    222  require (len > 0, concat_3str("invalid length value (", int2str(len), ")")); \
    +
    223  int d = numDigits((int)num); \
    +
    224  if (len > d) \
    +
    225  d = len; \
    +
    226  char* __res__ = (char*)alloca(d+1); \
    +
    227  sprintf(__res__, "%0*d", d, (int)num); \
    +
    228  __res__; \
    +
    229  })
    +
    230 
    +
    238 #define long2str(num) \
    +
    239  ({ \
    +
    240  char* __res__ = (char*)alloca(numDigits((long)num)+1); \
    +
    241  sprintf(__res__, "%ld", (long)num); \
    +
    242  __res__; \
    +
    243  })
    +
    244 
    +
    259 #define long2nstr(num, len) \
    +
    260  ({ \
    +
    261  require (len > 0, concat_3str("invalid length value (", int2str(len), ")")); \
    +
    262  int d = numDigits((int)num); \
    +
    263  if (len > d) \
    +
    264  d = len; \
    +
    265  char* __res__ = (char*)alloca(d+1); \
    +
    266  sprintf(__res__, "%0*ld", d, (long)num); \
    +
    267  __res__; \
    +
    268  })
    +
    269 
    +
    281 #define perc2str(percentage) \
    +
    282  ({ \
    +
    283  require (percentage >= 0 && percentage <= 100, concat_3str("invalid percentage value (", int2str(percentage), ")")); \
    +
    284  char* __res__ = (char*)alloca(4+1); \
    +
    285  sprintf(__res__, "%3d%%", (int)percentage); \
    +
    286  __res__; \
    +
    287  })
    +
    288 
    +
    296 #define length_vargs_string_list(first) \
    +
    297  ({ \
    +
    298  int __res__ = 0; \
    +
    299  va_list ap; \
    +
    300  va_start(ap, first); \
    +
    301  char* t = first; \
    +
    302  while (t != NULL) \
    +
    303  { \
    +
    304  __res__ += strlen(t); \
    +
    305  t = va_arg(ap, char*); \
    +
    306  } \
    +
    307  va_end(ap); \
    +
    308  __res__; \
    +
    309  })
    +
    310 
    +
    311 #if defined __cplusplus && defined EXCEPTION_POLICY
    +
    312 #define not_null(pnt) \
    +
    313  ({ \
    +
    314  if ((pnt) == NULL) \
    +
    315  throw string_concat(NULL, 0, (char*)"Null pointer error", (char*)", pointer: \"", #pnt, (char*)"\", function: \"", __FUNCTION__, (char*)"\":", int2str(__LINE__), (char*)", file: \"", __FILE__, (char*)"\"\n", NULL); \
    +
    316  pnt; \
    +
    317  })
    +
    318 #else
    +
    319 
    +
    336 #define not_null(pnt) \
    +
    337  ({ \
    +
    338  if ((pnt) == NULL) \
    +
    339  { \
    +
    340  fprintf (stderr, "Null pointer error, pointer: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \
    +
    341  #pnt, __FUNCTION__, __LINE__ , __FILE__); \
    +
    342  *((int*)0) = 0; \
    +
    343  abort (); \
    +
    344  } \
    +
    345  pnt; \
    +
    346  })
    +
    347 #endif
    +
    348 
    +
    367 void* mem_alloc(int size);
    +
    368 
    +
    378 void mem_free(void* pnt);
    +
    379 
    +
    393 char* string_clone(char* str);
    +
    394 
    +
    406 int string_num_lines(char* text);
    +
    407 
    +
    419 int string_num_columns(char* text);
    +
    420 
    +
    434 int string_count_char(char* text, char* ch);
    +
    435 
    +
    449 int string_starts_with(char* text, char* prefix);
    +
    450 
    +
    464 int string_ends_with(char* text, char* suffix);
    +
    465 
    +
    487 char* string_concat(char* res, int max_length, char* text, ...);
    +
    488 
    +
    504 int random_boolean(int trueProb);
    +
    505 
    +
    521 int random_int(int min, int max);
    +
    522 
    +
    541 char* random_string(char** list, int* used, int length);
    +
    542 
    +
    546 void clear_console();
    +
    547 
    +
    558 void move_cursor(int line,int column);
    +
    559 
    +
    563 void hide_cursor();
    +
    564 
    +
    568 void show_cursor();
    +
    569 
    +
    581 int string_list_length(char** list);
    +
    582 
    +
    596 char** string_list_clone(char** list);
    +
    597 
    +
    611 char** string_list_free(char** list);
    +
    612 
    +
    613 int numDigits(int num);
    +
    614 
    +
    632 char* int2nstring(char* res, int num, int len);
    +
    633 
    +
    649 char* percentage2string(char* res, int percentage);
    +
    650 
    +
    651 #endif
    +
    652 
    +
    653 /* ************************************************** */
    +
    657 /* ************************************************** */
    +
    658 
    +
    +
    +
    int random_int(int min, int max)
    Generates a random integer value within a given interval.
    +
    int string_list_length(char **list)
    Number of elements of a NULL terminated list of strings.
    +
    char * string_clone(char *str)
    Replicates a string.
    +
    Design-by-Contract module.
    +
    void mem_free(void *pnt)
    A replacement for free function.
    +
    int string_ends_with(char *text, char *suffix)
    Tests if a string ends with a suffix.
    +
    char ** string_list_free(char **list)
    Frees the memory allocated to a NULL terminated list of strings.
    +
    int string_count_char(char *text, char *ch)
    Counts the number of occurrences of an UTF8 character in a text.
    +
    void show_cursor()
    Shows the terminal cursor.
    +
    char * percentage2string(char *res, int percentage)
    Converts an int percentage to a string.
    +
    int random_boolean(int trueProb)
    Generates a random boolean value.
    +
    int string_num_lines(char *text)
    Number of lines of a string.
    +
    void clear_console()
    Clears the terminal.
    +
    int string_starts_with(char *text, char *prefix)
    Tests if a string starts with a prefix.
    +
    void * mem_alloc(int size)
    A replacement for malloc function.
    +
    void move_cursor(int line, int column)
    Moves the cursor to a position in terminal.
    +
    char * random_string(char **list, int *used, int length)
    Returns a random string from a given string list.
    +
    char * int2nstring(char *res, int num, int len)
    Converts an int value to a string.
    +
    char * string_concat(char *res, int max_length, char *text,...)
    Concatenates a NULL terminated list of string arguments.
    +
    char ** string_list_clone(char **list)
    Replicates a NULL terminated list of strings.
    +
    int string_num_columns(char *text)
    Maximum number of columns of a string (not counting character ‘’\n'`).
    +
    void hide_cursor()
    Hides the terminal cursor.
    + + + + diff --git a/3ano/1semestre/so/practice-exam/src/include/dbc.h b/3ano/1semestre/so/practice-exam/src/include/dbc.h new file mode 100644 index 0000000..83bfcc9 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/include/dbc.h @@ -0,0 +1,186 @@ +/** + * \defgroup DbC DbC + * \ingroup concurrency-library + * \brief Design-by-Contract module. + * + * \details This module gives a better support for DbC in C++. + * + * When compared with `assert.h` this module offers the following functionalities: + * - separates different assertion types (preconditions, postconditions, invariants, and others); + * - augments assert with error message strings; + * - implements two error handling policies: + * -# EXIT_POLICY (default): describes the failed assertion in `stderr` (with the identification + * and the precise location of the assertion), generates a segmentation fault + * (enabling a stack trace within a debugger like `gdb`), and exits program execution; + * -# EXCEPTION_POLICY: throws a `char*` exception with the description of the failed assertion. + * + * Debug settings: + * - As happens with `assert.h`, this module accepts `NDEBUG` macro definition to disable all + * assertion run-time verification. + * - Also, each assertion type verification can be disabled with macros: `NDEBUG_CHECKS`, + * `NDEBUG_PRECONDITIONS`, `NDEBUG_POSTCONDITIONS`, and `NDEBUG_INVARIANTS`. + * - A special (high priority) macro named `DEBUG_ONLY_PRECONDITIONS` ensures that only precondition + * debugging remains active (regardless of other debug definitions). + * + * \author Miguel Oliveira e Silva, 2018 + * @{ + **/ + +/*! + * \file + * \brief Design-by-Contract module. + */ + +#ifndef DBC_H +#define DBC_H + +#include +#include +#include +#include "utils.h" + +#ifdef NDEBUG +#define NDEBUG_CHECKS +#define NDEBUG_PRECONDITIONS +#define NDEBUG_POSTCONDITIONS +#define NDEBUG_INVARIANTS +#endif + +#ifdef DEBUG_ONLY_PRECONDITIONS +#ifdef NDEBUG_PRECONDITIONS +#undef NDEBUG_PRECONDITIONS +#endif +#ifndef NDEBUG_CHECKS +#define NDEBUG_CHECKS +#endif +#ifndef NDEBUG_POSTCONDITIONS +#define NDEBUG_POSTCONDITIONS +#endif +#ifndef NDEBUG_INVARIANTS +#define NDEBUG_INVARIANTS +#endif +#endif + +// check: +#ifdef NDEBUG_CHECKS +#define check(condition, message) +#else +#if defined __cplusplus && defined EXCEPTION_POLICY +#define check(condition, message) \ + if (!(condition)) \ + throw string_concat(NULL, 0, (char*)"Assertion fail", message[0] ? (char*)": " : (char*)"", message, (char*)", assertion: \"", #condition, (char*)"\", function: \"", __FUNCTION__, (char*)"\":", int2str(__LINE__), (char*)", file: \"", __FILE__, (char*)"\"\n", NULL) +#else // EXIT_POLICY (default) +/** + * \brief Checks the verification of an general algorithm assertion. + * + * \details This assertion verification can be disabled at compile time by defining the macro `NDEBUG_CHECKS`. + * + * \param [in] condition expression to assert its truthness + * \param [in] message text to be presented with error information when the assertion fails + */ +#define check(condition, message) \ + if (!(condition)) \ + do { \ + fprintf (stderr, "Assertion fail%s%s, assertion: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \ + message[0] ? ": " : "", message, #condition, __FUNCTION__, __LINE__ , __FILE__); \ + *((int*)0) = 0; \ + abort (); \ + } while (0) +#endif +#endif + + +// precondition: +#ifdef NDEBUG_PRECONDITIONS +#define require(condition, message) +#else +#if defined __cplusplus && defined EXCEPTION_POLICY +#define require(condition, message) \ + if (!(condition)) \ + throw string_concat(NULL, 0, (char*)"Precondition fail", message[0] ? (char*)": " : (char*)"", message, (char*)", assertion: \"", #condition, (char*)"\", function: \"", __FUNCTION__, (char*)"\":", int2str(__LINE__), (char*)", file: \"", __FILE__, (char*)"\"\n", NULL) +#else // EXIT_POLICY (default) +/** + * \brief Checks the verification of a precondition. + * + * \details This assertion verification can be disabled at compile time by defining the macro `NDEBUG_PRECONDITIONS`. + * + * \param [in] condition expression to assert its truthness + * \param [in] message text to be presented with error information when the assertion fails + */ +#define require(condition, message) \ + if (!(condition)) \ + do { \ + fprintf (stderr, "Precondition fail%s%s, assertion: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \ + message[0] ? ": " : "", message, #condition, __FUNCTION__, __LINE__ , __FILE__); \ + *((int*)0) = 0; \ + abort (); \ + } while (0) +#endif +#endif + + +// postcondition: +#ifdef NDEBUG_POSTCONDITIONS +#define ensure(condition, message) +#else +#if defined __cplusplus && defined EXCEPTION_POLICY +#define ensure(condition, message) \ + if (!(condition)) \ + throw string_concat(NULL, 0, (char*)"Postcondition fail", message[0] ? (char*)": " : (char*)"", message, (char*)", assertion: \"", #condition, (char*)"\", function: \"", __FUNCTION__, (char*)"\":", int2str(__LINE__), (char*)", file: \"", __FILE__, (char*)"\"\n", NULL) +#else // EXIT_POLICY (default) +/** + * \brief Checks the verification of a postcondition. + * + * \details This assertion verification can be disabled at compile time by defining the macro `NDEBUG_POSTCONDITIONS`. + * + * \param [in] condition expression to assert its truthness + * \param [in] message text to be presented with error information when the assertion fails + */ +#define ensure(condition, message) \ + if (!(condition)) \ + do { \ + fprintf (stderr, "Postcondition fail%s%s, assertion: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \ + message[0] ? ": " : "", message, #condition, __FUNCTION__, __LINE__ , __FILE__); \ + *((int*)0) = 0; \ + abort (); \ + } while (0) +#endif +#endif + +// +// invariant: +#ifdef NDEBUG_INVARIANTS +#define invariant(condition, message) +#else +#if defined __cplusplus && defined EXCEPTION_POLICY +#define invariant(condition, message) \ + if (!(condition)) \ + throw string_concat(NULL, 0, (char*)"Invariant fail", message[0] ? (char*)": " : (char*)"", message, (char*)", assertion: \"", #condition, (char*)"\", function: \"", __FUNCTION__, (char*)"\":", int2str(__LINE__), (char*)", file: \"", __FILE__, (char*)"\"\n", NULL) +#else // EXIT_POLICY (default) +/** + * \brief Checks the verification of an invariant. + * + * \details This assertion verification can be disabled at compile time by defining the macro `NDEBUG_INVARIANTS`. + * + * \param [in] condition expression to assert its truthness + * \param [in] message text to be presented with error information when the assertion fails + */ +#define invariant(condition, message) \ + if (!(condition)) \ + do { \ + fprintf (stderr, "Invariant fail%s%s, assertion: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \ + message[0] ? ": " : "", message, #condition, __FUNCTION__, __LINE__ , __FILE__); \ + *((int*)0) = 0; \ + abort (); \ + } while (0) +#endif +#endif + +#endif + +/* ************************************************** */ +/** + * @} close group DbC + **/ +/* ************************************************** */ + diff --git a/3ano/1semestre/so/practice-exam/src/include/process.h b/3ano/1semestre/so/practice-exam/src/include/process.h new file mode 100644 index 0000000..9f236ef --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/include/process.h @@ -0,0 +1,531 @@ +/** + * \defgroup process process + * \ingroup concurrency-library + * + * \brief \ref process "Process", \ref sysV "System-V", and \ref posix_sem "POSIX libraries" wrapper module. + * + * \details This module removes defensive programming approach of native libraries. + * + * All implemented functions, have exactly the same arguments and/or result of the original function, + * with the exception of returning an error indication. + * + * Errors are handled by the implementation of two policies: + * -# EXIT_POLICY (default): describes the failed call in `stderr` (with the identification + * of the errno error, and the precise location the call), generates a segmentation fault + * (enabling a stack trace within a debugger like `gdb`), and exits program execution; + * -# EXCEPTION_POLICY: throws a `int` exception with the (errno) status error returned by the original function. + * + *

    System V group of IPC mechanisms + * + * @anchor sysV + * + * There are three resources for IPC: \ref shm "shared memory", \ref sem "semaphores", and \ref msg "message queues". + * + * Common to all, is resource handling through a non-negative integer identifier. + * After proper creation and initialization, different processes can establish communication + * using the same integer identifier. + * + * A key (`key_t`) is used to establish this common identifier. + * There are three possibilities to define a key: + * + * 1. `IPC_PRIVATE`: In this case an alternative channel to communicate the identifier + * between processes is necessary (parent/child fork, file system, ...). + * + * 2. A fixed predetermined key number (may collide with other existing keys). + * + * 3. `ftok` function to generate a key from a path and a byte integer. + * + * Usage: + * + * - create new identifier: `msgget`/`semget`/`shmget` with a key and `IPC_CREAT` and `IPC_EXCL` flags + * - get existing identifier: `msgget`/`semget`/`shmget` with a key and other arguments as zero + * + * \author Miguel Oliveira e Silva, 2017-2018 + * @{ + **/ + +/*! + * \file + * + * \brief \ref process "Process", \ref sysV "System-V", and \ref posix_sem "POSIX libraries" wrapper module. + * \remarks Removes defensive programming from native libraries + **/ + +#ifndef PROCESS_H +#define PROCESS_H + +#include +#include +#include +#include +#include +#include +#include + +//#define EXCEPTION_POLICY +//#define EXIT_POLICY // DEFAULT + + +/** @name Process handling + * @anchor process @{ + */ + +/** + * \brief `fork` wrapper function. + * + * \details Other documentation in @verbatim man 2 fork @endverbatim + * + * @see https://man.cx/fork(2) + */ +pid_t pfork(void); + +/** + * \brief `wait` wrapper function. + * + * \details Other documentation in @verbatim man 2 wait @endverbatim + * + * @see https://man.cx/wait(2) + */ +pid_t pwait(int *status); + +/** + * \brief `waitpid` wrapper function. + * + * \details Other documentation in @verbatim man 2 waitpid @endverbatim + * + * @see https://man.cx/waitpid(2) + */ +pid_t pwaitpid(pid_t pid, int *status, int options); + +/** + * \brief `kill` wrapper function. + * + * \details Other documentation in @verbatim man 2 kill @endverbatim + * + * @see https://man.cx/kill(2) + */ +void pkill(pid_t pid, int sig); + +/** + * \brief `execl` wrapper function. + * + * \details Other documentation in @verbatim man 3 execl @endverbatim + * + * @see https://man.cx/execl(3) + */ +void pexecl(const char *pathname, const char *arg, ... /* (char *) NULL */); + +/** + * \brief `sigaction` wrapper function. + * + * \details Other documentation in @verbatim man 2 sigaction @endverbatim + * + * @see https://man.cx/sigaction(2) + */ +void psigaction(int signum, const struct sigaction *act, struct sigaction *oldact); + +/** @} */ + + +/** @name System V - shared memory + * @anchor shm + * + * \par Example + * @code + #include // #include + ... + int shmid; + // creation: + shmid = pshmget(key, size, 0600 | IPC_CREAT | IPC_EXCL); + // or, use existing: + shmid = pshmget(key, 0, 0); + ... + // attach shm to pointer address: + void* p = pshmat(shmid, NULL, 0); + ... + // detach shm from pointer address: + pshmdt(p); + ... + // destroy shm: + pshmctl(shmid, IPC_RMID, NULL); + @endcode + * + * @{ + */ + +/** + * \brief `shmget` wrapper function. + * + *

    Precondition:
    + *
    (size > 0) || !(shmflg & IPC_CREAT)
    + *
    + * + * \details Other documentation in @verbatim man 2 shmget @endverbatim + * + * @see https://man.cx/shmget(2) + */ +int pshmget(key_t key, size_t size, int shmflg); + +/** + * \brief `shmctl` wrapper function. + * + * \details Other documentation in @verbatim man 2 shmctl @endverbatim + * + * @see https://man.cx/shmctl(2) + */ +int pshmctl(int shmid, int cmd, struct shmid_ds *buf); + +/** + * \brief `shmat` wrapper function. + * + * \details Other documentation in @verbatim man 2 shmat @endverbatim + * + * @see https://man.cx/shmat(2) + */ +void *pshmat(int shmid, const void *shmaddr, int shmflg); + +/** + * \brief `shmdt` wrapper function. + * + * \details Other documentation in @verbatim man 2 shmdt @endverbatim + * + * @see https://man.cx/shmdt(2) + */ +void pshmdt(const void *shmaddr); + +/** @} */ + + +/** @name System V - semaphores + * @anchor sem + * + * \par Example + * @code + #include // #include + ... + int semid; + // creation: + semid = psemget(key, 1, 0600 | IPC_CREAT | IPC_EXCL); // 1 semaphore! + // or, use existing: + semid = psemget(key, 0, 0); + ... + // decrement: + struct sembuf down = {0, -1, 0}; + psemop(semid, &down, 1); + // or, simply use provided function: + psem_down(semid, 0); // NOTE: there is no sem_down in default library! + ... + // increment: + struct sembuf up = {0, 1, 0}; + psemop(semid, &up, 1); + // or, simply use provided function: + psem_up(semid, 0); // NOTE: there is no sem_up in default library! + ... + // destroy sem 0: + psemctl(semid, 0, IPC_RMID, NULL); + @endcode + * + * @{ + */ + +/** + * \brief `semget` wrapper function. + * + *
    Precondition:
    + *
    nsems > 0
    + *
    + * + * \details Other documentation in @verbatim man 2 semget @endverbatim + * + * @see https://man.cx/semget(2) + */ +int psemget(key_t key, int nsems, int semflg); + +/** + * \brief `semctl` wrapper function. + * + * \details Other documentation in @verbatim man 2 semctl @endverbatim + * + * @see https://man.cx/semctl(2) + */ +int psemctl(int semid, int semnum, int cmd); +int psemctl(int semid, int semnum, int cmd, void *u); + +/** + * \brief `semop` wrapper function. + * + * \details Other documentation in @verbatim man 2 semop @endverbatim + * + * @see https://man.cx/semop(2) + */ +void psemop(int semid, struct sembuf *sops, size_t nsops); + +/** + * \brief Increment a semaphore (uses psemop()). + */ +void psem_up(int semid, short unsigned int index); + +/** + * \brief Decrements a semaphore (uses psemop()). + */ +void psem_down(int semid, short unsigned int index); + +/** + * \brief Decrements atomically two semaphores in a System V semaphore array (uses psemop()). + */ +void psem_down2(int semid, short unsigned int index1, unsigned int index2); + +/** @} */ + + +/** @name System V - message queues + * @anchor msg + * + * \par Example + * @code + #include // #include + ... + typedef struct Item + { + ... + } Item; + typedef struct Message + { + long type; + Item item; + } Message; + ... + int msgid; + // creation: + msgid = pmsgget(key, 0600 | IPC_CREAT | IPC_EXCL); + // or, use existing: + msgid = pmsgget(key, 0); + ... + Message msg; + // send msg: + msg = ...; + pmsgsnd(msgid, &msg, sizeof(Item), 0); + ... + // receive msg: + pmsgrcv(msgid, &msg, sizeof(Item), type, 0); + ... + // destroy msg: + pmsgctl(msgid, IPC_RMID, NULL); + @endcode + * + * @{ + */ + +/** + * \brief `msgget` wrapper function. + * + * \details Other documentation in @verbatim man 2 msgget @endverbatim + * + * @see https://man.cx/msgget(2) + */ +int pmsgget(key_t key, int msgflg); + +/** + * \brief `msgctl` wrapper function. + * + * \details Other documentation in @verbatim man 2 msgctl @endverbatim + * + * @see https://man.cx/msgctl(2) + */ +int pmsgctl(int msqid, int cmd, struct msqid_ds *buf); + +/** + * \brief `msgsnd` wrapper function. + * + * \details Other documentation in @verbatim man 2 msgsnd @endverbatim + * + * @see https://man.cx/msgsnd(2) + */ +void pmsgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); + +/** + * \brief `msgrcv` wrapper function. + * + * \details Other documentation in @verbatim man 2 msgrcv @endverbatim + * + * @see https://man.cx/msgrcv(2) + */ +size_t pmsgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); + +/** @} */ + + +/** @name POSIX semaphores + * @anchor posix_sem @{ + */ + +// named: +/** + * \brief `sem_open` wrapper function. + * + * \details Other documentation in @verbatim man 3 sem_open @endverbatim + * + * @see https://man.cx/sem_open(3) + */ +sem_t *psem_open(const char *name, int oflag); +sem_t *psem_open(const char *name, int oflag, mode_t mode, unsigned int value); + +/** + * \brief `sem_close` wrapper function. + * + *
    Precondition:
    + *
    sem != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 sem_close @endverbatim + * + * @see https://man.cx/sem_close(3) + */ +void psem_close(sem_t *sem); + +/** + * \brief `sem_unlink` wrapper function. + * + * \details Other documentation in @verbatim man 3 sem_unlink @endverbatim + * + * @see https://man.cx/sem_unlink(3) + */ +void psem_unlink(const char *name); + +// unnamed: +/** + * \brief `sem_init` wrapper function. + * + *
    Precondition:
    + *
    sem != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 sem_init @endverbatim + * + * @see https://man.cx/sem_init(3) + */ +void psem_init(sem_t *sem, int pshared, unsigned int value); + +/** + * \brief `sem_destroy` wrapper function. + * + *
    Precondition:
    + *
    sem != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 sem_destroy @endverbatim + * + * @see https://man.cx/sem_destroy(3) + */ +void psem_destroy(sem_t *sem); + +// named and unnamed: +/** + * \brief `sem_wait` wrapper function. + * + *
    Precondition:
    + *
    sem != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 sem_wait @endverbatim + * + * @see https://man.cx/sem_wait(3) + */ +void psem_wait(sem_t *sem); + +/** + * \brief `sem_trywait` wrapper function. + * + *
    Precondition:
    + *
    sem != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 sem_trywait @endverbatim + * + * @see https://man.cx/sem_trywait(3) + * + * \return true (`!=0`) on success, false (`0`) if semaphore is zero + */ +int psem_trywait(sem_t *sem); + +/** + * \brief `sem_timedwait` wrapper function. + * + *
    Precondition:
    + *
    sem != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 sem_timedwait @endverbatim + * + * @see https://man.cx/sem_timedwait(3) + * + * \return true (`!=0`) on success, false (`0`) if timeout has expired before being able to decrement the semaphore + */ +int psem_timedwait(sem_t *sem, const struct timespec *abs_timeout); + +/** + * \brief `sem_post` wrapper function. + * + *
    Precondition:
    + *
    sem != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 sem_post @endverbatim + * + * @see https://man.cx/sem_post(3) + */ +void psem_post(sem_t *sem); + +/** @} */ + +/** @name UNIX pipes + * @anchor pipes @{ + */ + +/** + * \brief `pipe` wrapper function. + * + * \details Other documentation in @verbatim man 3 pipe @endverbatim + * + * @see https://man.cx/pipe + */ +void ppipe(int pipefd[2]); + +/** + * \brief `popen` wrapper function. + * + *
    Precondition:
    + *
    command != NULL
    + *
    type != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 popen @endverbatim + * + * @see https://man.cx/popen + */ +FILE *ppopen(const char *command, const char *type); + +/** + * \brief `pclose` wrapper function. + * + *
    Precondition:
    + *
    stream != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pclose @endverbatim + * + * @see https://man.cx/pclose + */ +void ppclose(FILE *stream); + +/** @} */ + + +#endif + +/* ************************************************** */ +/** + * @} close group process + **/ +/* ************************************************** */ + diff --git a/3ano/1semestre/so/practice-exam/src/include/thread.h b/3ano/1semestre/so/practice-exam/src/include/thread.h new file mode 100644 index 0000000..64ea295 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/include/thread.h @@ -0,0 +1,665 @@ +/** + * \defgroup thread thread + * \ingroup concurrency-library + * \brief POSIX threads library wrapper module. + * + * \details This module removes defensive programming approach of native POSIX threads library. + * + * All implemented functions, have exactly the same arguments and/or result of the original function, + * with the exception of returning an error indication. + * + * Errors are handled by the implementation of two policies: + * -# EXIT_POLICY (default): describes the failed call in `stderr` (with the identification + * of the errno error, and the precise location the call), generates a segmentation fault + * (enabling a stack trace within a debugger like `gdb`), and exits program execution; + * -# EXCEPTION_POLICY: throws a `int` exception with the (errno) status error returned by the original function. + * + * \author Miguel Oliveira e Silva, 2017-2018 + * + * @{ + **/ +/*! + * \file + * + * \brief POSIX threads library wrapper module. + * \remarks Removes defensive programming from native libraries + **/ + +#ifndef THREAD_H +#define THREAD_H + +#include + +//#define EXCEPTION_POLICY +//#define EXIT_POLICY // DEFAULT + +/** @name Thread handling + * + * @details + * + * Variable type: `pthread_t` + * + * @anchor thread @{ + */ + +/** + * \brief `pthread_equal` wrapper function. + * + * \details Other documentation in @verbatim man 3 pthread_equal @endverbatim + * + * @see https://man.cx/pthread_equal(3) + */ +int thread_equal(pthread_t t1, pthread_t t2); + +/** + * \brief `pthread_create` wrapper function. + * + *
    Precondition:
    + *
    t != NULL

    + *
    thread_main != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_create @endverbatim + * + * @see https://man.cx/pthread_create(3) + */ +void thread_create(pthread_t* t, pthread_attr_t* attr, void *(*thread_main)(void*), void* arg); + +/** + * \brief `pthread_self` wrapper function. + * + * \details Other documentation in @verbatim man 3 pthread_self @endverbatim + * + * @see https://man.cx/pthread_self(3) + */ +pthread_t thread_self(); + +/** + * \brief `sched_yield` wrapper function. + * + * \details Other documentation in @verbatim man 3 sched_yield @endverbatim + * + * @see https://man.cx/sched_yield(3) + */ +void thread_sched_yield(void); + +/** + * \brief `pthread_exit` wrapper function. + * + * \details Other documentation in @verbatim man 3 pthread_exit @endverbatim + * + * @see https://man.cx/pthread_exit(3) + */ +void thread_exit(void *retval); + +/** + * \brief `pthread_detach` wrapper function. + * + * \details Other documentation in @verbatim man 3 pthread_detach @endverbatim + * + * @see https://man.cx/pthread_detach(3) + */ +void thread_detach(pthread_t thread); + +/** + * \brief `pthread_join` wrapper function. + * + * \details Other documentation in @verbatim man 3 pthread_join @endverbatim + * + * @see https://man.cx/pthread_join(3) + */ +void thread_join(pthread_t t, void** result); + +/** @} */ + + +/** @name Mutexes + * + * @details + * + * Variable type: `pthread_mutex_t` + * + * Initialization of mutexes can be static or dynamic. + * + * In static initialization the following initialization macros are suggested: + * - `PTHREAD_MUTEX_INITIALIZER` - standard initializer + * - `PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP` - initializer that ensures error checking + * - `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP` - for recursive mutexes (note that recursive mutexes should be avoid) + * + * Dynamic initialization is done by mutex_init() and mutex_destroy(). + * + * @anchor mutex @{ + */ + +/** + * \brief `pthread_mutex_init` wrapper function. + * + *
    Precondition:
    + *
    pmtx != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_mutex_init @endverbatim + * + * @see https://man.cx/pthread_mutex_init(3) + */ +void mutex_init(pthread_mutex_t* pmtx, pthread_mutexattr_t* attr); + +/** + * \brief `pthread_mutex_destroy` wrapper function. + * + *
    Precondition:
    + *
    pmtx != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_mutex_destroy @endverbatim + * + * @see https://man.cx/pthread_mutex_destroy(3) + */ +void mutex_destroy(pthread_mutex_t* pmtx); + +/** + * \brief `pthread_mutex_lock` wrapper function. + * + *
    Precondition:
    + *
    pmtx != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_mutex_lock @endverbatim + * + * @see https://man.cx/pthread_mutex_lock(3) + */ +void mutex_lock(pthread_mutex_t* pmtx); + +/** + * \brief `pthread_mutex_trylock` wrapper function. + * + *
    Precondition:
    + *
    pmtx != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_mutex_trylock @endverbatim + * + * @see https://man.cx/pthread_mutex_trylock(3) + * + * \return true (`!=0`) if lock succeeds, false (`0`) otherwise + */ +int mutex_trylock(pthread_mutex_t* pmtx); + +/** + * \brief `pthread_mutex_unlock` wrapper function. + * + *
    Precondition:
    + *
    pmtx != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_mutex_unlock @endverbatim + * + * @see https://man.cx/pthread_mutex_unlock(3) + */ +void mutex_unlock(pthread_mutex_t* pmtx); + +/** @} */ + + +/** @name Condition variables + * + * @details + * + * Variable type: `pthread_cond_t` + * + * Initialization of condition variables can be static or dynamic. + * + * In static initialization the following initialization macros should be used: + * - `PTHREAD_COND_INITIALIZER` - standard initializer + * + * Dynamic initialization is done by cond_init() and cond_destroy(). + * + * @anchor cvar @{ + */ + +/** + * \brief `pthread_cond_init` wrapper function. + * + *
    Precondition:
    + *
    pcvar != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_cond_init @endverbatim + * + * @see https://man.cx/pthread_cond_init(3) + */ +void cond_init(pthread_cond_t* pcvar, pthread_condattr_t* attr); + +/** + * \brief `pthread_cond_destroy` wrapper function. + * + *
    Precondition:
    + *
    pcvar != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_cond_destroy @endverbatim + * + * @see https://man.cx/pthread_cond_destroy(3) + */ +void cond_destroy(pthread_cond_t* pcvar); + +/** + * \brief `pthread_cond_wait` wrapper function. + * + *
    Precondition:
    + *
    pcvar != NULL

    + *
    pmtx != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_cond_wait @endverbatim + * + * @see https://man.cx/pthread_cond_wait(3) + */ +void cond_wait(pthread_cond_t* pcvar, pthread_mutex_t* pmtx); + +/** + * \brief `pthread_cond_timedwait` wrapper function. + * + *
    Precondition:
    + *
    pcvar != NULL

    + *
    pmtx != NULL

    + *
    abstime != NULL
    + *
    + * + * \return true (`!=0`) if condition variable was signaled, false (`0`) it time out has expired. + * + * \details Other documentation in @verbatim man 3 pthread_cond_timedwait @endverbatim + * + * @see https://man.cx/pthread_cond_wait(3) + */ +int cond_timedwait(pthread_cond_t* pcvar, pthread_mutex_t* pmtx, const struct timespec *abstime); + +/** + * \brief `pthread_cond_timedwait` wrapper function accepting relative time (in microseconds) instead of absolute time. + * + *
    Precondition:
    + *
    pcvar != NULL

    + *
    pmtx != NULL

    + *
    relative_time_us > 0L
    + *
    + * + * \return true (`!=0`) if condition variable was signaled, false (`0`) it time out has expired. + * + * \details Documentation in @verbatim man 3 pthread_cond_timedwait @endverbatim + * + * @see https://man.cx/pthread_cond_wait(3) + */ +int cond_timedwait(pthread_cond_t* pcvar, pthread_mutex_t* pmtx, long relative_time_us); + +/** + * \brief `pthread_cond_signal` wrapper function. + * + *
    Precondition:
    + *
    pcvar != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_cond_signal @endverbatim + * + * @see https://man.cx/pthread_cond_signal(3) + */ +void cond_signal(pthread_cond_t* pcvar); + +/** + * \brief `pthread_cond_broadcast` wrapper function. + * + *
    Precondition:
    + *
    pcvar != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_cond_broadcast @endverbatim + * + * @see https://man.cx/pthread_cond_broadcast(3) + */ +void cond_broadcast(pthread_cond_t* pcvar); + +/** @} */ + + +/** @name One-time initialization + * + * @details + * + * Variable type: `pthread_once_t` + * + * POSIX thread library support a mechanism that ensures a one-time execution of a function. + * It does it through `pthread_once_t` variables, and by passing a callback function + * (in C/C++ is simply a function pointer). + * + * \par Example + * @verbatim + void once_init_routine(void) { ... } + ... + pthread_once_t once_control = PTHREAD_ONCE_INIT; + thread_once(&once_control, &once_init_routine); // one time execution over pthread_once_t + // variable is guaranteed, regardless of the + // number of threads that execute over that + // variable. + @endverbatim + * + * @anchor thread_once @{ + */ + +/** + * \brief `pthread_once` wrapper function. + * + *
    Precondition:
    + *
    once_control != NULL

    + *
    init_routine != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_once @endverbatim + * + * @see https://man.cx/pthread_once(3) + */ +void thread_once(pthread_once_t *once_control, void (*init_routine) (void)); + +/** @} */ + + +/** @name Thread-specific data + * + * @details + * + * Variable type: `pthread_key_t` + * + * Thread-specific data allows the definition of variable whose scope is limited to each thread. + * In practice, we will have a common variable, with a common access, but with different values for each thread. + * + * @anchor thread_specific @{ + */ + +/** + * \brief `pthread_key_create` wrapper function. + * + * \details This function should be executed once for each key (use thread_once()). + * + *
    Precondition:
    + *
    key != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_key_create @endverbatim + * + * @see https://man.cx/pthread_key_create(3) + */ +void thread_key_create(pthread_key_t *key, void (*destr_function) (void *)); + +/** + * \brief `pthread_key_delete` wrapper function. + * + * \details This function should be executed once for each key (use thread_once()). + * + *
    Precondition:
    + *
    key != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_key_delete @endverbatim + * + * @see https://man.cx/pthread_key_delete(3) + */ +void thread_key_delete(pthread_key_t key); + +/** + * \brief `pthread_setspecific` wrapper function. + * + *
    Precondition:
    + *
    pointer != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_setspecific @endverbatim + * + * @see https://man.cx/pthread_setspecific(3) + */ +void thread_setspecific(pthread_key_t key, void* pointer); + +/** + * \brief `pthread_getspecific` wrapper function. + * + *
    Precondition:
    + *
    key != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_getspecific @endverbatim + * + * @see https://man.cx/pthread_getspecific(3) + */ +void* thread_getspecific(pthread_key_t key); + +/** @} */ + + +/** @name Mutex attributes + * + * @details + * + * Variable type: `pthread_mutexattr_t` + * + * @anchor mutex_attr @{ + */ + +/** + * \brief `pthread_mutexattr_init` wrapper function. + * + *
    Precondition:
    + *
    attr != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_mutexattr_init @endverbatim + * + * @see https://man.cx/pthread_mutexattr_init(3) + */ +void mutexattr_init(pthread_mutexattr_t *attr); + +/** + * \brief `pthread_mutexattr_destroy` wrapper function. + * + *
    Precondition:
    + *
    attr != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_mutexattr_destroy @endverbatim + * + * @see https://man.cx/pthread_mutexattr_destroy(3) + */ +void mutexattr_destroy(pthread_mutexattr_t *attr); + +/** + * \brief `pthread_mutexattr_settype` wrapper function. + * + *
    Precondition:
    + *
    attr != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_mutexattr_settype @endverbatim + * + * @see https://man.cx/pthread_mutexattr_settype(3) + */ +void mutexattr_settype(pthread_mutexattr_t *attr, int type); + +/** + * \brief `pthread_mutexattr_gettype` wrapper function. + * + *
    Precondition:
    + *
    attr != NULL

    + *
    kind != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_mutexattr_gettype @endverbatim + * + * @see https://man.cx/pthread_mutexattr_gettype(3) + */ +void mutexattr_gettype(const pthread_mutexattr_t *attr, int *kind); + +/** @} */ + + +/** @name Condition variables attributes + * + * @details + * + * Variable type: `pthread_condattr_t` + * + * @anchor cond_attr @{ + */ + +/** + * \brief `pthread_condattr_init` wrapper function. + * + *
    Precondition:
    + *
    attr != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_condattr_init @endverbatim + * + * @see https://man.cx/pthread_condattr_init(3) + */ +void condattr_init(pthread_condattr_t *attr); + +/** + * \brief `pthread_condattr_destroy` wrapper function. + * + *
    Precondition:
    + *
    attr != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_condattr_destroy @endverbatim + * + * @see https://man.cx/pthread_condattr_destroy(3) + */ +void condattr_destroy(pthread_condattr_t *attr); + +/** @} */ + + +/** @name Thread attributes + * + * @details + * + * Variable type: `pthread_attr_t` + * + * @anchor thread_attr @{ + */ + +/** + * \brief `pthread_attr_init` wrapper function. + * + *
    Precondition:
    + *
    attr != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_attr_init @endverbatim + * + * @see https://man.cx/pthread_attr_init(3) + */ +void thread_attr_init(pthread_attr_t *attr); + +/** + * \brief `pthread_attr_destroy` wrapper function. + * + *
    Precondition:
    + *
    attr != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_attr_destroy @endverbatim + * + * @see https://man.cx/pthread_attr_destroy(3) + */ +void thread_attr_destroy(pthread_attr_t *attr); + +/** + * \brief `pthread_attr_setdetachstate` wrapper function. + * + *
    Precondition:
    + *
    attr != NULL

    + *
    detachstate == PTHREAD_CREATE_DETACHED || detachstate == PTHREAD_CREATE_JOINABLE
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_attr_setdetachstate @endverbatim + * + * @see https://man.cx/pthread_attr_setdetachstate(3) + */ +void thread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); + +/** + * \brief `pthread_attr_getdetachstate` wrapper function. + * + *
    Precondition:
    + *
    attr != NULL

    + *
    pdetachstate != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_attr_getdetachstate @endverbatim + * + * @see https://man.cx/pthread_attr_getdetachstate(3) + */ +void thread_attr_getdetachstate(const pthread_attr_t *attr, int *pdetachstate); + +/** @} */ + + +/** @name Cancellation + * + * @anchor thread_cancellation @{ + */ + +/** + * \brief `pthread_cancel` wrapper function. + * + * \details Other documentation in @verbatim man 3 pthread_cancel @endverbatim + * + * @see https://man.cx/pthread_cancel(3) + */ +void thread_cancel(pthread_t thread); + +/** + * \brief `pthread_setcancelstate` wrapper function. + * + *
    Precondition:
    + *
    state == PTHREAD_CANCEL_ENABLE || state == PTHREAD_CANCEL_DISABLE

    + *
    oldstate != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_setcancelstate @endverbatim + * + * @see https://man.cx/pthread_setcancelstate(3) + */ +void thread_setcancelstate(int state, int *oldstate); + +/** + * \brief `pthread_setcanceltype` wrapper function. + * + *
    Precondition:
    + *
    type == PTHREAD_CANCEL_DEFERRED || type == PTHREAD_CANCEL_ASYNCHRONOUS

    + *
    oldtype != NULL
    + *
    + * + * \details Other documentation in @verbatim man 3 pthread_setcanceltype @endverbatim + * + * @see https://man.cx/pthread_setcanceltype(3) + */ +void thread_setcanceltype(int type, int *oldtype); + +/** + * \brief `pthread_testcancel` wrapper function. + * + * \details Other documentation in @verbatim man 3 pthread_testcancel @endverbatim + * + * @see https://man.cx/pthread_testcancel(3) + */ +void thread_testcancel(void); + + +/** @} */ + +#endif + +/* ************************************************** */ +/** + * @} close group thread + **/ +/* ************************************************** */ + diff --git a/3ano/1semestre/so/practice-exam/src/include/utils.h b/3ano/1semestre/so/practice-exam/src/include/utils.h new file mode 100644 index 0000000..aa3674c --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/include/utils.h @@ -0,0 +1,658 @@ +/** + * \defgroup utils utils + * \ingroup concurrency-library + * \brief Useful common functions and macros. + * \author Miguel Oliveira e Silva, 2017-2018 + * @{ + **/ + +/*! + * \file + * + * \brief Useful common functions and macros. + **/ + +#ifndef UTILS_H +#define UTILS_H + +#include +#include +#include +#include "dbc.h" + +/** @name String concatenation in stack memory + * @anchor concat @{ + */ +/** + * \brief Concatenates two strings in the stack memory (thus it cannot be implemented in a function). + * + * \details A `NULL` reference is treated as an empty string. + * + * \param [in] str1 string 1 + * \param [in] str2 string 2 + * + * \return the concatenated string + */ +#define concat_2str(str1,str2) \ + ({ \ + char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \ + char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \ + char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+1); \ + strcpy(__res__, s1); \ + strcat(__res__, s2); \ + __res__; \ + }) + +/** + * \brief Concatenates three strings in the stack memory (thus it cannot be implemented in a function). + * + * \details A `NULL` reference is treated as an empty string. + * + * \param [in] str1 string 1 + * \param [in] str2 string 2 + * \param [in] str3 string 3 + * + * \return the concatenated string + */ +#define concat_3str(str1,str2,str3) \ + ({ \ + char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \ + char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \ + char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \ + char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+1); \ + strcpy(__res__, s1); \ + strcat(__res__, s2); \ + strcat(__res__, s3); \ + __res__; \ + }) + +/** + * \brief Concatenates four strings in the stack memory (thus it cannot be implemented in a function). + * + * \details A `NULL` reference is treated as an empty string. + * + * \param [in] str1 string 1 + * \param [in] str2 string 2 + * \param [in] str3 string 3 + * \param [in] str4 string 4 + * + * \return the concatenated string + */ +#define concat_4str(str1,str2,str3,str4) \ + ({ \ + char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \ + char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \ + char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \ + char* s4 = (str4) == NULL ? (char*)"" : (char*)(str4); \ + char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+strlen(s4)+1); \ + strcpy(__res__, s1); \ + strcat(__res__, s2); \ + strcat(__res__, s3); \ + strcat(__res__, s4); \ + __res__; \ + }) + +/** + * \brief Concatenates five strings in the stack memory (thus it cannot be implemented in a function). + * + * \details A `NULL` reference is treated as an empty string. + * + * \param [in] str1 string 1 + * \param [in] str2 string 2 + * \param [in] str3 string 3 + * \param [in] str4 string 4 + * \param [in] str5 string 5 + * + * \return the concatenated string + */ +#define concat_5str(str1,str2,str3,str4,str5) \ + ({ \ + char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \ + char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \ + char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \ + char* s4 = (str4) == NULL ? (char*)"" : (char*)(str4); \ + char* s5 = (str5) == NULL ? (char*)"" : (char*)(str5); \ + char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+strlen(s4)+strlen(s5)+1); \ + strcpy(__res__, s1); \ + strcat(__res__, s2); \ + strcat(__res__, s3); \ + strcat(__res__, s4); \ + strcat(__res__, s5); \ + __res__; \ + }) + +/** + * \brief Concatenates six strings in the stack memory (thus it cannot be implemented in a function). + * + * \details A `NULL` reference is treated as an empty string. + * + * \param [in] str1 string 1 + * \param [in] str2 string 2 + * \param [in] str3 string 3 + * \param [in] str4 string 4 + * \param [in] str5 string 5 + * \param [in] str6 string 6 + * + * \return the concatenated string + */ +#define concat_6str(str1,str2,str3,str4,str5,str6) \ + ({ \ + char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \ + char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \ + char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \ + char* s4 = (str4) == NULL ? (char*)"" : (char*)(str4); \ + char* s5 = (str5) == NULL ? (char*)"" : (char*)(str5); \ + char* s6 = (str6) == NULL ? (char*)"" : (char*)(str6); \ + char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+strlen(s4)+strlen(s5)+strlen(s6)+1); \ + strcpy(__res__, s1); \ + strcat(__res__, s2); \ + strcat(__res__, s3); \ + strcat(__res__, s4); \ + strcat(__res__, s5); \ + strcat(__res__, s6); \ + __res__; \ + }) + +/** + * \brief Concatenates seven strings in the stack memory (thus it cannot be implemented in a function). + * + * \details A `NULL` reference is treated as an empty string. + * + * \param [in] str1 string 1 + * \param [in] str2 string 2 + * \param [in] str3 string 3 + * \param [in] str4 string 4 + * \param [in] str5 string 5 + * \param [in] str6 string 6 + * \param [in] str7 string 7 + * + * \return the concatenated string + */ +#define concat_7str(str1,str2,str3,str4,str5,str6,str7) \ + ({ \ + char* s1 = (str1) == NULL ? (char*)"" : (char*)(str1); \ + char* s2 = (str2) == NULL ? (char*)"" : (char*)(str2); \ + char* s3 = (str3) == NULL ? (char*)"" : (char*)(str3); \ + char* s4 = (str4) == NULL ? (char*)"" : (char*)(str4); \ + char* s5 = (str5) == NULL ? (char*)"" : (char*)(str5); \ + char* s6 = (str6) == NULL ? (char*)"" : (char*)(str6); \ + char* s7 = (str7) == NULL ? (char*)"" : (char*)(str7); \ + char* __res__ = (char*)alloca(strlen(s1)+strlen(s2)+strlen(s3)+strlen(s4)+strlen(s5)+strlen(s6)+strlen(s7)+1); \ + strcpy(__res__, s1); \ + strcat(__res__, s2); \ + strcat(__res__, s3); \ + strcat(__res__, s4); \ + strcat(__res__, s5); \ + strcat(__res__, s6); \ + strcat(__res__, s7); \ + __res__; \ + }) +/** @} */ + +/** + * \brief Converts an `int` value to a stack allocated string. + * + * \param [in] num integer number + * + * \return the converted string + */ +#define int2str(num) \ + ({ \ + char* __res__ = (char*)alloca(numDigits((int)num)+1); \ + sprintf(__res__, "%d", (int)num); \ + __res__; \ + }) + +/** + * \brief Converts an `int` value to a stack allocated string. + * + * \details If necessary, fills the result string with left zeros. + * + * \param [in] num integer number + * \param [in] len minimum length of result string + * + *
    Precondition:
    + *
    len > 0
    + *
    + * + * \return the converted string + */ +#define int2nstr(num, len) \ + ({ \ + require (len > 0, concat_3str("invalid length value (", int2str(len), ")")); \ + int d = numDigits((int)num); \ + if (len > d) \ + d = len; \ + char* __res__ = (char*)alloca(d+1); \ + sprintf(__res__, "%0*d", d, (int)num); \ + __res__; \ + }) + +/** + * \brief Converts an `long` value to a stack allocated string. + * + * \param [in] num long integer number + * + * \return the converted string + */ +#define long2str(num) \ + ({ \ + char* __res__ = (char*)alloca(numDigits((long)num)+1); \ + sprintf(__res__, "%ld", (long)num); \ + __res__; \ + }) + +/** + * \brief Converts an `long` value to a stack allocated string. + * + * \details If necessary, fills the result string with left zeros. + * + * \param [in] num long integer number + * \param [in] len minimum length of result string + * + *
    Precondition:
    + *
    len > 0
    + *
    + * + * \return the converted string + */ +#define long2nstr(num, len) \ + ({ \ + require (len > 0, concat_3str("invalid length value (", int2str(len), ")")); \ + int d = numDigits((int)num); \ + if (len > d) \ + d = len; \ + char* __res__ = (char*)alloca(d+1); \ + sprintf(__res__, "%0*ld", d, (long)num); \ + __res__; \ + }) + +/** + * \brief Converts an `int` percentage to a stack allocated string. + * + * \param [in] percentage an integer number with a percentage value + * + *
    Precondition:
    + *
    percentage >= 0 && percentage <= 100
    + *
    + * + * \return the converted string + */ +#define perc2str(percentage) \ + ({ \ + require (percentage >= 0 && percentage <= 100, concat_3str("invalid percentage value (", int2str(percentage), ")")); \ + char* __res__ = (char*)alloca(4+1); \ + sprintf(__res__, "%3d%%", (int)percentage); \ + __res__; \ + }) + +/** + * \brief Determines the length of all strings passed as a NULL terminated variable list of arguments (vargs). + * + * \param [in] first the argument that precedes the vargs argument list. + * + * \return the sum of the length of all strings (not counting terminator `'\0'`) + */ +#define length_vargs_string_list(first) \ + ({ \ + int __res__ = 0; \ + va_list ap; \ + va_start(ap, first); \ + char* t = first; \ + while (t != NULL) \ + { \ + __res__ += strlen(t); \ + t = va_arg(ap, char*); \ + } \ + va_end(ap); \ + __res__; \ + }) + +#if defined __cplusplus && defined EXCEPTION_POLICY +#define not_null(pnt) \ + ({ \ + if ((pnt) == NULL) \ + throw string_concat(NULL, 0, (char*)"Null pointer error", (char*)", pointer: \"", #pnt, (char*)"\", function: \"", __FUNCTION__, (char*)"\":", int2str(__LINE__), (char*)", file: \"", __FILE__, (char*)"\"\n", NULL); \ + pnt; \ + }) +#else +/** + * \brief Checks if address is not `NULL`, before its application. + * + * \details This macro is a non-defensive implementation of a null pointer verification. + * It implements two error handling policies: + * - EXIT_POLICY (default): describes the error in `stderr` (with the identification + * and the precise location of the failure), generates a segmentation fault + * (enabling a stack trace within a debugger like `gdb`), and exits program execution; + * - EXCEPTION_POLICY: throws a `char*` exception with the description of the failure. + * + * \par Example + * @skipline\code + * not_null(pnt)->something(); + * \endcode + * + * \param [in] pnt memory address + */ +#define not_null(pnt) \ + ({ \ + if ((pnt) == NULL) \ + { \ + fprintf (stderr, "Null pointer error, pointer: \"%s\", function: \"%s\":%d, file: \"%s\"\n", \ + #pnt, __FUNCTION__, __LINE__ , __FILE__); \ + *((int*)0) = 0; \ + abort (); \ + } \ + pnt; \ + }) +#endif + +/** + * \brief A replacement for `malloc` function. + * + * \details This function is a non-defensive implementation of `malloc` error verification. + * It implements two error handling policies: + * - EXIT_POLICY (default): describes the error in `stderr` (with the identification + * and the precise location of the failure), generates a segmentation fault + * (enabling a stack trace within a debugger like `gdb`), and exits program execution; + * - EXCEPTION_POLICY: throws a `char*` exception with the description of the failure. + * + * \param [in] size number of bytes to be allocated + * + *
    Precondition:
    + *
    size >= 0
    + *
    + * + * \return address of the allocated memory + */ +void* mem_alloc(int size); + +/** + * \brief A replacement for `free` function. + * + * \param [in] pnt memory address to be freed + * + *
    Precondition:
    + *
    pnt != NULL
    + *
    + */ +void mem_free(void* pnt); + +/** + * \brief Replicates a string. + * + * \details The memory is allocated in the heap (using mem_alloc()). + * + * \param [in] str string to be replicated + * + *
    Precondition:
    + *
    str != NULL
    + *
    + * + * \return pointer to the replicated string + */ +char* string_clone(char* str); + +/** + * \brief Number of lines of a string. + * + * \param [in] text string text to process + * + *
    Precondition:
    + *
    text != NULL
    + *
    + * + * \return number of counted lines + */ +int string_num_lines(char* text); + +/** + * \brief Maximum number of columns of a string (not counting character `'\\n'`). + * + * \param [in] text string text to process + * + *
    Precondition:
    + *
    text != NULL
    + *
    + * + * \return maximum number of counted columns + */ +int string_num_columns(char* text); + +/** + * \brief Counts the number of occurrences of an UTF8 character in a text. + * + * \param [in] text string text to process + * \param [in] ch string containing the sequence of bytes (one or more) of an UTF8 single character + * + *
    Precondition:
    + *
    text != NULL

    + *
    ch != NULL && num_chars_utf8(ch) == 1
    + *
    + * + * \return number of counted occurrences + */ +int string_count_char(char* text, char* ch); + +/** + * \brief Tests if a string starts with a prefix. + * + * \param [in] text string text to process + * \param [in] prefix string to test if is a prefix + * + *
    Precondition:
    + *
    text != NULL

    + *
    prefix != NULL
    + *
    + * + * \return true (`!=0`) if prefix starts text, false (`0`) otherwise + */ +int string_starts_with(char* text, char* prefix); + +/** + * \brief Tests if a string ends with a suffix. + * + * \param [in] text string text to process + * \param [in] suffix string to test if is a suffix + * + *
    Precondition:
    + *
    text != NULL

    + *
    suffix != NULL
    + *
    + * + * \return true (`!=0`) if suffix ends text, false (`0`) otherwise + */ +int string_ends_with(char* text, char* suffix); + +/** + * \brief Concatenates a `NULL` terminated list of string arguments. + * + * \details + * This function treats all vargs arguments as strings (`char*`), + * and requires that the list is terminated with a NULL argument. + * + * It allocates memory in heap (using mem_alloc()) if `NULL` + * is passed in the `res` argument. + * + * \param [in,out] res address of result string (if not `NULL`) + * \param [in] max_length `res` input argument maximum length (not counting terminator `'\0'`), only applies if `(res != NULL)` + * \param [in] text the first string to be used in concatenation + * + *
    Precondition:
    + *
    text != NULL

    + *
    res == NULL || (max_length > 0 && length_vargs_string_list(text) <= max_length)
    + *
    + * + * \return the concatenated string + */ +char* string_concat(char* res, int max_length, char* text, ...); + +/** + * \brief Generates a random boolean value. + * + * \details + * This function generates boolean values with defined probabilities + * for true (`!=0`) and false (`0`) values. + * + * \param [in] trueProb probability (in interval `[0;100]`). + * + *
    Precondition:
    + *
    trueProb >= 0 && trueProb <= 100
    + *
    + * + * \return the random boolean value + */ +int random_boolean(int trueProb); + +/** + * \brief Generates a random integer value within a given interval. + * + * \details + * This function generates integer values in the interval `[min;max]`with an uniform distribution for all values. + * + * \param [in] min lower value of interval + * \param [in] max higher value of interval + * + *
    Precondition:
    + *
    max >= min
    + *
    + * + * \return the random integer value + */ +int random_int(int min, int max); + +/** + * \brief Returns a random string from a given string list. + * + * \details + * This function stores the previous randomly selected string's (using the integer indexes of the string list) + * to disallow its repeated generation. + * + * \param [in] list list of strings to be selected (`NULL` terminated) + * \param [in,out] used indexes of strings already selected + * \param [in] length number of elements of lists `list` (not counting `NULL` entry) and `used` + * + *
    Precondition:
    + *
    list != NULL

    + *
    used != NULL
    + *
    + * + * \return the random string + */ +char* random_string(char** list, int* used, int length); + +/** + * \brief Clears the terminal. + */ +void clear_console(); + +/** + * \brief Moves the cursor to a position in terminal. + * + * \param [in] line position in the terminal + * \param [in] column position in the terminal + * + *
    Precondition:
    + *
    line >= 0 && column >= 0
    + *
    + */ +void move_cursor(int line,int column); + +/** + * \brief Hides the terminal cursor. + */ +void hide_cursor(); + +/** + * \brief Shows the terminal cursor. + */ +void show_cursor(); + +/** + * \brief Number of elements of a `NULL` terminated list of strings. + * + * \param [in] list `NULL` terminated array of strings + * + *
    Precondition:
    + *
    list != NULL
    + *
    + * + * \return number of elements of list (not counting `NULL`) + */ +int string_list_length(char** list); + +/** + * \brief Replicates a `NULL` terminated list of strings. + * + * \details The memory is allocated in the heap (using mem_alloc()). + * + * \param [in] list `NULL` terminated array of strings + * + *
    Precondition:
    + *
    list != NULL
    + *
    + * + * \return pointer to the replicated list + */ +char** string_list_clone(char** list); + +/** + * \brief Frees the memory allocated to a `NULL` terminated list of strings. + * + * \details This function is totally compatible with string_list_clone(), and always returns `NULL`. + * + * \param [in] list `NULL` terminated array of strings + * + *
    Precondition:
    + *
    list != NULL
    + *
    + * + * \return `NULL` + */ +char** string_list_free(char** list); + +int numDigits(int num); + +/** + * \brief Converts an `int` value to a string. + * + * \details If necessary, fills the result string with left zeros. + * It allocates memory in heap (using mem_alloc()) if `NULL` + * is passed in the `res` argument. + * + * \param [in,out] res address of result string (if not `NULL`) + * \param [in] num integer number + * \param [in] len minimum length of result string (not counting terminator `'\0'`) + * + *
    Precondition:
    + *
    len >= numDigits(num)
    + *
    + * + * \return the converted string + */ +char* int2nstring(char* res, int num, int len); + +/** + * \brief Converts an `int` percentage to a string. + * + * \details It allocates memory in heap (using mem_alloc()) if `NULL` + * is passed in the `res` argument. + * + * \param [in,out] res address of result string (if not `NULL`) + * \param [in] percentage an integer number with a percentage value + * + *
    Precondition:
    + *
    percentage >= 0 && percentage <= 100
    + *
    + * + * \return the converted string (if not `NULL`, it returns `res`) + */ +char* percentage2string(char* res, int percentage); + +#endif + +/* ************************************************** */ +/** + * @} close group utils + **/ +/* ************************************************** */ + diff --git a/3ano/1semestre/so/practice-exam/src/lib/libsoconcur-excp.a b/3ano/1semestre/so/practice-exam/src/lib/libsoconcur-excp.a new file mode 100644 index 0000000..19df3c2 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/lib/libsoconcur-excp.a differ diff --git a/3ano/1semestre/so/practice-exam/src/lib/libsoconcur.a b/3ano/1semestre/so/practice-exam/src/lib/libsoconcur.a new file mode 100644 index 0000000..6925522 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/lib/libsoconcur.a differ diff --git a/3ano/1semestre/so/practice-exam/src/pfifo.cpp b/3ano/1semestre/so/practice-exam/src/pfifo.cpp new file mode 100644 index 0000000..657d5e7 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/pfifo.cpp @@ -0,0 +1,171 @@ +#include "pfifo.h" +#include +#include +#include + +static void print_pfifo(PriorityFIFO *pfifo); +static int empty_pfifo(PriorityFIFO *pfifo); +static int full_pfifo(PriorityFIFO *pfifo); + +// TODO: point: initialization changes may be required in this function +void init_pfifo(PriorityFIFO *pfifo) { + require(pfifo != NULL, + "NULL pointer to FIFO"); // a false value indicates a program error + + memset(pfifo->array, 0, sizeof(pfifo->array)); + pfifo->inp = pfifo->out = pfifo->cnt = 0; + pfifo->is_closed = 0; + + pthread_mutex_init(&pfifo->mutex, NULL); + pthread_cond_init(&pfifo->not_full, NULL); + pthread_cond_init(&pfifo->not_empty, NULL); +} + +/* --------------------------------------- */ + +// TODO: point: termination changes may be required in this function +void term_pfifo(PriorityFIFO *pfifo) { + require(pfifo != NULL, + "NULL pointer to FIFO"); // a false value indicates a program error + require(is_closed_pfifo(pfifo), "FIFO open"); + + pthread_mutex_destroy(&pfifo->mutex); + pthread_cond_destroy(&pfifo->not_full); + pthread_cond_destroy(&pfifo->not_empty); +} + +/* --------------------------------------- */ + +// TODO: point: synchronization changes may be required in this function +void insert_pfifo(PriorityFIFO *pfifo, int id, int priority) { + require(pfifo != NULL, "NULL pointer to FIFO"); + require(id >= 0 && id <= MAX_ID, "invalid id"); + require(priority > 0 && priority <= MAX_PRIORITY, "invalid priority value"); + + // printf("[insert_pfifo] value=%d, priority=%d, pfifo->inp=%d, + // pfifo->out=%d\n", id, priority, pfifo->inp, pfifo->out); + + pthread_mutex_lock(&pfifo->mutex); + while(!pfifo->is_closed && full_pfifo(pfifo)) { + pthread_cond_wait(&pfifo->not_full, &pfifo->mutex); + } + require(pfifo->is_closed || !full_pfifo(pfifo), "open FIFO is full"); + + if (!pfifo->is_closed) { + int idx = pfifo->inp; + int prev = (idx + FIFO_MAXSIZE - 1) % FIFO_MAXSIZE; + while ((idx != pfifo->out) && + (pfifo->array[prev].priority > priority)) { + // printf("[insert_pfifo] idx=%d, prev=%d\n", idx, prev); + pfifo->array[idx] = pfifo->array[prev]; + idx = prev; + prev = (idx + FIFO_MAXSIZE - 1) % FIFO_MAXSIZE; + } + // printf("[insert_pfifo] idx=%d, prev=%d\n", idx, prev); + pfifo->array[idx].id = id; + pfifo->array[idx].priority = priority; + pfifo->inp = (pfifo->inp + 1) % FIFO_MAXSIZE; + pfifo->cnt++; + // printf("[insert_pfifo] pfifo->inp=%d, pfifo->out=%d\n", pfifo->inp, + // pfifo->out); + } + + pthread_cond_broadcast(&pfifo->not_empty); + pthread_mutex_unlock(&pfifo->mutex); +} + +/* --------------------------------------- */ + +// TODO: point: synchronization changes may be required in this function +int retrieve_pfifo(PriorityFIFO *pfifo) { + require(pfifo != NULL, "NULL pointer to FIFO"); + + pthread_mutex_lock(&pfifo->mutex); + while(!pfifo->is_closed && empty_pfifo(pfifo)) { + pthread_cond_wait(&pfifo->not_empty, &pfifo->mutex); + } + require(pfifo->is_closed || !empty_pfifo(pfifo), "FIFO is empty"); + + int result = -1; + if (!pfifo->is_closed) { + check_valid_patient_id(pfifo->array[pfifo->out].id); + check_valid_priority(pfifo->array[pfifo->out].priority); + + result = pfifo->array[pfifo->out].id; + pfifo->array[pfifo->out].id = INVALID_ID; + pfifo->array[pfifo->out].priority = INVALID_PRIORITY; + pfifo->out = (pfifo->out + 1) % FIFO_MAXSIZE; + pfifo->cnt--; + + // update priority of all remaing elements (increase priority by one) + int idx = pfifo->out; + for (int i = 1; i <= pfifo->cnt; i++) { + if (pfifo->array[idx].priority > 1 && + pfifo->array[idx].priority != INVALID_PRIORITY) + pfifo->array[idx].priority--; + idx = (idx + 1) % FIFO_MAXSIZE; + } + } + + ensure((result >= 0 && result <= MAX_ID) || is_closed_pfifo(pfifo), "OPEN FIFO with an invalid id"); + + pthread_cond_broadcast(&pfifo->not_full); + pthread_mutex_unlock(&pfifo->mutex); + + return result; +} + +// TODO: point: synchronization changes may be required in this function +void close_pfifo(PriorityFIFO *pfifo) { + require(pfifo != NULL, + "NULL pointer to FIFO"); // a false value indicates a program error + require(!is_closed_pfifo(pfifo), + "FIFO already closed"); // a false value indicates a program error + + pthread_mutex_lock(&pfifo->mutex); + pfifo->is_closed = 1; + pthread_cond_broadcast(&pfifo->not_empty); + pthread_mutex_unlock(&pfifo->mutex); +} + +// TODO: point: synchronization changes may be required in this function +int is_closed_pfifo(PriorityFIFO *pfifo) { + require(pfifo != NULL, + "NULL pointer to FIFO"); // a false value indicates a program error + + return pfifo->is_closed; +} + +/* --------------------------------------- */ + +static int empty_pfifo(PriorityFIFO *pfifo) { + require(pfifo != NULL, + "NULL pointer to FIFO"); // a false value indicates a program error + + return pfifo->cnt == 0; +} + +/* --------------------------------------- */ + +static int full_pfifo(PriorityFIFO *pfifo) { + require(pfifo != NULL, + "NULL pointer to FIFO"); // a false value indicates a program error + + return pfifo->cnt == FIFO_MAXSIZE; +} + +/* --------------------------------------- */ + +static void print_pfifo(PriorityFIFO *pfifo) { + require(pfifo != NULL, + "NULL pointer to FIFO"); // a false value indicates a program error + + int idx = pfifo->out; + for (int i = 1; i <= pfifo->cnt; i++) { + check_valid_patient_id(pfifo->array[pfifo->out].id); + check_valid_priority(pfifo->array[pfifo->out].priority); + printf("[%02d] value = %d, priority = %d\n", i, pfifo->array[idx].id, + pfifo->array[idx].priority); + idx = (idx + 1) % FIFO_MAXSIZE; + } +} diff --git a/3ano/1semestre/so/practice-exam/src/pfifo.h b/3ano/1semestre/so/practice-exam/src/pfifo.h new file mode 100644 index 0000000..09f0447 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/pfifo.h @@ -0,0 +1,47 @@ +/* + * @brief A priority FIFO (implemented with a circular array), + * whose elements are pairs of integers, one being an + * non-negative id and the other a positive priority value. + * + * The following operations are defined: + * \li initialization + * \li destruction + * \li insertion of a value with a given priority + * \li retrieval of a value. + * \li close + * \li check is it is closed + **/ + +#ifndef PFIFO_H +#define PFIFO_H + +#include "settings.h" +#include + +// TODO: point: uncomment the desired implementation +#include "thread.h" +// #include "process.h" + +typedef struct { + struct { + int id; // element ID (works as an index in array all_patients) + int priority; // patient priority in FIFO + } array[FIFO_MAXSIZE]; + int inp; ///< point of insertion (queue tail) + int out; ///< point of retrieval (queue head) + int cnt; ///< number of items stored + int is_closed; ///< true when closed + // TODO: point: if necessary, add synchronization declarations here + pthread_mutex_t mutex; + pthread_cond_t not_full; + pthread_cond_t not_empty; +} PriorityFIFO; + +void init_pfifo(PriorityFIFO *pfifo); +void term_pfifo(PriorityFIFO *pfifo); +void insert_pfifo(PriorityFIFO *pfifo, int id, int priority); +int retrieve_pfifo(PriorityFIFO *pfifo); +void close_pfifo(PriorityFIFO *pfifo); +int is_closed_pfifo(PriorityFIFO *pfifo); + +#endif diff --git a/3ano/1semestre/so/practice-exam/src/settings.h b/3ano/1semestre/so/practice-exam/src/settings.h new file mode 100644 index 0000000..7fda72c --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/settings.h @@ -0,0 +1,96 @@ +/** + * @brief Simulation parameter values. + */ + +#ifndef SETTINGS_H +#define SETTINGS_H + +#include +#include + +/** + * \brief maximum patient name length + */ +#define MAX_NAME 31 + +/** + * \brief maximum number of patients + */ +#define MAX_PATIENTS 100 + +/** + * \brief maximum number of nurses + */ +#define MAX_NURSES 20 + +/** + * \brief maximum number of doctors + */ +#define MAX_DOCTORS 20 + +/** + * \brief maximum time (in microseconds) in random waits + */ +#define MAX_WAIT 100000 + +/** + * \brief initial priority value for Manchester system colors + */ +#define RED 1 +#define ORANGE 2 +#define YELLOW 4 +#define GREEN 8 +#define BLUE 16 + +/** + * \brief maximum elements in FIFO + */ +#define FIFO_MAXSIZE 5 + +/** + * \brief maximum value accepted for an id + */ +#define MAX_ID (MAX_PATIENTS-1) + +/** + * \brief invalid id number + */ +#define INVALID_ID 99999999 + +/** + * \brief maximum value accepted for a priority + */ +#define MAX_PRIORITY BLUE + +/** + * \brief invalid priority number + */ +#define INVALID_PRIORITY 55555555 + +/** + * \brief patient id verification test + */ +#define check_valid_patient_id(id) do { if(id < 0 || id > MAX_ID) { printf("\e[31;01m[%s, line %d, function %s] ERROR: invalid patient ID %d!\e[0m\n", __FILE__, __LINE__, __FUNCTION__, id); exit(EXIT_FAILURE); } } while(0) + +/** + * \brief nurse id verification test + */ +#define check_valid_nurse_id(id) do { if(id < 0 || id >= MAX_NURSES) { printf("\e[31;01m[%s, line %d, function %s] ERROR: invalid nurse ID %d!\e[0m\n", __FILE__, __LINE__, __FUNCTION__, id); exit(EXIT_FAILURE); } } while(0) + +/** + * \brief doctor id verification test + */ +#define check_valid_doctor_id(id) do { if(id < 0 || id >= MAX_DOCTORS) { printf("\e[31;01m[%s, line %d, function %s] ERROR: invalid doctor ID %d!\e[0m\n", __FILE__, __LINE__, __FUNCTION__, id); exit(EXIT_FAILURE); } } while(0) + +/** + * \brief priority verification test + */ +#define check_valid_priority(priority) do { if(priority < 1 || priority > MAX_PRIORITY) { printf("\e[31;01m[%s, line %d, function %s] ERROR: invalid priority %d!\e[0m\n", __FILE__, __LINE__, __FUNCTION__, priority); exit(EXIT_FAILURE); } } while(0) + +/** + * \brief patient name verification test + */ +#define check_valid_name(name) do { if(name[0] == '\0') { printf("\e[31;01m[%s, line %d, function %s] ERROR: invalid patient with name \"%s\"!\e[0m\n", __FILE__, __LINE__, __FUNCTION__, name); exit(EXIT_FAILURE); } } while(0) + +#endif + diff --git a/3ano/1semestre/so/practice-exam/src/urgency b/3ano/1semestre/so/practice-exam/src/urgency new file mode 100755 index 0000000..2d451e0 Binary files /dev/null and b/3ano/1semestre/so/practice-exam/src/urgency differ diff --git a/3ano/1semestre/so/practice-exam/src/urgency.cpp b/3ano/1semestre/so/practice-exam/src/urgency.cpp new file mode 100644 index 0000000..99c9332 --- /dev/null +++ b/3ano/1semestre/so/practice-exam/src/urgency.cpp @@ -0,0 +1,374 @@ +/** + * @file + * + * \brief A hospital pediatric urgency with a Manchester triage system. + */ + +#include "pfifo.h" +#include "settings.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* DO NOT CHANGE THE FOLLOWING VALUES, run program with option -h to set a + * different values */ + +static int npatients = 4; ///< number of patients +static int nnurses = 1; ///< number of triage nurses +static int ndoctors = 1; ///< number of doctors + +#define USAGE \ + "Synopsis: %s [options]\n" \ + "\t----------+-----------------------------------------------------------" \ + "--\n" \ + "\t Option | Description " \ + " \n" \ + "\t----------+-----------------------------------------------------------" \ + "--\n" \ + "\t -p num | number of patients (dfl: %d, min: %d, max: %d) " \ + " \n" \ + "\t -n num | number of nurses (dfl: %d, min: %d, max: %d) " \ + " \n" \ + "\t -d num | number of doctors (dfl: %d, min: %d, max: %d) " \ + " \n" \ + "\t -h | this help " \ + " \n" \ + "\t----------+-----------------------------------------------------------" \ + "--\n", \ + basename(argv[0]), npatients, 1, MAX_PATIENTS, nnurses, 1, MAX_NURSES, \ + ndoctors, 1, MAX_DOCTORS + +// TODO: point: changes may be required in these date structures + +/** + * \brief Patient data structure + */ +typedef struct { + char name[MAX_NAME + 1]; + int done; // 0: waiting for consultation; 1: consultation finished + // TODO: point: if necessary, add new fields here + pthread_mutex_t mutex; + pthread_cond_t cond; +} Patient; + +typedef struct { + int num_patients; + Patient all_patients[MAX_PATIENTS]; + PriorityFIFO triage_queue; + PriorityFIFO doctor_queue; + // TODO: point: if necessary, add new fields here +} HospitalData; + +HospitalData *hd = NULL; + +// TODO: point: if necessary, add module variables here + +/** + * \brief verification tests: + */ +#define check_valid_patient(id) \ + do { \ + check_valid_patient_id(id); \ + check_valid_name(hd->all_patients[id].name); \ + } while (0) +#define check_valid_nurse(id) \ + do { \ + check_valid_nurse_id(id); \ + } while (0) +#define check_valid_doctor(id) \ + do { \ + check_valid_doctor_id(id); \ + } while (0) + +int random_manchester_triage_priority(); +void new_patient(Patient *patient); // initializes a new patient +void random_wait(); + +/* ************************************************* */ + +// TODO: point: changes may be required to this function +void init_simulation(int np) { + printf("Initializing simulation\n"); + hd = (HospitalData *)mem_alloc(sizeof( + HospitalData)); // mem_alloc is a malloc with NULL pointer verification + memset(hd, 0, sizeof(HospitalData)); + hd->num_patients = np; + init_pfifo(&hd->triage_queue); + init_pfifo(&hd->doctor_queue); +} + +/* ************************************************* */ + +// TODO: point: changes may be required to this function +void term_simulation(int np) { + // DO NOT WAIT THE TERMINATION OF ACTIVE ENTITIES IN THIS FUNCTION! + // This function is just to release the allocated resources + + printf("Releasing resources\n"); + term_pfifo(&hd->doctor_queue); + term_pfifo(&hd->triage_queue); + free(hd); + hd = NULL; +} + +/* ************************************************* */ + +// TODO: point: changes may be required to this function +int nurse_iteration(int id) // return value can be used to request termination +{ + check_valid_nurse(id); + printf("\e[34;01mNurse %d: get next patient\e[0m\n", id); + int patient = retrieve_pfifo(&hd->triage_queue); + // TODO: point: PUT YOUR NURSE TERMINATION CODE HERE: + if (patient == -1) return -1; + check_valid_patient(patient); + printf("\e[34;01mNurse %d: evaluate patient %d priority\e[0m\n", id, + patient); + int priority = random_manchester_triage_priority(); + printf("\e[34;01mNurse %d: add patient %d with priority %d to doctor " + "queue\e[0m\n", + id, patient, priority); + insert_pfifo(&hd->doctor_queue, patient, priority); + + return 0; +} + +/* ************************************************* */ + +// TODO: point: changes may be required to this function +int doctor_iteration(int id) // return value can be used to request termination +{ + check_valid_doctor(id); + printf("\e[32;01mDoctor %d: get next patient\e[0m\n", id); + int patient = retrieve_pfifo(&hd->doctor_queue); + // TODO: point: PUT YOUR DOCTOR TERMINATION CODE HERE: + if (patient == -1) return -1; + check_valid_patient(patient); + printf("\e[32;01mDoctor %d: treat patient %d\e[0m\n", id, patient); + random_wait(); + printf("\e[32;01mDoctor %d: patient %d treated\e[0m\n", id, patient); + // TODO: point: PUT YOUR PATIENT CONSULTATION FINISHED NOTIFICATION CODE + // HERE: + pthread_mutex_lock(&hd->all_patients[patient].mutex); + hd->all_patients[patient].done = 1; + pthread_cond_broadcast(&hd->all_patients[patient].cond); + pthread_mutex_unlock(&hd->all_patients[patient].mutex); + + return 0; +} + +/* ************************************************* */ + +void patient_goto_urgency(int id) { + new_patient(&hd->all_patients[id]); + check_valid_name(hd->all_patients[id].name); + printf("\e[30;01mPatient %s (number %d): get to hospital\e[0m\n", + hd->all_patients[id].name, id); + insert_pfifo(&hd->triage_queue, id, + 1); // all elements in triage queue with the same priority! +} + +// TODO: point: changes may be required to this function +void patient_wait_end_of_consultation(int id) { + check_valid_name(hd->all_patients[id].name); + // TODO: point: PUT YOUR WAIT CODE FOR FINISHED CONSULTATION HERE: + + pthread_mutex_lock(&hd->all_patients[id].mutex); + while (!hd->all_patients[id].done) + pthread_cond_wait(&hd->all_patients[id].cond, &hd->all_patients[id].mutex); + pthread_mutex_unlock(&hd->all_patients[id].mutex); + + printf("\e[30;01mPatient %s (number %d): health problems treated\e[0m\n", + hd->all_patients[id].name, id); +} + +// TODO: point: changes are required to this function +void patient_life(int id) { + patient_goto_urgency(id); + // nurse_iteration( + // 0); // TODO: point: to be commented/deleted in concurrent version + // doctor_iteration( + // 0); // TODO: point: to be commented/deleted in concurrent version + patient_wait_end_of_consultation(id); + + pthread_mutex_destroy(&hd->all_patients[id].mutex); + pthread_cond_destroy(&hd->all_patients[id].cond); + + memset(&(hd->all_patients[id]), 0, sizeof(Patient)); // patient finished +} + +/* ************************************************* */ + +// TODO: point: if necessary, add extra functions here: + +void *pthread_fn_patient(void *arg) { + int id = *(int *)arg; + patient_life(id); + + int status = EXIT_SUCCESS; + pthread_exit(&status); +} + +void *pthread_fn_nurse(void *arg) { + int id = *(int *)arg; + + while (nurse_iteration(id) != -1); + + int status = EXIT_SUCCESS; + pthread_exit(&status); +} + +void *pthread_fn_doctor(void *arg) { + int id = *(int *)arg; + + while (doctor_iteration(id) != -1); + + int status = EXIT_SUCCESS; + pthread_exit(&status); +} + +/* ************************************************* */ + +int main(int argc, char *argv[]) { + /* command line processing */ + int option; + while ((option = getopt(argc, argv, "p:n:d:h")) != -1) { + switch (option) { + case 'p': + npatients = atoi(optarg); + if (npatients < 1 || npatients > MAX_PATIENTS) { + fprintf(stderr, "Invalid number of patients!\n"); + return EXIT_FAILURE; + } + break; + case 'n': + nnurses = atoi(optarg); + if (nnurses < 1 || nnurses > MAX_NURSES) { + fprintf(stderr, "Invalid number of nurses!\n"); + return EXIT_FAILURE; + } + break; + case 'd': + ndoctors = atoi(optarg); + if (ndoctors < 1 || nnurses > MAX_DOCTORS) { + fprintf(stderr, "Invalid number of doctors!\n"); + return EXIT_FAILURE; + } + break; + case 'h': + printf(USAGE); + return EXIT_SUCCESS; + default: + fprintf(stderr, "Non valid option!\n"); + fprintf(stderr, USAGE); + return EXIT_FAILURE; + } + } + + /* start random generator */ + srand(getpid()); + + /* init simulation */ + init_simulation(npatients); + + // TODO: point: REPLACE THE FOLLOWING DUMMY CODE WITH code to launch + // active entities and code to properly terminate the simulation. + /* dummy code to show a very simple sequential behavior */ + // for(int i = 0; i < npatients; i++) + // { + // printf("\n"); + // random_wait(); // random wait for patience creation + // patient_life(i); + // } + /* end of dummy code */ + + // ###################################### + // CREATE + + pthread_t patients[npatients]; + pthread_t nurses[nnurses]; + pthread_t doctors[ndoctors]; + + int patients_ids[npatients]; + int nurses_ids[nnurses]; + int doctors_ids[ndoctors]; + + for (int i = 0; i < npatients; i++) { + patients_ids[i] = i; + pthread_create(&patients[i], NULL, pthread_fn_patient, (void *)&patients_ids[i]); + } + + for (int i = 0; i < nnurses; i++) { + nurses_ids[i] = i; + pthread_create(&nurses[i], NULL, pthread_fn_nurse, (void *)&nurses_ids[i]); + } + + for (int i = 0; i < ndoctors; i++) { + doctors_ids[i] = i; + pthread_create(&doctors[i], NULL, pthread_fn_doctor, (void *)&doctors_ids[i]); + } + + // ###################################### + // JOIN + + for (int i = 0; i < npatients; i++) + pthread_join(patients[i], NULL); + + close_pfifo(&hd->triage_queue); + close_pfifo(&hd->doctor_queue); + + for (int i = 0; i < nnurses; i++) + pthread_join(nurses[i], NULL); + + for (int i = 0; i < ndoctors; i++) + pthread_join(doctors[i], NULL); + + /* terminate simulation */ + term_simulation(npatients); + + return EXIT_SUCCESS; +} + +/* IGNORE THE FOLLOWING CODE */ + +int random_manchester_triage_priority() { + int result; + int perc = random_int(0, 100); + if (perc < 10) + result = RED; + else if (perc < 30) + result = ORANGE; + else if (perc < 50) + result = YELLOW; + else if (perc < 75) + result = GREEN; + else + result = BLUE; + return result; +} + +static char **names = + (char *[]){"Ana", "Miguel", "Luis", "Joao", "Artur", "Maria", + "Luisa", "Mario", "Augusto", "Antonio", "Jose", "Alice", + "Almerindo", "Gustavo", "Paulo", "Paula", NULL}; +static int names_len = 16; + +char *random_name() { return names[random_int(0, names_len - 1)]; } + +void new_patient(Patient *patient) { + strcpy(patient->name, random_name()); + patient->done = 0; +} + +void random_wait() { usleep((useconds_t)random_int(0, MAX_WAIT)); }