Simple library for C language divided into modules.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
4.3KB

  1. /*
  2. * Moss Library >>> http://moss.aculo.pl
  3. *
  4. * /'\_/`\
  5. * /\ \ ___ ____ ____
  6. * \ \ \__\ \ / __`\ /',__\ /',__\
  7. * \ \ \_/\ \/\ \L\ \/\__, `\/\__, `\
  8. * \ \_\\ \_\ \____/\/\____/\/\____/
  9. * \/_/ \/_/\/___/ \/___/ \/___/
  10. *
  11. * This file is part of Moss Library
  12. * Copyright (c) by sobiemir <sobiemir@aculo.pl>
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation, either version 3 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. */
  27. #include <moss.h>
  28. #include <stdio.h>
  29. #include <locale.h>
  30. #define FPS 60
  31. const int LIST[] =
  32. {
  33. 313, 392, 403, 283, 413, 431, 463, 450, 378, 506, 384, 477, 289, 376, 346, 296, 311, 465, 436, 434, 312,
  34. 299, 371, 482, 402, 325, 263, 448, 491, 381, 308, 512, 342, 280, 290, 417, 305, 359, 336, 498, 363, 326,
  35. 368, 508, 279, 453, 318, 406, 271, 319, 293, 354, 374, 323, 459, 454, 507, 467, 440, 292, 470, 306, 409,
  36. 270, 488, 393, 341, 257, 358, 416, 284, 343, 473, 495, 266, 464, 383, 460, 361, 380, 432, 304, 439, 369,
  37. 339, 273, 348, 286, 404, 499, 272, 394, 423, 476, 382, 487, 469, 309, 366, 489, 405, 501, 267, 377, 301,
  38. 397, 462, 412, 461, 347, 320, 474, 269, 294, 276, 445, 370, 388, 492, 430, 437, 481, 315, 387, 365, 256,
  39. 421, 446, 410, 332, 471, 395, 265, 324, 504, 355, 295, 303, 335, 468, 351, 505, 420, 386, 458, 372, 281,
  40. 285, 373, 344, 400, 274, 379, 398, 298, 364, 277, 327, 411, 475, 331, 362, 494, 316, 428, 288, 291, 422,
  41. 391, 457, 287, 300, 338, 390, 389, 350, 456, 407, 356, 375, 441, 401, 333, 275, 502, 509, 511, 349, 337,
  42. 490, 424, 414, 435, 282, 451, 496, 353, 260, 317, 314, 352, 329, 418, 302, 340, 345, 442, 447, 321, 486,
  43. 357, 478, 503, 500, 307, 310, 367, 297, 278, 264, 268, 425, 360, 429, 443, 419, 322, 426, 497, 484, 427,
  44. 466, 433, 334, 479, 483, 261, 455, 510, 444, 262, 415, 449, 452, 472, 328, 493, 396, 399, 259, 438, 330,
  45. 385, 480, 258, 485
  46. };
  47. int main( int argc, char **argv )
  48. {
  49. int retval;
  50. char chr[MB_LEN_MAX + 1];
  51. MS_STRING str1;
  52. MS_STRING str2;
  53. MS_STRING str3;
  54. setlocale( LC_ALL, "pl_PL.utf8" );
  55. if( ms_string_init_cs(&str1, "TestCSTRc", 0) )
  56. printf( "Błąd podczas tworzenia CSTR\n" );
  57. if( (retval = ms_string_init_mbs(&str2, "Zażółć gęślą jaźń", 0)) )
  58. printf( "Błąd podczas tworzenia MBSTR 0x%X\n", retval );
  59. // if( ms_string_init_wcs(&str3, L"Źdźbło łączy trawy", 0) )
  60. if( ms_string_init_wcs(&str3, L"Poczekaj tu!", 0) )
  61. printf( "Błąd podczas tworzenia WSTR\n" );
  62. // _setmode( _fileno(stdout), 0x00020000 );
  63. printf( "%s\n", str2.Data.Char );
  64. if( (retval = ms_string_insert_cs(&str2, 7, "- porzeczka - ", 0)) )
  65. printf( "Błąd podczas wstawiania CSTR\n" );
  66. printf( "%S\n", str3.Data.Wide );
  67. if( (retval = ms_string_insert_cs(&str3, 9, "no zaraz ", 0)) )
  68. printf( "Błąd podczas wstawiania CSTR\n" );
  69. printf( "%S\n", str3.Data.Wide );
  70. if( (retval = ms_string_insert_cs(&str3, str3.Length, " Jak cudne manowce.", 0)) )
  71. printf( "Błąd podczas wstawiania CSTR\n" );
  72. printf( "%S\n", str3.Data.Wide );
  73. printf( "%s\n", str2.Data.Char );
  74. if( (retval = ms_string_insert_mbs(&str2, 7, "- przełęcz ", 0)) )
  75. printf( "Błąd podczas wstawiania CSTR\n" );
  76. if( (retval = ms_string_insert_cs(&str2, str2.MBInfo->Length, " STOP COMP.", 0)) )
  77. printf( "Błąd podczas wstawiania CSTR\n" );
  78. printf( "%s\n", str2.Data.Char );
  79. if( (retval = ms_string_insert_wcs(&str2, 7, L"Łącki", 0)) )
  80. printf( "Błąd podczas wstawiania CSTR\n" );
  81. printf( "%s\n", str2.Data.Char );
  82. for( retval = 0; retval < str2.MBInfo->Length; ++retval )
  83. {
  84. MS_MBINFO info = ms_array_get( str2.MBInfo, MS_MBINFO, retval );
  85. memcpy( chr, &str2.Data.Char[info.Offset], info.Bytes );
  86. chr[(int)info.Bytes] = '\0';
  87. printf( "Size: %d > Char: %s > Shift: 0x%02lX\n", info.Bytes, chr, info.Offset );
  88. }
  89. ms_string_free( &str1 );
  90. ms_string_free( &str2 );
  91. ms_string_free( &str3 );
  92. return 0;
  93. }