├── CppCon 2020 - Cpp20 An (Almost) Complete Overview.pptx ├── CppCon 2020 - Cpp20 String Formatting Library An Overview and Use with Custom Types.pptx ├── LICENSE ├── Meeting Cpp2019_Cpp20_The small things.pdf ├── README.md ├── atomic_extensionCpp20.md ├── bit.md ├── chrono_extensionCpp20.md ├── codes ├── mudmuhan-ReCpp20 │ ├── DM-1.2.DOC │ ├── DM.DOC │ ├── README.NOW │ ├── README.md │ ├── src │ │ ├── .mtype.h.swo │ │ ├── README │ │ ├── README.update │ │ ├── action.c │ │ ├── alias.c │ │ ├── auth.c │ │ ├── bank.c │ │ ├── bank_check.c │ │ ├── board.c │ │ ├── board.h │ │ ├── command1.c │ │ ├── command10.c │ │ ├── command11.c │ │ ├── command12.c │ │ ├── command2.c │ │ ├── command3.c │ │ ├── command4.c │ │ ├── command5.c │ │ ├── command6.c │ │ ├── command7.c │ │ ├── command8.c │ │ ├── command9.c │ │ ├── compress.c │ │ ├── creature.c │ │ ├── dm1.c │ │ ├── dm2.c │ │ ├── dm3.c │ │ ├── dm4.c │ │ ├── dm5.c │ │ ├── dm6.c │ │ ├── files1.c │ │ ├── files2.c │ │ ├── files3.c │ │ ├── finger.c │ │ ├── global.c │ │ ├── io.c │ │ ├── kstbl.h │ │ ├── magic1.c │ │ ├── magic2.c │ │ ├── magic3.c │ │ ├── magic4.c │ │ ├── magic5.c │ │ ├── magic6.c │ │ ├── magic7.c │ │ ├── magic8.c │ │ ├── main.c │ │ ├── makefile │ │ ├── mextern.h │ │ ├── misc.c │ │ ├── mstruct.h │ │ ├── mstruct2.h │ │ ├── mtype.h │ │ ├── object.c │ │ ├── player.c │ │ ├── player2.c │ │ ├── plist.c │ │ ├── post.c │ │ ├── room.c │ │ ├── sc.c │ │ ├── sp.c │ │ ├── special1.c │ │ ├── startm.c │ │ ├── strstr.c │ │ ├── update.c │ │ └── update.h │ └── util │ │ ├── README.util │ │ ├── dos2unix │ │ ├── dos_ed │ │ ├── README │ │ ├── ed.arj │ │ ├── editor.doc │ │ └── editor.exe │ │ ├── ed │ │ ├── Makefile │ │ ├── compress.c │ │ ├── editor.c │ │ ├── editor.h │ │ ├── editor2.c │ │ ├── editor3.c │ │ ├── editor4.c │ │ ├── files2.c │ │ ├── kstbl.h │ │ ├── mextern.h │ │ ├── mstruct.h │ │ └── mtype.h │ │ ├── italk │ │ └── italk.c │ │ ├── list │ │ ├── list.c │ │ ├── mstruct.h │ │ └── mtype.h │ │ ├── msg │ │ └── message.c │ │ ├── muddle │ │ ├── Makefile │ │ ├── README │ │ ├── conn.c │ │ ├── macro.c │ │ ├── muddle │ │ ├── muddle.c │ │ ├── muddle.h │ │ └── sample.muddle │ │ ├── startm │ │ ├── startm.c │ │ ├── startm.doc │ │ └── startm2.c │ │ └── trans │ │ ├── trans │ │ └── trans_final ├── mudmuhan-master.zip └── std_format │ ├── main.cpp │ ├── std_format.sln │ ├── std_format.vcxproj │ └── std_format.vcxproj.filters ├── concept.md ├── concurrency_in_cpp20_and_beyond__anthony_williams__cppcon_2019.pdf ├── module ├── README.md ├── images │ └── 001.png ├── module_01-01 │ ├── main.cpp │ ├── module_01-01.sln │ ├── module_01-01.vcxproj │ └── module_01-01.vcxproj.filters ├── module_01 │ ├── main.cpp │ ├── module_01.sln │ ├── module_01.vcxproj │ ├── module_01.vcxproj.filters │ ├── mylib.cpp │ └── mylib.ixx ├── module_02 │ ├── main.cpp │ ├── module_02.sln │ ├── module_02.vcxproj │ ├── module_02.vcxproj.filters │ └── mylib.ixx ├── module_03 │ ├── main.cpp │ ├── module_03.sln │ ├── module_03.vcxproj │ ├── module_03.vcxproj.filters │ ├── mylib.cpp │ └── mylib.ixx ├── module_04-01 │ ├── main.cpp │ ├── module_04-01.sln │ ├── module_04-01.vcxproj │ ├── module_04-01.vcxproj.filters │ ├── mylib.ixx │ ├── mylib1.ixx │ └── mylib2.ixx ├── module_04 │ ├── main.cpp │ ├── module_04.sln │ ├── module_04.vcxproj │ ├── module_04.vcxproj.filters │ ├── mylib.cpp │ ├── mylib.ixx │ ├── mylib_interface1.ixx │ └── mylib_interface2.ixx ├── module_05 │ ├── main.cpp │ ├── module_05.sln │ ├── module_05.vcxproj │ ├── module_05.vcxproj.filters │ ├── mylib.ixx │ ├── mylib1.cpp │ └── mylib2.cpp ├── module_06 │ ├── main.cpp │ ├── module_06.sln │ ├── module_06.vcxproj │ ├── module_06.vcxproj.filters │ ├── mylib.ixx │ ├── mylib1.cpp │ └── mylib2.cpp ├── module_07 │ ├── main.cpp │ ├── module_07.sln │ ├── module_07.vcxproj │ ├── module_07.vcxproj.filters │ ├── shop │ │ ├── shop-unit.cpp │ │ └── shop.ixx │ ├── types │ │ └── types.ixx │ └── util │ │ └── util.ixx └── module_all.sln ├── ranges.md └── thread_extensionCpp20.md /CppCon 2020 - Cpp20 An (Almost) Complete Overview.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/CppCon 2020 - Cpp20 An (Almost) Complete Overview.pptx -------------------------------------------------------------------------------- /CppCon 2020 - Cpp20 String Formatting Library An Overview and Use with Custom Types.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/CppCon 2020 - Cpp20 String Formatting Library An Overview and Use with Custom Types.pptx -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Choi HeungBae 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Meeting Cpp2019_Cpp20_The small things.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/Meeting Cpp2019_Cpp20_The small things.pdf -------------------------------------------------------------------------------- /atomic_extensionCpp20.md: -------------------------------------------------------------------------------- 1 | # atomic Extensions in C++20 2 | 3 | ## std::atomic_ref 4 | atomic_ref 클래스 템플릿은 생성자에서 받은 T 타입 변수에 참조에 대한 원자 조작을 적용하는 형태이다. 5 | 비 원자적 개체에 대해서, 값 복사에 의한 std::atomic 타입 변환 필요 없이 원자 조작을 적용한다. 6 | 7 | 개체가 대부분의 경우에 비 원자적으로 사용되고, 충돌 해결을 위해 원자적으로 행동해야하는 것이 일부 장면인 경우 개체를 강제로 원자 객체로 변환 해 버리는 것은 성능 저하로 이어진다. atomic_ref 클래스를 사용하여 이러한 상황에 대응하고, 일부 상황에서만 객체를 원자적으로 동작하도록 한다. 8 | 9 | 같은 객체를 참조하는 서로 다른 atomic_ref 객체를 통해 이루어지는 원자적 조작은 공통 참조하는 개체에 대해 원자적으로 이루어진다. 즉, 국소적으로 atomic_ref 객체로 변환 하여 연산을 적용 할 수있다. 10 | 11 | 객체를 참조로 원자적 조작을 하기 위한 제약으로 아키텍처 별 얼라이먼트 제약을 채우는 것이 요구된다. 생성자와 대입 연산자 객체를 참조 할 때 멤버 상수로 얼라이먼트 값 required_alignment의 위치에 오브젝트가 배치 되는 것이다. 12 | 13 | atomic_ref 클래스 템플릿은 타입 T의 값을 복사가 아닌 참조로 유지하기 위해 atomic_ref 개체보다 먼저 참조되는 변수의 수명이 다 되어서는 안된다. 14 | 15 | 16 | ### 공통 멤버 변수 17 | 18 | | 이름 | 설명 | 대응 버전 | 19 | |-------------------------|----------------------------------------------------|----------------| 20 | | (constructor) | 생성자 | C++20 | 21 | | ~atomic_ref() = default | 소멸자 | C++20 | 22 | | operator= | 대임 | C++20 | 23 | | is_lock_free | 오브젝트가 락프리 행동을 할 수 있는지 판정한다 | C++20 | 24 | | store | 값을 쓴다 | C++20 | 25 | | load | 값을 읽는다 | C++20 | 26 | | operator T | 변수 T로의 변환 연산자 | C++20 | 27 | | exchange | 값을 교체한다 | C++20 | 28 | | compare_exchange_weak | 약한 비교러 값을 교체한다 | C++20 | 29 | | compare_exchange_strong | 강한 비교로 값을 교체한다 | C++20 | 30 | | wait | 깨울 때까지 대기한다 | C++20 | 31 | | notify_one | 대기하고 있는 스레드를 하나 깨운다 | C++20 | 32 | | notify_all | 대기하고 있는 모든 스레드를 깨운다 | C++20 | 33 | 34 | 35 | ### 예제 코드 36 | 37 | ``` 38 | #include 39 | #include 40 | #include 41 | 42 | struct Info { 43 | int value = 0; 44 | }; 45 | 46 | int main() 47 | { 48 | Info info; 49 | 50 | std::thread consumer_thread {[&info] { 51 | std::atomic_ref x{info.value}; 52 | while (true) { 53 | if (int value = x.exchange(0); value != 0) { 54 | std::cout << value << std::endl; 55 | break; 56 | } 57 | } 58 | }}; 59 | 60 | std::atomic_ref{info.value}.store(3); // 클래스 템플릿의 템플릿 인수 추론도 사용 가능( 생략) 61 | consumer_thread.join(); 62 | } 63 | ``` 64 | 65 | 출력 66 |
 67 | 3
 68 | 
69 | 70 | 71 | 72 | ## std::atomic_wait 73 | 이 함수는 블럭킹 동기를 하기 위한 기능이고, 비지 루프에 의한 폴링 보다 에너지 소비가 낮은 효율적인 대기를 구현할 수 있다. 74 | 이 함수에 의해 대기하면 이것을 깨워주는 함수는 atomic_notify_one(), atomic_notify_all() 이다. 75 | 76 | 이 함수는 Windows에서는 WaitOnAddress() 함수, POSIX에서는 futex() 함수를 사용하고 있다. 77 | 78 | ``` 79 | #include 80 | #include 81 | #include 82 | 83 | class my_mutex { 84 | std::atomic state_{false}; // false:unlock, true:lock 85 | public: 86 | void lock() noexcept { 87 | while (std::atomic_exchange(&state_, true) == true) { 88 | std::atomic_wait(&state_, true); 89 | } 90 | } 91 | 92 | void unlock() noexcept { 93 | std::atomic_store(&state_, false); 94 | std::atomic_notify_one(&state_); 95 | } 96 | }; 97 | 98 | my_mutex mut; 99 | void print(int x) { 100 | mut.lock(); 101 | std::cout << x << std::endl; 102 | mut.unlock(); 103 | } 104 | 105 | int main() 106 | { 107 | std::thread t1 {[] { 108 | for (int i = 0; i < 5; ++i) { 109 | print(i); 110 | } 111 | }}; 112 | std::thread t2 {[] { 113 | for (int i = 5; i < 10; ++i) { 114 | print(i); 115 | } 116 | }}; 117 | 118 | t1.join(); 119 | t2.join(); 120 | } 121 | ``` 122 | 123 | 출력 124 |
125 | 0
126 | 5
127 | 1
128 | 6
129 | 2
130 | 7
131 | 3
132 | 8
133 | 4
134 | 9
135 | 
136 | 137 | 138 | ## std::atomic_wait_explicit 139 | 기능적으로 std::atomic_wait와 같다. 차이는 memory order 최적화를 할 수 있다. 140 | ``` 141 | void lock() noexcept { 142 | while (std::atomic_exchange_explicit(&state_, true, std::memory_order::acquire) == true) { 143 | std::atomic_wait_explicit(&state_, true, std::memory_order::relaxed); 144 | } 145 | } 146 | ``` 147 | 148 | 149 | ## std::atomic_notify_one 150 | `atomic_wait`로 대기 하고 있는 것 중 하나를 깨운다 151 | ``` 152 | std::atomic_notify_one(&state_); 153 | ``` 154 | 155 | 156 | ## std::atomic_notify_all 157 | `atomic_wait`로 대기 하고 있는 것 모두를 깨운다 158 | ``` 159 | std::atomic_notify_all(&state_); 160 | ``` 161 | 162 | 163 | ## std::atomic_flag_test 164 | 현재 값을 bool 값으로 얻는다. 165 | memory order이 memory_order_release, memory_order_acq_rel 에서는 사용 불가. 166 | ``` 167 | #include 168 | #include 169 | 170 | int main() 171 | { 172 | std::cout << std::boolalpha; 173 | 174 | std::atomic_flag x = ATOMIC_FLAG_INIT; 175 | std::cout << std::atomic_flag_test(&x) << std::endl; 176 | 177 | std::atomic_flag_test_and_set(&x); 178 | std::cout << std::atomic_flag_test(&x) << std::endl; 179 | } 180 | ``` 181 | 182 | 출력 183 |
184 | false
185 | true
186 | 
187 | 188 | 189 | ## std::atomic_flag_test_explicit 190 | 현재 값을 bool 값으로 얻는다. 191 | memory order이 memory_order_release, memory_order_acq_rel 에서는 사용 불가. 192 | ``` 193 | #include 194 | #include 195 | 196 | int main() 197 | { 198 | std::cout << std::boolalpha; 199 | 200 | std::atomic_flag x = ATOMIC_FLAG_INIT; 201 | std::cout << std::atomic_flag_test_explicit(&x, std::memory_order::acquire) << std::endl; 202 | 203 | std::atomic_flag_test_and_set(&x, std::memory_order::release); 204 | std::cout << std::atomic_flag_test_explicit(&x, std::memory_order::acquire) << std::endl; 205 | } 206 | ``` 207 | 208 | 209 | ## std::atomic_flag_wait 210 | `atomic_wait`와 비슷하며, atomic_flag_notify_one(), atomic_flag_notify_all() 함수로 대기에서 깨어난다. 211 | ``` 212 | class my_mutex { 213 | std::atomic_flag state_ = ATOMIC_FLAG_INIT; // clear:unlock, set:lock 214 | public: 215 | void lock() noexcept { 216 | while (std::atomic_flag_test_and_set(&state_)) { 217 | std::atomic_flag_wait(&state_, true); 218 | } 219 | } 220 | 221 | void unlock() noexcept { 222 | std::atomic_flag_clear(&state_); 223 | std::atomic_flag_notify_one(&state_); 224 | } 225 | }; 226 | ``` 227 | 228 | 229 | ## std::atomic_flag_wait_explicit 230 | `std::atomic_flag_wait`와 같으면 momory order 지정이 가능. 231 | ``` 232 | #include 233 | #include 234 | #include 235 | 236 | class my_mutex { 237 | std::atomic_flag state_ = ATOMIC_FLAG_INIT; // clear:unlock, set:lock 238 | public: 239 | void lock() noexcept { 240 | while (std::atomic_flag_test_and_set_explicit(&state_, std::memory_order::acquire)) { 241 | std::atomic_flag_wait_explicit(&state_, true, std::memory_order::relaxed); 242 | } 243 | } 244 | 245 | void unlock() noexcept { 246 | std::atomic_flag_clear_explicit(&state_, std::memory_order::release); 247 | std::atomic_flag_notify_one(&state_); 248 | } 249 | }; 250 | ``` 251 | 252 | 253 | ## std::atomic_flag_notify_one 254 | `atomic_flag_wait`에 의한 대기 상태에서 하나만 깨운다. 255 | 256 | 257 | ## std::atomic_flag_notify_all 258 | `atomic_flag_wait`에 의한 대기 상태에서 모두 깨운다. 259 | 260 | 261 | ## 참고 사이트 262 | - https://cpprefjp.github.io/reference/atomic.html 263 | 264 | -------------------------------------------------------------------------------- /bit.md: -------------------------------------------------------------------------------- 1 | # std::bit 2 | `` 헤더를 include 한다. 3 | 4 | ## 변환 5 | bit_cast: 비트 레벨 재해석 캐스트 6 | ``` 7 | float f = 3.14f; 8 | std::uint32_t n = std::bit_cast(f); 9 | ``` 10 | 11 | 12 | ## 2의 거듭제곱 정수 13 | 14 | ### has_single_bit 15 | 1비트만 1로 되어 있는가를 판정한다 16 | 17 | ``` 18 | #include 19 | #include 20 | 21 | void check_pow2(unsigned int x) 22 | { 23 | std::cout << x << "\t : " << std::has_single_bit(x) << std::endl; 24 | } 25 | 26 | int main() 27 | { 28 | std::cout << std::boolalpha; 29 | 30 | if (std::has_single_bit(128u)) { 31 | std::cout << "128 is power of 2" << std::endl; 32 | } 33 | check_pow2(0u); 34 | check_pow2(3u); 35 | check_pow2(0xffu); 36 | 37 | std::cout << "---" << std::endl; 38 | 39 | check_pow2(1u); 40 | for (unsigned int i = 2u; i <= 1024u; i *= 2) { 41 | check_pow2(i); 42 | } 43 | } 44 | ``` 45 | 결과 46 |
 47 | 128 is power of 2
 48 | 0    : false
 49 | 3    : false
 50 | 255  : false
 51 | ---
 52 | 1    : true
 53 | 2    : true
 54 | 4    : true
 55 | 8    : true
 56 | 16   : true
 57 | 32   : true
 58 | 64   : true
 59 | 128  : true
 60 | 256  : true
 61 | 512  : true
 62 | 1024     : true
 63 | 
64 | 65 | ### bit_ceil 66 | 정수 값을 2의 거듭제곱 값으로 올림한다 67 | ``` 68 | #include 69 | #include 70 | 71 | void convert_to_pow2(unsigned int x) 72 | { 73 | std::cout << x << "\t : " << std::bit_ceil(x) << std::endl; 74 | } 75 | 76 | int main() 77 | { 78 | std::cout << "127\t : " << std::bit_ceil(127u) << std::endl; 79 | 80 | for (unsigned int i = 0u; i <= 32u; ++i) { 81 | convert_to_pow2(i); 82 | } 83 | } 84 | ``` 85 | 86 |
 87 | 127  : 128
 88 | 0    : 1
 89 | 1    : 1
 90 | 2    : 2
 91 | 3    : 4
 92 | 4    : 4
 93 | 5    : 8
 94 | 6    : 8
 95 | 7    : 8
 96 | 8    : 8
 97 | 9    : 16
 98 | 10   : 16
 99 | 11   : 16
100 | 12   : 16
101 | 13   : 16
102 | 14   : 16
103 | 15   : 16
104 | 16   : 16
105 | 17   : 32
106 | 18   : 32
107 | 19   : 32
108 | 20   : 32
109 | 21   : 32
110 | 22   : 32
111 | 23   : 32
112 | 24   : 32
113 | 25   : 32
114 | 26   : 32
115 | 27   : 32
116 | 28   : 32
117 | 29   : 32
118 | 30   : 32
119 | 31   : 32
120 | 32   : 32
121 | 
122 | 123 | 124 | ### bit_floor 125 | 정수 값을 2의 거듭제곱 값으로 내림한다 126 | ``` 127 | #include 128 | #include 129 | 130 | void convert_to_pow2(unsigned int x) 131 | { 132 | std::cout << x << "\t : " << std::bit_floor(x) << std::endl; 133 | } 134 | 135 | int main() 136 | { 137 | std::cout << "129\t : " << std::bit_floor(129u) << std::endl; 138 | 139 | for (unsigned int i = 0u; i <= 34u; ++i) { 140 | convert_to_pow2(i); 141 | } 142 | } 143 | ``` 144 | 145 |
146 | 129  : 128
147 | 0    : 0
148 | 1    : 1
149 | 2    : 2
150 | 3    : 2
151 | 4    : 4
152 | 5    : 4
153 | 6    : 4
154 | 7    : 4
155 | 8    : 8
156 | 9    : 8
157 | 10   : 8
158 | 11   : 8
159 | 12   : 8
160 | 13   : 8
161 | 14   : 8
162 | 15   : 8
163 | 16   : 16
164 | 17   : 16
165 | 18   : 16
166 | 19   : 16
167 | 20   : 16
168 | 21   : 16
169 | 22   : 16
170 | 23   : 16
171 | 24   : 16
172 | 25   : 16
173 | 26   : 16
174 | 27   : 16
175 | 28   : 16
176 | 29   : 16
177 | 30   : 16
178 | 31   : 16
179 | 32   : 32
180 | 33   : 32
181 | 34   : 32
182 | 
183 | 184 | 185 | ### bit_width 186 | 값을 표현하기 위해 필요한 비트 폭을 구한다 187 | 188 | ``` 189 | #include 190 | #include 191 | 192 | void convert_to_width(unsigned int x) 193 | { 194 | std::cout << x << "\t : " << std::bit_width(x) << std::endl; 195 | } 196 | 197 | int main() 198 | { 199 | std::cout << "129\t : " << std::bit_width(129u) << std::endl; 200 | convert_to_width(127u); 201 | convert_to_width(1u); 202 | convert_to_width(0u); 203 | 204 | std::cout << "---" << std::endl; 205 | for (unsigned int i = 1024u; i >= 2u; i /= 2) { 206 | convert_to_width(i); 207 | } 208 | } 209 | ``` 210 | 211 |
212 | 129  : 8
213 | 127  : 7
214 | 1    : 1
215 | 0    : 0
216 | ---
217 | 1024     : 11
218 | 512  : 10
219 | 256  : 9
220 | 128  : 8
221 | 64   : 7
222 | 32   : 6
223 | 16   : 5
224 | 8    : 4
225 | 4    : 3
226 | 2    : 2
227 | 
228 | 229 | 230 | 231 | ## 순환 비트 시프트 232 | 233 | ### rotl 234 | 왼쪽 순환 시프트 235 | 236 | ``` 237 | #include 238 | #include 239 | #include 240 | 241 | int main() 242 | { 243 | auto i = static_cast(0b0001'0000'0000'0000'0000'0000'0000'0000u); 244 | std::uint32_t a = std::rotl(i, 4); 245 | assert(a == 0b0000'0000'0000'0000'0000'0000'0000'0001u); 246 | 247 | std::uint32_t b = std::rotl(i, -4); 248 | assert(b == 0b0000'0001'0000'0000'0000'0000'0000'0000u); 249 | } 250 | ``` 251 | 252 | 253 | ### rotr 254 | 오른쪽 순환 시프트 255 | 256 | ``` 257 | #include 258 | #include 259 | #include 260 | 261 | int main() 262 | { 263 | auto i = static_cast(0b0000'0000'0000'0000'0000'0000'0000'1000u); 264 | std::uint32_t a = std::rotr(i, 4); 265 | assert(a == 0b1000'0000'0000'0000'0000'0000'0000'0000u); 266 | 267 | std::uint32_t b = std::rotr(i, -4); 268 | assert(b == 0b0000'0000'0000'0000'0000'0000'1000'0000u); 269 | } 270 | ``` 271 | 272 | 273 | 274 | ## 비트 카운트 275 | 276 | ### countl_zero 277 | 왼쪽에서 연속한 0의 비트를 계산한다 278 | 279 | ``` 280 | #include 281 | #include 282 | #include 283 | 284 | int main() 285 | { 286 | auto i = static_cast(0b0001'0000'0000'0000'0000'0000'0000'0000u); 287 | int n = std::countl_zero(i); 288 | assert(n == 3); 289 | 290 | 291 | assert(std::countl_zero(static_cast(0b1000'0000'0000'0000'0000'0000'0000'0000u)) == 0); 292 | assert(std::countl_zero(static_cast(0b0100'0000'0000'0000'0000'0000'0000'0000u)) == 1); 293 | assert(std::countl_zero(static_cast(0u)) == 32); 294 | } 295 | ``` 296 | 297 | 298 | ### countl_one 299 | 왼쪽에서 연속한 1의 비트를 계산한다 300 | 301 | ``` 302 | #include 303 | #include 304 | #include 305 | 306 | int main() 307 | { 308 | auto i = static_cast(0b1110'0000'0000'0000'0000'0000'0000'0000u); 309 | int n = std::countl_one(i); 310 | assert(n == 3); 311 | 312 | i = static_cast(0b1110'0000'0000'0000'0000'0000'0000'0001u); 313 | n = std::countl_one(i); 314 | assert(n == 3); 315 | 316 | assert(std::countl_one(static_cast(0u)) == 0); 317 | assert(std::countl_one(static_cast(0b1000'0000'0000'0000'0000'0000'0000'0000u)) == 1); 318 | assert(std::countl_one(static_cast(0b1111'1111'1111'1111'1111'1111'1111'1111u)) == 32); 319 | } 320 | ``` 321 | 322 | 323 | ### countr_zero 324 | 오른쪽에서 연속한 0의 비트를 계산한다 325 | 326 | ``` 327 | #include 328 | #include 329 | #include 330 | 331 | int main() 332 | { 333 | auto i = static_cast(0b0000'0000'0000'0000'0000'0000'0000'1000u); 334 | int n = std::countr_zero(i); 335 | assert(n == 3); 336 | 337 | assert(std::countr_zero(static_cast(0b0000'0000'0000'0000'0000'0000'0000'0001u)) == 0); 338 | assert(std::countr_zero(static_cast(0b0000'0000'0000'0000'0000'0000'0000'0010u)) == 1); 339 | assert(std::countr_zero(static_cast(0u)) == 32); 340 | } 341 | ``` 342 | 343 | 344 | ### countr_one 345 | 오른쪽에서 연속한 1의 비트를 계산한다 346 | 347 | ``` 348 | #include 349 | #include 350 | #include 351 | 352 | int main() 353 | { 354 | auto i = static_cast(0b0000'0000'0000'0000'0000'0000'0000'0111u); 355 | int n = std::countr_one(i); 356 | assert(n == 3); 357 | 358 | assert(std::countr_one(static_cast(0u)) == 0); 359 | assert(std::countr_one(static_cast(0b0000'0000'0000'0000'0000'0000'0000'0001u)) == 1); 360 | assert(std::countr_one(static_cast(0b1111'1111'1111'1111'1111'1111'1111'1111u)) == 32); 361 | } 362 | ``` 363 | 364 | 365 | ### popcount 366 | 1로 된 비트를 계산한다 367 | 368 | ``` 369 | #include 370 | #include 371 | #include 372 | 373 | int main() 374 | { 375 | auto i = static_cast(0b1000'0000'0000'1010'0000'0000'0000'1000u); 376 | int n = std::popcount(i); 377 | assert(n == 4); 378 | } 379 | ``` 380 | 381 | 382 | 383 | ## 참고 사이트 384 | - https://cpprefjp.github.io/reference/bit.html 385 | - [ in Visual Studio 2019 version 16.8 Preview 2](https://devblogs.microsoft.com/cppblog/bit-in-visual-studio-2019-version-16-8-preview-2/ ) -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/DM-1.2.DOC: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/DM-1.2.DOC -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/DM.DOC: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/DM.DOC -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/README.NOW: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/README.NOW -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/README.md: -------------------------------------------------------------------------------- 1 | # mudmuhan 2 | 텍스트 머드에 많이 사용되는 muhan소스 3 | (근간은 modor엔진, 금오공대 네트웍 동아리에서 한글화 및 수정) 4 | (telet서버이나, 소켓통신, c기반 코딩되 있음) 5 | 6 | https://github.com/jacking75 7 | 님 요청으로 올려둠 8 | 9 | 원래 찾아서 공유하려던 나이스캡짱은 아직 소스를 못 찾음. 10 | (기반은 그놈이 그놈임, 안시코드가 화려하고, 컨텐츠가 틀릴뿐임) -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/.mtype.h.swo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/.mtype.h.swo -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/README -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/README.update: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/README.update -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/action.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/action.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/alias.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/alias.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/auth.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTH.C: 3 | * 4 | * Performs user authentication services. Retrieves the 5 | * host name of the user. Also retrieves the user id if 6 | * the host is running identd. 7 | * 8 | * Copyright (C) 1994 Brett J. Vickers 9 | * 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #define MIGNORE 24 | #include "mstruct.h" 25 | #include "mextern.h" 26 | #include "strstr.c" 27 | 28 | char Output[2][80]; 29 | char *start_auth(); 30 | void parse(); 31 | int abort(); 32 | 33 | main(argc, argv) 34 | int argc; 35 | char *argv[]; 36 | { 37 | FILE *fp; 38 | char ipaddr[80], filename[127]; 39 | int oport, iport; 40 | char buf[80]; 41 | struct hostent *h; 42 | struct in_addr in; 43 | struct itimerval timer_value; 44 | 45 | timer_value.it_interval.tv_sec = 0L; 46 | timer_value.it_interval.tv_usec = 0L; 47 | timer_value.it_value.tv_sec = 20L; 48 | timer_value.it_value.tv_usec = 0L; 49 | 50 | setitimer(ITIMER_REAL, &timer_value, 0); 51 | 52 | signal(SIGALRM, abort); 53 | 54 | if(argc != 4) { 55 | fprintf(stderr, "Syntax: %s ip_address oport iport\n", argv[0]); 56 | exit(0); 57 | } 58 | 59 | strcpy(ipaddr, argv[1]); 60 | oport = atoi(argv[2]); 61 | iport = atoi(argv[3]); 62 | in.s_addr = inet_addr(ipaddr); 63 | 64 | /* Perform the host name lookup on the IP address*/ 65 | h = gethostbyaddr((char *)&in, sizeof(in), AF_INET); 66 | if(!h) 67 | strcpy(Output[1], "UNKNOWN"); 68 | else 69 | strcpy(Output[1], h->h_name); 70 | 71 | /* Begin the user id lookup */ 72 | if(start_auth(&in, oport, iport, buf)) 73 | strcpy(Output[0], buf); 74 | else 75 | strcpy(Output[0], "no_port"); 76 | 77 | /* Save the results to a file so frp can look them up */ 78 | sprintf(filename, "%s/auth/lookup.%d", LOGPATH, getpid()); 79 | fp = fopen(filename, "w"); 80 | if(!fp) exit(-1); 81 | fprintf(fp, "%s\n%s\n", Output[0], Output[1]); 82 | fclose(fp); 83 | 84 | exit(0); 85 | } 86 | 87 | /************************************************************************/ 88 | /* start_auth */ 89 | /************************************************************************/ 90 | 91 | /* This function opens a socket to the identd port of the player's */ 92 | /* machine (port 113) and requests the user id of that player. */ 93 | 94 | char *start_auth(in, oport, iport, buf) 95 | struct in_addr *in; 96 | int oport, iport; 97 | char *buf; 98 | { 99 | struct sockaddr_in sin; 100 | int fd, i, n, Tablesize, len; 101 | fd_set Sockets, sockcheck; 102 | struct timeval t; 103 | char outstr[80]; 104 | 105 | t.tv_sec = 10L; 106 | t.tv_usec = 0L; 107 | 108 | sin.sin_addr.s_addr = in->s_addr; 109 | sin.sin_family = AF_INET; 110 | sin.sin_port = htons(113); 111 | 112 | fd = socket(AF_INET, SOCK_STREAM, 0); 113 | if(fd < 0) return((char *)0); 114 | 115 | if(connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) 116 | return((char *)0); 117 | 118 | FD_ZERO(&Sockets); 119 | FD_SET(fd, &Sockets); 120 | 121 | /* Generate request string */ 122 | sprintf(outstr, "%d , %d\r\n", oport, iport); 123 | len = strlen(outstr); 124 | 125 | Tablesize = getdtablesize(); 126 | sockcheck = Sockets; 127 | 128 | /* Wait until we can send our request */ 129 | if(select(Tablesize, 0, &sockcheck, 0, &t) <= 0) 130 | return((char *)0); 131 | 132 | /* Send the request */ 133 | n = write(fd, outstr, len); 134 | if(n < len) return((char *)0); 135 | 136 | /* Wait until the other side responds */ 137 | sockcheck = Sockets; 138 | if(select(Tablesize, &sockcheck, 0, 0, &t) <= 0) 139 | return((char *)0); 140 | 141 | /* Read the response */ 142 | n = read(fd, buf, 80); 143 | close(fd); 144 | if(n <= 0) 145 | return((char *)0); 146 | else { 147 | buf[n-1] = 0; 148 | parse(buf); 149 | return(buf); 150 | } 151 | } 152 | 153 | /************************************************************************/ 154 | /* parse */ 155 | /************************************************************************/ 156 | 157 | /* This function parses the response from the identity server. It */ 158 | /* essentially strips out the user id if there is one to be obtained. */ 159 | 160 | void parse(buf) 161 | char *buf; 162 | { 163 | char *p, temp[80]; 164 | 165 | if(p = (char *)strstr(buf, "USERID")) { 166 | while(*p && *p != ':') p++; p++; 167 | while(*p && *p != ':') p++; 168 | while(*p && 169 | !(*p <= '9' && *p >= '0') && 170 | !(*p <= 'z' && *p >= 'a') && 171 | !(*p <= 'Z' && *p >= 'A')) p++; 172 | strcpy(temp, p); 173 | p = temp; 174 | while(*p && 175 | ((*p >= 'a' && *p <='z') || 176 | (*p >= 'A' && *p <='Z') || 177 | (*p >= '0' && *p <= '9'))) p++; 178 | *p = 0; 179 | strcpy(buf, temp); 180 | buf[8] = 0; 181 | } 182 | else { 183 | strcpy(buf, "unknown"); 184 | } 185 | 186 | } 187 | 188 | /************************************************************************/ 189 | /* logf */ 190 | /************************************************************************/ 191 | 192 | /* Log debugging information if necessary. */ 193 | 194 | void logf(fmt, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10) 195 | char *fmt; 196 | int i1, i2, i3, i4, i5, i6, i7, i8, i9, i10; 197 | { 198 | char file[80]; 199 | char str[1024]; 200 | int fd; 201 | 202 | sprintf(file, "%s/authlog", LOGPATH); 203 | fd = open(file, O_RDWR, 0); 204 | if(fd < 0) { 205 | fd = open(file, O_RDWR | O_CREAT, ACC); 206 | if(fd < 0) return; 207 | } 208 | lseek(fd, 0L, 2); 209 | 210 | sprintf(str, fmt, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10); 211 | 212 | write(fd, str, strlen(str)); 213 | 214 | close(fd); 215 | } 216 | 217 | int abort() 218 | { 219 | exit(0); 220 | } 221 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/bank.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/bank.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/bank_check.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/bank_check.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/board.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/board.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/board.h: -------------------------------------------------------------------------------- 1 | #ifndef _BOARD_H_ 2 | #define _BOARD_H_ 3 | 4 | extern object *board_obj[PMAX]; 5 | extern int board_handle[PMAX]; 6 | extern int board_handle2[PMAX]; 7 | extern long board_pos[PMAX]; 8 | extern char board_title[PMAX][44]; 9 | 10 | int look_board(); 11 | void list_board(); 12 | int writeboard(); 13 | void write_board(); 14 | int read_board(); 15 | int del_board(); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/command1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/command1.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/command10.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/command10.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/command11.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/command11.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/command12.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/command12.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/command2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/command2.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/command3.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/command3.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/command4.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/command4.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/command5.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/command5.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/command6.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/command6.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/command7.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/command7.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/command8.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/command8.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/command9.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/command9.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/compress.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COMPRESS.C: 3 | * 4 | * Routines to do LZW compression on the player data. 5 | * Compression code was adapted from another program 6 | * and modified to perform in-memory compression. 7 | * 8 | * Copyright (C) 1992, 1993 Brett J. Vickers 9 | * 10 | */ 11 | 12 | #ifdef COMPRESS 13 | 14 | #include 15 | #include "mstruct.h" 16 | #include "mextern.h" 17 | 18 | #define FALSE 0 19 | #define TRUE !FALSE 20 | #define TABSIZE 4096 21 | #define STACKSIZE TABSIZE 22 | #define NO_PRED 0xFFFF 23 | #define EMPTY 0xFFFF 24 | #define NOT_FND 0xFFFF 25 | #define UEOF ((unsigned)EOF) 26 | #define UPDATE TRUE 27 | #define NO_UPDATE FALSE 28 | 29 | static struct tabent { 30 | char used; 31 | unsigned int next; 32 | unsigned int predecessor; 33 | unsigned char follower; 34 | } string_tab[TABSIZE]; 35 | 36 | static char *start_inbuf, *start_outbuf; 37 | static char *inbuf, *outbuf; 38 | static int sizeof_inbuf, sizeof_outbuf; 39 | static unsigned int temp_inbuf; 40 | static unsigned int temp_outbuf; 41 | static char stack[STACKSIZE]; 42 | static int sp; 43 | 44 | unsigned int h(), eolist(), hash(), unhash(), getcode(), readc(), writec(); 45 | void init_tab(), upd_tab(), flushout(), putcode(), push(); 46 | int pop(), compress(), uncompress(); 47 | 48 | unsigned int h(prev, next) 49 | unsigned int prev; 50 | unsigned char next; 51 | { 52 | long i, j; 53 | 54 | i = (prev + next) | 0x0800; 55 | j = i * i; 56 | i = (j >> 6) & 0x0FFF; 57 | return(i); 58 | } 59 | 60 | unsigned int eolist(i) 61 | unsigned int i; 62 | { 63 | register int t; 64 | 65 | while(t = string_tab[i].next) 66 | i = t; 67 | return(i); 68 | } 69 | 70 | unsigned int hash(prev, next, update) 71 | unsigned int prev; 72 | unsigned char next; 73 | int update; 74 | { 75 | unsigned int i, temp; 76 | struct tabent *ep; 77 | 78 | i = h(prev, next); 79 | if(!string_tab[i].used) 80 | return(i); 81 | else { 82 | i = eolist(i); 83 | temp = (i + 101) & 0x0FFF; 84 | ep = &string_tab[temp]; 85 | while(ep->used) { 86 | temp++; 87 | if(temp == TABSIZE) { 88 | temp = 0; 89 | ep = string_tab; 90 | } 91 | else 92 | ep++; 93 | } 94 | 95 | if(update) 96 | string_tab[i].next = temp; 97 | return(temp); 98 | } 99 | } 100 | 101 | unsigned int unhash(prev, next) 102 | unsigned int prev; 103 | unsigned char next; 104 | { 105 | unsigned int i, offset; 106 | struct tabent *ep; 107 | 108 | i = h(prev, next); 109 | loop: 110 | ep = &string_tab[i]; 111 | if((ep->predecessor == prev) && (ep->follower == next)) 112 | return(i); 113 | if(!ep->next) 114 | return(NOT_FND); 115 | i = ep->next; 116 | goto loop; 117 | } 118 | 119 | void init_tab() 120 | { 121 | int i; 122 | 123 | temp_outbuf = temp_inbuf = EMPTY; 124 | sp = 0; 125 | memset((char *)string_tab, 0, sizeof(string_tab)); 126 | for(i=0; i<256; i++) 127 | upd_tab(NO_PRED,i); 128 | } 129 | 130 | void upd_tab(prev, next) 131 | unsigned int prev, next; 132 | { 133 | struct tabent *ep; 134 | 135 | ep = &string_tab[hash(prev, next, UPDATE)]; 136 | ep->used = TRUE; 137 | ep->next = 0; 138 | ep->predecessor = prev; 139 | ep->follower = next; 140 | } 141 | 142 | unsigned int getcode() 143 | { 144 | unsigned int localbuf, returnval; 145 | 146 | if(temp_inbuf == EMPTY) { 147 | if((localbuf = readc()) == UEOF) 148 | return(UEOF); 149 | localbuf &= 0xFF; 150 | 151 | if((temp_inbuf = readc()) == UEOF) 152 | return(UEOF); 153 | temp_inbuf &= 0xFF; 154 | 155 | returnval = ((localbuf << 4) & 0xFF0) | 156 | ((temp_inbuf >> 4) & 0x00F); 157 | temp_inbuf &= 0x000F; 158 | } 159 | 160 | else { 161 | if((localbuf = readc()) == UEOF) 162 | return(UEOF); 163 | localbuf &= 0xFF; 164 | 165 | returnval = localbuf | ((temp_inbuf << 8) & 0xF00); 166 | temp_inbuf = EMPTY; 167 | } 168 | 169 | return(returnval); 170 | } 171 | 172 | void putcode(code) 173 | unsigned int code; 174 | { 175 | unsigned int localbuf; 176 | 177 | if(temp_outbuf == EMPTY) { 178 | writec((code >> 4) & 0xFF); 179 | temp_outbuf = code & 0x000F; 180 | } 181 | 182 | else { 183 | writec(((temp_outbuf << 4) & 0xFF0) | ((code >> 8) & 0x00F)); 184 | writec(code & 0x00FF); 185 | temp_outbuf = EMPTY; 186 | } 187 | } 188 | 189 | unsigned int readc() 190 | { 191 | if(inbuf - start_inbuf >= sizeof_inbuf) 192 | return(UEOF); 193 | else 194 | return((*(inbuf++) & 0xFF)); 195 | } 196 | 197 | unsigned int writec(ch) 198 | int ch; 199 | { 200 | *outbuf = (char)ch; 201 | outbuf++; 202 | sizeof_outbuf++; 203 | } 204 | 205 | void flushout() 206 | { 207 | if(temp_outbuf != EMPTY) { 208 | *outbuf = (temp_outbuf << 4) & 0xFF0; 209 | outbuf++; 210 | sizeof_outbuf++; 211 | } 212 | } 213 | 214 | int compress(in, out, size) 215 | char *in; 216 | char *out; 217 | int size; 218 | { 219 | unsigned int c, code, localcode; 220 | int code_count = TABSIZE - 256; 221 | 222 | start_inbuf = inbuf = in; 223 | start_outbuf = outbuf = out; 224 | sizeof_inbuf = size; 225 | sizeof_outbuf = 0; 226 | 227 | init_tab(); 228 | c = readc(); 229 | code = unhash(NO_PRED, c); 230 | 231 | while((c = readc()) != UEOF) { 232 | if((localcode = unhash(code, c)) != NOT_FND) { 233 | code = localcode; 234 | continue; 235 | } 236 | 237 | putcode(code); 238 | if(code_count) { 239 | upd_tab(code, c); 240 | code_count--; 241 | } 242 | 243 | code = unhash(NO_PRED, c); 244 | } 245 | 246 | putcode(code); 247 | flushout(); 248 | 249 | return(sizeof_outbuf); 250 | } 251 | 252 | int uncompress(in, out, size) 253 | char *in; 254 | char *out; 255 | int size; 256 | { 257 | unsigned int c, tempc, code, oldcode, incode, finchar, lastchar; 258 | char unknown = FALSE; 259 | int code_count = TABSIZE - 256; 260 | struct tabent *ep; 261 | 262 | start_inbuf = inbuf = in; 263 | start_outbuf = outbuf = out; 264 | sizeof_inbuf = size; 265 | sizeof_outbuf = 0; 266 | 267 | init_tab(); 268 | code = oldcode = getcode(); 269 | 270 | c = string_tab[code].follower; 271 | writec(c); 272 | finchar = c; 273 | 274 | while((code = incode = getcode()) != UEOF) { 275 | ep = &string_tab[code]; 276 | if(!ep->used) { 277 | lastchar = finchar; 278 | code = oldcode; 279 | unknown = TRUE; 280 | ep = &string_tab[code]; 281 | } 282 | 283 | while(ep->predecessor != NO_PRED) { 284 | push(ep->follower); 285 | code = ep->predecessor; 286 | ep = &string_tab[code]; 287 | } 288 | 289 | finchar = ep->follower; 290 | writec(finchar); 291 | while((tempc = pop()) != EMPTY) 292 | writec(tempc); 293 | 294 | if(unknown) { 295 | writec(finchar = lastchar); 296 | unknown = FALSE; 297 | } 298 | if(code_count) { 299 | upd_tab(oldcode,finchar); 300 | code_count--; 301 | } 302 | oldcode = incode; 303 | } 304 | flushout(); 305 | 306 | return(sizeof_outbuf); 307 | } 308 | 309 | void push(c) 310 | int c; 311 | { 312 | stack[sp] = (char) c; 313 | sp++; 314 | if(sp >= STACKSIZE) 315 | merror(FATAL, "Stack overflow"); 316 | } 317 | 318 | int pop() 319 | { 320 | if(sp > 0) { 321 | sp--; 322 | return((int)stack[sp]); 323 | } 324 | else 325 | return(EMPTY); 326 | } 327 | 328 | #endif 329 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/creature.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/creature.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/dm1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/dm1.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/dm2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/dm2.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/dm3.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/dm3.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/dm4.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/dm4.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/dm5.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/dm5.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/dm6.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/dm6.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/files1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/files1.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/finger.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FINGER.C: 3 | * 4 | * Remote finger functions 5 | * 6 | * Copyright (C) 1992, 1993 Brett J. Vickers 7 | * 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define write_fd(a,b) write(a, b, strlen(b)); 23 | 24 | main(argc, argv) 25 | int argc; 26 | char *argv[]; 27 | { 28 | void finger(); 29 | int fd; 30 | 31 | if(argc < 3) exit(0); 32 | 33 | fd = atoi(argv[1]); 34 | if(argc == 4) 35 | finger(fd, argv[2], argv[3]); 36 | else 37 | finger(fd, argv[2], ""); 38 | } 39 | 40 | /************************************************************************/ 41 | /* finger */ 42 | /************************************************************************/ 43 | 44 | void finger(fd, address, person) 45 | int fd; 46 | char *address; 47 | char *person; 48 | { 49 | int new_sock, n, Tablesize; 50 | char buf[80]; 51 | unsigned long addr; 52 | struct sockaddr_in sin; 53 | struct hostent *h; 54 | fd_set mask; 55 | 56 | if((addr = inet_addr(address)) != -1) 57 | sin.sin_family = AF_INET; 58 | 59 | else if((h = gethostbyname(address)) != NULL) { 60 | sin.sin_family = h->h_addrtype; 61 | bcopy(h->h_addr, &addr, h->h_length); 62 | } 63 | 64 | else { 65 | write_fd(fd, "\n\rInvalid host address\n\r"); 66 | exit(0); 67 | } 68 | 69 | sin.sin_addr.s_addr = addr; 70 | sin.sin_port = htons(79); 71 | 72 | if((new_sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { 73 | write_fd(fd, "\n\rUnable to connect to finger server.\n\r"); 74 | exit(0); 75 | } 76 | 77 | if(connect(new_sock, (struct sockaddr *)&sin, sizeof(sin)) < 0) { 78 | write_fd(fd, "\n\rUnable to connect to finger server.\n\r"); 79 | exit(0); 80 | } 81 | 82 | write(new_sock, person, strlen(person)); 83 | write(new_sock, "\n\r\n\r", 4); 84 | 85 | FD_ZERO(&mask); 86 | 87 | Tablesize = getdtablesize(); 88 | 89 | while(1) { 90 | FD_SET(new_sock, &mask); 91 | select(Tablesize, &mask, 0, 0, 0); 92 | n = read(new_sock, buf, 80); 93 | if(n <= 0) { 94 | close(new_sock); 95 | exit(0); 96 | } 97 | write(fd, buf, n); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/global.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/global.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/io.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/io.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/kstbl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/kstbl.h -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/magic1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/magic1.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/magic2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/magic2.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/magic3.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/magic3.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/magic4.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/magic4.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/magic5.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/magic5.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/magic6.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/magic6.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/magic7.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/magic7.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/magic8.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/magic8.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/main.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/makefile -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/mextern.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/mextern.h -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/misc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/misc.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/mstruct.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/mstruct.h -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/mstruct2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/mstruct2.h -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/mtype.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/mtype.h -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/object.c: -------------------------------------------------------------------------------- 1 | /* 2 | * OBJECT.C: 3 | * 4 | * Routines that deal with objects and items. 5 | * 6 | * Copyright (C) 1991, 1992, 1993 Brett J. Vickers 7 | * 8 | */ 9 | 10 | #include "mstruct.h" 11 | #include "mextern.h" 12 | 13 | int check_event_obj(crt_ptr) 14 | creature *crt_ptr; 15 | { 16 | otag *op, *op2; 17 | if(!crt_ptr->first_obj) return 0; 18 | op=crt_ptr->first_obj; 19 | while(1) { 20 | if(F_ISSET(op->obj, OEVENT)) return 1; 21 | if(op->obj->questnum) return 1; 22 | 23 | if(op->obj->first_obj) { 24 | op2=op->obj->first_obj; 25 | while(1) { 26 | if(F_ISSET(op2->obj, OEVENT)) return 1; 27 | if(op2->obj->questnum) return 1; 28 | if(!op2->next_tag) break; 29 | op2=op2->next_tag; 30 | } 31 | } 32 | if(!op->next_tag) return 0; 33 | op=op->next_tag; 34 | } 35 | } 36 | 37 | /**********************************************************************/ 38 | /* add_obj_obj */ 39 | /**********************************************************************/ 40 | 41 | /* This function adds the object pointed to by the first parameter to */ 42 | /* the contents of the object pointed to by the second parameter. It */ 43 | /* is done alphabetically. */ 44 | 45 | void add_obj_obj(obj_ptr1, obj_ptr2) 46 | object *obj_ptr1; 47 | object *obj_ptr2; 48 | { 49 | otag *op, *temp, *prev; 50 | 51 | obj_ptr1->parent_obj = obj_ptr2; 52 | obj_ptr1->parent_crt = 0; 53 | obj_ptr1->parent_rom = 0; 54 | 55 | op = (otag *)malloc(sizeof(otag)); 56 | if(!op) 57 | merror("add_obj_obj", FATAL); 58 | op->obj = obj_ptr1; 59 | op->next_tag = 0; 60 | 61 | if(!obj_ptr2->first_obj) { 62 | obj_ptr2->first_obj = op; 63 | return; 64 | } 65 | 66 | temp = obj_ptr2->first_obj; 67 | if(strcmp(temp->obj->name, obj_ptr1->name) > 0 || 68 | (!strcmp(temp->obj->name, obj_ptr1->name) && 69 | temp->obj->adjustment > obj_ptr1->adjustment)) { 70 | op->next_tag = temp; 71 | obj_ptr2->first_obj = op; 72 | return; 73 | } 74 | 75 | while(temp) { 76 | if(strcmp(temp->obj->name, obj_ptr1->name) > 0 || 77 | (!strcmp(temp->obj->name, obj_ptr1->name) && 78 | temp->obj->adjustment > obj_ptr1->adjustment)) 79 | break; 80 | prev = temp; 81 | temp = temp->next_tag; 82 | } 83 | op->next_tag = prev->next_tag; 84 | prev->next_tag = op; 85 | 86 | } 87 | 88 | /**********************************************************************/ 89 | /* del_obj_obj */ 90 | /**********************************************************************/ 91 | 92 | /* This function removes the object pointed to by the first parameter */ 93 | /* from the object pointed to by the second. */ 94 | 95 | void del_obj_obj(obj_ptr1, obj_ptr2) 96 | object *obj_ptr1; 97 | object *obj_ptr2; 98 | { 99 | otag *temp, *prev; 100 | 101 | obj_ptr1->parent_crt = 0; 102 | if(obj_ptr2->first_obj->obj == obj_ptr1) { 103 | temp = obj_ptr2->first_obj->next_tag; 104 | free(obj_ptr2->first_obj); 105 | obj_ptr2->first_obj = temp; 106 | return; 107 | } 108 | 109 | prev = obj_ptr2->first_obj; 110 | temp = prev->next_tag; 111 | while(temp) { 112 | if(temp->obj == obj_ptr1) { 113 | prev->next_tag = temp->next_tag; 114 | free(temp); 115 | return; 116 | } 117 | prev = temp; 118 | temp = temp->next_tag; 119 | } 120 | } 121 | 122 | /**********************************************************************/ 123 | /* find_obj */ 124 | /**********************************************************************/ 125 | 126 | /* This function is used to search through a room's, creature's or */ 127 | /* object's inventory in order to look for a particular item. The */ 128 | /* first parameter contains a pointer to the creature who is doing the */ 129 | /* search. The second is a pointer to the first object tag in the */ 130 | /* list to be searched. The third parameter is a string that contains */ 131 | /* the name of the object being searched for. The last parameter */ 132 | /* contains the version of the string being searched for. */ 133 | 134 | object *find_obj(ply_ptr, first_ot, str, val) 135 | creature *ply_ptr; 136 | otag *first_ot; 137 | char *str; 138 | int val; 139 | { 140 | otag *op; 141 | int match=0, found=0; 142 | 143 | op = first_ot; 144 | while(op) { 145 | if(EQUAL(op->obj, str) && 146 | (F_ISSET(ply_ptr, PDINVI) ? 147 | 1:!F_ISSET(op->obj, OINVIS))) { 148 | match++; 149 | if(match == val) { 150 | found = 1; 151 | break; 152 | } 153 | } 154 | op = op->next_tag; 155 | } 156 | 157 | if(found) 158 | return(op->obj); 159 | else 160 | return(0); 161 | } 162 | 163 | /**********************************************************************/ 164 | /* list_obj */ 165 | /**********************************************************************/ 166 | 167 | /* This function produces a string which lists all the objects in a */ 168 | /* player's, room's or object's inventory. The first parameter holds */ 169 | /* a pointer to the string which will be produced. The second is a */ 170 | /* pointer to the player who is having the list produced. The last */ 171 | /* is a pointer to the first object tag in the list of items that */ 172 | /* it being listed. */ 173 | 174 | int list_obj(str, ply_ptr, first_otag) 175 | char *str; 176 | creature *ply_ptr; 177 | otag *first_otag; 178 | { 179 | otag *op; 180 | int m, n=0, flags=0; 181 | 182 | if(F_ISSET(ply_ptr, PDINVI)) 183 | flags |= INV; 184 | if(F_ISSET(ply_ptr, PDMAGI)) 185 | flags |= MAG; 186 | 187 | str[0] = 0; 188 | op = first_otag; 189 | while(op && strlen(str) < 1970) { 190 | if((F_ISSET(ply_ptr, PDINVI) ? 1:!F_ISSET(op->obj, OINVIS)) && 191 | !F_ISSET(op->obj, OHIDDN) && !F_ISSET(op->obj, OSCENE)) { 192 | m=1; 193 | while(op->next_tag) { 194 | if(!strcmp(op->next_tag->obj->name, 195 | op->obj->name) && 196 | (op->next_tag->obj->adjustment == 197 | op->obj->adjustment || 198 | !F_ISSET(ply_ptr, PDMAGI)) && 199 | (F_ISSET(ply_ptr, PDINVI) ? 200 | 1:!F_ISSET(op->next_tag->obj, OINVIS)) && 201 | !F_ISSET(op->next_tag->obj, OHIDDN) && 202 | !F_ISSET(op->next_tag->obj, OSCENE)) { 203 | m++; 204 | op = op->next_tag; 205 | } 206 | else 207 | break; 208 | } 209 | strcat(str, obj_str(op->obj, m, flags)); 210 | 211 | strcat(str, ", "); 212 | n++; 213 | } 214 | op = op->next_tag; 215 | } 216 | if(n) { 217 | str[strlen(str)-2] = 0; 218 | return(1); 219 | } 220 | else 221 | return(0); 222 | 223 | } 224 | 225 | /**********************************************************************/ 226 | /* weight_obj */ 227 | /**********************************************************************/ 228 | 229 | /* This function computes the total amount of weight of an object and */ 230 | /* all its contents. */ 231 | 232 | int weight_obj(obj_ptr) 233 | object *obj_ptr; 234 | { 235 | int n; 236 | otag *op; 237 | 238 | n = obj_ptr->weight; 239 | op = obj_ptr->first_obj; 240 | while(op) { 241 | if(!F_ISSET(op->obj, OWTLES)) 242 | n += weight_obj(op->obj); 243 | op = op->next_tag; 244 | } 245 | 246 | return(n); 247 | 248 | } 249 | 250 | 251 | /************************************************************************/ 252 | /* rand_enchant */ 253 | /************************************************************************/ 254 | 255 | /* This function randomly enchants an object if its random-enchant flag */ 256 | /* is set. */ 257 | 258 | void rand_enchant(obj_ptr) 259 | object *obj_ptr; 260 | { 261 | char m; 262 | 263 | m = mrand(1,100); 264 | if(m > 98) { 265 | F_SET(obj_ptr, OENCHA); 266 | obj_ptr->adjustment = 3; 267 | obj_ptr->pdice += 3; 268 | } 269 | else if(m > 90) { 270 | F_SET(obj_ptr, OENCHA); 271 | obj_ptr->adjustment = 2; 272 | obj_ptr->pdice += 2; 273 | } 274 | else if(m > 50) { 275 | F_SET(obj_ptr, OENCHA); 276 | obj_ptr->adjustment = 1; 277 | obj_ptr->pdice += 1; 278 | } 279 | 280 | obj_ptr->pdice = MAX(obj_ptr->pdice, obj_ptr->adjustment); 281 | } 282 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/player.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/player.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/player2.c: -------------------------------------------------------------------------------- 1 | #include "mstruct.h" 2 | #include "mextern.h" 3 | 4 | int init_ply2(ply_ptr) 5 | creature *ply_ptr; 6 | { 7 | int handle,fd; 8 | creature2 *new_ptr; 9 | 10 | fd=ply_ptr->fd; 11 | 12 | new_ptr=(creature2 *)malloc(sizeof(creature2)); 13 | if(!new_ptr) merror("init_ply2",FATAL); 14 | 15 | strcpy(new_ptr->title, 16 | if((handle=open(name,O_RDONLY))==-1) { 17 | 18 | save_ply2(fd); 19 | return; 20 | } 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/plist.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "mstruct.h" 4 | #include "mextern.h" 5 | 6 | #define set_flag(f,n) ((f) |= 1 << (n)) 7 | #define clr_flag(f,n) ((f) &= ~(1 << (n))) 8 | #define is_fset(f,n) ((f) & 1 << (n)) 9 | 10 | main(int argc, char *argv[]) 11 | /* plist coomand provides a quick way to check a given players * 12 | * level, class, password and inventory without having to log * 13 | * the player in or use the editor */ 14 | 15 | { 16 | creature *player; 17 | int i,adj,lvl=0; 18 | char flags = 0; 19 | 20 | adj = 1; 21 | 22 | 23 | if (argc < 2) { 24 | printf("syntax: plist [[-pni] [-l #]] \n"); 25 | return; 26 | } 27 | 28 | for (i=1;i\n"); 64 | return; 65 | } 66 | 67 | } 68 | adj = i; 69 | 70 | if (adj >= argc){ 71 | printf("syntax: plist [[-pni] [-l #]] \n"); 72 | return; 73 | } 74 | 75 | for(i= adj;i < argc; i++){ 76 | 77 | if(!isupper(argv[i][0])) 78 | continue; 79 | if(load_ply(argv[i], &player) < 0){ 80 | printf("Player Load Error (%s).\n", argv[i]); 81 | continue; 82 | } 83 | 84 | /* not lvl check or player = lvl */ 85 | if( !lvl || player->level == lvl){ 86 | printf("%s%s",(!is_fset(flags,1)) ? "Name: " : "", 87 | player->name); 88 | 89 | /*print password */ 90 | if (is_fset(flags,2)) 91 | printf(" (%s)\n",player->password); 92 | else 93 | printf("\n"); 94 | 95 | /* if not name only display */ 96 | if(!is_fset(flags,1)) 97 | printf("Class: %s (%d) %s\n",class_str[player->class], 98 | player->level,race_str[player->race]); 99 | 100 | /* print players inventory */ 101 | if(is_fset(flags,0)){ 102 | otag *obj, *cnt; 103 | int len = 0; 104 | 105 | printf("Inventory:\n"); 106 | obj = player->first_obj; 107 | if(!obj) printf("none"); 108 | 109 | while(obj){ 110 | printf("%s%s",obj->obj->name, (obj->next_tag) ? 111 | (F_ISSET(obj->obj,OCONTN)) ? ":" :", " : "."); 112 | len += strlen(obj->obj->name); 113 | 114 | if(F_ISSET(obj->obj,OCONTN)){ 115 | cnt = obj->obj->first_obj; 116 | printf("("); 117 | if (!cnt) printf("empty"); 118 | while(cnt){ 119 | printf("%s%s",cnt->obj->name, 120 | (cnt->next_tag) ? ", " : ""); 121 | len += strlen(cnt->obj->name); 122 | if (len > 50){ 123 | printf("\n"); 124 | len = 0; } 125 | cnt = cnt->next_tag; 126 | } 127 | printf(")%s",(obj->next_tag) ? ", " : "."); 128 | } 129 | if (len > 50){ 130 | printf("\n"); 131 | len = 0; 132 | } 133 | obj = obj->next_tag; 134 | } 135 | printf("\n"); 136 | } 137 | } 138 | 139 | free_crt(player); 140 | } 141 | 142 | return; 143 | } 144 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/post.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/post.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/room.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/room.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/sc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/sc.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/sp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/sp.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/special1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/special1.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/startm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct termio mbuf,systerm; 6 | void main() 7 | { 8 | if(fork()) exit(0); 9 | close(0);close(1);close(2); 10 | 11 | while(1) { 12 | ioctl(0, TCSETAF, &systerm); 13 | system("/home/muhan/bin/frp -r"); 14 | ioctl(0, TCSETAF, &mbuf); 15 | 16 | sleep(30); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/strstr.c: -------------------------------------------------------------------------------- 1 | /*Copyright (c) 1991 Xerox Corporation. All Rights Reserved. 2 | 3 | Permission to use, copy, modify and distribute without 4 | charge this software, documentation, images, etc. is grant- 5 | ed, provided that this copyright and the author's name is 6 | retained. 7 | 8 | A fee may be charged for this program ONLY to recover costs 9 | for distribution (i.e. media costs). No profit can be made 10 | on this program. 11 | 12 | The author assumes no responsibility for disasters (natural 13 | or otherwise) as a consequence of use of this software. 14 | 15 | Adam Stein (stein.wbst129@xerox.com) 16 | */ 17 | 18 | #include 19 | 20 | /*This function will find the first occurrence of a midstring (s2) in a 21 | string (s1). This function is here because BSD systems don't have it. 22 | 23 | Inputs: s1 - string to search through 24 | s2 - midstring to search for 25 | Outputs: pointer - start of midstring in string, NULL if midstring not found 26 | Locals: pointer - pointer to go through string 27 | save_s2 - save s2 since s2 changes when checking 28 | Globals: NULL - 0 29 | */ 30 | char *strstr(s1,s2) 31 | register char *s1,*s2; 32 | { 33 | register char *pointer,*save_s2; 34 | 35 | save_s2 = s2; 36 | 37 | for(pointer = s1;*pointer;++pointer) { 38 | if(*pointer == *s2) 39 | while(*pointer && *s2 && *(++pointer) == *(++s2)) ; 40 | 41 | /*If we matched every character from s2 then return pointer 42 | (which is pointing to the end of the substring in the main 43 | string) - the length of the substring. Else, return s2 to 44 | what it was originally and start looking again*/ 45 | if(!(*s2)) return(pointer-strlen(save_s2)); 46 | else s2 = save_s2; 47 | } 48 | 49 | return(NULL); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/update.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/update.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/src/update.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/src/update.h -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/README.util: -------------------------------------------------------------------------------- 1 | 2 | UTILITIES -- 3 | This is where the utility source code is. You will definitely 4 | need the editor at least, and it should compile with a simple 'make'. 5 | Also included here is the list command which allows you to look at the 6 | database on line. You need to compile it and put it in the bin directory 7 | if you want to examine the database while online. 8 | Message is a simple program that outputs a message when someone connets 9 | to a port. You can use it to put up a message on the game port when you 10 | are down for whatever reason. 11 | Italk and muddle are both clients. 12 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/dos2unix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/dos2unix -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/dos_ed/README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/dos_ed/README -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/dos_ed/ed.arj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/dos_ed/ed.arj -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/dos_ed/editor.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/dos_ed/editor.doc -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/dos_ed/editor.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/dos_ed/editor.exe -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/ed/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS = -m486 -O2 2 | LIBS = -lm -s 3 | CC = cc 4 | 5 | OBJECTS = global.o main.o files1.o files2.o command1.o command2.o \ 6 | command3.o command4.o command5.o command6.o command7.o \ 7 | command8.o magic1.o magic2.o magic3.o dm1.o io.o player.o \ 8 | creature.o room.o object.o update.o post.o misc.o 9 | 10 | OBJECTS2 = editor.o editor2.o editor3.o editor4.o compress.o 11 | 12 | OBJECTS3 = chat.o 13 | 14 | editor: $(OBJECTS2) 15 | $(CC) $(CFLAGS) $(OBJECTS2) -o editor $(LIBS) 16 | chmod o-rwx editor 17 | 18 | frp: $(OBJECTS) 19 | $(CC) $(CFLAGS) $(OBJECTS) -o frp $(LIBS) 20 | chmod o-wrx frp 21 | 22 | chat: $(OBJECTS3) 23 | $(CC) $(CFLAGS) $(OBJECTS3) -o chat $(LIBS) 24 | chmod o-rwx chat 25 | 26 | clean: 27 | rm $(OBJECTS) $(OBJECTS2) 28 | 29 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/ed/compress.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COMPRESS.C: 3 | * 4 | * Routines to do LZW compression on the player data. 5 | * 6 | * Copyright (C) 1992 Brett J. Vickers 7 | * 8 | */ 9 | 10 | #ifdef COMPRESS 11 | 12 | #include 13 | #include "mstruct.h" 14 | #include "mextern.h" 15 | 16 | #define FALSE 0 17 | #define TRUE !FALSE 18 | #define TABSIZE 4096 19 | #define STACKSIZE TABSIZE 20 | #define NO_PRED 0xFFFF 21 | #define EMPTY 0xFFFF 22 | #define NOT_FND 0xFFFF 23 | #define UEOF ((unsigned)EOF) 24 | #define UPDATE TRUE 25 | #define NO_UPDATE FALSE 26 | 27 | static struct entry { 28 | char used; 29 | unsigned int next; 30 | unsigned int predecessor; 31 | unsigned char follower; 32 | } string_tab[TABSIZE]; 33 | 34 | static char *start_inbuf, *start_outbuf; 35 | static char *inbuf, *outbuf; 36 | static int sizeof_inbuf, sizeof_outbuf; 37 | static unsigned int temp_inbuf; 38 | static unsigned int temp_outbuf; 39 | static char stack[STACKSIZE]; 40 | static int sp; 41 | 42 | unsigned int h(), eolist(), hash(), unhash(), getcode(), readc(), writec(); 43 | void init_tab(), upd_tab(), flushout(), putcode(), push(); 44 | int pop(), compress(), uncompress(); 45 | 46 | /* h uses the 'mid-square' algorithm. I.E. for a hash val of n bits */ 47 | /* hash = middle binary digits of (key * key). Upon collision, hash */ 48 | /* searches down linked list of keys that hashed to that key already. */ 49 | /* It will NOT notice if the table is full. This must be handled */ 50 | /* elsewhere */ 51 | 52 | unsigned int h(pred,foll) 53 | unsigned int pred; 54 | unsigned char foll; 55 | { 56 | long temp, local; 57 | 58 | local = (pred + foll) | 0x0800; 59 | temp = local * local; 60 | local = (temp >> 6) & 0x0FFF; 61 | return local; 62 | } 63 | 64 | /* return last element in a collision list */ 65 | unsigned int eolist(index) 66 | unsigned int index; 67 | { 68 | register int temp; 69 | 70 | while((temp = string_tab[index].next) != 0) 71 | index = temp; 72 | return index; 73 | } 74 | 75 | unsigned int hash(pred, foll, update) 76 | unsigned int pred; 77 | unsigned char foll; 78 | int update; 79 | { 80 | unsigned int local, tempnext; 81 | struct entry *ep; 82 | 83 | local = h(pred,foll); 84 | if(!string_tab[local].used) 85 | return local; 86 | else { 87 | local = eolist(local); 88 | tempnext = (local + 101) & 0x0FFF; 89 | ep = &string_tab[tempnext]; 90 | while (ep->used) { 91 | ++tempnext; 92 | if(tempnext == TABSIZE) { 93 | tempnext = 0; 94 | ep = string_tab; 95 | } 96 | else 97 | ep++; 98 | } 99 | 100 | if (update) 101 | string_tab[local].next = tempnext; 102 | return tempnext; 103 | } 104 | } 105 | 106 | /* unhash uses the 'next' field to go down the collision tree to find */ 107 | /* the entry corresponding to the passed key */ 108 | /* passed key and returns either the matching entry # or NOT_FND */ 109 | 110 | unsigned int unhash(pred, foll) 111 | unsigned int pred; 112 | unsigned char foll; 113 | { 114 | unsigned int local, offset; 115 | struct entry *ep; 116 | 117 | local = h(pred,foll); 118 | loop: 119 | ep = &string_tab[local]; 120 | if((ep->predecessor == pred) && (ep->follower == foll)) 121 | return local; 122 | if(!ep->next) 123 | return NOT_FND; 124 | local = ep->next; 125 | goto loop; 126 | } 127 | 128 | void init_tab() 129 | { 130 | int i; 131 | 132 | temp_outbuf = temp_inbuf = EMPTY; 133 | sp = 0; 134 | memset((char *)string_tab, 0, sizeof(string_tab)); 135 | for(i=0; i<256; i++) 136 | upd_tab(NO_PRED,i); 137 | } 138 | 139 | void upd_tab(pred, foll) 140 | unsigned int pred, foll; 141 | { 142 | struct entry *ep; 143 | 144 | ep = &string_tab[hash(pred,foll,UPDATE)]; 145 | ep->used = TRUE; 146 | ep->next = 0; 147 | ep->predecessor = pred; 148 | ep->follower = foll; 149 | } 150 | 151 | /* getcode and putcode 'gallop' through input and output - they either */ 152 | /* output two bytes or one depending on the contents of the buffer. */ 153 | 154 | unsigned int getcode() 155 | { 156 | unsigned int localbuf, returnval; 157 | 158 | if(temp_inbuf == EMPTY) { 159 | if((localbuf = readc()) == UEOF) 160 | return UEOF; 161 | localbuf &= 0xFF; 162 | 163 | if((temp_inbuf = readc()) == UEOF) 164 | return UEOF; 165 | temp_inbuf &= 0xFF; 166 | 167 | returnval = ((localbuf << 4) & 0xFF0) | 168 | ((temp_inbuf >> 4) & 0x00F); 169 | temp_inbuf &= 0x000F; 170 | } 171 | 172 | else { 173 | if((localbuf = readc()) == UEOF) 174 | return UEOF; 175 | localbuf &= 0xFF; 176 | 177 | returnval = localbuf | ((temp_inbuf << 8) & 0xF00); 178 | temp_inbuf = EMPTY; 179 | } 180 | 181 | return returnval; 182 | } 183 | 184 | void putcode(code) 185 | unsigned int code; 186 | { 187 | unsigned int localbuf; 188 | 189 | if(temp_outbuf == EMPTY) { 190 | writec((code >> 4) & 0xFF); 191 | temp_outbuf = code & 0x000F; 192 | } 193 | 194 | else { 195 | writec(((temp_outbuf << 4) & 0xFF0) | ((code >> 8) & 0x00F)); 196 | writec(code & 0x00FF); 197 | temp_outbuf = EMPTY; 198 | } 199 | } 200 | 201 | unsigned int readc() 202 | { 203 | if(inbuf - start_inbuf >= sizeof_inbuf) 204 | return(UEOF); 205 | else 206 | return((*(inbuf++) & 0xFF)); 207 | } 208 | 209 | unsigned int writec(ch) 210 | int ch; 211 | { 212 | *outbuf = (char)ch; 213 | outbuf++; 214 | sizeof_outbuf++; 215 | } 216 | 217 | /* flushout makes sure fractional output buffer gets written */ 218 | 219 | void flushout() 220 | { 221 | if(temp_outbuf != EMPTY) { 222 | *outbuf = (temp_outbuf << 4) & 0xFF0; 223 | outbuf++; 224 | sizeof_outbuf++; 225 | } 226 | } 227 | 228 | /* Compress routines */ 229 | 230 | int compress(in, out, size) 231 | char *in; 232 | char *out; 233 | int size; 234 | { 235 | unsigned int c, code, localcode; 236 | int code_count = TABSIZE - 256; 237 | 238 | start_inbuf = inbuf = in; 239 | start_outbuf = outbuf = out; 240 | sizeof_inbuf = size; 241 | sizeof_outbuf = 0; 242 | 243 | init_tab(); 244 | c = readc(); 245 | code = unhash(NO_PRED, c); 246 | 247 | while((c = readc()) != UEOF) { 248 | if((localcode = unhash(code, c)) != NOT_FND) { 249 | code = localcode; 250 | continue; 251 | } 252 | 253 | putcode(code); 254 | if(code_count) { 255 | upd_tab(code, c); 256 | code_count--; 257 | } 258 | 259 | code = unhash(NO_PRED, c); 260 | } 261 | 262 | putcode(code); 263 | flushout(); 264 | 265 | return sizeof_outbuf; 266 | } 267 | 268 | /* Uncompression routines */ 269 | 270 | int uncompress(in, out, size) 271 | char *in; 272 | char *out; 273 | int size; 274 | { 275 | unsigned int c, tempc, code, oldcode, incode, finchar, lastchar; 276 | char unknown = FALSE; 277 | int code_count = TABSIZE - 256; 278 | struct entry *ep; 279 | 280 | start_inbuf = inbuf = in; 281 | start_outbuf = outbuf = out; 282 | sizeof_inbuf = size; 283 | sizeof_outbuf = 0; 284 | 285 | init_tab(); 286 | code = oldcode = getcode(); 287 | 288 | c = string_tab[code].follower; 289 | writec(c); 290 | finchar = c; 291 | 292 | while ((code = incode = getcode()) != UEOF) { 293 | ep = &string_tab[code]; 294 | if(!ep->used) { 295 | lastchar = finchar; 296 | code = oldcode; 297 | unknown = TRUE; 298 | ep = &string_tab[code]; 299 | } 300 | 301 | while(ep->predecessor != NO_PRED) { 302 | push(ep->follower); 303 | code = ep->predecessor; 304 | ep = &string_tab[code]; 305 | } 306 | 307 | finchar = ep->follower; 308 | writec(finchar); 309 | while((tempc = pop()) != EMPTY) 310 | writec(tempc); 311 | 312 | if(unknown) { 313 | writec(finchar = lastchar); 314 | unknown = FALSE; 315 | } 316 | if(code_count) { 317 | upd_tab(oldcode,finchar); 318 | code_count--; 319 | } 320 | oldcode = incode; 321 | } 322 | flushout(); 323 | 324 | return sizeof_outbuf; 325 | } 326 | 327 | void push(c) 328 | int c; 329 | { 330 | stack[sp] = (char) c; 331 | sp++; 332 | if(sp >= STACKSIZE) 333 | merror(FATAL, "Stack overflow"); 334 | } 335 | 336 | int pop() 337 | { 338 | if(sp > 0) { 339 | sp--; 340 | return((int)stack[sp]); 341 | } 342 | else 343 | return EMPTY; 344 | } 345 | 346 | #endif 347 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/ed/editor.h: -------------------------------------------------------------------------------- 1 | #include 2 | #ifndef TC 3 | #include 4 | #endif 5 | 6 | extern int count_obj(), write_obj(), count_inv(), write_crt(), 7 | count_mon(), count_ite(), count_ext(), count_ply(), 8 | write_rom(), read_obj(), read_crt(), read_rom(); 9 | extern void free_obj(), free_crt(), free_rom(); 10 | 11 | extern void edit_object(), edit_monster(), edit_room(), edit_exits(), 12 | clearscreen(), posit(), getnum(), getnums(), getstr(), 13 | savepos(), restorepos(), zero(), merror(); 14 | extern int load_obj_from_file(), save_obj_to_file(), 15 | load_crt_from_file(), save_crt_to_file(), 16 | load_rom_from_file(), save_rom_to_file(); 17 | 18 | extern void check_ply(), edit_player(), edit_items(); 19 | extern int load_ply_from_file(), save_ply_to_file(); 20 | extern int ishan(), is_hangul(); 21 | extern char *first_han(); 22 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/ed/editor2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/ed/editor2.c -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/ed/editor4.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FILES3.C: 3 | * 4 | * File I/O Routines. 5 | * 6 | * Copyright (C) 1991 Brett J. Vickers 7 | * 8 | */ 9 | 10 | #include "mstruct.h" 11 | #include "mextern.h" 12 | 13 | /************************************************************************/ 14 | /* write_obj_to_mem */ 15 | /************************************************************************/ 16 | 17 | /* Save an object to a block of memory. */ 18 | /* This function recursively saves the items that are contained inside */ 19 | /* the object as well. If perm_only != 0 then only permanent objects */ 20 | /* within the object are saved with it. This function returns the */ 21 | /* number of bytes that were written. */ 22 | 23 | int write_obj_to_mem(buf, obj_ptr, perm_only) 24 | char *buf; 25 | object *obj_ptr; 26 | char perm_only; 27 | { 28 | int n, cnt, cnt2=0, error=0; 29 | char *bufstart; 30 | otag *op; 31 | 32 | bufstart = buf; 33 | 34 | memcpy(buf, obj_ptr, sizeof(object)); 35 | buf += sizeof(object); 36 | 37 | cnt = count_obj(obj_ptr, perm_only); 38 | memcpy(buf, &cnt, sizeof(int)); 39 | buf += sizeof(int); 40 | 41 | if(cnt > 0) { 42 | op = obj_ptr->first_obj; 43 | while(op) { 44 | if(!perm_only || (perm_only && 45 | (F_ISSET(op->obj, OPERMT) || 46 | F_ISSET(op->obj, OPERM2)))) { 47 | if((n = write_obj_to_mem(buf, 48 | op->obj, perm_only)) < 0) 49 | error = 1; 50 | else 51 | buf += n; 52 | cnt2++; 53 | } 54 | op = op->next_tag; 55 | } 56 | } 57 | 58 | if(cnt != cnt2 || error) 59 | return(-1); 60 | else 61 | return(buf - bufstart); 62 | 63 | } 64 | 65 | /************************************************************************/ 66 | /* write_crt_to_mem */ 67 | /************************************************************************/ 68 | 69 | /* Save a creature to memory. This function */ 70 | /* also saves all the items the creature is holding. If perm_only != 0 */ 71 | /* then only those items which the creature is carrying that are */ 72 | /* permanent will be saved. */ 73 | 74 | int write_crt_to_mem(buf, crt_ptr, perm_only) 75 | char *buf; 76 | creature *crt_ptr; 77 | char perm_only; 78 | { 79 | int n, cnt, cnt2=0, error=0; 80 | char *bufstart; 81 | otag *op; 82 | 83 | bufstart = buf; 84 | 85 | memcpy(buf, crt_ptr, sizeof(creature)); 86 | buf += sizeof(creature); 87 | 88 | cnt = count_inv(crt_ptr, perm_only); 89 | memcpy(buf, &cnt, sizeof(int)); 90 | buf += sizeof(int); 91 | 92 | if(cnt > 0) { 93 | op = crt_ptr->first_obj; 94 | while(op) { 95 | if(!perm_only || (perm_only && 96 | (F_ISSET(op->obj, OPERMT) || 97 | F_ISSET(op->obj, OPERM2)))) { 98 | if((n = write_obj_to_mem(buf, op->obj, 99 | perm_only)) < 0) 100 | error = 1; 101 | else 102 | buf += n; 103 | cnt2++; 104 | } 105 | op = op->next_tag; 106 | } 107 | } 108 | 109 | if(cnt != cnt2 || error) 110 | return(-1); 111 | else 112 | return(buf - bufstart); 113 | } 114 | 115 | /************************************************************************/ 116 | /* read_obj_from_mem */ 117 | /************************************************************************/ 118 | 119 | /* Loads the object from memory, returns the number of bytes read, */ 120 | /* and also loads every object which it might contain. Returns -1 if */ 121 | /* there was an error. */ 122 | 123 | int read_obj_from_mem(buf, obj_ptr) 124 | char *buf; 125 | object *obj_ptr; 126 | { 127 | int n, cnt, error=0; 128 | char *bufstart; 129 | otag *op; 130 | otag **prev; 131 | object *obj; 132 | 133 | bufstart = buf; 134 | 135 | memcpy(obj_ptr, buf, sizeof(object)); 136 | buf += sizeof(object); 137 | 138 | obj_ptr->first_obj = 0; 139 | obj_ptr->parent_obj = 0; 140 | obj_ptr->parent_rom = 0; 141 | obj_ptr->parent_crt = 0; 142 | if(obj_ptr->shotscur > obj_ptr->shotsmax) 143 | obj_ptr->shotscur = obj_ptr->shotsmax; 144 | 145 | memcpy(&cnt, buf, sizeof(int)); 146 | buf += sizeof(int); 147 | 148 | prev = &obj_ptr->first_obj; 149 | while(cnt > 0) { 150 | cnt--; 151 | op = (otag *)malloc(sizeof(otag)); 152 | if(op) { 153 | obj = (object *)malloc(sizeof(object)); 154 | if(obj) { 155 | if((n = read_obj_from_mem(buf, obj)) < 0) 156 | error = 1; 157 | else 158 | buf += n; 159 | obj->parent_obj = obj_ptr; 160 | op->obj = obj; 161 | op->next_tag = 0; 162 | *prev = op; 163 | prev = &op->next_tag; 164 | } 165 | else 166 | merror("read_obj", FATAL); 167 | } 168 | else 169 | merror("read_obj", FATAL); 170 | } 171 | 172 | if(error) 173 | return(-1); 174 | else 175 | return(buf - bufstart); 176 | } 177 | 178 | /************************************************************************/ 179 | /* read_crt_from_mem */ 180 | /************************************************************************/ 181 | 182 | /* Loads a creature from memory & returns bytes read. The creature is */ 183 | /* loaded at the mem location specified by the second parameter. In */ 184 | /* addition, all the creature's objects have memory allocated for them */ 185 | /* and are loaded as well. Returns -1 on fail. */ 186 | 187 | int read_crt_from_mem(buf, crt_ptr) 188 | char *buf; 189 | creature *crt_ptr; 190 | { 191 | int n, cnt, error=0; 192 | char *bufstart; 193 | otag *op; 194 | otag **prev; 195 | object *obj; 196 | 197 | bufstart = buf; 198 | 199 | memcpy(crt_ptr, buf, sizeof(creature)); 200 | buf += sizeof(creature); 201 | 202 | crt_ptr->first_obj = 0; 203 | crt_ptr->first_fol = 0; 204 | crt_ptr->first_enm = 0; 205 | crt_ptr->parent_rom = 0; 206 | crt_ptr->following = 0; 207 | for(n=0; n<20; n++) 208 | crt_ptr->ready[n] = 0; 209 | if(crt_ptr->mpcur > crt_ptr->mpmax) 210 | crt_ptr->mpcur = crt_ptr->mpmax; 211 | if(crt_ptr->hpcur > crt_ptr->hpmax) 212 | crt_ptr->hpcur = crt_ptr->hpmax; 213 | 214 | memcpy(&cnt, buf, sizeof(int)); 215 | buf += sizeof(int); 216 | 217 | prev = &crt_ptr->first_obj; 218 | while(cnt > 0) { 219 | cnt--; 220 | op = (otag *)malloc(sizeof(otag)); 221 | if(op) { 222 | obj = (object *)malloc(sizeof(object)); 223 | if(obj) { 224 | if((n = read_obj_from_mem(buf, obj)) < 0) 225 | error = 1; 226 | else 227 | buf += n; 228 | obj->parent_crt = crt_ptr; 229 | op->obj = obj; 230 | op->next_tag = 0; 231 | *prev = op; 232 | prev = &op->next_tag; 233 | } 234 | else 235 | merror("read_crt", FATAL); 236 | } 237 | else 238 | merror("read_crt", FATAL); 239 | } 240 | 241 | if(error) 242 | return(-1); 243 | else 244 | return(buf - bufstart); 245 | } 246 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/ed/kstbl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/ed/kstbl.h -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/ed/mextern.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/ed/mextern.h -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/ed/mstruct.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/ed/mstruct.h -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/ed/mtype.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/ed/mtype.h -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/list/mstruct.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/list/mstruct.h -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/list/mtype.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/list/mtype.h -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/msg/message.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #define saddr ntohl(sin.sin_addr.s_addr) 14 | #define PORT 4040 15 | #define FILENAME "/home/mordor/.msg" 16 | 17 | extern errno; 18 | int cfd, s2; 19 | void aborting(); 20 | 21 | main(argc, argv) 22 | int argc; 23 | char *argv[]; 24 | { 25 | int s,i; 26 | int fd; 27 | int len = sizeof(struct sockaddr_in); 28 | struct servent *ps; 29 | struct sockaddr_in sin; 30 | 31 | signal(SIGPIPE,SIG_IGN); 32 | 33 | if((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { 34 | exit(1); 35 | } 36 | 37 | sin.sin_addr.s_addr = INADDR_ANY; 38 | sin.sin_port = htons(PORT); 39 | 40 | i = 1; 41 | setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(int)); 42 | 43 | if(bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) { 44 | exit(1); 45 | } 46 | 47 | listen(s, 5); 48 | while(1) { 49 | len = sizeof(struct sockaddr_in); 50 | if((fd = accept(s, (struct sockaddr *) &sin, &len)) < 0) { 51 | exit(1); 52 | } 53 | 54 | log("connection accepted from: %d.%d.%d.%d\n", 55 | (unsigned)(saddr)>>24, 56 | (saddr & 0x00ff0000)>>16, 57 | (saddr & 0x0000ff00)>>8, 58 | (saddr & 0x000000ff)); 59 | 60 | if(fork()) { 61 | cfd = fd; 62 | if(fd > 16) { 63 | printf("Descriptor too large.\n"); 64 | exit(0); 65 | } 66 | signal(SIGPIPE,aborting); 67 | client(); 68 | } 69 | close(fd); 70 | } 71 | } 72 | 73 | client() 74 | { 75 | int readfds; 76 | char buf[1024], address[30], port[10]; 77 | int len=1, i=0, j=0; 78 | unsigned long addr; 79 | struct sockaddr_in sin2; 80 | int s2_flag, cfd_flag, readfds_flag; 81 | char outbuf[8192]; 82 | FILE *fp; 83 | 84 | ioctl(cfd, FIONBIO, &len); 85 | fp = fopen(FILENAME, "r"); 86 | if(!fp) aborting(); 87 | 88 | fread(outbuf, 8192, 1, fp); 89 | fclose(fp); 90 | 91 | write_msg(outbuf); 92 | sleep(4); 93 | aborting(); 94 | } 95 | 96 | write_msg(str) 97 | char *str; 98 | { 99 | write(cfd, str, strlen(str)); 100 | } 101 | 102 | read_msg(str,slen) 103 | char *str; 104 | int slen; 105 | { 106 | int readfds; 107 | int num=0, len; 108 | char ch; 109 | 110 | do { 111 | readfds = 1< 3 | #include 4 | #include 5 | } 6 | #include "muddle.h" 7 | 8 | int conn::update_buf(void) 9 | { 10 | static char tempbuf[1024]; 11 | extern auton *First_auton; 12 | extern int Target; 13 | 14 | int n = read(fd, tempbuf, 1024); 15 | if(!n) return -1; 16 | if(n<0) return 0; 17 | tempbuf[n] = 0; 18 | 19 | // Check for autons 20 | if(fd) for(auton *a=First_auton; a; a=a->next) 21 | if(a->match(tempbuf, slot)) 22 | a->out(Target, slot); 23 | 24 | // If the circular buffer's right edge is to be overstepped... 25 | if(head+n >= bufsize) { 26 | if(head < bufsize) 27 | strncpy(&buf[head], tempbuf, bufsize-head); 28 | memcpy(buf, &tempbuf[bufsize-head], n-bufsize+head); 29 | int temp = head; 30 | head = (head + n) % bufsize; 31 | if(tail > temp || tail <= head) 32 | tail = head+1; 33 | } 34 | 35 | // Otherwise, just copy it in. 36 | else { 37 | memcpy(&buf[head], tempbuf, n); 38 | if(tail > head && tail <= (head+n)) 39 | tail = head+n+1; 40 | head += n; 41 | } 42 | 43 | return 0; 44 | } 45 | 46 | void conn::output_buf(void) 47 | { 48 | // If we don't have to wrap-around the buffer, just output 49 | if(head > tail) { 50 | write(1, &buf[tail], head-tail); 51 | tail = head; 52 | } 53 | 54 | // Otherwise, output in two parts. 55 | else if(head < tail) { 56 | write(1, &buf[tail], bufsize-tail); 57 | write(1, buf, head); 58 | tail = head; 59 | } 60 | } 61 | 62 | int conn::check_command(char *str) 63 | { 64 | if(head == tail) return 0; 65 | 66 | int j=0; 67 | if(head > tail) { 68 | for(int i=tail; i 3 | #include 4 | #include 5 | } 6 | #include "muddle.h" 7 | 8 | int macro::match(char *str, char **array, int *len) 9 | { 10 | int i = 0, j = 0, last, n; 11 | int l = strlen(str); 12 | int l2 = strlen(key); 13 | 14 | if(!l || !l2) return 0; 15 | 16 | // strip header white space 17 | while(i < l && str[i] == ' ') i++; 18 | while(j < l2 && str[j] == ' ') j++; 19 | 20 | // interpret macro including %wildcards 21 | while(i < l && j < l2) { 22 | // Handle non-wildcard comparisons, and %%->% translation 23 | while(i < l && j < l2 && str[i] == key[j]) { 24 | if(key[j] == '%' && key[j+1] == '%') j++; 25 | i++; j++; 26 | } 27 | 28 | // Do we already have a match? 29 | if(i == l && j == l2) return 1; 30 | 31 | // No match, so it better be a % wildcard symbol. 32 | if(key[j++] != '%') return 0; 33 | 34 | // Make sure the %n symbol is such that n is a number 35 | // from 1 to 9 or a *. 36 | if((key[j+1] != ' ' && key[j+1] != 0) || 37 | ((key[j] < '1' || key[j] > '9') && key[j] != '*')) 38 | return 0; 39 | 40 | // If it's a *, use array location 0 to store wildcard info 41 | // and return success. 42 | if(key[j] == '*') { 43 | array[0] = &str[i]; 44 | len[0] = l-i; 45 | return 1; 46 | } 47 | 48 | // Get macro # from ascii value and store wildcard info 49 | // in that #'s wildcard spot. 50 | n = key[j] - '0'; 51 | array[n] = &str[i]; 52 | j++; last = i; 53 | while(str[i] != ' ' && str[i] != 0) i++; 54 | len[n] = i-last; 55 | } 56 | 57 | // If there's nothing left, we have a match. 58 | return(i == l && j == l2); 59 | } 60 | 61 | void macro::out(int cur, char **array, int *len) 62 | { 63 | int i=0, j=0, n=cur; 64 | int l = strlen(output); 65 | char outstr[512]; 66 | extern conn *Conn[]; 67 | 68 | // Interpret the macro, and output it to the appropriate descriptor. 69 | while(i < l) { 70 | 71 | // Check for %%, $$, and ^^ combinations. Output a single 72 | // one if it is found. 73 | if((output[i] == '%' || output[i] == '$' || 74 | output[i] == '^') && output[i+1] == output[i]) { 75 | outstr[j++] = output[i]; 76 | i+=2; 77 | continue; 78 | } 79 | 80 | // Handle control characters. 81 | if(output[i] == '^') { 82 | outstr[j++] = output[++i] - 'A' + 1; 83 | i++; 84 | continue; 85 | } 86 | 87 | // Handle wildcards. 88 | else if(output[i] == '%') { 89 | i++; 90 | if(isdigit(output[i])) { 91 | int d = output[i] - '0'; 92 | if(d < 1 || !array[d]) 93 | { i++; continue; } 94 | for(int k=0; k0; k--) { 116 | if(Conn[k]) Conn[k]->send(outstr); 117 | if(k == cur) printf(outstr); 118 | } 119 | else { 120 | Conn[n]->send(outstr); 121 | if(n == cur) printf(outstr); 122 | } 123 | j=0; n = d; 124 | } 125 | 126 | // Just a regular character 127 | else outstr[j++] = output[i]; 128 | i++; 129 | } 130 | 131 | // Wrap things up by outputting the last string. 132 | if(j) { 133 | outstr[j] = 0; 134 | if(!n) for(int k=9; k>0; k--) { 135 | if(Conn[k]) Conn[k]->send(outstr); 136 | if(k==cur) printf(outstr); 137 | } 138 | else { 139 | Conn[n]->send(outstr); 140 | if(n == cur) printf(outstr); 141 | } 142 | } 143 | } 144 | 145 | int auton::match(char *str, int slot) 146 | { 147 | int matchslot = -1; 148 | char *matchstr = key; 149 | 150 | if(matchstr[0] == '$') { 151 | if(matchstr[1] == '$') matchstr++; 152 | else { 153 | matchslot = matchstr[1] - '0'; 154 | matchstr += 2; 155 | } 156 | } 157 | 158 | if(matchslot > -1 && matchslot != slot) 159 | return 0; 160 | 161 | if(strstr(str, matchstr)) 162 | return 1; 163 | 164 | return 0; 165 | } 166 | 167 | void auton::out(int cur, int slot) 168 | { 169 | int i=0, j=0, n=slot; 170 | int l = strlen(output); 171 | char outstr[512]; 172 | extern conn *Conn[]; 173 | 174 | // Interpret the macro, and output it to the appropriate descriptor. 175 | while(i < l) { 176 | 177 | // Check for $$ and ^^ combinations. Output a single 178 | // one if it is found. 179 | if((output[i] == '$' || output[i] == '^') && 180 | output[i+1] == output[i]) { 181 | outstr[j++] = output[i]; 182 | i+=2; 183 | continue; 184 | } 185 | 186 | // Handle control characters. 187 | if(output[i] == '^') { 188 | outstr[j++] = output[++i] - 'A' + 1; 189 | i++; 190 | continue; 191 | } 192 | 193 | // Handle multi-descriptor outputs. 194 | else if(output[i] == '$') { 195 | i++; 196 | if((output[i] == '0' || !isdigit(output[i])) && 197 | output[i] != '*') 198 | { i++; continue; } 199 | int d; 200 | if(output[i] == '*') d = 0; 201 | else d = output[i] - '0'; 202 | if(!Conn[d]) { i++; continue; } 203 | outstr[j] = 0; 204 | if(!n) for(int k=9; k>0; k--) { 205 | if(Conn[k]) Conn[k]->send(outstr); 206 | if(k == cur) printf(outstr); 207 | } 208 | else { 209 | Conn[n]->send(outstr); 210 | if(n == cur) printf(outstr); 211 | } 212 | j=0; n = d; 213 | } 214 | 215 | // Just a regular character 216 | else outstr[j++] = output[i]; 217 | i++; 218 | } 219 | 220 | // Wrap things up by outputting the last string. 221 | if(j) { 222 | outstr[j] = 0; 223 | if(!n) for(int k=9; k>0; k--) { 224 | if(Conn[k]) Conn[k]->send(outstr); 225 | if(k==cur) printf(outstr); 226 | } 227 | else { 228 | Conn[n]->send(outstr); 229 | if(n == cur) printf(outstr); 230 | } 231 | } 232 | } 233 | 234 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/muddle/muddle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/muddle/muddle -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/muddle/muddle.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #define MACRO 1 5 | #define SITE 2 6 | #define COMMENT 3 7 | #define AUTON 4 8 | #define DEFSIZE 4096 9 | 10 | struct macro; 11 | struct site; 12 | struct conn; 13 | 14 | void client(void); 15 | void handle_command(char *); 16 | void io_check(void); 17 | void open_connection(char *, char *, char); 18 | void open_connection(char *); 19 | void load_macros(void); 20 | int read_parse_macro(char *, char **, char **, char **, char **); 21 | int write_parse_macro(char *); 22 | int iswhite(char); 23 | int parse(char *, char **, int *, int); 24 | void usleep(long); 25 | 26 | void sigstop(int); 27 | void sigint(int); 28 | 29 | struct macro { 30 | char *key; 31 | char *output; 32 | macro *next; 33 | 34 | macro(char *k, char *o, macro *n) { key = k; output = o; next = n; } 35 | ~macro() { if(key) delete key; if(output) delete output; } 36 | int match(char *, char **, int *); 37 | void out(int, char **, int *); 38 | }; 39 | 40 | struct auton { 41 | char *key; 42 | char *output; 43 | auton *next; 44 | 45 | auton(char *k, char *o, auton *n) { key = k; output = o; next = n; } 46 | ~auton() { if(key) delete key; if(output) delete output; } 47 | int match(char *, int); 48 | void out(int, int); 49 | }; 50 | 51 | struct site { 52 | char *key; 53 | char *address; 54 | char *port; 55 | char *init; 56 | site *next; 57 | 58 | site(char *k, char *a, char *p, char *i, site *n) { key = k; 59 | address = a; port = p; init = i; next = n; } 60 | ~site() { if(key) delete key; if(port) delete port; 61 | if(address) delete address; if(init) delete init; } 62 | }; 63 | 64 | struct conn { 65 | int fd; 66 | int slot; 67 | int bufsize; 68 | char *buf; 69 | int head, tail; 70 | char *addr; 71 | char *port; 72 | 73 | conn(int i) { addr = 0; port = 0; bufsize = DEFSIZE; 74 | buf = new char[DEFSIZE]; fd = -1; head = tail = 0; slot = i;} 75 | ~conn() { if(buf) delete buf; if(addr) delete addr; 76 | if(port) delete port; } 77 | void send(char *s) { write(fd, s, strlen(s)); } 78 | void output_buf(void); 79 | int update_buf(void); 80 | int check_command(char *); 81 | }; 82 | 83 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/muddle/sample.muddle: -------------------------------------------------------------------------------- 1 | ; Macro and Site specification file for MUDDLE 2 | ; This file should be customized to your needs and then renamed .muddle 3 | ; These are the sites: 4 | site="Isengard" addr="128.200.21.101" port="4040" init="Guest" 5 | 6 | ; These are the macros. 7 | ; 8 | ; $[1-9] cause your player on connection #[1-9] to perform the 9 | ; following commands 10 | ; $* causes all your connected players to perform the following 11 | ; commands 12 | ; %[1-9] These are just variable name placeholders for a SINGLE 13 | ; whitespace-separated word. 14 | ; %* This is a variable name placeholder for all text that follows. 15 | ; ^[A-Z] These are control characters. Use ^J for carriage return. 16 | ; 17 | in="Guest" out="guest^Jpassword^Jwho^J" 18 | in="cc" out="$2cast vigor aragorn^J" 19 | in="ccc" out="$2cast vigor finduril^J" 20 | in="g" out="$2get all corpse^J" 21 | in="j" out="$2junk corpse^J" 22 | in="jj %1" out="get %1 corpse^Jdrop %1^Jjunk %1^J" 23 | in="armor" out="$2cast 'armor' aragorn^Jcast 'armor' finduril^J" 24 | in="k %*" out="$*kill %*^J" 25 | in="f %1" out="$2cast 'fae' %1^J" 26 | in="rec" out="$*quaff blue^J" 27 | in="grp" out="$2follow garth^J$1group aragorn^J$1group finduril^J" 28 | in="all %*" out="$*%*^J" 29 | 30 | ; These are the automatons. They automatically respond to text messages 31 | ; your characters receive. 32 | 33 | ; 34 | auto="You are hungry" out="get bread bag^Jeat bread^J" 35 | auto="You are thirsty" out="drink waterskin^J!^J" 36 | auto="BLEEDING so" out="$*quaff blue^J" 37 | auto="$2tells you" out="tell player1 ***I got a msg from 2***^J" 38 | auto="$3tells you" out="tell urine ***I got a msg from 3***^J" 39 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/startm/startm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct termio mbuf,systerm; 6 | void main() 7 | { 8 | if(fork()) exit(0); 9 | close(0);close(1);close(2); 10 | 11 | while(1) { 12 | ioctl(0, TCSETAF, &systerm); 13 | system("/home/mordor/bin/frp -r"); 14 | ioctl(0, TCSETAF, &mbuf); 15 | 16 | sleep(30); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/startm/startm.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/startm/startm.doc -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/startm/startm2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct termio mbuf,systerm; 6 | void main() 7 | { 8 | int OUT,MUDID = -1; 9 | 10 | if(fork()) exit(0); 11 | close(0);close(1);close(2); 12 | 13 | while(1) { 14 | OUT = getpgid(MUDID); 15 | if(OUT==-1) { 16 | if(fork()) { 17 | ioctl(0, TCSETAF, &systerm); 18 | system("/home/mordor/bin/frp -r"); 19 | ioctl(0, TCSETAF, &mbuf); 20 | MUDID = getpid()+1; 21 | exit(); 22 | } 23 | } 24 | 25 | sleep(30); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/trans/trans: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/trans/trans -------------------------------------------------------------------------------- /codes/mudmuhan-ReCpp20/util/trans/trans_final: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-ReCpp20/util/trans/trans_final -------------------------------------------------------------------------------- /codes/mudmuhan-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/codes/mudmuhan-master.zip -------------------------------------------------------------------------------- /codes/std_format/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::cout << std::format("{}, {}!", "Hello", "World") << std::endl; 7 | 8 | std::cout << std::format("{1}, {0}!", "World", "Hello") << std::endl; 9 | 10 | return 0; 11 | } -------------------------------------------------------------------------------- /codes/std_format/std_format.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31321.278 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "std_format", "std_format.vcxproj", "{EE53522D-CFDC-434D-83BE-15A37768682F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {EE53522D-CFDC-434D-83BE-15A37768682F}.Debug|x64.ActiveCfg = Debug|x64 17 | {EE53522D-CFDC-434D-83BE-15A37768682F}.Debug|x64.Build.0 = Debug|x64 18 | {EE53522D-CFDC-434D-83BE-15A37768682F}.Debug|x86.ActiveCfg = Debug|Win32 19 | {EE53522D-CFDC-434D-83BE-15A37768682F}.Debug|x86.Build.0 = Debug|Win32 20 | {EE53522D-CFDC-434D-83BE-15A37768682F}.Release|x64.ActiveCfg = Release|x64 21 | {EE53522D-CFDC-434D-83BE-15A37768682F}.Release|x64.Build.0 = Release|x64 22 | {EE53522D-CFDC-434D-83BE-15A37768682F}.Release|x86.ActiveCfg = Release|Win32 23 | {EE53522D-CFDC-434D-83BE-15A37768682F}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {F13106A8-5E4A-4EB4-9039-5F4749E3714A} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /codes/std_format/std_format.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {ee53522d-cfdc-434d-83be-15a37768682f} 25 | stdformat 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v142 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v142 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v142 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v142 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | true 101 | true 102 | true 103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | Console 108 | true 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | true 117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | stdcpplatest 120 | 121 | 122 | Console 123 | true 124 | 125 | 126 | 127 | 128 | Level3 129 | true 130 | true 131 | true 132 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 133 | true 134 | stdcpplatest 135 | 136 | 137 | Console 138 | true 139 | true 140 | true 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /codes/std_format/std_format.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /concurrency_in_cpp20_and_beyond__anthony_williams__cppcon_2019.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/concurrency_in_cpp20_and_beyond__anthony_williams__cppcon_2019.pdf -------------------------------------------------------------------------------- /module/README.md: -------------------------------------------------------------------------------- 1 | # module 2 | 3 | ## 모듈의 도입 이유 4 | 프리프로세서(preprocessor, 전처리기)인 include는 헤더 파일의 내용을 그 장소에 전개한다. 이것은 아래와 같은 문제가 지적된다. 5 | 6 | 1. 컴파일 시간이 길어진다. 7 | 헤더 파일 내용이 재귀적으로 전개되어, 프로그램이 길어진다(Hello world 만으로도 수만행에 달한다) 8 | 또 전개가 번역 단위마다 행하므로 전체로 보면 같은 헤더 파일을 몇 번이나 해석된다 9 | 2. 프리프로세서의 상태에 의해 include 결과가 달라진다 10 | include 순번에 따라서 에러가 발생할 수 있다 11 | 3. 헤더 파일 내의 기술 영향을 너무 받는다 12 | 영향이 너무 커서 헤더 파일 내에 쓰는 것이 주저되는 것이 있다 13 | using namespace 이나 매크로(예를들면 Windows 에서의 max) 등 14 | 15 | 출처: https://cpprefjp.github.io/lang/cpp20/modules.html 16 | 17 |
18 | 19 | ## 얻는 혜택 20 | 모듈은 전처리기를 사용하지 않고 프로그램을 분할할 수 있다. 즉 모듈은 `#include`와 같이 프리프로세서에서 헤더를 전개하여 종속성을 해결하는 것이 아니라 컴파일시 자동으로 종속성을 해결해 주는 것이다. 이렇게하면 `#include` 문제가 아래와 같이 해결된다. 21 | 22 | 1. 컴파일 시간이 길어진다 23 | 번역 단위마다 헤더 파일을 전개하지 않기 때문에 어구 해석이 빨라진다. 그 결과, 일반적으로 모듈을 사용하는 것이 컴파일 시간이 짧아진다. 24 | 2. 전 처리기의 상태에 따라 포함 결과가 변경된다. 25 | 3. 헤더 파일 내의 기술 영향을 너무 받는다 26 | 모듈에 기술한 `using namespace`나 매크로가 그 모듈을 사용하는 소스 파일에 누설되지 않게 된다. 이에 따라, 프리프로세서의 처리를 따르지 않으면 쉽게 발견할 수 없었던 버그가 발생하지 않게 된다. 27 | 28 |
29 | 30 | ## 추가 BMI 디렉터리 31 | 지시문에 전달된 import 이름을 확인하기 위해 검색할 하나 이상의 디렉터리를 지정한다. 32 | 둘 이상이 있는 경우 세미콜론('';)을 사용하여 디렉터리를 구분한다. 33 | 명령어로 할 때는 `/ifcSearchDir[path]` 컴파일러 옵션을 설정한다. 34 | 35 | ![BMI(./images/001.png) 36 | 37 | 38 | ## 참조 39 | - [모듈에 대해서](https://docs.google.com/document/d/18USNv9vlIvuzURRjS44QzqdgM9mEicLm06FevA3FpfU/edit?usp=sharing ) 40 | - [모듈(module)](https://kukuta.tistory.com/389 ) 41 | - C++20 Modules 소개와 사용 - [1](https://openmynotepad.tistory.com/78) [2](https://openmynotepad.tistory.com/79) 42 | - [당신이 module을 써야만 하는 이유](https://kukuta.tistory.com/393 ) 43 | - [MS Docs C++ 모듈 개요](https://docs.microsoft.com/ko-kr/cpp/cpp/modules-cpp?view=msvc-160) 44 | - [A Tour of C++ Modules in Visual Studio](https://devblogs.microsoft.com/cppblog/a-tour-of-cpp-modules-in-visual-studio/ ) 45 | - 다른 디렉토리에 있는, 정적 라이브러리에 있는 모듈을 참조할 수 있는 방법 설명 46 | - [Standard C++20 Modules support with MSVC in Visual Studio 2019 version 16.8](https://devblogs.microsoft.com/cppblog/standard-c20-modules-support-with-msvc-in-visual-studio-2019-version-16-8/ ) 47 | - Practical C++ Modules [pdf](https://github.com/CppCon/CppCon2019/blob/master/Presentations/practical_cpp_modules/practical_cpp_modules__boris_kolpackov__cppcon_2019.pdf ) 48 | - [Modules in VC++ 2019 16.5](https://mariusbancila.ro/blog/2020/05/07/modules-in-vc-2019-16-5/ ) 49 | - [C++20: A Simple math Module](http://www.modernescpp.com/index.php/cpp20-a-first-module ) 50 | - [(일어)C++20의 모듈과 include의 차이에 대해서 자세히 조사해 보았다](https://logicalbeat.jp/blog/6223/) 51 | - [(일어) 모듈 이론 기초편](https://onihusube.hatenablog.com/entry/2019/07/07/025446 ) 52 | - (일어) C++ 모듈 인터페이스 파티션 사용처: [1](https://zenn.dev/uyamae/articles/0acaee53777832 ) [2](https://zenn.dev/uyamae/articles/51074bc5cff43b ) 53 | - [Example project for C++20 module support in CMake](https://github.com/calgray/cmake-cpp-modules-template ) 54 | - [Moving a project to C++ named Modules](https://devblogs.microsoft.com/cppblog/moving-a-project-to-cpp-named-modules/ ) 55 | - [C++20 Modules Status Report](https://github.com/royjacobson/modules-report ) 56 | -------------------------------------------------------------------------------- /module/images/001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/images/001.png -------------------------------------------------------------------------------- /module/module_01-01/main.cpp: -------------------------------------------------------------------------------- 1 | // 모듈로된 STL 사용하기 2 | // 프로젝트 설정에서 "C/C++" -> "언어" -> "실험용 C++ 표준 라이브러리 모듈 사용"을 "예"로한다 3 | 4 | import std.core; 5 | import std.memory; 6 | import std.threading; 7 | 8 | int main() 9 | { 10 | std::thread t([] { std::cout << "func() called." << std::endl; }); 11 | std::cout << "Main function" << std::endl; 12 | t.join(); 13 | 14 | auto ptr = std::make_unique(5); 15 | (*ptr)++; 16 | std::cout << "*ptr: " << *ptr << std::endl; 17 | } -------------------------------------------------------------------------------- /module/module_01-01/module_01-01.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33414.496 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_01-01", "module_01-01.vcxproj", "{068FEEDB-5B75-48ED-9F3F-D43D2202EB33}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.ActiveCfg = Debug|x64 17 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.Build.0 = Debug|x64 18 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.ActiveCfg = Debug|Win32 19 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.Build.0 = Debug|Win32 20 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.ActiveCfg = Release|x64 21 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.Build.0 = Release|x64 22 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.ActiveCfg = Release|Win32 23 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D0682853-361C-439B-81F0-312F7E939F81} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /module/module_01-01/module_01-01.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {926354AF-093B-4D64-A1C5-6C01717F67BD} 25 | module01 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Console 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | true 89 | true 90 | true 91 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | stdcpp20 108 | true 109 | true 110 | 111 | 112 | Console 113 | true 114 | 115 | 116 | 117 | 118 | Level3 119 | true 120 | true 121 | true 122 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 123 | true 124 | stdcpp20 125 | 126 | 127 | Console 128 | true 129 | true 130 | true 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /module/module_01-01/module_01-01.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /module/module_01/main.cpp: -------------------------------------------------------------------------------- 1 | //https://zenn.dev/onihusube/articles/299ed7a3bc6062068fdd 2 | // 간단한 모듈 사용 예 3 | 4 | import mylib; // mylib 모듈 import 선언 5 | 6 | int main() 7 | { 8 | // mylib은 모듈의 이름이 아니고 import한 모듈의 네임스페이스 이름이다. 9 | mylib::S s1{}; 10 | mylib::S s2{ 20 }; 11 | 12 | mylib::print_S(s1); // 0 13 | mylib::print_S(s2); // 20 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /module/module_01/module_01.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33414.496 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_01", "module_01.vcxproj", "{068FEEDB-5B75-48ED-9F3F-D43D2202EB33}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.ActiveCfg = Debug|x64 17 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.Build.0 = Debug|x64 18 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.ActiveCfg = Debug|Win32 19 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.Build.0 = Debug|Win32 20 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.ActiveCfg = Release|x64 21 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.Build.0 = Release|x64 22 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.ActiveCfg = Release|Win32 23 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D0682853-361C-439B-81F0-312F7E939F81} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /module/module_01/module_01.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {068feedb-5b75-48ed-9f3f-d43d2202eb33} 25 | module01 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Console 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | true 89 | true 90 | true 91 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | stdcpp20 108 | 109 | 110 | Console 111 | true 112 | 113 | 114 | 115 | 116 | Level3 117 | true 118 | true 119 | true 120 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | stdcpp20 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /module/module_01/module_01.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /module/module_01/mylib.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_01/mylib.cpp -------------------------------------------------------------------------------- /module/module_01/mylib.ixx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_01/mylib.ixx -------------------------------------------------------------------------------- /module/module_02/main.cpp: -------------------------------------------------------------------------------- 1 | //https://zenn.dev/onihusube/articles/299ed7a3bc6062068fdd 2 | 3 | // private 모듈 플래그먼트 4 | // 모듈의 1개의 파일로 했을 때 외부에 공개하고 싶지 않은 부분(구현부 등)은 private 모듈 플래그먼트로 감싸서 숨길 수 있다. 5 | 6 | // 이 예제는 빌드되지 않는다 7 | // Visual Studio 2022(2023.03.21)에서는 아직 private 모듈 플래그먼트를 지원하지 않는다 8 | // https://developercommunity.visualstudio.com/t/c-modules-change-in-private-module-triggers-recomp/1651834#T-N1660981 9 | 10 | import mylib; // mylib 모듈 import 선언 11 | 12 | int main() 13 | { 14 | // mylib은 모듈의 이름이 아니고 import한 모듈의 네임스페이스 이름이다. 15 | mylib::S s1{}; 16 | mylib::S s2{ 20 }; 17 | 18 | mylib::print_S(s1); // 0 19 | mylib::print_S(s2); // 20 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /module/module_02/module_02.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33414.496 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_02", "module_02.vcxproj", "{068FEEDB-5B75-48ED-9F3F-D43D2202EB33}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.ActiveCfg = Debug|x64 17 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.Build.0 = Debug|x64 18 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.ActiveCfg = Debug|Win32 19 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.Build.0 = Debug|Win32 20 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.ActiveCfg = Release|x64 21 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.Build.0 = Release|x64 22 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.ActiveCfg = Release|Win32 23 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D0682853-361C-439B-81F0-312F7E939F81} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /module/module_02/module_02.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {219D2B0D-6092-44A6-844B-D39270740CEC} 25 | module02 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Console 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | true 89 | true 90 | true 91 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | stdcpp20 108 | 109 | 110 | Console 111 | true 112 | 113 | 114 | 115 | 116 | Level3 117 | true 118 | true 119 | true 120 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | stdcpp20 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /module/module_02/module_02.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /module/module_02/mylib.ixx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_02/mylib.ixx -------------------------------------------------------------------------------- /module/module_03/main.cpp: -------------------------------------------------------------------------------- 1 | //https://zenn.dev/onihusube/articles/299ed7a3bc6062068fdd 2 | 3 | // 모두 한번에 export 하기 4 | 5 | 6 | import mylib; // mylib 모듈 import 선언 7 | 8 | int main() 9 | { 10 | // mylib은 모듈의 이름이 아니고 import한 모듈의 네임스페이스 이름이다. 11 | mylib::S s1{}; 12 | mylib::S s2{ 20 }; 13 | 14 | mylib::print_S(s1); // 0 15 | mylib::print_S(s2); // 20 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /module/module_03/module_03.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33414.496 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_03", "module_03.vcxproj", "{068FEEDB-5B75-48ED-9F3F-D43D2202EB33}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.ActiveCfg = Debug|x64 17 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.Build.0 = Debug|x64 18 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.ActiveCfg = Debug|Win32 19 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.Build.0 = Debug|Win32 20 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.ActiveCfg = Release|x64 21 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.Build.0 = Release|x64 22 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.ActiveCfg = Release|Win32 23 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D0682853-361C-439B-81F0-312F7E939F81} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /module/module_03/module_03.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {DC423F7D-4A4D-40E7-A857-C4149996D4FE} 25 | module01 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Console 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | true 89 | true 90 | true 91 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | stdcpp20 108 | 109 | 110 | Console 111 | true 112 | 113 | 114 | 115 | 116 | Level3 117 | true 118 | true 119 | true 120 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | stdcpp20 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /module/module_03/module_03.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /module/module_03/mylib.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_03/mylib.cpp -------------------------------------------------------------------------------- /module/module_03/mylib.ixx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_03/mylib.ixx -------------------------------------------------------------------------------- /module/module_04-01/main.cpp: -------------------------------------------------------------------------------- 1 | //https://zenn.dev/onihusube/articles/98a0fce9827fa87a88d3 2 | 3 | // 인터페이스 파일은 1개만 있을 수 있다 4 | // 다만 인터페이스를 몇개의 파일로 나누고 싶을 때는 파티션 으로 분할 할 수 있다. 5 | // 같은 모듈에 속해 있는 인터페이스 파티션은 모두 프라이머리 인터페이스 단위에서 export 해야 한다 6 | 7 | 8 | import mylib; // mylib 모듈 import 선언 9 | 10 | int main() 11 | { 12 | // mylib은 모듈의 이름이 아니고 import한 모듈의 네임스페이스 이름이다. 13 | mylib::S s1{}; 14 | mylib::S s2{ 20 }; 15 | 16 | mylib::print_S(s1); // 0 17 | mylib::print_S(s2); // 20 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /module/module_04-01/module_04-01.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33414.496 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_04-01", "module_04-01.vcxproj", "{068FEEDB-5B75-48ED-9F3F-D43D2202EB33}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.ActiveCfg = Debug|x64 17 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.Build.0 = Debug|x64 18 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.ActiveCfg = Debug|Win32 19 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.Build.0 = Debug|Win32 20 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.ActiveCfg = Release|x64 21 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.Build.0 = Release|x64 22 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.ActiveCfg = Release|Win32 23 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D0682853-361C-439B-81F0-312F7E939F81} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /module/module_04-01/module_04-01.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {2C29A891-7DA0-42E4-8B12-37626AF56AB9} 25 | module01 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Console 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | true 89 | true 90 | true 91 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | stdcpp20 108 | 109 | 110 | Console 111 | true 112 | 113 | 114 | 115 | 116 | Level3 117 | true 118 | true 119 | true 120 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | stdcpp20 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /module/module_04-01/module_04-01.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /module/module_04-01/mylib.ixx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_04-01/mylib.ixx -------------------------------------------------------------------------------- /module/module_04-01/mylib1.ixx: -------------------------------------------------------------------------------- 1 | module; 2 | 3 | #include 4 | 5 | // mylib. 을 붙이지 않아도 괜찮다. export module mylib1; 해도 main.cpp에서 접근할 수 있다 6 | export module mylib.mylib1; 7 | 8 | namespace mylib { 9 | 10 | export class S { 11 | int m_num = 0; 12 | public: 13 | 14 | S() = default; 15 | S(int n) : m_num{ n } {} 16 | 17 | int get() const 18 | { 19 | return this->m_num; 20 | } 21 | }; 22 | } -------------------------------------------------------------------------------- /module/module_04-01/mylib2.ixx: -------------------------------------------------------------------------------- 1 | module; 2 | 3 | #include 4 | 5 | export module mylib.mylib2; 6 | 7 | // 클래스 S의 선언을 참조하기 위해 import 한다 8 | import mylib.mylib1; 9 | 10 | namespace mylib { 11 | 12 | // 프리 함수 export 13 | export void print_S(const S& s) 14 | { 15 | std::cout << s.get() << std::endl; 16 | } 17 | } -------------------------------------------------------------------------------- /module/module_04/main.cpp: -------------------------------------------------------------------------------- 1 | //https://zenn.dev/onihusube/articles/98a0fce9827fa87a88d3 2 | 3 | // 인터페이스 파일은 1개만 있을 수 있다 4 | // 다만 인터페이스를 몇개의 파일로 나누고 싶을 때는 파티션 으로 분할 할 수 있다. 5 | // 같은 모듈에 속해 있는 인터페이스 파티션은 모두 프라이머리 인터페이스 단위에서 export 해야 한다 6 | 7 | 8 | import mylib; // mylib 모듈 import 선언 9 | 10 | int main() 11 | { 12 | // mylib은 모듈의 이름이 아니고 import한 모듈의 네임스페이스 이름이다. 13 | mylib::S s1{}; 14 | mylib::S s2{ 20 }; 15 | 16 | mylib::print_S(s1); // 0 17 | mylib::print_S(s2); // 20 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /module/module_04/module_04.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33414.496 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_04", "module_04.vcxproj", "{068FEEDB-5B75-48ED-9F3F-D43D2202EB33}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.ActiveCfg = Debug|x64 17 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.Build.0 = Debug|x64 18 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.ActiveCfg = Debug|Win32 19 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.Build.0 = Debug|Win32 20 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.ActiveCfg = Release|x64 21 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.Build.0 = Release|x64 22 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.ActiveCfg = Release|Win32 23 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D0682853-361C-439B-81F0-312F7E939F81} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /module/module_04/module_04.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {65E8A6A9-04FD-4A0F-A28E-D53602414FD3} 25 | module01 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Console 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | true 89 | true 90 | true 91 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | stdcpp20 108 | 109 | 110 | Console 111 | true 112 | 113 | 114 | 115 | 116 | Level3 117 | true 118 | true 119 | true 120 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | stdcpp20 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /module/module_04/module_04.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /module/module_04/mylib.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_04/mylib.cpp -------------------------------------------------------------------------------- /module/module_04/mylib.ixx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_04/mylib.ixx -------------------------------------------------------------------------------- /module/module_04/mylib_interface1.ixx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_04/mylib_interface1.ixx -------------------------------------------------------------------------------- /module/module_04/mylib_interface2.ixx: -------------------------------------------------------------------------------- 1 |  2 | export module mylib:interface2; 3 | 4 | // 클래스 S의 선언을 참조하기 위해 import 한다 5 | import :interface1; 6 | 7 | namespace mylib { 8 | 9 | // 프리 함수 export 10 | export void print_S(const S& s); 11 | } -------------------------------------------------------------------------------- /module/module_05/main.cpp: -------------------------------------------------------------------------------- 1 | //https://zenn.dev/onihusube/articles/0202ca564da2c3f5f98a 2 | 3 | // 인터페이스는 1개의 파일에 구현 부분은 복수 파일로 할 수 있음 4 | // 구현 파티션으로 나눈다. 5 | 6 | 7 | import mylib; // mylib 모듈 import 선언 8 | 9 | int main() 10 | { 11 | // mylib은 모듈의 이름이 아니고 import한 모듈의 네임스페이스 이름이다. 12 | mylib::S s1{}; 13 | mylib::S s2{ 20 }; 14 | 15 | mylib::print_S(s1); // 0 16 | mylib::print_S(s2); // 20 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /module/module_05/module_05.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33414.496 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_05", "module_05.vcxproj", "{068FEEDB-5B75-48ED-9F3F-D43D2202EB33}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.ActiveCfg = Debug|x64 17 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.Build.0 = Debug|x64 18 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.ActiveCfg = Debug|Win32 19 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.Build.0 = Debug|Win32 20 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.ActiveCfg = Release|x64 21 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.Build.0 = Release|x64 22 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.ActiveCfg = Release|Win32 23 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D0682853-361C-439B-81F0-312F7E939F81} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /module/module_05/module_05.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {55FEE192-3FAB-4EB3-B03E-A3D0A347C49C} 25 | module01 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Console 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | true 89 | true 90 | true 91 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | stdcpp20 108 | 109 | 110 | Console 111 | true 112 | 113 | 114 | 115 | 116 | Level3 117 | true 118 | true 119 | true 120 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | stdcpp20 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /module/module_05/module_05.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /module/module_05/mylib.ixx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_05/mylib.ixx -------------------------------------------------------------------------------- /module/module_05/mylib1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_05/mylib1.cpp -------------------------------------------------------------------------------- /module/module_05/mylib2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_05/mylib2.cpp -------------------------------------------------------------------------------- /module/module_06/main.cpp: -------------------------------------------------------------------------------- 1 | //https://zenn.dev/onihusube/articles/0202ca564da2c3f5f98a 2 | 3 | // 인터페이스는 1개의 파일에 구현 부분은 복수 파일로 할 수 있음 4 | // 구현 파티션을 사용하지 않는 형태 5 | 6 | 7 | import mylib; // mylib 모듈 import 선언 8 | 9 | int main() 10 | { 11 | // mylib은 모듈의 이름이 아니고 import한 모듈의 네임스페이스 이름이다. 12 | mylib::S s1{}; 13 | mylib::S s2{ 20 }; 14 | 15 | mylib::print_S(s1); // 0 16 | mylib::print_S(s2); // 20 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /module/module_06/module_06.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33414.496 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_06", "module_06.vcxproj", "{068FEEDB-5B75-48ED-9F3F-D43D2202EB33}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.ActiveCfg = Debug|x64 17 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.Build.0 = Debug|x64 18 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.ActiveCfg = Debug|Win32 19 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.Build.0 = Debug|Win32 20 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.ActiveCfg = Release|x64 21 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.Build.0 = Release|x64 22 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.ActiveCfg = Release|Win32 23 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D0682853-361C-439B-81F0-312F7E939F81} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /module/module_06/module_06.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {E646A100-FAFA-4467-B28B-01D61DE8F458} 25 | module01 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Console 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | true 89 | true 90 | true 91 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | stdcpp20 108 | 109 | 110 | Console 111 | true 112 | 113 | 114 | 115 | 116 | Level3 117 | true 118 | true 119 | true 120 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | stdcpp20 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /module/module_06/module_06.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /module/module_06/mylib.ixx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_06/mylib.ixx -------------------------------------------------------------------------------- /module/module_06/mylib1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_06/mylib1.cpp -------------------------------------------------------------------------------- /module/module_06/mylib2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_06/mylib2.cpp -------------------------------------------------------------------------------- /module/module_07/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_com2us_cpp20_Training/f2045c946e5044aa52ebb492206d702c9c45c5f7/module/module_07/main.cpp -------------------------------------------------------------------------------- /module/module_07/module_07.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33414.496 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_07", "module_07.vcxproj", "{068FEEDB-5B75-48ED-9F3F-D43D2202EB33}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.ActiveCfg = Debug|x64 17 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.Build.0 = Debug|x64 18 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.ActiveCfg = Debug|Win32 19 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.Build.0 = Debug|Win32 20 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.ActiveCfg = Release|x64 21 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.Build.0 = Release|x64 22 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.ActiveCfg = Release|Win32 23 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D0682853-361C-439B-81F0-312F7E939F81} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /module/module_07/module_07.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 16.0 30 | Win32Proj 31 | {4BA7760B-167D-490A-8AF4-9C04C968069E} 32 | module01 33 | 10.0 34 | 35 | 36 | 37 | Application 38 | true 39 | v143 40 | Unicode 41 | 42 | 43 | Application 44 | false 45 | v143 46 | true 47 | Unicode 48 | 49 | 50 | Application 51 | true 52 | v143 53 | Unicode 54 | 55 | 56 | Application 57 | false 58 | v143 59 | true 60 | Unicode 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | Level3 83 | true 84 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 85 | true 86 | 87 | 88 | Console 89 | true 90 | 91 | 92 | 93 | 94 | Level3 95 | true 96 | true 97 | true 98 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 99 | true 100 | 101 | 102 | Console 103 | true 104 | true 105 | true 106 | 107 | 108 | 109 | 110 | Level3 111 | true 112 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 113 | true 114 | stdcpp20 115 | 116 | 117 | Console 118 | true 119 | 120 | 121 | 122 | 123 | Level3 124 | true 125 | true 126 | true 127 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 128 | true 129 | stdcpp20 130 | 131 | 132 | Console 133 | true 134 | true 135 | true 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /module/module_07/module_07.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {7ae9fa45-d13b-44f7-a835-483755e168ff} 6 | 7 | 8 | {92b13ff6-a4d4-4475-860f-65091431b3e9} 9 | 10 | 11 | {f5b12315-1245-4fd5-89bd-db74883f14e6} 12 | 13 | 14 | 15 | 16 | util 17 | 18 | 19 | types 20 | 21 | 22 | shop 23 | 24 | 25 | shop 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /module/module_07/shop/shop-unit.cpp: -------------------------------------------------------------------------------- 1 | module; 2 | #include 3 | module shop; 4 | import util; 5 | 6 | ShoppingBag shop() { 7 | ShoppingBag bag; 8 | bag.products.push_back(produce("fruit")); 9 | bag.products.push_back(produce("veggie")); 10 | return bag; 11 | } -------------------------------------------------------------------------------- /module/module_07/shop/shop.ixx: -------------------------------------------------------------------------------- 1 | export module shop; 2 | 3 | import types; 4 | 5 | export 6 | ShoppingBag shop(); -------------------------------------------------------------------------------- /module/module_07/types/types.ixx: -------------------------------------------------------------------------------- 1 | module; 2 | #include 3 | #include 4 | export module types; 5 | 6 | export 7 | struct Product { 8 | std::string value; 9 | }; 10 | 11 | export 12 | struct ShoppingBag { 13 | std::vector products; 14 | }; -------------------------------------------------------------------------------- /module/module_07/util/util.ixx: -------------------------------------------------------------------------------- 1 | module; 2 | #include 3 | export module util; 4 | 5 | import types; 6 | 7 | export 8 | Product produce(const char* product) { return { .value = product }; } -------------------------------------------------------------------------------- /module/module_all.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33516.290 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_01", "module_01\module_01.vcxproj", "{068FEEDB-5B75-48ED-9F3F-D43D2202EB33}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_02", "module_02\module_02.vcxproj", "{219D2B0D-6092-44A6-844B-D39270740CEC}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_03", "module_03\module_03.vcxproj", "{DC423F7D-4A4D-40E7-A857-C4149996D4FE}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_04", "module_04\module_04.vcxproj", "{65E8A6A9-04FD-4A0F-A28E-D53602414FD3}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_05", "module_05\module_05.vcxproj", "{55FEE192-3FAB-4EB3-B03E-A3D0A347C49C}" 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_06", "module_06\module_06.vcxproj", "{E646A100-FAFA-4467-B28B-01D61DE8F458}" 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_07", "module_07\module_07.vcxproj", "{4BA7760B-167D-490A-8AF4-9C04C968069E}" 19 | EndProject 20 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_01-01", "module_01-01\module_01-01.vcxproj", "{926354AF-093B-4D64-A1C5-6C01717F67BD}" 21 | EndProject 22 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module_04-01", "module_04-01\module_04-01.vcxproj", "{2C29A891-7DA0-42E4-8B12-37626AF56AB9}" 23 | EndProject 24 | Global 25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 26 | Debug|x64 = Debug|x64 27 | Debug|x86 = Debug|x86 28 | Release|x64 = Release|x64 29 | Release|x86 = Release|x86 30 | EndGlobalSection 31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 32 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.ActiveCfg = Debug|x64 33 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x64.Build.0 = Debug|x64 34 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.ActiveCfg = Debug|Win32 35 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Debug|x86.Build.0 = Debug|Win32 36 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.ActiveCfg = Release|x64 37 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x64.Build.0 = Release|x64 38 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.ActiveCfg = Release|Win32 39 | {068FEEDB-5B75-48ED-9F3F-D43D2202EB33}.Release|x86.Build.0 = Release|Win32 40 | {219D2B0D-6092-44A6-844B-D39270740CEC}.Debug|x64.ActiveCfg = Debug|x64 41 | {219D2B0D-6092-44A6-844B-D39270740CEC}.Debug|x64.Build.0 = Debug|x64 42 | {219D2B0D-6092-44A6-844B-D39270740CEC}.Debug|x86.ActiveCfg = Debug|Win32 43 | {219D2B0D-6092-44A6-844B-D39270740CEC}.Debug|x86.Build.0 = Debug|Win32 44 | {219D2B0D-6092-44A6-844B-D39270740CEC}.Release|x64.ActiveCfg = Release|x64 45 | {219D2B0D-6092-44A6-844B-D39270740CEC}.Release|x64.Build.0 = Release|x64 46 | {219D2B0D-6092-44A6-844B-D39270740CEC}.Release|x86.ActiveCfg = Release|Win32 47 | {219D2B0D-6092-44A6-844B-D39270740CEC}.Release|x86.Build.0 = Release|Win32 48 | {DC423F7D-4A4D-40E7-A857-C4149996D4FE}.Debug|x64.ActiveCfg = Debug|x64 49 | {DC423F7D-4A4D-40E7-A857-C4149996D4FE}.Debug|x64.Build.0 = Debug|x64 50 | {DC423F7D-4A4D-40E7-A857-C4149996D4FE}.Debug|x86.ActiveCfg = Debug|Win32 51 | {DC423F7D-4A4D-40E7-A857-C4149996D4FE}.Debug|x86.Build.0 = Debug|Win32 52 | {DC423F7D-4A4D-40E7-A857-C4149996D4FE}.Release|x64.ActiveCfg = Release|x64 53 | {DC423F7D-4A4D-40E7-A857-C4149996D4FE}.Release|x64.Build.0 = Release|x64 54 | {DC423F7D-4A4D-40E7-A857-C4149996D4FE}.Release|x86.ActiveCfg = Release|Win32 55 | {DC423F7D-4A4D-40E7-A857-C4149996D4FE}.Release|x86.Build.0 = Release|Win32 56 | {65E8A6A9-04FD-4A0F-A28E-D53602414FD3}.Debug|x64.ActiveCfg = Debug|x64 57 | {65E8A6A9-04FD-4A0F-A28E-D53602414FD3}.Debug|x64.Build.0 = Debug|x64 58 | {65E8A6A9-04FD-4A0F-A28E-D53602414FD3}.Debug|x86.ActiveCfg = Debug|Win32 59 | {65E8A6A9-04FD-4A0F-A28E-D53602414FD3}.Debug|x86.Build.0 = Debug|Win32 60 | {65E8A6A9-04FD-4A0F-A28E-D53602414FD3}.Release|x64.ActiveCfg = Release|x64 61 | {65E8A6A9-04FD-4A0F-A28E-D53602414FD3}.Release|x64.Build.0 = Release|x64 62 | {65E8A6A9-04FD-4A0F-A28E-D53602414FD3}.Release|x86.ActiveCfg = Release|Win32 63 | {65E8A6A9-04FD-4A0F-A28E-D53602414FD3}.Release|x86.Build.0 = Release|Win32 64 | {55FEE192-3FAB-4EB3-B03E-A3D0A347C49C}.Debug|x64.ActiveCfg = Debug|x64 65 | {55FEE192-3FAB-4EB3-B03E-A3D0A347C49C}.Debug|x64.Build.0 = Debug|x64 66 | {55FEE192-3FAB-4EB3-B03E-A3D0A347C49C}.Debug|x86.ActiveCfg = Debug|Win32 67 | {55FEE192-3FAB-4EB3-B03E-A3D0A347C49C}.Debug|x86.Build.0 = Debug|Win32 68 | {55FEE192-3FAB-4EB3-B03E-A3D0A347C49C}.Release|x64.ActiveCfg = Release|x64 69 | {55FEE192-3FAB-4EB3-B03E-A3D0A347C49C}.Release|x64.Build.0 = Release|x64 70 | {55FEE192-3FAB-4EB3-B03E-A3D0A347C49C}.Release|x86.ActiveCfg = Release|Win32 71 | {55FEE192-3FAB-4EB3-B03E-A3D0A347C49C}.Release|x86.Build.0 = Release|Win32 72 | {E646A100-FAFA-4467-B28B-01D61DE8F458}.Debug|x64.ActiveCfg = Debug|x64 73 | {E646A100-FAFA-4467-B28B-01D61DE8F458}.Debug|x64.Build.0 = Debug|x64 74 | {E646A100-FAFA-4467-B28B-01D61DE8F458}.Debug|x86.ActiveCfg = Debug|Win32 75 | {E646A100-FAFA-4467-B28B-01D61DE8F458}.Debug|x86.Build.0 = Debug|Win32 76 | {E646A100-FAFA-4467-B28B-01D61DE8F458}.Release|x64.ActiveCfg = Release|x64 77 | {E646A100-FAFA-4467-B28B-01D61DE8F458}.Release|x64.Build.0 = Release|x64 78 | {E646A100-FAFA-4467-B28B-01D61DE8F458}.Release|x86.ActiveCfg = Release|Win32 79 | {E646A100-FAFA-4467-B28B-01D61DE8F458}.Release|x86.Build.0 = Release|Win32 80 | {4BA7760B-167D-490A-8AF4-9C04C968069E}.Debug|x64.ActiveCfg = Debug|x64 81 | {4BA7760B-167D-490A-8AF4-9C04C968069E}.Debug|x64.Build.0 = Debug|x64 82 | {4BA7760B-167D-490A-8AF4-9C04C968069E}.Debug|x86.ActiveCfg = Debug|Win32 83 | {4BA7760B-167D-490A-8AF4-9C04C968069E}.Debug|x86.Build.0 = Debug|Win32 84 | {4BA7760B-167D-490A-8AF4-9C04C968069E}.Release|x64.ActiveCfg = Release|x64 85 | {4BA7760B-167D-490A-8AF4-9C04C968069E}.Release|x64.Build.0 = Release|x64 86 | {4BA7760B-167D-490A-8AF4-9C04C968069E}.Release|x86.ActiveCfg = Release|Win32 87 | {4BA7760B-167D-490A-8AF4-9C04C968069E}.Release|x86.Build.0 = Release|Win32 88 | {926354AF-093B-4D64-A1C5-6C01717F67BD}.Debug|x64.ActiveCfg = Debug|x64 89 | {926354AF-093B-4D64-A1C5-6C01717F67BD}.Debug|x64.Build.0 = Debug|x64 90 | {926354AF-093B-4D64-A1C5-6C01717F67BD}.Debug|x86.ActiveCfg = Debug|Win32 91 | {926354AF-093B-4D64-A1C5-6C01717F67BD}.Debug|x86.Build.0 = Debug|Win32 92 | {926354AF-093B-4D64-A1C5-6C01717F67BD}.Release|x64.ActiveCfg = Release|x64 93 | {926354AF-093B-4D64-A1C5-6C01717F67BD}.Release|x64.Build.0 = Release|x64 94 | {926354AF-093B-4D64-A1C5-6C01717F67BD}.Release|x86.ActiveCfg = Release|Win32 95 | {926354AF-093B-4D64-A1C5-6C01717F67BD}.Release|x86.Build.0 = Release|Win32 96 | {2C29A891-7DA0-42E4-8B12-37626AF56AB9}.Debug|x64.ActiveCfg = Debug|x64 97 | {2C29A891-7DA0-42E4-8B12-37626AF56AB9}.Debug|x64.Build.0 = Debug|x64 98 | {2C29A891-7DA0-42E4-8B12-37626AF56AB9}.Debug|x86.ActiveCfg = Debug|Win32 99 | {2C29A891-7DA0-42E4-8B12-37626AF56AB9}.Debug|x86.Build.0 = Debug|Win32 100 | {2C29A891-7DA0-42E4-8B12-37626AF56AB9}.Release|x64.ActiveCfg = Release|x64 101 | {2C29A891-7DA0-42E4-8B12-37626AF56AB9}.Release|x64.Build.0 = Release|x64 102 | {2C29A891-7DA0-42E4-8B12-37626AF56AB9}.Release|x86.ActiveCfg = Release|Win32 103 | {2C29A891-7DA0-42E4-8B12-37626AF56AB9}.Release|x86.Build.0 = Release|Win32 104 | EndGlobalSection 105 | GlobalSection(SolutionProperties) = preSolution 106 | HideSolutionNode = FALSE 107 | EndGlobalSection 108 | GlobalSection(ExtensibilityGlobals) = postSolution 109 | SolutionGuid = {54F75D9D-0B90-4C24-8061-22C7F90F1DC3} 110 | EndGlobalSection 111 | EndGlobal 112 | --------------------------------------------------------------------------------