ooxml_crypt 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +58 -0
  5. data/Rakefile +12 -0
  6. data/bin/console +15 -0
  7. data/bin/setup +8 -0
  8. data/ext/ooxml_crypt/extconf.rb +18 -0
  9. data/ext/ooxml_crypt/ooxml_crypt.c +27 -0
  10. data/ext/ooxml_crypt/ooxml_crypt.h +7 -0
  11. data/lib/ooxml_crypt/version.rb +5 -0
  12. data/lib/ooxml_crypt.rb +75 -0
  13. data/vendor/cybozulib/.github/workflows/main.yml +12 -0
  14. data/vendor/cybozulib/.gitignore +5 -0
  15. data/vendor/cybozulib/CMakeLists.txt +6 -0
  16. data/vendor/cybozulib/COPYRIGHT +27 -0
  17. data/vendor/cybozulib/Makefile +26 -0
  18. data/vendor/cybozulib/bin/libeay32.dll +0 -0
  19. data/vendor/cybozulib/bin/libmecab.dll +0 -0
  20. data/vendor/cybozulib/bin/ssleay32.dll +0 -0
  21. data/vendor/cybozulib/common.mk +116 -0
  22. data/vendor/cybozulib/common.props +25 -0
  23. data/vendor/cybozulib/cybozulib.sln +286 -0
  24. data/vendor/cybozulib/debug.props +14 -0
  25. data/vendor/cybozulib/include/cybozu/array.hpp +197 -0
  26. data/vendor/cybozulib/include/cybozu/atoi.hpp +238 -0
  27. data/vendor/cybozulib/include/cybozu/atomic.hpp +146 -0
  28. data/vendor/cybozulib/include/cybozu/base64.hpp +210 -0
  29. data/vendor/cybozulib/include/cybozu/benchmark.hpp +212 -0
  30. data/vendor/cybozulib/include/cybozu/bfd.hpp +105 -0
  31. data/vendor/cybozulib/include/cybozu/bit_operation.hpp +139 -0
  32. data/vendor/cybozulib/include/cybozu/bitvector.hpp +358 -0
  33. data/vendor/cybozulib/include/cybozu/condition_variable.hpp +113 -0
  34. data/vendor/cybozulib/include/cybozu/condition_variable_cs.hpp +74 -0
  35. data/vendor/cybozulib/include/cybozu/config.hpp +392 -0
  36. data/vendor/cybozulib/include/cybozu/critical_section.hpp +60 -0
  37. data/vendor/cybozulib/include/cybozu/crypto.hpp +321 -0
  38. data/vendor/cybozulib/include/cybozu/csucvector.hpp +624 -0
  39. data/vendor/cybozulib/include/cybozu/csv.hpp +294 -0
  40. data/vendor/cybozulib/include/cybozu/data_type.hpp +27 -0
  41. data/vendor/cybozulib/include/cybozu/endian.hpp +224 -0
  42. data/vendor/cybozulib/include/cybozu/env.hpp +63 -0
  43. data/vendor/cybozulib/include/cybozu/event.hpp +122 -0
  44. data/vendor/cybozulib/include/cybozu/exception.hpp +253 -0
  45. data/vendor/cybozulib/include/cybozu/file.hpp +626 -0
  46. data/vendor/cybozulib/include/cybozu/fmindex.hpp +291 -0
  47. data/vendor/cybozulib/include/cybozu/format.hpp +93 -0
  48. data/vendor/cybozulib/include/cybozu/frequency.hpp +264 -0
  49. data/vendor/cybozulib/include/cybozu/hash.hpp +67 -0
  50. data/vendor/cybozulib/include/cybozu/inttype.hpp +174 -0
  51. data/vendor/cybozulib/include/cybozu/itoa.hpp +336 -0
  52. data/vendor/cybozulib/include/cybozu/json.hpp +120 -0
  53. data/vendor/cybozulib/include/cybozu/line_stream.hpp +149 -0
  54. data/vendor/cybozulib/include/cybozu/link_libeay32.hpp +21 -0
  55. data/vendor/cybozulib/include/cybozu/link_mpir.hpp +18 -0
  56. data/vendor/cybozulib/include/cybozu/link_ssleay32.hpp +19 -0
  57. data/vendor/cybozulib/include/cybozu/log.hpp +237 -0
  58. data/vendor/cybozulib/include/cybozu/minixml.hpp +452 -0
  59. data/vendor/cybozulib/include/cybozu/mmap.hpp +143 -0
  60. data/vendor/cybozulib/include/cybozu/mutex.hpp +144 -0
  61. data/vendor/cybozulib/include/cybozu/nlp/mecab.hpp +96 -0
  62. data/vendor/cybozulib/include/cybozu/nlp/plsi.hpp +315 -0
  63. data/vendor/cybozulib/include/cybozu/nlp/random.hpp +74 -0
  64. data/vendor/cybozulib/include/cybozu/nlp/sparse.hpp +529 -0
  65. data/vendor/cybozulib/include/cybozu/nlp/svd.hpp +486 -0
  66. data/vendor/cybozulib/include/cybozu/nlp/tfidf.hpp +226 -0
  67. data/vendor/cybozulib/include/cybozu/nlp/top_score.hpp +75 -0
  68. data/vendor/cybozulib/include/cybozu/option.hpp +743 -0
  69. data/vendor/cybozulib/include/cybozu/parallel.hpp +88 -0
  70. data/vendor/cybozulib/include/cybozu/pcg.hpp +72 -0
  71. data/vendor/cybozulib/include/cybozu/process.hpp +324 -0
  72. data/vendor/cybozulib/include/cybozu/quit_signal_handler.hpp +66 -0
  73. data/vendor/cybozulib/include/cybozu/random_generator.hpp +144 -0
  74. data/vendor/cybozulib/include/cybozu/regex.hpp +463 -0
  75. data/vendor/cybozulib/include/cybozu/select8.hpp +279 -0
  76. data/vendor/cybozulib/include/cybozu/serializer.hpp +363 -0
  77. data/vendor/cybozulib/include/cybozu/sha1.hpp +209 -0
  78. data/vendor/cybozulib/include/cybozu/sha2.hpp +506 -0
  79. data/vendor/cybozulib/include/cybozu/siphash.hpp +105 -0
  80. data/vendor/cybozulib/include/cybozu/socket.hpp +785 -0
  81. data/vendor/cybozulib/include/cybozu/ssl.hpp +203 -0
  82. data/vendor/cybozulib/include/cybozu/stacktrace.hpp +291 -0
  83. data/vendor/cybozulib/include/cybozu/stream.hpp +269 -0
  84. data/vendor/cybozulib/include/cybozu/string.hpp +1746 -0
  85. data/vendor/cybozulib/include/cybozu/string_operation.hpp +365 -0
  86. data/vendor/cybozulib/include/cybozu/sucvector.hpp +378 -0
  87. data/vendor/cybozulib/include/cybozu/test.hpp +373 -0
  88. data/vendor/cybozulib/include/cybozu/thread.hpp +229 -0
  89. data/vendor/cybozulib/include/cybozu/time.hpp +281 -0
  90. data/vendor/cybozulib/include/cybozu/tls.hpp +115 -0
  91. data/vendor/cybozulib/include/cybozu/unordered_map.hpp +13 -0
  92. data/vendor/cybozulib/include/cybozu/unordered_set.hpp +13 -0
  93. data/vendor/cybozulib/include/cybozu/v128.hpp +376 -0
  94. data/vendor/cybozulib/include/cybozu/wavelet_matrix.hpp +345 -0
  95. data/vendor/cybozulib/include/cybozu/xorshift.hpp +189 -0
  96. data/vendor/cybozulib/include/cybozu/zlib.hpp +325 -0
  97. data/vendor/cybozulib/include/sais.hxx +364 -0
  98. data/vendor/cybozulib/misc/make_select8tbl.cpp +26 -0
  99. data/vendor/cybozulib/mk.bat +37 -0
  100. data/vendor/cybozulib/readme.md +29 -0
  101. data/vendor/cybozulib/release.props +12 -0
  102. data/vendor/cybozulib/sample/Makefile +30 -0
  103. data/vendor/cybozulib/sample/csucvector_smpl.cpp +42 -0
  104. data/vendor/cybozulib/sample/data/svd/org/test1.S +4 -0
  105. data/vendor/cybozulib/sample/data/svd/org/test1.U +4 -0
  106. data/vendor/cybozulib/sample/data/svd/org/test1.V +6 -0
  107. data/vendor/cybozulib/sample/data/svd/test1 +4 -0
  108. data/vendor/cybozulib/sample/data/svd/test2 +4 -0
  109. data/vendor/cybozulib/sample/desymbol.cpp +127 -0
  110. data/vendor/cybozulib/sample/exception_smpl.cpp +46 -0
  111. data/vendor/cybozulib/sample/fmindex_smpl.cpp +231 -0
  112. data/vendor/cybozulib/sample/log_smpl.cpp +19 -0
  113. data/vendor/cybozulib/sample/mecab_smpl.cpp +37 -0
  114. data/vendor/cybozulib/sample/option2_smpl.cpp +68 -0
  115. data/vendor/cybozulib/sample/option_smpl.cpp +42 -0
  116. data/vendor/cybozulib/sample/plsi_smpl.cpp +207 -0
  117. data/vendor/cybozulib/sample/proj/exception_smpl.vcproj +184 -0
  118. data/vendor/cybozulib/sample/proj/mecab_smpl.vcproj +184 -0
  119. data/vendor/cybozulib/sample/proj/ssl_smpl/ssl_smpl.vcxproj +85 -0
  120. data/vendor/cybozulib/sample/proj/ssl_smpl.vcproj +347 -0
  121. data/vendor/cybozulib/sample/proj/stacktrace_smpl/stacktrace_smpl.vcxproj +85 -0
  122. data/vendor/cybozulib/sample/proj/svd_smpl.vcproj +184 -0
  123. data/vendor/cybozulib/sample/quit_signal_handler.cpp +30 -0
  124. data/vendor/cybozulib/sample/serializer_smpl.cpp +196 -0
  125. data/vendor/cybozulib/sample/socket_smpl.cpp +82 -0
  126. data/vendor/cybozulib/sample/ssl_smpl.cpp +39 -0
  127. data/vendor/cybozulib/sample/stacktrace_smpl.cpp +52 -0
  128. data/vendor/cybozulib/sample/svd_bench_smpl.cpp +143 -0
  129. data/vendor/cybozulib/sample/svd_smpl.cpp +94 -0
  130. data/vendor/cybozulib/sample/wm_bench_smpl.cpp +182 -0
  131. data/vendor/cybozulib/sample/zlib_smpl.cpp +41 -0
  132. data/vendor/cybozulib/src/Makefile +8 -0
  133. data/vendor/cybozulib/src/base/Makefile +19 -0
  134. data/vendor/cybozulib/test/Makefile +12 -0
  135. data/vendor/cybozulib/test/base/Makefile +37 -0
  136. data/vendor/cybozulib/test/base/array_test.cpp +173 -0
  137. data/vendor/cybozulib/test/base/atoi_test.cpp +774 -0
  138. data/vendor/cybozulib/test/base/atomic_test.cpp +49 -0
  139. data/vendor/cybozulib/test/base/base64_test.cpp +113 -0
  140. data/vendor/cybozulib/test/base/bit_operation_test.cpp +134 -0
  141. data/vendor/cybozulib/test/base/bitvector_test.cpp +204 -0
  142. data/vendor/cybozulib/test/base/condition_variable_cs_test.cpp +92 -0
  143. data/vendor/cybozulib/test/base/condition_variable_test.cpp +88 -0
  144. data/vendor/cybozulib/test/base/config_test.cpp +236 -0
  145. data/vendor/cybozulib/test/base/crypto_test.cpp +122 -0
  146. data/vendor/cybozulib/test/base/csucvector_test.cpp +63 -0
  147. data/vendor/cybozulib/test/base/csv_test.cpp +182 -0
  148. data/vendor/cybozulib/test/base/data/a.xml +26 -0
  149. data/vendor/cybozulib/test/base/endian_test.cpp +56 -0
  150. data/vendor/cybozulib/test/base/env_test.cpp +22 -0
  151. data/vendor/cybozulib/test/base/event_test.cpp +41 -0
  152. data/vendor/cybozulib/test/base/file_test.cpp +233 -0
  153. data/vendor/cybozulib/test/base/fmindex_test.cpp +118 -0
  154. data/vendor/cybozulib/test/base/format_test.cpp +12 -0
  155. data/vendor/cybozulib/test/base/frequency_test.cpp +104 -0
  156. data/vendor/cybozulib/test/base/itoa_test.cpp +522 -0
  157. data/vendor/cybozulib/test/base/line_stream_test.cpp +208 -0
  158. data/vendor/cybozulib/test/base/mecab_test.cpp +41 -0
  159. data/vendor/cybozulib/test/base/minixml_test.cpp +103 -0
  160. data/vendor/cybozulib/test/base/mmap_test.cpp +15 -0
  161. data/vendor/cybozulib/test/base/option_test.cpp +487 -0
  162. data/vendor/cybozulib/test/base/parallel_test.cpp +48 -0
  163. data/vendor/cybozulib/test/base/proj/array_test/array_test.vcxproj +86 -0
  164. data/vendor/cybozulib/test/base/proj/atoi_test/atoi_test.vcxproj +86 -0
  165. data/vendor/cybozulib/test/base/proj/atomic_test/atomic_test.vcxproj +86 -0
  166. data/vendor/cybozulib/test/base/proj/base64_test/base64_test.vcxproj +86 -0
  167. data/vendor/cybozulib/test/base/proj/condition_variable_cs_test/condition_variable_cs_test.vcxproj +86 -0
  168. data/vendor/cybozulib/test/base/proj/condition_variable_test/condition_variable_test.vcxproj +86 -0
  169. data/vendor/cybozulib/test/base/proj/config_test/config_test.vcxproj +86 -0
  170. data/vendor/cybozulib/test/base/proj/csv_test/csv_test.vcxproj +86 -0
  171. data/vendor/cybozulib/test/base/proj/endian_test/endian_test.vcxproj +86 -0
  172. data/vendor/cybozulib/test/base/proj/env_test/env_test.vcxproj +86 -0
  173. data/vendor/cybozulib/test/base/proj/event_test/event_test.vcxproj +86 -0
  174. data/vendor/cybozulib/test/base/proj/file_test/file_test.vcxproj +86 -0
  175. data/vendor/cybozulib/test/base/proj/itoa_test/itoa_test.vcxproj +86 -0
  176. data/vendor/cybozulib/test/base/proj/mecab_test/mecab_test.vcxproj +88 -0
  177. data/vendor/cybozulib/test/base/proj/minixml_test/minixml_test.vcxproj +86 -0
  178. data/vendor/cybozulib/test/base/proj/mmap_test/mmap_test.vcxproj +86 -0
  179. data/vendor/cybozulib/test/base/proj/serializer_test/serializer_test.vcxproj +86 -0
  180. data/vendor/cybozulib/test/base/proj/sha1_test/sha1_test.vcxproj +86 -0
  181. data/vendor/cybozulib/test/base/proj/stream_test/stream_test.vcxproj +86 -0
  182. data/vendor/cybozulib/test/base/proj/string_operation_test/string_operation_test.vcxproj +86 -0
  183. data/vendor/cybozulib/test/base/proj/string_test/string_test.vcxproj +86 -0
  184. data/vendor/cybozulib/test/base/proj/thread_test/thread_test.vcxproj +86 -0
  185. data/vendor/cybozulib/test/base/proj/time_test/time_test.vcxproj +86 -0
  186. data/vendor/cybozulib/test/base/proj/tls_test/tls_test.vcxproj +86 -0
  187. data/vendor/cybozulib/test/base/proj/zlib_test/zlib_test.vcxproj +86 -0
  188. data/vendor/cybozulib/test/base/random_generator_test.cpp +28 -0
  189. data/vendor/cybozulib/test/base/regex_test.cpp +74 -0
  190. data/vendor/cybozulib/test/base/serializer_test.cpp +483 -0
  191. data/vendor/cybozulib/test/base/sha1_test.cpp +61 -0
  192. data/vendor/cybozulib/test/base/sha2_test.cpp +191 -0
  193. data/vendor/cybozulib/test/base/siphash_test.cpp +33 -0
  194. data/vendor/cybozulib/test/base/socket_test.cpp +76 -0
  195. data/vendor/cybozulib/test/base/stream_test.cpp +101 -0
  196. data/vendor/cybozulib/test/base/string_operation_test.cpp +340 -0
  197. data/vendor/cybozulib/test/base/string_test.cpp +1705 -0
  198. data/vendor/cybozulib/test/base/sucvector_test.cpp +312 -0
  199. data/vendor/cybozulib/test/base/thread_test.cpp +62 -0
  200. data/vendor/cybozulib/test/base/time_test.cpp +164 -0
  201. data/vendor/cybozulib/test/base/tls_test.cpp +50 -0
  202. data/vendor/cybozulib/test/base/wavelet_matrix_test.cpp +145 -0
  203. data/vendor/cybozulib/test/base/zlib_test.cpp +371 -0
  204. data/vendor/cybozulib/test/nlp/Makefile +27 -0
  205. data/vendor/cybozulib/test/nlp/proj/random_test.vcproj +184 -0
  206. data/vendor/cybozulib/test/nlp/proj/sparse_test.vcproj +184 -0
  207. data/vendor/cybozulib/test/nlp/proj/svd_test.vcproj +184 -0
  208. data/vendor/cybozulib/test/nlp/random_test.cpp +62 -0
  209. data/vendor/cybozulib/test/nlp/sparse_test.cpp +347 -0
  210. data/vendor/cybozulib/test/nlp/svd_test.cpp +234 -0
  211. data/vendor/cybozulib/test/nlp/top_score_test.cpp +40 -0
  212. data/vendor/cybozulib/tool/create_vcproj.py +186 -0
  213. data/vendor/cybozulib/tool/vcproj_tmpl.py +185 -0
  214. data/vendor/msoffice/COPYRIGHT +27 -0
  215. data/vendor/msoffice/Makefile +29 -0
  216. data/vendor/msoffice/bin/64/msoc.dll +0 -0
  217. data/vendor/msoffice/bin/64/msocsample.exe +0 -0
  218. data/vendor/msoffice/bin/64/msoffice-crypt.exe +0 -0
  219. data/vendor/msoffice/bin/msoc.dll +0 -0
  220. data/vendor/msoffice/bin/msocsample.exe +0 -0
  221. data/vendor/msoffice/bin/msoffice-crypt.exe +0 -0
  222. data/vendor/msoffice/common.mk +71 -0
  223. data/vendor/msoffice/common.props +26 -0
  224. data/vendor/msoffice/debug.props +14 -0
  225. data/vendor/msoffice/include/attack.hpp +211 -0
  226. data/vendor/msoffice/include/cfb.hpp +777 -0
  227. data/vendor/msoffice/include/crypto_util.hpp +450 -0
  228. data/vendor/msoffice/include/custom_sha1.hpp +342 -0
  229. data/vendor/msoffice/include/decode.hpp +240 -0
  230. data/vendor/msoffice/include/encode.hpp +221 -0
  231. data/vendor/msoffice/include/make_dataspace.hpp +316 -0
  232. data/vendor/msoffice/include/msoc.h +129 -0
  233. data/vendor/msoffice/include/resource.hpp +7 -0
  234. data/vendor/msoffice/include/standard_encryption.hpp +145 -0
  235. data/vendor/msoffice/include/uint32vec.hpp +179 -0
  236. data/vendor/msoffice/include/util.hpp +212 -0
  237. data/vendor/msoffice/lib/.emptydir +0 -0
  238. data/vendor/msoffice/misc/decrypt-xls.vbs +46 -0
  239. data/vendor/msoffice/mk.bat +1 -0
  240. data/vendor/msoffice/mkdll.bat +3 -0
  241. data/vendor/msoffice/msoc.def +13 -0
  242. data/vendor/msoffice/msocsample.py +178 -0
  243. data/vendor/msoffice/msoffice12.sln +31 -0
  244. data/vendor/msoffice/readme.md +110 -0
  245. data/vendor/msoffice/release.props +28 -0
  246. data/vendor/msoffice/src/Makefile +19 -0
  247. data/vendor/msoffice/src/attack.cpp +124 -0
  248. data/vendor/msoffice/src/cfb_test.cpp +77 -0
  249. data/vendor/msoffice/src/minisample.c +54 -0
  250. data/vendor/msoffice/src/msocdll.cpp +276 -0
  251. data/vendor/msoffice/src/msocsample.c +136 -0
  252. data/vendor/msoffice/src/msoffice-crypt.cpp +219 -0
  253. data/vendor/msoffice/src/proj/attack/attack.vcxproj +88 -0
  254. data/vendor/msoffice/src/proj/main/msoffice-crypt.vcxproj +88 -0
  255. data/vendor/msoffice/src/sha1.cpp +234 -0
  256. data/vendor/msoffice/test/Makefile +20 -0
  257. data/vendor/msoffice/test/cfb_test.cpp +74 -0
  258. data/vendor/msoffice/test/hash_test.cpp +59 -0
  259. data/vendor/msoffice/test/proj/cfb/cfb_test.vcxproj +90 -0
  260. data/vendor/msoffice/test/proj/hash/hash_test.vcxproj +90 -0
  261. data/vendor/msoffice/test/sampl.bat +8 -0
  262. data/vendor/msoffice/test_all.py +46 -0
  263. data/vendor/update +4 -0
  264. metadata +351 -0
@@ -0,0 +1,186 @@
1
+ import os, sys, re
2
+ import string
3
+ import optparse
4
+ import shutil
5
+
6
+ import vcproj_tmpl
7
+
8
+ TOP_DIR = 'cybozulib'
9
+ BACKUP_SUF = '.old'
10
+ THIS_PATH = os.path.abspath(__file__)
11
+
12
+ INCLUDE_DIR = [
13
+ # move to common.vcprops
14
+ ]
15
+
16
+ LIB_DIR = [
17
+ r'lib'
18
+ ]
19
+
20
+ # get relative path to top dir from here
21
+
22
+ def getPathToTop(path, topDir):
23
+ list = path.split("\\")
24
+ dir = topDir if topDir else TOP_DIR
25
+ try:
26
+ p = list.index(dir)
27
+ return "..\\" * (len(list) - p - 1)
28
+ except:
29
+ print "not found topdir:" + dir
30
+ exit(1)
31
+
32
+ def makeGUID(projName):
33
+ try:
34
+ f = open(projName, 'r')
35
+ p = re.compile(r'.*ProjectGUID="(\{.*?\})"')
36
+ for line in f:
37
+ s = p.split(line)
38
+ if (len(s) > 1):
39
+ return s[1]
40
+ print "bad format:" + projName
41
+ exit(1)
42
+ except:
43
+ import uuid
44
+ return '{' + str(uuid.uuid4()).upper() + '}'
45
+
46
+ def makeSourceList(src):
47
+ return string.join('<File RelativePath="' + s + '"></File>' for s in src)
48
+
49
+ def makeList(inc, relTop):
50
+ return string.join((relTop + '../cybozulib/' + i for i in inc), ';')
51
+
52
+ def getSlnGuid(slnData):
53
+ for line in slnData:
54
+ p = re.search(r'Project\("(\{.*?\})"\)', line)
55
+ if p:
56
+ return p.group(1)
57
+
58
+ def getLibGuid(lib, slnData):
59
+ for line in slnData:
60
+ p = re.search(r'Project\(.*?\) = "' + lib + '",.*(\{.*?\})"', line)
61
+ if p:
62
+ return p.group(1)
63
+
64
+ def appendProjToSln(sln, targetName, projGuid, lib):
65
+ projPath = os.getcwd().split(TOP_DIR + '\\')[1] + '\\' + targetName + '.vcproj'
66
+ backup = sln + BACKUP_SUF
67
+
68
+ # if not os.path.exists(backup):
69
+ shutil.copy(sln, backup)
70
+
71
+ fi = open(backup, "rb")
72
+ slnData = [line for line in fi]
73
+
74
+ cybozulibGuid = getSlnGuid(slnData)
75
+
76
+
77
+ libGuid = [getLibGuid(name, slnData) for name in lib]
78
+
79
+ # append top
80
+ pos = 2
81
+ slnData.insert(pos, r'Project(' + cybozulibGuid + r'") = "' + targetName + r'", "' + projPath + r'", "' + projGuid + '"\r\n')
82
+ pos = pos + 1
83
+ if len(libGuid) > 0:
84
+ slnData.insert(pos, '\tProjectSection(ProjectDependencies) = postProject\r\n')
85
+ pos = pos + 1
86
+ for guid in libGuid:
87
+ slnData.insert(pos, guid + r' = ' + guid + '\r\n')
88
+ pos = pos + 1
89
+ slnData.insert(pos, '\tEndProjectSection\nEndProject\r\n')
90
+
91
+ pos = slnData.index('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n')
92
+ pos = pos + 1
93
+
94
+ list = ['Debug|Win32.ActiveCfg = Debug|Win32',
95
+ 'Debug|Win32.Build.0 = Debug|Win32',
96
+ 'Debug|x64.ActiveCfg = Debug|Win32',
97
+ 'Debug|x64.Build.0 = Debug|Win32',
98
+ 'Release|Win32.ActiveCfg = Release|Win32',
99
+ 'Release|Win32.Build.0 = Release|Win32',
100
+ 'Release|x64.ActiveCfg = Release|Win32',
101
+ 'Release|x64.Build.0 = Release|Win32']
102
+ for t in list:
103
+ slnData.insert(pos, '\t\t' + projGuid + r'.' + t + '\r\n')
104
+ pos = pos + 1
105
+
106
+ fo = open(sln, "wb")
107
+ for line in slnData:
108
+ fo.write(line)
109
+
110
+ def createProj(target, src, topDir, outDir):
111
+ targetName, targetSuf = os.path.splitext(target)
112
+ if (not targetSuf in [".exe", ".lib"]):
113
+ print "target must be exe or lib"
114
+ exit(1)
115
+ projName = targetName + '.vcproj'
116
+ projGuid = makeGUID(projName)
117
+
118
+ relTop = getPathToTop(os.getcwd(), topDir)
119
+
120
+ class MyTemplate(string.Template):
121
+ delimiter = '@'
122
+
123
+ tmpl = MyTemplate(vcproj_tmpl.tmpl)
124
+
125
+ outputBase = relTop + '../' + outDir + '/' + ("bin\\" if targetSuf == '.exe' else "lib\\") + targetName
126
+
127
+ definition = '_LIB' if targetSuf == '.lib' else ''
128
+
129
+ proj = tmpl.substitute({
130
+ 'PROJECT_GUID' : projGuid,
131
+ 'ROOT_NAMESPACE' : targetName,
132
+ 'CONFIGURATION_TYPE' : '1' if targetSuf == '.exe' else '4',
133
+ 'INHERITED_PROPERTY_SHEETS' : makeList(['common.vsprops', 'release.vsprops'], relTop),
134
+ 'INHERITED_PROPERTY_SHEETS_D' : makeList(['common.vsprops', 'debug.vsprops'], relTop),
135
+ 'ADDITIONAL_INCLUDE_DIRECTORIES' : makeList(INCLUDE_DIR, relTop),
136
+ 'ADDITIONAL_LIBRARY_DERECTORIES' : makeList(LIB_DIR, relTop),
137
+ 'PREPROCESSOR_DEFINITIONS' : definition,
138
+ 'PREPROCESSOR_DEFINITIONS_D' : definition,
139
+ 'OUTPUT_FILE' : outputBase + targetSuf,
140
+ 'OUTPUT_FILE_D' : outputBase + 'd' + targetSuf,
141
+ 'SOURCE_FILE' : makeSourceList(src)
142
+ })
143
+
144
+ f = open(projName, 'wb')
145
+ f.write(proj)
146
+ f.close()
147
+
148
+ """
149
+ ex.
150
+ test\src>python ..\..\cybozulib\tool\create_vcproj.py test.exe test.cpp -d test -o ..\..\cybozulib
151
+ """
152
+ def main():
153
+ parser = optparse.OptionParser(usage = 'usage: %prog [-d top dir] [-o outdir] prog.exe file1.cpp file2.cpp ...')
154
+ parser.add_option('-d', '--dir', help = 'top directory', dest = 'dir')
155
+ parser.add_option('-o', '--out', help = 'out directory', dest = 'out')
156
+
157
+ (options, args) = parser.parse_args()
158
+
159
+ topDir = ""
160
+ if options.dir:
161
+ dirs = options.dir.split(',')
162
+ if len(dirs) > 0:
163
+ topDir = dirs[-1]
164
+
165
+ outDir = "cybozulib"
166
+ if options.out:
167
+ dirs = options.out.split(',')
168
+ if len(dirs) > 0:
169
+ outDir = dirs[-1]
170
+
171
+ if len(args) == 0:
172
+ parser.error('need progname')
173
+ exit(1)
174
+
175
+ target = args[0]
176
+ src = args[1::]
177
+
178
+ print 'target:' + target
179
+ print 'src:' + str(src)
180
+ print 'dir:' + topDir
181
+ print 'outdir:' + outDir
182
+
183
+ createProj(target, src, topDir, outDir)
184
+
185
+ if __name__ == '__main__':
186
+ main()
@@ -0,0 +1,185 @@
1
+ tmpl = r'''<?xml version="1.0" encoding="shift_jis"?>
2
+ <VisualStudioProject
3
+ ProjectType="Visual C++"
4
+ Version="9.00"
5
+ Name="@{ROOT_NAMESPACE}"
6
+ ProjectGUID="@{PROJECT_GUID}"
7
+ RootNamespace="@{ROOT_NAMESPACE}"
8
+ Keyword="Win32Proj"
9
+ TargetFrameworkVersion="196613"
10
+ >
11
+ <Platforms>
12
+ <Platform
13
+ Name="Win32"
14
+ />
15
+ <Platform
16
+ Name="x64"
17
+ />
18
+ </Platforms>
19
+ <ToolFiles>
20
+ </ToolFiles>
21
+ <Configurations>
22
+ <Configuration
23
+ Name="Debug|Win32"
24
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
25
+ IntermediateDirectory="$(ConfigurationName)\@{ROOT_NAMESPACE}"
26
+ ConfigurationType="@{CONFIGURATION_TYPE}"
27
+ InheritedPropertySheets="@{INHERITED_PROPERTY_SHEETS_D}"
28
+ CharacterSet="2"
29
+ >
30
+ <Tool
31
+ Name="VCCLCompilerTool"
32
+ Optimization="0"
33
+ AdditionalIncludeDirectories="@{ADDITIONAL_INCLUDE_DIRECTORIES}"
34
+ PreprocessorDefinitions="@{PREPROCESSOR_DEFINITIONS_D}"
35
+ MinimalRebuild="true"
36
+ BasicRuntimeChecks="3"
37
+ RuntimeLibrary="3"
38
+ UsePrecompiledHeader="0"
39
+ DebugInformationFormat="4"
40
+ />
41
+ <Tool
42
+ Name="VCLinkerTool"
43
+ OutputFile="@{OUTPUT_FILE_D}"
44
+ AdditionalLibraryDirectories="@{ADDITIONAL_LIBRARY_DERECTORIES}"
45
+ LinkIncremental="2"
46
+ GenerateDebugInformation="true"
47
+ SubSystem="1"
48
+ TargetMachine="1"
49
+ />
50
+ <Tool
51
+ Name="VCLibrarianTool"
52
+ OutputFile="@{OUTPUT_FILE_D}"
53
+ />
54
+ </Configuration>
55
+ <Configuration
56
+ Name="Release|Win32"
57
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
58
+ IntermediateDirectory="$(ConfigurationName)\@{ROOT_NAMESPACE}"
59
+ ConfigurationType="@{CONFIGURATION_TYPE}"
60
+ InheritedPropertySheets="@{INHERITED_PROPERTY_SHEETS}"
61
+ CharacterSet="2"
62
+ WholeProgramOptimization="1"
63
+ >
64
+ <Tool
65
+ Name="VCCLCompilerTool"
66
+ Optimization="2"
67
+ EnableIntrinsicFunctions="true"
68
+ AdditionalIncludeDirectories="@{ADDITIONAL_INCLUDE_DIRECTORIES}"
69
+ PreprocessorDefinitions="@{PREPROCESSOR_DEFINITIONS}"
70
+ RuntimeLibrary="2"
71
+ EnableFunctionLevelLinking="true"
72
+ UsePrecompiledHeader="0"
73
+ DebugInformationFormat="3"
74
+ />
75
+ <Tool
76
+ Name="VCLibrarianTool"
77
+ OutputFile="@{OUTPUT_FILE}"
78
+ />
79
+ <Tool
80
+ Name="VCLinkerTool"
81
+ OutputFile="@{OUTPUT_FILE}"
82
+ AdditionalLibraryDirectories="@{ADDITIONAL_LIBRARY_DERECTORIES}"
83
+ LinkIncremental="1"
84
+ GenerateDebugInformation="true"
85
+ SubSystem="1"
86
+ OptimizeReferences="2"
87
+ EnableCOMDATFolding="2"
88
+ TargetMachine="1"
89
+ />
90
+ </Configuration>
91
+ <Configuration
92
+ Name="Debug|x64"
93
+ OutputDirectory="$(SolutionDir)$(PlatformName)$(ConfigurationName)"
94
+ IntermediateDirectory="$(ConfigurationName)\$(RootNamespace)64"
95
+ ConfigurationType="@{CONFIGURATION_TYPE}"
96
+ InheritedPropertySheets="@{INHERITED_PROPERTY_SHEETS_D}"
97
+ CharacterSet="2"
98
+ >
99
+ <Tool
100
+ Name="VCMIDLTool"
101
+ TargetEnvironment="3"
102
+ />
103
+ <Tool
104
+ Name="VCCLCompilerTool"
105
+ Optimization="0"
106
+ AdditionalIncludeDirectories="@{ADDITIONAL_INCLUDE_DIRECTORIES}"
107
+ PreprocessorDefinitions="@{PREPROCESSOR_DEFINITIONS_D}"
108
+ MinimalRebuild="true"
109
+ BasicRuntimeChecks="3"
110
+ RuntimeLibrary="3"
111
+ UsePrecompiledHeader="0"
112
+ DebugInformationFormat="3"
113
+ />
114
+ <Tool
115
+ Name="VCLinkerTool"
116
+ OutputFile="@{OUTPUT_FILE_D}"
117
+ AdditionalLibraryDirectories="@{ADDITIONAL_LIBRARY_DERECTORIES}"
118
+ LinkIncremental="2"
119
+ GenerateDebugInformation="true"
120
+ SubSystem="1"
121
+ TargetMachine="17"
122
+ />
123
+ <Tool
124
+ Name="VCLibrarianTool"
125
+ OutputFile="@{OUTPUT_FILE_D}"
126
+ />
127
+ </Configuration>
128
+ <Configuration
129
+ Name="Release|x64"
130
+ OutputDirectory="$(SolutionDir)$(PlatformName)$(ConfigurationName)"
131
+ IntermediateDirectory="$(ConfigurationName)\$(RootNamespace)64"
132
+ ConfigurationType="@{CONFIGURATION_TYPE}"
133
+ InheritedPropertySheets="@{INHERITED_PROPERTY_SHEETS}"
134
+ CharacterSet="2"
135
+ WholeProgramOptimization="1"
136
+ >
137
+ <Tool
138
+ Name="VCMIDLTool"
139
+ TargetEnvironment="3"
140
+ />
141
+ <Tool
142
+ Name="VCCLCompilerTool"
143
+ Optimization="2"
144
+ EnableIntrinsicFunctions="true"
145
+ AdditionalIncludeDirectories="@{ADDITIONAL_INCLUDE_DIRECTORIES}"
146
+ PreprocessorDefinitions="@{PREPROCESSOR_DEFINITIONS}"
147
+ RuntimeLibrary="2"
148
+ EnableFunctionLevelLinking="true"
149
+ UsePrecompiledHeader="0"
150
+ DebugInformationFormat="3"
151
+ />
152
+ <Tool
153
+ Name="VCLibrarianTool"
154
+ OutputFile="@{OUTPUT_FILE}"
155
+ />
156
+ <Tool
157
+ Name="VCLinkerTool"
158
+ OutputFile="@{OUTPUT_FILE}"
159
+ AdditionalLibraryDirectories="@{ADDITIONAL_LIBRARY_DERECTORIES}"
160
+ LinkIncremental="1"
161
+ GenerateDebugInformation="true"
162
+ SubSystem="1"
163
+ OptimizeReferences="2"
164
+ EnableCOMDATFolding="2"
165
+ TargetMachine="17"
166
+ />
167
+ </Configuration>
168
+ </Configurations>
169
+ <References>
170
+ </References>
171
+ <Files>
172
+ <Filter
173
+ Name="Source Files"
174
+ Filter="cpp;c;cc;cxx">
175
+ @{SOURCE_FILE}
176
+ </Filter>
177
+ <Filter
178
+ Name="Header Files"
179
+ Filter="h;hpp">
180
+ </Filter>
181
+ </Files>
182
+ <Globals>
183
+ </Globals>
184
+ </VisualStudioProject>
185
+ '''
@@ -0,0 +1,27 @@
1
+
2
+ Copyright (c) 2007-2015 Cybozu Labs, Inc.
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+ Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+ Neither the name of the Cybozu Labs, Inc. nor the names of its contributors may
14
+ be used to endorse or promote products derived from this software without
15
+ specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27
+ THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,29 @@
1
+ include common.mk
2
+
3
+ MSOC_LIB=lib/libmsoc.a
4
+ MSOC_SLIB=lib/libmsoc.$(LIB_SUF)
5
+
6
+ all:
7
+ $(MAKE) -C src
8
+ $(MAKE) $(MSOC_LIB)
9
+ $(MAKE) $(MSOC_SLIB)
10
+
11
+ test:
12
+ python test_all.py
13
+ clean:
14
+ $(MAKE) -C src clean
15
+ $(MAKE) -C test clean
16
+ $(RM) -rf $(MSOC_LIB) $(MSOC_SLIB)
17
+
18
+ src/$(OBJDIR)/msocdll.o: src/msocdll.cpp include/msoc.h
19
+ $(CXX) -c $< -o $@ $(CFLAGS) -fPIC
20
+
21
+ $(MSOC_LIB): src/$(OBJDIR)/msocdll.o
22
+ $(AR) $@ $<
23
+
24
+ $(MSOC_SLIB): src/$(OBJDIR)/msocdll.o
25
+ $(CXX) -o $@ $< -shared $(LDFLAGS)
26
+
27
+ bin/minisample: src/minisample.c include/msoc.h $(MSOC_LIB)
28
+ $(CC) $< -o $@ $(MSOC_LIB) -lstdc++ -lcrypto -Iinclude -Wall -Wextra -lcrypto
29
+
Binary file
Binary file
Binary file
@@ -0,0 +1,71 @@
1
+ CP = cp -f
2
+ AR = ar r
3
+ MKDIR=mkdir -p
4
+ RM=rm -fr
5
+ CFLAGS_OPT = -Ofast -fomit-frame-pointer -DNDEBUG -march=native -msse4
6
+ #CFLAGS_WARN=-Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wfloat-equal -Wpointer-arith #-Wswitch-enum -Wstrict-aliasing=2
7
+ CFLAGS_WARN=-Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith #-Wswitch-enum -Wstrict-aliasing=2
8
+ CFLAGS = -g -D_FILE_OFFSET_BITS=64 -msse2 -fno-operator-names
9
+ CFLAGS+=$(CFLAGS_WARN)
10
+ LDFLAGS = -lcrypto -lssl
11
+ UNAME_S=$(shell uname -s)
12
+ ifeq ($(UNAME_S),Darwin)
13
+ CFLAGS+=-I/usr/local/opt/openssl/include
14
+ LDFLAGS+=-L/usr/local/opt/openssl/lib
15
+ LIB_SUF=dylib
16
+ else
17
+ LIB_SUF=so
18
+ endif
19
+
20
+ DEBUG=0
21
+ ifeq ($(RELEASE),1)
22
+ DEBUG=0
23
+ endif
24
+
25
+ ifeq ($(DEBUG),0)
26
+ CFLAGS+=$(CFLAGS_OPT)
27
+ OBJDIR=release
28
+ OBJSUF=
29
+ else
30
+ OBJDIR=debug
31
+ OBJSUF=d
32
+ endif
33
+
34
+ TOPDIR:=$(realpath $(dir $(lastword $(MAKEFILE_LIST))))/
35
+ CFLAGS+= -I$(TOPDIR)include -I$(TOPDIR)../cybozulib/include -I$(TOPDIR)../mie/include
36
+ LDFLAGS+= -L$(TOPDIR)lib -lcrypto -lpthread
37
+ ifneq ($(UNAME_S),Darwin)
38
+ LDFLAGS+=-lrt
39
+ endif
40
+
41
+ MKDEP = sh -ec '$(CC) -MM $(CFLAGS) $< | sed "s@\($*\)\.o[ :]*@$(OBJDIR)/\1.o $@ : @g" > $@; [ -s $@ ] || rm -f $@'
42
+
43
+ CLEAN=$(RM) $(TARGET) $(OBJDIR)
44
+
45
+ define UNIT_TEST
46
+ sh -ec 'for i in $(TARGET); do $$i|grep "ctest:name"; done' > result.txt
47
+ grep -v "ng=0, exception=0" result.txt || echo "all unit tests are ok"
48
+ endef
49
+
50
+ define SAMPLE_TEST
51
+ sh -ec 'for i in $(TARGET); do $$i; done'
52
+ endef
53
+
54
+ .SUFFIXES: .cpp .d .exe
55
+
56
+ $(OBJDIR)/%.o: %.cpp
57
+ $(CXX) -c $< -o $@ $(CFLAGS)
58
+
59
+ $(OBJDIR)/%.d: %.cpp $(OBJDIR)
60
+ @$(MKDEP)
61
+
62
+ $(TOPDIR)bin/%$(OBJSUF).exe: $(OBJDIR)/%.o $(LIBS)
63
+ $(CXX) $< -o $@ $(LIBS) $(LDFLAGS)
64
+
65
+ OBJS=$(addprefix $(OBJDIR)/,$(SRC:.cpp=.o))
66
+
67
+ DEPEND_FILE=$(addprefix $(OBJDIR)/, $(SRC:.cpp=.d))
68
+ TEST_FILE=$(addprefix $(TOPDIR)bin/, $(SRC:.cpp=$(OBJSUF).exe))
69
+
70
+ .PHONY: test
71
+
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <ImportGroup Label="PropertySheets" />
4
+ <PropertyGroup Label="UserMacros" />
5
+ <PropertyGroup>
6
+ <OutDir>$(SolutionDir)bin\</OutDir>
7
+ </PropertyGroup>
8
+ <ItemDefinitionGroup>
9
+ <ClCompile>
10
+ <AdditionalIncludeDirectories>$(SolutionDir)../xbyak;$(SolutionDir)../cybozulib/include;$(SolutionDir)../cybozulib_ext/openssl/include;$(SolutionDir)../cybozulib_ext/mpir/include;$(SolutionDir)include</AdditionalIncludeDirectories>
11
+ </ClCompile>
12
+ </ItemDefinitionGroup>
13
+ <ItemDefinitionGroup>
14
+ <ClCompile>
15
+ <WarningLevel>Level4</WarningLevel>
16
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
17
+ <PrecompiledHeaderFile />
18
+ <PrecompiledHeaderOutputFile />
19
+ <PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);NOMINMAX</PreprocessorDefinitions>
20
+ </ClCompile>
21
+ <Link>
22
+ <AdditionalLibraryDirectories>$(SolutionDir)../cybozulib_ext/mpir/lib;$(SolutionDir)../cybozulib_ext/openssl/lib</AdditionalLibraryDirectories>
23
+ </Link>
24
+ </ItemDefinitionGroup>
25
+ <ItemGroup />
26
+ </Project>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <ImportGroup Label="PropertySheets" />
4
+ <PropertyGroup Label="UserMacros" />
5
+ <PropertyGroup>
6
+ <TargetName>$(ProjectName)d</TargetName>
7
+ </PropertyGroup>
8
+ <ItemDefinitionGroup>
9
+ <ClCompile>
10
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
11
+ </ClCompile>
12
+ </ItemDefinitionGroup>
13
+ <ItemGroup />
14
+ </Project>