Advertisement
Guest User

anthony gorecki anthony@anthonygorecki.ca

a guest
Nov 14th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.67 KB | None | 0 0
  1. Sat Nov 14 02:51:02 EST 2015
  2. dev/libgc-proj/proj-make.txt
  3. #===============================================================================
  4. # This file is part of Libgc-proj.
  5. # Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca
  6. #
  7. # GPLv3 License here
  8. #===============================================================================
  9. # gc-proj-conf (tracks config; can reconfigure)
  10. # gc-proj-make (will rebuild changed files; will rebuild only necessary after conf change)
  11. # gc-proj-inst (installs all built targets)
  12.  
  13. DTGT gc-proj
  14.  
  15. TGEN dev
  16. MAKE
  17. EXEC lib/pkgconfig/make.sh $PREF
  18. INST
  19. COPY include/gc $PREF/include
  20. MOVE lib/pkgconfig/gc-proj.pc.tmp $PREF/lib/pkgconfig/gc-proj.pc
  21.  
  22. TLIB gc-proj
  23. dev/libgc-base/src/ct/u8b.c
  24. //==============================================================================
  25. // This file is part of Libgc-base.
  26. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  27. //
  28. // Libgc-base is free software: you can redistribute it and/or modify it under
  29. // the terms of the GNU General Public License as published by the Free Software
  30. // Foundation, either version 3 of the License, or (at your option) any later
  31. // version.
  32. //
  33. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  34. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  35. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  36. //
  37. // You should have received a copy of the GNU General Public License along with
  38. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  39. //==============================================================================
  40. #include <gc/mem.h>
  41.  
  42. #include <gc/u8b.h>
  43.  
  44.  
  45.  
  46. //==============================================================================
  47. // Initialization and deinitialization
  48. //==============================================================================
  49. u8 u8b_init(struct u8b_i *buf, struct u8b_c *conf)
  50. {
  51. buf->dbeg = mem_alloc(conf->size);
  52.  
  53. if (unlikely(buf->dbeg == NULL))
  54. return 1;
  55.  
  56. buf->cbeg = size;
  57. buf->ccur = 0;
  58. buf->dcur = NULL;
  59. return 0;
  60. }
  61.  
  62.  
  63. void u8b_deinit(struct u8b_i *buf)
  64. {
  65. mem_dealloc(buf->dbeg);
  66. }
  67.  
  68.  
  69.  
  70. //==============================================================================
  71. // Utility
  72. //==============================================================================
  73. void u8b_rda(struct u8b_i *buf, u32 size)
  74. {
  75. // circular buffer
  76. buf->cread -= size;
  77. buf->cwrite += size;
  78. buf->dread += size;
  79. }
  80.  
  81.  
  82. u32 u8b_rdgc(struct u8b_i *buf)
  83. {
  84. return buf->cread;
  85. }
  86.  
  87.  
  88. void u8b_wra(struct u8b_i *buf, u32 size)
  89. {
  90. buf->cread += size;
  91. buf->cwrite -= size;
  92. buf->dwrite += size;
  93. }
  94.  
  95.  
  96. u32 u8b_wrgc(struct u8b_i *buf)
  97. {
  98. return buf->cwrite;
  99. }
  100.  
  101.  
  102.  
  103. //==============================================================================
  104. // Peeking
  105. //==============================================================================
  106. u8 u8b_peek1(struct u8b_i *buf)
  107. {
  108. return buf->dread[0];
  109. }
  110.  
  111.  
  112. u16 u8b_peek2(struct u8b_i *buf)
  113. {
  114. u8 cdata[2];
  115.  
  116. cdata[0] = buf->dread[0];
  117. cdata[1] = buf->dread[1];
  118.  
  119. return (u16)cdata;
  120. }
  121. dev/libgc-base/src/util/pars.c
  122. //==============================================================================
  123. // This file is part of Libgc-base.
  124. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  125. //
  126. // Libgc-base is free software: you can redistribute it and/or modify it under
  127. // the terms of the GNU General Public License as published by the Free Software
  128. // Foundation, either version 3 of the License, or (at your option) any later
  129. // version.
  130. //
  131. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  132. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  133. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  134. //
  135. // You should have received a copy of the GNU General Public License along with
  136. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  137. //==============================================================================
  138. #include <gc/pars.h>
  139.  
  140.  
  141.  
  142. //==============================================================================
  143. // "u8's"
  144. //==============================================================================
  145. u8 pars_u8c(struct u8b_i *buf, u8 data)
  146. {
  147. u32 orig_cnt = u8b_cnt(buf);
  148.  
  149. while (u8b_cnt(buf)) {
  150. if (u8b_peek1(buf) != data)
  151. break;
  152.  
  153. u8b_adv(buf, 1);
  154. }
  155.  
  156. return !(u8b_cnt(buf) < orig_cnt);
  157. }
  158.  
  159.  
  160. u8 pars_u8c2(struct u8b_i *buf, u8 data1, u8 data2)
  161. {
  162. u8 cdata[] = {data1, data2};
  163. u32 orig_cnt = u8b_cnt(buf);
  164.  
  165. while (u8b_cnt(buf) >= 2) {
  166. if (u8b_peek2(buf) != (u16)cdata)
  167. break;
  168.  
  169. u8b_adv(buf, 2);
  170. }
  171.  
  172. return !(u8b_cnt(buf) < orig_cnt);
  173. }
  174.  
  175.  
  176.  
  177. //==============================================================================
  178. // New line characters
  179. //==============================================================================
  180. u8 pars_nld(struct u8b_i *buf, u8 types)
  181. {
  182. assert((types & NL_RN) || (types & NL_N) || (types & NL_R));
  183.  
  184. u8 rn[] = {'\r', '\n'};
  185.  
  186. if (u8b_cnt(buf) >= 2 && (types & NL_RN) && u8b_peek2(buf) == (u16)rn)
  187. return NL_RN;
  188.  
  189. if (u8b_cnt(buf)) {
  190. if ((types & NL_N) && u8b_peek(buf) == '\n')
  191. return NL_N;
  192.  
  193. if ((types & NL_R) && u8b_peek(buf) == '\r')
  194. return NL_R;
  195. }
  196.  
  197. return 0;
  198. }
  199.  
  200.  
  201. u8 pars_nlcs(struct u8b_i *buf, u8 types)
  202. {
  203. u8 dtype = pars_nld(buf, types);
  204.  
  205. if (unlikely(!dtype))
  206. return 1;
  207.  
  208. if ((dtype & NL_RN)) {
  209. u8b_adv(buf, 2);
  210. pars_u8c2(buf, '\r', '\n');
  211. }
  212.  
  213. else {
  214. u8b_adv(buf, 1);
  215.  
  216. if ((dtype & NL_N))
  217. pars_u8c(buf, '\n');
  218.  
  219. if ((dtype & NL_R))
  220. pars_u8c(buf, '\r');
  221. }
  222.  
  223. return 0;
  224. }
  225.  
  226.  
  227. u8 pars_nlcm(struct u8b_i *buf, u8 types)
  228. {
  229. u8 ret = 1;
  230.  
  231. for (;;) {
  232. if (pars_nlcs(buf, types))
  233. break;
  234.  
  235. ret = 0;
  236. }
  237.  
  238. return ret;
  239. }
  240.  
  241. dev/libgc-base/src/os/unix/proc.c
  242. //==============================================================================
  243. // This file is part of Libgc-base.
  244. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  245. //
  246. // Libgc-base is free software: you can redistribute it and/or modify it under
  247. // the terms of the GNU General Public License as published by the Free Software
  248. // Foundation, either version 3 of the License, or (at your option) any later
  249. // version.
  250. //
  251. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  252. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  253. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  254. //
  255. // You should have received a copy of the GNU General Public License along with
  256. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  257. //==============================================================================
  258. // proc_st_init, proc_st_next, ...
  259.  
  260.  
  261.  
  262. //==============================================================================
  263. // Execution
  264. //==============================================================================
  265. u8 proc_exec(void)
  266. {
  267. }
  268. dev/libgc-base/src/os/unix/mem.c
  269. //==============================================================================
  270. // This file is part of Libgc-base.
  271. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  272. //
  273. // Libgc-base is free software: you can redistribute it and/or modify it under
  274. // the terms of the GNU General Public License as published by the Free Software
  275. // Foundation, either version 3 of the License, or (at your option) any later
  276. // version.
  277. //
  278. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  279. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  280. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  281. //
  282. // You should have received a copy of the GNU General Public License along with
  283. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  284. //==============================================================================
  285. #include <gc/mem.h>
  286.  
  287. #include <string.h>
  288.  
  289.  
  290.  
  291. //==============================================================================
  292. // Allocation, reallocation and deallocation
  293. //==============================================================================
  294. void *mem_alloc(size_t size)
  295. {
  296. return malloc(size);
  297. }
  298.  
  299.  
  300. void *mem_realloc(void *ptr, size_t size)
  301. {
  302. return realloc(ptr, size);
  303. }
  304.  
  305.  
  306. void mem_dealloc(void *ptr)
  307. {
  308. free(ptr);
  309. }
  310.  
  311.  
  312.  
  313. //==============================================================================
  314. // Utility
  315. //==============================================================================
  316. s8 mem_comp(void *data1, void *data2, size_t size)
  317. {
  318. return memcmp(data1, data2, size);
  319. }
  320.  
  321.  
  322. void mem_copy(void *dest, void *src, size_t size)
  323. {
  324. memcpy(dest, src, size);
  325. }
  326.  
  327.  
  328. void mem_move(void *dest, void *src, size_t size)
  329. {
  330. memmove(dest, src, size);
  331. }
  332.  
  333.  
  334. void mem_set(void *ptr, u8 data, size_t size)
  335. {
  336. memset(ptr, data, size);
  337. }
  338. dev/libgc-base/src/os/unix/file.c
  339. //==============================================================================
  340. // This file is part of Libgc-base.
  341. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  342. //
  343. // Libgc-base is free software: you can redistribute it and/or modify it under
  344. // the terms of the GNU General Public License as published by the Free Software
  345. // Foundation, either version 3 of the License, or (at your option) any later
  346. // version.
  347. //
  348. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  349. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  350. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  351. //
  352. // You should have received a copy of the GNU General Public License along with
  353. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  354. //==============================================================================
  355. #include <gc/file.h>
  356.  
  357.  
  358.  
  359. //==============================================================================
  360. // Initialization and deinitialization
  361. //==============================================================================
  362. u8 file_init(struct file_i *file, struct file_c *conf)
  363. {
  364. if (!(conf->flags & DIO_CREAT))
  365. file->fd = open(conf->path, conf->flags);
  366.  
  367. else
  368. file->fd = open(conf->path, conf->flags, conf->mode);
  369.  
  370. if (unlikely(file->fd == -1))
  371. return 1;
  372.  
  373. return 0;
  374. }
  375.  
  376.  
  377. void file_deinit(struct file_i *file)
  378. {
  379. close(file->fd);
  380. }
  381.  
  382.  
  383.  
  384. //==============================================================================
  385. // Read and write
  386. //==============================================================================
  387. u8 file_read(struct file_i *file, struct u8b_i *buf)
  388. {
  389. ssize_t size = read(file->fd, buf->dwrite, buf->cwrite);
  390.  
  391. if (unlikely(size == -1))
  392. return 1;
  393.  
  394. u8b_wrr(buf, size);
  395. return 0;
  396. }
  397.  
  398.  
  399. u8 file_write(struct file_i *file, struct u8b_i *buf)
  400. {
  401. ssize_t size = write(file->fd, buf->dread, buf->cread);
  402.  
  403. if (unlikely(size == -1))
  404. return 1;
  405.  
  406. u8b_rdr(buf, size);
  407. return 0;
  408. }
  409.  
  410.  
  411.  
  412. //==============================================================================
  413. // Utility
  414. //==============================================================================
  415. u8 file_gstats(struct file_i *file, struct file_stats *stats)
  416. {
  417. if (unlikely(fstat(file->fd, &stats->data)))
  418. return 1;
  419.  
  420. return 0;
  421. }
  422. dev/libgc-base/include/gc/proc.h
  423. //==============================================================================
  424. // This file is part of Libgc-base.
  425. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  426. //
  427. // Libgc-base is free software: you can redistribute it and/or modify it under
  428. // the terms of the GNU General Public License as published by the Free Software
  429. // Foundation, either version 3 of the License, or (at your option) any later
  430. // version.
  431. //
  432. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  433. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  434. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  435. //
  436. // You should have received a copy of the GNU General Public License along with
  437. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  438. //==============================================================================
  439. #pragma once
  440.  
  441. #if defined(__use_gnu_bktrc)
  442. #include <gc/proc-gnu-bktrc.h>
  443. #endif
  444.  
  445. #if defined(__use_lunwind)
  446. #include <gc/proc-lunwind.h>
  447. #endif
  448.  
  449. // Null function pointers for systems where back traces are not supported.
  450. dev/libgc-base/include/gc/common.h
  451. //==============================================================================
  452. // This file is part of Libgc-base.
  453. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  454. //
  455. // Libgc-base is free software: you can redistribute it and/or modify it under
  456. // the terms of the GNU General Public License as published by the Free Software
  457. // Foundation, either version 3 of the License, or (at your option) any later
  458. // version.
  459. //
  460. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  461. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  462. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  463. //
  464. // You should have received a copy of the GNU General Public License along with
  465. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  466. //==============================================================================
  467. #pragma once
  468.  
  469. #include <stddef.h>
  470. #include <stdint.h>
  471.  
  472. typedef int8_t s8;
  473. typedef int16_t s16;
  474. typedef int32_t s32;
  475. typedef int64_t s64;
  476.  
  477. typedef uint8_t u8;
  478. typedef uint16_t u16;
  479. typedef uint32_t u32;
  480. typedef uint64_t u64;
  481. dev/libgc-base/include/gc/u8b.h
  482. dev/libgc-base/include/gc/pars.h
  483. dev/libgc-base/include/gc/mem.h
  484. //==============================================================================
  485. // This file is part of Libgc-base.
  486. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  487. //
  488. // Libgc-base is free software: you can redistribute it and/or modify it under
  489. // the terms of the GNU General Public License as published by the Free Software
  490. // Foundation, either version 3 of the License, or (at your option) any later
  491. // version.
  492. //
  493. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  494. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  495. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  496. //
  497. // You should have received a copy of the GNU General Public License along with
  498. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  499. //==============================================================================
  500. #pragma once
  501.  
  502. #include <gc/common.h>
  503. dev/doc/includes.txt
  504. External Gc headers, Gc header for local file, all other headers; groups
  505. separated by a single new line.
  506. dev/doc/code-style.txt
  507. Soft limit for line length is 80 characters, hard limit is 100 characters.
  508.  
  509. Conditional statements requiring multiple lines should indent the subsequent
  510. lines with two tabs (one additional tab, relative the the code following the
  511. conditional statement).
  512. dev/doc/func-naming.txt
  513. Hard limit for function name first part is five characters. Soft limit is
  514. four characters.
  515.  
  516. Function name hard limit for second part is five characters (initialization /
  517. activation). Does not apply to names that have been shortened to individual
  518. characters per word.
  519.  
  520. Struct member name soft limit is four characters.
  521. script/upload-pastebin.sh
  522. cd /root
  523. date > upload-data.txt
  524.  
  525. echo 'Files:'
  526.  
  527. files=$(find dev -name '*.c' -o -name '*.h' -o -name '*.py' -o -name '*.sh' -o -name '*.txt' -o -name '.vimrc')
  528.  
  529. for file in $files; do
  530. echo " $file"
  531. echo $file >> upload-data.txt
  532. cat $file >> upload-data.txt
  533. done
  534.  
  535. files=$(find script -name '*.c' -o -name '*.h' -o -name '*.py' -o -name '*.sh' -o -name '*.txt' -o -name '.vimrc')
  536.  
  537. for file in $files; do
  538. echo " $file"
  539. echo $file >> upload-data.txt
  540. cat $file >> upload-data.txt
  541. done
  542.  
  543. echo
  544. echo -n 'URL: '
  545. python ./script/intrn/upload-pastebin.py `cat script/intrn/dev-key`
  546. rm upload-data.txt
  547. script/intrn/upload-pastebin.py
  548. import pastebin_python
  549. import sys
  550.  
  551. pb = pastebin_python.pastebin.PastebinPython(api_dev_key=sys.argv[1])
  552. print pb.createPasteFromFile('upload-data.txt', 'anthony gorecki anthony@anthonygorecki.ca', '', '0', 'N')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement