Advertisement
Guest User

anthony gorecki anthony@anthonygorecki.ca

a guest
Nov 13th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.99 KB | None | 0 0
  1. dev/libgc-base/src/ct/u8b.c
  2. //==============================================================================
  3. // This file is part of Libgc-base.
  4. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  5. //
  6. // Libgc-base is free software: you can redistribute it and/or modify it under
  7. // the terms of the GNU General Public License as published by the Free Software
  8. // Foundation, either version 3 of the License, or (at your option) any later
  9. // version.
  10. //
  11. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  12. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  13. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License along with
  16. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  17. //==============================================================================
  18. #include <gc/u8b.h>
  19.  
  20.  
  21.  
  22. //==============================================================================
  23. // General
  24. //==============================================================================
  25. void u8b_adv(struct u8b_i *buf, u32 len)
  26. {
  27. buf->ccur -= len;
  28. buf->dcur += len;
  29. }
  30.  
  31.  
  32. u32 u8b_cnt(struct u8b_i *buf)
  33. {
  34. return buf->ccur;
  35. }
  36.  
  37.  
  38.  
  39. //==============================================================================
  40. // Peeking
  41. //==============================================================================
  42. u8 u8b_peek1(struct u8b_i *buf)
  43. {
  44. return buf->dcur[0];
  45. }
  46.  
  47.  
  48. u16 u8b_peek2(struct u8b_i *buf)
  49. {
  50. u8 cdata[2];
  51.  
  52. cdata[0] = buf->dcur[0];
  53. cdata[1] = buf->dcur[1];
  54.  
  55. return (u16)cdata;
  56. }
  57. dev/libgc-base/src/util/pars.c
  58. //==============================================================================
  59. // This file is part of Libgc-base.
  60. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  61. //
  62. // Libgc-base is free software: you can redistribute it and/or modify it under
  63. // the terms of the GNU General Public License as published by the Free Software
  64. // Foundation, either version 3 of the License, or (at your option) any later
  65. // version.
  66. //
  67. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  68. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  69. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  70. //
  71. // You should have received a copy of the GNU General Public License along with
  72. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  73. //==============================================================================
  74. #include <gc/pars.h>
  75.  
  76.  
  77.  
  78. //==============================================================================
  79. // "u8's"
  80. //==============================================================================
  81. u8 pars_u8c(struct u8b_i *buf, u8 data)
  82. {
  83. u32 orig_cnt = u8b_cnt(buf);
  84.  
  85. while (u8b_cnt(buf)) {
  86. if (u8b_peek1(buf) != data)
  87. break;
  88.  
  89. u8b_adv(buf, 1);
  90. }
  91.  
  92. return !(u8b_cnt(buf) < orig_cnt);
  93. }
  94.  
  95.  
  96. u8 pars_u8c2(struct u8b_i *buf, u8 data1, u8 data2)
  97. {
  98. u8 cdata[] = {data1, data2};
  99. u32 orig_cnt = u8b_cnt(buf);
  100.  
  101. while (u8b_cnt(buf) >= 2) {
  102. if (u8b_peek2(buf) != (u16)cdata)
  103. break;
  104.  
  105. u8b_adv(buf, 2);
  106. }
  107.  
  108. return !(u8b_cnt(buf) < orig_cnt);
  109. }
  110.  
  111.  
  112.  
  113. //==============================================================================
  114. // New line characters
  115. //==============================================================================
  116. u8 pars_nld(struct u8b_i *buf, u8 types)
  117. {
  118. assert((types & NL_RN) || (types & NL_N) || (types & NL_R));
  119.  
  120. u8 rn[] = {'\r', '\n'};
  121.  
  122. if (u8b_cnt(buf) >= 2 && (types & NL_RN) && u8b_peek2(buf) == (u16)rn)
  123. return NL_RN;
  124.  
  125. if (u8b_cnt(buf)) {
  126. if ((types & NL_N) && u8b_peek(buf) == '\n')
  127. return NL_N;
  128.  
  129. if ((types & NL_R) && u8b_peek(buf) == '\r')
  130. return NL_R;
  131. }
  132.  
  133. return 0;
  134. }
  135.  
  136.  
  137. u8 pars_nlcs(struct u8b_i *buf, u8 types)
  138. {
  139. u8 dtype = pars_nld(buf, types);
  140.  
  141. if (unlikely(!dtype))
  142. return 1;
  143.  
  144. if ((dtype & NL_RN)) {
  145. u8b_adv(buf, 2);
  146. pars_u8c2(buf, '\r', '\n');
  147. }
  148.  
  149. else {
  150. u8b_adv(buf, 1);
  151.  
  152. if ((dtype & NL_N))
  153. pars_u8c(buf, '\n');
  154.  
  155. if ((dtype & NL_R))
  156. pars_u8c(buf, '\r');
  157. }
  158.  
  159. return 0;
  160. }
  161.  
  162.  
  163. u8 pars_nlcm(struct u8b_i *buf, u8 types)
  164. {
  165. u8 ret = 1;
  166.  
  167. for (;;) {
  168. if (pars_nlcs(buf, types))
  169. break;
  170.  
  171. ret = 0;
  172. }
  173.  
  174. return ret;
  175. }
  176.  
  177. dev/libgc-base/src/os/unix/proc.c
  178. //==============================================================================
  179. // This file is part of Libgc-base.
  180. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  181. //
  182. // Libgc-base is free software: you can redistribute it and/or modify it under
  183. // the terms of the GNU General Public License as published by the Free Software
  184. // Foundation, either version 3 of the License, or (at your option) any later
  185. // version.
  186. //
  187. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  188. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  189. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  190. //
  191. // You should have received a copy of the GNU General Public License along with
  192. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  193. //==============================================================================
  194. // proc_st_init, proc_st_next, ...
  195.  
  196.  
  197.  
  198. //==============================================================================
  199. // Execution
  200. //==============================================================================
  201. u8 proc_exec(void)
  202. {
  203. }
  204. dev/libgc-base/src/os/unix/mem.c
  205. //==============================================================================
  206. // This file is part of Libgc-base.
  207. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  208. //
  209. // Libgc-base is free software: you can redistribute it and/or modify it under
  210. // the terms of the GNU General Public License as published by the Free Software
  211. // Foundation, either version 3 of the License, or (at your option) any later
  212. // version.
  213. //
  214. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  215. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  216. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  217. //
  218. // You should have received a copy of the GNU General Public License along with
  219. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  220. //==============================================================================
  221. #include <gc/mem.h>
  222.  
  223. #include <string.h>
  224.  
  225.  
  226.  
  227. //==============================================================================
  228. // Allocation, reallocation and deallocation
  229. //==============================================================================
  230. void *mem_alloc(size_t size)
  231. {
  232. return malloc(size);
  233. }
  234.  
  235.  
  236. void *mem_realloc(void *ptr, size_t size)
  237. {
  238. return realloc(ptr, size);
  239. }
  240.  
  241.  
  242. void mem_dealloc(void *ptr)
  243. {
  244. free(ptr);
  245. }
  246.  
  247.  
  248.  
  249. //==============================================================================
  250. // Utility
  251. //==============================================================================
  252. s8 mem_comp(void *data1, void *data2, size_t size)
  253. {
  254. return memcmp(data1, data2, size);
  255. }
  256.  
  257.  
  258. void mem_copy(void *dest, void *src, size_t size)
  259. {
  260. memcpy(dest, src, size);
  261. }
  262.  
  263.  
  264. void mem_move(void *dest, void *src, size_t size)
  265. {
  266. memmove(dest, src, size);
  267. }
  268.  
  269.  
  270. void mem_set(void *ptr, u8 data, size_t size)
  271. {
  272. memset(ptr, data, size);
  273. }
  274. dev/libgc-base/include/gc/proc.h
  275. //==============================================================================
  276. // This file is part of Libgc-base.
  277. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  278. //
  279. // Libgc-base is free software: you can redistribute it and/or modify it under
  280. // the terms of the GNU General Public License as published by the Free Software
  281. // Foundation, either version 3 of the License, or (at your option) any later
  282. // version.
  283. //
  284. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  285. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  286. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  287. //
  288. // You should have received a copy of the GNU General Public License along with
  289. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  290. //==============================================================================
  291. #pragma once
  292.  
  293. #if defined(__use_gnu_bktrc)
  294. #include <gc/proc-gnu-bktrc.h>
  295. #endif
  296.  
  297. #if defined(__use_lunwind)
  298. #include <gc/proc-lunwind.h>
  299. #endif
  300.  
  301. // Null function pointers for systems where back traces are not supported.
  302. dev/libgc-base/include/gc/common.h
  303. //==============================================================================
  304. // This file is part of Libgc-base.
  305. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  306. //
  307. // Libgc-base is free software: you can redistribute it and/or modify it under
  308. // the terms of the GNU General Public License as published by the Free Software
  309. // Foundation, either version 3 of the License, or (at your option) any later
  310. // version.
  311. //
  312. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  313. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  314. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  315. //
  316. // You should have received a copy of the GNU General Public License along with
  317. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  318. //==============================================================================
  319. #pragma once
  320.  
  321. #include <stddef.h>
  322. #include <stdint.h>
  323.  
  324. typedef int8_t s8;
  325. typedef int16_t s16;
  326. typedef int32_t s32;
  327. typedef int64_t s64;
  328.  
  329. typedef uint8_t u8;
  330. typedef uint16_t u16;
  331. typedef uint32_t u32;
  332. typedef uint64_t u64;
  333. dev/libgc-base/include/gc/u8b.h
  334. dev/libgc-base/include/gc/pars.h
  335. dev/libgc-base/include/gc/mem.h
  336. //==============================================================================
  337. // This file is part of Libgc-base.
  338. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  339. //
  340. // Libgc-base is free software: you can redistribute it and/or modify it under
  341. // the terms of the GNU General Public License as published by the Free Software
  342. // Foundation, either version 3 of the License, or (at your option) any later
  343. // version.
  344. //
  345. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  346. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  347. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  348. //
  349. // You should have received a copy of the GNU General Public License along with
  350. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  351. //==============================================================================
  352. #pragma once
  353.  
  354. #include <gc/common.h>
  355. dev/doc/includes.txt
  356. External Gc headers, Gc header for local file, all other headers; groups
  357. separated by a single new line.
  358. dev/doc/code-style.txt
  359. Soft limit for line length is 80 characters, hard limit is 100 characters.
  360.  
  361. Conditional statements requiring multiple lines should indent the subsequent
  362. lines with two tabs (one additional tab, relative the the code following the
  363. conditional statement).
  364. dev/doc/func-naming.txt
  365. Hard limit for function name first part is five characters. Soft limit is
  366. four characters.
  367.  
  368. Function name hard limit for second part is five characters (initialization /
  369. activation). Does not apply to names that have been shortened to individual
  370. characters per word.
  371.  
  372. Struct member name soft limit is four characters.
  373. script/upload-pastebin.sh
  374. cd /root
  375. rm upload-data.txt 2>/dev/null
  376.  
  377. echo 'Files:'
  378.  
  379. files=$(find dev -name '*.c' -o -name '*.h' -o -name '*.py' -o -name '*.sh' -o -name '*.txt' -o -name '.vimrc')
  380.  
  381. for file in $files; do
  382. echo " $file"
  383. echo $file >> upload-data.txt
  384. cat $file >> upload-data.txt
  385. done
  386.  
  387. files=$(find script -name '*.c' -o -name '*.h' -o -name '*.py' -o -name '*.sh' -o -name '*.txt' -o -name '.vimrc')
  388.  
  389. for file in $files; do
  390. echo " $file"
  391. echo $file >> upload-data.txt
  392. cat $file >> upload-data.txt
  393. done
  394.  
  395. echo
  396. echo -n 'URL: '
  397. python ./script/intrn/upload-pastebin.py `cat script/intrn/dev-key`
  398. rm upload-data.txt
  399. script/intrn/upload-pastebin.py
  400. import pastebin_python
  401. import sys
  402.  
  403. pb = pastebin_python.pastebin.PastebinPython(api_dev_key=sys.argv[1])
  404. print pb.createPasteFromFile('upload-data.txt', 'anthony gorecki anthony@anthonygorecki.ca', '', '0', 'N')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement