example.odin 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //+ignore
  2. package zlib
  3. import "core:compress/zlib"
  4. import "core:bytes"
  5. import "core:fmt"
  6. main :: proc() {
  7. ODIN_DEMO := []u8{
  8. 120, 156, 101, 144, 77, 110, 131, 48, 16, 133, 215, 204, 41, 158, 44,
  9. 69, 73, 32, 148, 182, 75, 35, 14, 208, 125, 47, 96, 185, 195, 143,
  10. 130, 13, 50, 38, 81, 84, 101, 213, 75, 116, 215, 43, 246, 8, 53,
  11. 82, 126, 8, 181, 188, 152, 153, 111, 222, 147, 159, 123, 165, 247, 170,
  12. 98, 24, 213, 88, 162, 198, 244, 157, 243, 16, 186, 115, 44, 75, 227,
  13. 5, 77, 115, 72, 137, 222, 117, 122, 179, 197, 39, 69, 161, 170, 156,
  14. 50, 144, 5, 68, 130, 4, 49, 126, 127, 190, 191, 144, 34, 19, 57,
  15. 69, 74, 235, 209, 140, 173, 242, 157, 155, 54, 158, 115, 162, 168, 12,
  16. 181, 239, 246, 108, 17, 188, 174, 242, 224, 20, 13, 199, 198, 235, 250,
  17. 194, 166, 129, 86, 3, 99, 157, 172, 37, 230, 62, 73, 129, 151, 252,
  18. 70, 211, 5, 77, 31, 104, 188, 160, 113, 129, 215, 59, 205, 22, 52,
  19. 123, 160, 83, 142, 255, 242, 89, 123, 93, 149, 200, 50, 188, 85, 54,
  20. 252, 18, 248, 192, 238, 228, 235, 198, 86, 224, 118, 224, 176, 113, 166,
  21. 112, 67, 106, 227, 159, 122, 215, 88, 95, 110, 196, 123, 205, 183, 224,
  22. 98, 53, 8, 104, 213, 234, 201, 147, 7, 248, 192, 14, 170, 29, 25,
  23. 171, 15, 18, 59, 138, 112, 63, 23, 205, 110, 254, 136, 109, 78, 231,
  24. 63, 234, 138, 133, 204,
  25. };
  26. buf: bytes.Buffer;
  27. // We can pass ", true" to inflate a raw DEFLATE stream instead of a ZLIB wrapped one.
  28. err := zlib.inflate(ODIN_DEMO, &buf);
  29. defer bytes.buffer_destroy(&buf);
  30. if err != nil {
  31. fmt.printf("\nError: %v\n", err);
  32. }
  33. s := bytes.buffer_to_string(&buf);
  34. fmt.printf("Input: %v bytes, output (%v bytes):\n%v\n", len(ODIN_DEMO), len(s), s);
  35. assert(len(s) == 438);
  36. }