1. Си / Говнокод #26076

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    void sensor_init_regctl(void)
    
    {
      int iVar1;
      
                        /* Reading /rom/custom_setting_gm.ini
                           Setting I2CPortChange val from file */
      custom_setting_gm_get_I2C();
                        /* Checking for I2CPortChange in /rom/custom_setting_gm.ini
                           (default = 1) */
      iVar1 = GET_I2CPortChange_glob();
      if (iVar1 != 0) {system("rmmod gpioi2c"); usleep(50000);Regctl_main_function();system("insmod /npc/patch/gpioi2c2.ko");} return;}
    
    void Regctl_main_function(void)
    {
      uint uVar1; uVar1 = Regctl_set_ioctl5(0x90c00000,0x54);
      Regctl_set_2_dwWriteRegVal(-0x6f400000,0x54,uVar1 & 0xfffc3fff | 0x28000);
      return;
    }
    
    int Regctl_set_ioctl5(ulong param_1,ulong param_2)
    
    {
      int __fd;  int iVar1;  ulong local_20;  ulong uStack28;  int *local_10;  int iStack12;
    
      local_10 = &iStack12;
      local_20 = param_1;
      uStack28 = param_2;
      __fd = pl_open_file("/dev/regctl",2,"dwReadRegVal",0x1b);
      if (__fd == 0) {
        printf("%s: error:  open dev/misc/regctl  fail \n","dwReadRegVal");
      }
      else {
        iVar1 = ioctl(__fd,5,&local_20);
        if (iVar1 == -1) {
          printf("%s: error:  regctl ioctl fail \n","dwReadRegVal");
          pl_close_file(__fd,"dwReadRegVal",0x26);
          __fd = 0;
        }
        else {
          pl_close_file(__fd,"dwReadRegVal",0x2a);
          __fd = *local_10;
        }
      }
      return __fd;
    }
    int Regctl_set_2_dwWriteRegVal(int param_1,int param_2,int param_3)
    
    {
      int __fd; int iVar1; int local_24 [2];int local_1c; int local_18;int *local_c; local_c = local_24; local_24[0] = param_3;  local_1c = param_1; local_18 = param_2;
      __fd = pl_open_file("/dev/regctl",2,"dwWriteRegVal",0x3c);
      if (__fd == 0) {
        printf("%s: error:  open dev/misc/regctl  fail \n","dwWriteRegVal");
      }
      else {
        iVar1 = ioctl(__fd,1,&local_1c);
        if (iVar1 == -1) {
          printf("%s: error:  regctl ioctl fail \n","dwWriteRegVal");
          pl_close_file(__fd,"dwWriteRegVal",0x49);
          __fd = 0;
        }
        else {
          pl_close_file(__fd,"dwWriteRegVal",0x4d);
          __fd = 1;
        }
      }
      return __fd;
    }

    Помогите разреверсить код из прошивки камеры Rubetek RV-3414 (основана на SoC GrainMedia GM8136). Это код из Ghidra. Интересует функция Regctl_main_function.

    dump из strace:
    open("/dev/regctl", O_RDWR) = 3 <0.000901>
    ioctl(3, _IOC(_IOC_NONE, 0, 0x5, 0), 0x7eee2c18) = 0 <0.000308>
    close(3) = 0 <0.000256>
    open("/dev/regctl", O_RDWR) = 3 <0.000422>
    ioctl(3, FIBMAP, 0x7eee2c1c) = 0 <0.000105>
    close(3)

    local_20 и uStack28 - это struct?

    a0a1, 10 Декабря 2019

    Комментарии (55)
  2. Си / Говнокод #26067

    +2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    /* ../COBYLA2/cobyla2.f -- translated by f2c (version 20100827) */
    ...
    /* Subroutine */ int cobyla_(integer *n, integer *m, doublereal *x, 
    	doublereal *rhobeg, doublereal *rhoend, integer *iprint, integer *
    	maxfun, doublereal *w, integer *iact)
    {
        static integer ia, idx, mpp, icon, isim, isigb, idatm, iveta, isimi, 
    	    ivsig, iwork;
        extern /* Subroutine */ int cobylb_(integer *, integer *, integer *, 
    	    doublereal *, doublereal *, doublereal *, integer *, integer *, 
    	    doublereal *, doublereal *, doublereal *, doublereal *, 
    	    doublereal *, doublereal *, doublereal *, doublereal *, 
    	    doublereal *, doublereal *, integer *);
        /* Parameter adjustments */
        --iact;
        --w;
        --x;
    
        /* Function Body */
        mpp = *m + 2;
        icon = 1;
        isim = icon + mpp;
        isimi = isim + *n * *n + *n;
        idatm = isimi + *n * *n;
        ia = idatm + *n * mpp + mpp;
        ivsig = ia + *m * *n + *n;
        iveta = ivsig + *n;
        isigb = iveta + *n;
        idx = isigb + *n;
        iwork = idx + *n;
        cobylb_(n, m, &mpp, &x[1], rhobeg, rhoend, iprint, maxfun, &w[icon], &w[
    	    isim], &w[isimi], &w[idatm], &w[ia], &w[ivsig], &w[iveta], &w[
    	    isigb], &w[idx], &w[iwork], &iact[1]);
        return 0;
    } /* cobyla_ */
    ...
    /* Subroutine */ int cobylb_(integer *n, integer *m, integer *mpp, doublereal 
    	*x, doublereal *rhobeg, doublereal *rhoend, integer *iprint, integer *
    	maxfun, doublereal *con, doublereal *sim, doublereal *simi, 
    	doublereal *datmat, doublereal *a, doublereal *vsig, doublereal *veta,
    	 doublereal *sigbar, doublereal *dx, doublereal *w, integer *iact)
    {
        /* Format strings */
        static char fmt_10[] = "(/3x,\002The initial value of RHO is\002,1pe13.6"
    	    ",2x,\002and PARMU is set to zero.\002)";
        static char fmt_50[] = "(/3x,\002Return from subroutine COBYLA because t"
    	    "he \002,\002MAXFUN limit has been reached.\002)";
        static char fmt_70[] = "(/3x,\002NFVALS =\002,i5,3x,\002F =\002,1pe13.6,"
    	    "4x,\002MAXCV =\002,1pe13.6/3x,\002X =\002,1pe13.6,1p4e15.6)";
        static char fmt_80[] = "(1pe19.6,1p4e15.6)";
        static char fmt_210[] = "(/3x,\002Return from subroutine COBYLA because"
    	    " \002,\002rounding errors are becoming damaging.\002)";
        static char fmt_410[] = "(/3x,\002Increase in PARMU to\002,1pe13.6)";
        static char fmt_580[] = "(/3x,\002Reduction in RHO to\002,1pe13.6,\002  "
    	    "and PARMU =\002,1pe13.6)";
        static char fmt_590[] = "(/3x,\002Normal return from subroutine COBYL"
    	    "A\002)";
    
        /* System generated locals */
        integer sim_dim1, sim_offset, simi_dim1, simi_offset, datmat_dim1, 
    	    datmat_offset, a_dim1, a_offset, i__1, i__2, i__3;
        doublereal d__1, d__2;
    
        /* Builtin functions */
        integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
        double sqrt(doublereal);
    
        /* Local variables */
        static doublereal f;
        static integer i__, j, k, l, mp, np, iz;
        static doublereal phi, rho, sum, beta, cmin, cmax;
        static integer ivmc;
        static doublereal weta;
        static integer ivmd;
        static doublereal temp, wsig, gamma;
        static integer iflag;
        static doublereal alpha, delta, denom, tempa, barmu;
        static integer nbest, ifull, iptem, jdrop;
        static doublereal ratio, vmold, parmu, error, vmnew;
        extern /* Subroutine */ int calcfc_(integer *, integer *, doublereal *, 
    	    doublereal *, doublereal *);
        static integer ibrnch;
        static doublereal edgmax, pareta, prerec, phimin, parsig;
        static integer isdirn, nfvals, izdota;
        static doublereal cvmaxm, dxsign, prerem;
        static integer iptemp;
        static doublereal resmax, cvmaxp;
        static integer idxnew;
        static doublereal resnew, trured;
        extern /* Subroutine */ int trstlp_(integer *, integer *, doublereal *, 
    	    doublereal *, doublereal *, doublereal *, integer *, integer *, 
    	    doublereal *, doublereal *, doublereal *, doublereal *, 
    	    doublereal *, doublereal *);
    
        /* Fortran I/O blocks */
        static cilist io___22 = { 0, 6, 0, fmt_10, 0 };
        static cilist io___29 = { 0, 6, 0, fmt_50, 0 };
        static cilist io___33 = { 0, 6, 0, fmt_70, 0 };
        static cilist io___34 = { 0, 6, 0, fmt_80, 0 };
        static cilist io___39 = { 0, 6, 0, fmt_210, 0 };

    Найдено в зависимостях «SlangTNG». Библиотека «COBYLA», автоматически переведённая с «Фортрана».

    /* This subroutine minimizes an objective function F(X) subject to M */
    /* inequality constraints on X, where X is a vector of variables that has */
    /* N components. The algorithm employs linear approximations to the */
    /* objective and constraint functions, the approximations being formed by */
    /* linear interpolation at N+1 points in the space of the variables. */

    https://tng.tuxfamily.org/index.php?title=Main_Page

    XYPO3BO3, 05 Декабря 2019

    Комментарии (10)
  3. Си / Говнокод #26034

    +2

    1. 1
    2. 2
    Comparing structs with, let's say, memcmp, does not work,
     as you end up comparing the "unspecified" padding bytes as well — you must compare member-by-member.

    While writing this post, the author observed that some verions of GCC (experimentally, >= 4.7, < 8.0) do not zero padding if an empty intializer list is passed, under certain a certain code pattern; if an entire struct (i.e. sizeof(STRUCTNAME)) is subsequently memcpy'd after assigment of its members, and this intermediate buffer is what is used by the code going forward. This appears to be based on how optimization passes interact with GCC's built-in memcpy, since passing -fno-builtin-memcpy returns the behavior to the expected.
    https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2019/october/padding-the-struct-how-a-compiler-optimization-can-disclose-stack-memory/

    3.14159265, 18 Ноября 2019

    Комментарии (179)
  4. Си / Говнокод #26027

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    #include <stdio.h>
    #include <inttypes.h>
    #include <string.h>
    
    // endian dependend
    #define PUT3(a,b,c) (((uint64_t)a<<8*0) | ((uint64_t)b<<8*1) | ((uint64_t)c<<8*2))
    
    void testswitch(uint64_t x)
    {
      switch (x) 
      { 
        case PUT3('a','b','c'): printf("abc\n"); 
          break; 
        case PUT3('d','e','f'): printf("def\n"); 
          break; 
        case PUT3('g','h','i'): printf("ghi\n"); 
          break; 
        default: printf("Choice other than abc, def and ghi\n"); 
          break;   
       }
    }
    
    int main() 
    { 
       uint64_t x = 0;
       char a[] = "abc";
       memcpy(&x, a, sizeof(a)-1);
       testswitch(x);
    
       char b[] = "def";
       memcpy(&x, b, sizeof(a)-1);
       testswitch(x);
    
       char c[] = "ghi";
       memcpy(&x, c, sizeof(a)-1);
       testswitch(x);
       return 0; 
    }

    switch для строк!

    Перечитывал несвежие говнокоды, где я выкладывал творчество вконтактоолимпиадников https://govnokod.ru/23170#comment388376

    j123123, 12 Ноября 2019

    Комментарии (198)
  5. Си / Говнокод #26006

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    // https://gcc.gnu.org/onlinedocs/cpp/Directives-Within-Macro-Arguments.html
    
    // Occasionally it is convenient to use preprocessor directives within the arguments
    // of a macro. The C and C++ standards declare that behavior in these cases is
    // undefined. GNU CPP processes arbitrary directives within macro arguments in
    // exactly the same way as it would have processed the directive were the
    // function-like macro invocation not present. 
    
    // If, within a macro invocation, that macro is redefined, then the new definition
    // takes effect in time for argument pre-expansion, but the original definition is
    // still used for argument replacement. Here is a pathological example:
    
    #define f(x) x x
    f (1
    #undef f
    #define f 2
    f)
    
    // which expands to
    
    // 1 2 1 2

    Ну и хуйня.

    j123123, 31 Октября 2019

    Комментарии (6)
  6. Си / Говнокод #25997

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    // https://godbolt.org/z/dMT7v3
    
    unsigned div_eq(unsigned a, unsigned b)
    {
      ALWAYS_TRUE(a == b);
      return a/b;
    }
    
    unsigned div(unsigned a, unsigned b)
    {
      return a/b;
    }
    
    
    int test_array(unsigned char a[10])
    {
      for (int i = 1; i < 10; i++)
      {
        ALWAYS_TRUE(a[i-1] <= a[i]);
      }
      return a[0] <= a[2];
    }

    Refinement type
    Можно этой хуйней ассерты позаменять попробовать, и компилятор возможно что-то сможет за счет этого соптимизировать

    j123123, 26 Октября 2019

    Комментарии (6)
  7. Си / Говнокод #25977

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    /* --- PRINTF_BYTE_TO_BINARY macro's --- */
    #define PRINTF_BINARY_PATTERN_INT8 "%c%c%c%c%c%c%c%c"
    #define PRINTF_BYTE_TO_BINARY_INT8(i)    \
        (((i) & 0x80ll) ? '1' : '0'), \
        (((i) & 0x40ll) ? '1' : '0'), \
        (((i) & 0x20ll) ? '1' : '0'), \
        (((i) & 0x10ll) ? '1' : '0'), \
        (((i) & 0x08ll) ? '1' : '0'), \
        (((i) & 0x04ll) ? '1' : '0'), \
        (((i) & 0x02ll) ? '1' : '0'), \
        (((i) & 0x01ll) ? '1' : '0')
    
    #define PRINTF_BINARY_PATTERN_INT16 \
        PRINTF_BINARY_PATTERN_INT8              PRINTF_BINARY_PATTERN_INT8
    #define PRINTF_BYTE_TO_BINARY_INT16(i) \
        PRINTF_BYTE_TO_BINARY_INT8((i) >> 8),   PRINTF_BYTE_TO_BINARY_INT8(i)
    #define PRINTF_BINARY_PATTERN_INT32 \
        PRINTF_BINARY_PATTERN_INT16             PRINTF_BINARY_PATTERN_INT16
    #define PRINTF_BYTE_TO_BINARY_INT32(i) \
        PRINTF_BYTE_TO_BINARY_INT16((i) >> 16), PRINTF_BYTE_TO_BINARY_INT16(i)
    #define PRINTF_BINARY_PATTERN_INT64    \
        PRINTF_BINARY_PATTERN_INT32             PRINTF_BINARY_PATTERN_INT32
    #define PRINTF_BYTE_TO_BINARY_INT64(i) \
        PRINTF_BYTE_TO_BINARY_INT32((i) >> 32), PRINTF_BYTE_TO_BINARY_INT32(i)
    /* --- end macros --- */
    
    #include <stdio.h>
    int main() {
        long long int flag = 1648646756487983144ll;
        printf("My Flag "
               PRINTF_BINARY_PATTERN_INT64 "\n",
               PRINTF_BYTE_TO_BINARY_INT64(flag));
        return 0;
    }

    govnokod3r, 18 Октября 2019

    Комментарии (68)
  8. Си / Говнокод #25929

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    // https://jaycarlson.net/2019/09/06/whats-up-with-these-3-cent-microcontrollers/
    // The C code I used for those original MCU tests looked something like this:
    
    volatile int16_t in[25];
    volatile int16_t out[25];
    const int16_t a0 = 16384;
    const int16_t a1 = -32768;
    const int16_t a2 = 16384;
    const int16_t b1 = -25576;
    const int16_t b2 = 10508;
    int16_t z1, z2;
    int16_t outTemp;
    int16_t inTemp;
    void main()
    {
      while(1) {
        _pa = 2;
        for(i=0;i<25;i++)
        {
          inTemp = in[i];
          outTemp = inTemp * a0 + z1;
          z1 = inTemp * a1 + z2 - b1 * outTemp;
          z2 = inTemp * a2 - b2 * outTemp;
          out[i] = outTemp;
        }
        _pa = 0;
      }
    }
    
    // The Padauk code looks like this:
    
    WORD in[11];
    WORD out[11];
    WORD z1, z2;
    WORD pOut, pIn; // these are pointers, but aren't typed as such
    int i;
    void  FPPA0 (void)
    {
      .ADJUST_IC  SYSCLK=IHRC/2    //  SYSCLK=IHRC/2
      PAC.6 = 1; // make PA6 an output
      while(1) {
        PA.6 = 1;
        pOut = out;
        pIn = in;
        i = 0;
        do {
          *pOut = (*pIn << 14) + z1;
          z1 = -(*pIn << 15) + z2
            + (*pOut << 14)
            + (*pOut << 13)
            + (*pOut << 9)
            + (*pOut << 8)
            + (*pOut << 7)
            + (*pOut << 6)
            + (*pOut << 5)
            + (*pOut << 3);
          z2 = (*pIn << 14)
            - (*pOut << 13)
            - (*pOut << 11)
            - (*pOut << 8)
            - (*pOut << 3)
            - (*pOut << 2);
          i++;
          pOut++;
          pIn++;
        } while(i < 11);
        PA.6 = 0;
      }
    }

    > As for the filter function itself, you’ll see that all the multiplies have been replaced with shift-adds. The Padauk part does not recognize the * operator for multiplication; trying to use it to multiply two variables together results in a syntax error. No, I’m not joking.

    j123123, 11 Октября 2019

    Комментарии (58)
  9. Си / Говнокод #25910

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    #include <stdio.h>
     
    #define BIG_ENDIAN 0
    #define LITTLE_ENDIAN 1
     
    int TestByteOrder() {
            short int word = 0x0001;
            char *b = (char *)&word;
            return (b[0] ? LITTLE_ENDIAN : BIG_ENDIAN);
    }
     
    int main() {
            int r = TestByteOrder();
            printf("%s\n", r == LITTLE_ENDIAN ? "Little Endian" : "Big Endian");
            return r;
    }

    Игрушечная программа, проверяет порядковость байтов процессора ("endianness"); хотя изначально понятно что WinNT всегда "от младшего к старшему".
    Она безупречно правильная, но меня не устраивает ее размер. Ведь всё можно было бы уместить в две строки. (А еще лучше перевести на АСМ). Прошу знатоков поупражняться.

    tmayh, 06 Октября 2019

    Комментарии (41)
  10. Си / Говнокод #25899

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    #include <ncurses.h>
    
    #if defined(_WIN32) || defined(_WIN64) 
        #include <windows.h>
        #define msleep(msec) Sleep(msec)
    #else
        #include <unistd.h>
        #define msleep(msec) usleep(msec*1000)
    #endif
    
    int main()
    {
        initscr();
    
        char str[100];
        addstr("Enter string: ");
        getstr(str); //Считваем строку
        curs_set(0); //"Убиваем" курсор, чтобы не мешался
        while ( true )
        {
        //Перемещаем х-координату как можно дальше вправо, и будем уменьшать её, пока она != 0
            for ( unsigned x = getmaxx(stdscr); x; x-- ) 
            {
                clear();
                mvaddstr(getmaxy(stdscr) / 2, x, str);
                refresh();
                msleep(200);
            }
        }
    
        endwin();
        return 0;
    }

    https://code-live.ru/post/ncurses-input-output/#getstr-
    Сколько хуйни вы можете найти в этом примере?

    j123123, 04 Октября 2019

    Комментарии (96)