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

    +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
    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
    #include <stddef.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    char *concat(char *a, char *b)
    {
      char *ptr = malloc(strlen(a)+strlen(b)+6);
      if (ptr == NULL)
      {
        fprintf(stderr, "da ty ohuel!\n");
        exit(-1);
      }
      sprintf(ptr, "(%s)*(%s)", a, b);
      return ptr;
    }
    
    char *govno[255] = {"a"};
    
    void printfshit(const size_t pow, const char *mul_stuff)
    {
      printf("double pow_%zu(double a) {return %s;}\n\n", pow, mul_stuff);
    }
    
    void genshit(void)
    {
      //printfshit(0,"1");
      size_t end_ind = 1;
      size_t prev_stop = 0;
      size_t end_ind_tmp = 1;
      while (end_ind < 255)
      {
        for (size_t ind1 = 0; ind1 < end_ind_tmp; ind1++)
        {
          for (size_t ind2 = prev_stop; ind2 < end_ind_tmp; ind2++)
          {
            if ( 
                 ((ind1+1) + (ind2+1) < 256) &&
                 (govno[(ind1+1) + (ind2+1)-1] == NULL)
               )
            {
              govno[(ind1+1) + (ind2+1)-1] = concat(govno[ind1], govno[ind2]);
              end_ind++;
            }
          }
        }
        prev_stop = end_ind_tmp;
        end_ind_tmp = end_ind;
      }
      printfshit(1,govno[0]);
      for (size_t i = 1; i < 255; i++ )
      {
        printfshit(i+1,govno[i]);
        free(govno[i]);
      }
    }
    
    int main(void)
    {
      genshit();
      return 0;
    }

    Кодогенератор, написаный специально для Antervis
    http://govnokod.ru/23227#comment388895

    j123123, 08 Августа 2017

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

    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
    #include <stdio.h>
    #include <string.h>
    #include <http_fetcher.h>
    #include <stdlib.h>
    
    int main(int argc, char *argv[])
    {
      if(argc != 2) { printf("Using: %s [url]\n", argv[0]); return 1; }
      http_setTimeout(15);
      if( http_setUserAgent("Mozilla/5.0 (Linux; Android 7.0; Pixel C Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Safari/537.36") == -1)
        http_perror("setUserAgent");
      http_setRedirects(15);
      http_setReferer("http://no-site.ru/");
      
      char *file_name = "";
      if( http_parseFilename(argv[1], &file_name) == -1)
        { http_perror("parseFilename"); return 1; }
      
      printf("Download file: %s\n", file_name);
      
      char *buff = malloc(5000);
      
      if( http_fetch(argv[1], &buff) == -1)
        { http_perror("fetch"); return 1; }
        
      printf("Write on file..\n");
      
      FILE *f = fopen(file_name, "a");
      fprintf(f, "%s", buff);
      fclose(f);
      printf("Successfully written to file \"%s\"\n", file_name);
      
      return 0;
    }

    Блять писал программу а она нихуя не контачит, ёбанная библиотека https не поддерживает!
    Не используйте эту говно библиотеку

    Bro-C, 03 Августа 2017

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

    +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
    #define UM8(CONST_FLOAT,CHISLO_INT) \
                     ((CONST_FLOAT+1.0/16)<(1.0/8))?((CHISLO_INT*0)>>3):\
                      (((CONST_FLOAT+1.0/16)<(2.0/8))?((CHISLO_INT*1)>>3):\
                        (((CONST_FLOAT+1.0/16)<(3.0/8))?((CHISLO_INT*2)>>3):\
                          (((CONST_FLOAT+1.0/16)<(4.0/8))?((CHISLO_INT*3)>>3):\
                            (((CONST_FLOAT+1.0/16)<(5.0/8))?((CHISLO_INT*4)>>3):\
                              (((CONST_FLOAT+1.0/16)<(6.0/8))?((CHISLO_INT*5)>>3):\
                                (((CONST_FLOAT+1.0/16)<(7.0/8))?((CHISLO_INT*6)>>3):\
                                  (((CONST_FLOAT+1.0/16)<(8.0/8))?((CHISLO_INT*7)>>3):\
                                    (CHISLO_INT)\
                                   )\
                                 )\
                               )\
                             )\
                           )\
                         )\
                       )

    https://habrahabr.ru/post/334758/

    inho, 02 Августа 2017

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

    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
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <unistd.h>
    
    int checkFile(char *s)
    {
    	return ( open(s, O_RDONLY, 0) == -1) ? 0 : 1;
    }
    
    int main(int argc, char *argv[])
    {
    	if(argc != 2) { printf("Тут один аргумент важен хуле\n"); return 1; }
    	if(checkFile(argv[1]))
    	{
    		int fd = open(argv[1], O_RDONLY, 0);
    		char buffer[1024];
    		read(fd, &buffer, sizeof(buffer));
    		printf("%s\n", buffer);
    		if( close(fd) == -1) perror("close");
    	}
    	else
    		printf("Файл не существует\n");
    	return 0;
    }

    Моя альтернатива программе cat, отсасывай cat ябучий!!

    Bro-C, 02 Августа 2017

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

    −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
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    BYTE1 *GetLanguageCodeString( BYTE1	upper, BYTE1 lower , BYTE1  *lang_idx )
    {
    	int index = 0;
    	
    	switch(upper){
    		case 'a' :
    			switch(lower){
    				case 'a' : index = 0; break;
    				case 'b' : index = 1; break;
    				case 'f' : index = 2; break;
    				case 'm': index = 3; break;
    				case 'r': index = 4; break;
    				case 's': index = 5; break;
    				case 'y': index = 6; break;
    				case 'z': index = 7; break;
    				default: break;
    			}
    			break;
    		case 'b' :
    			switch(lower){
    				case 'a' : index = 8; break;
    				case 'e' : index = 9; break;
    				case 'g' : index = 10; break;
    				case 'h': index = 11; break;
    				case 'i': index = 12; break;
    				case 'n': index = 13; break;
    				case 'o': index = 14; break;
    				case 's': index = 136; break;	/* Added in SEIN 2004.04.01 KTJ */
    				default: break;
    			}
    			break;
    		case 'c' :
    			switch(lower){
    				case 'a' : index = 15; break;
    				case 'o' : index = 16; break;
    				case 's' : index = 17; break;
    				case 'y': index = 18; break;
    				default: break;
    			}
    			break;
    		case 'd' :
    			switch(lower){
    				case 'a' : index = 19; break;
    				case 'e' : index = 20; break;
    				case 'z' : index = 21; break;
    				default: break;
    			}
    			break;			
    		case 'e' :
    			switch(lower){
    				case 'l' : index = 22; break;
    				case 'n' : index = 23; break;
    				case 'o' : index = 24; break;
    				case 's': index = 25; break;
    				case 't': index = 26; break;
    				case 'u': index = 27; break;
    				break;
    			}
    			break;
    		case 'f' :
    			switch(lower){
    				case 'a' : index = 28; break;
    				case 'i' : index = 29; break;
    				case 'j' : index = 30; break;
    				case 'o': index = 31; break;
    				case 'r': index = 32; break;
    				case 'y': index = 33; break;
    				default: break;
    			}
    			break;
    		case 'g' :
    			switch(lower){
    				case 'a' : index = 34; break;
    				case 'd' : index = 35; break;
    				case 'l' : index = 36; break;
    				case 'n': index = 37; break;
    				case 'u': index = 38; break;
    				default: break;
    			}
    			break;
    		case 'h' :
    			switch(lower){
    				case 'a' : index = 39; break;
    				case 'e' : index = 40; break;
    				case 'i' : index = 41; break;
    				case 'r': index = 42; break;
    				case 'u': index = 43; break;
    				case 'y': index = 44; break;				
    				default: break;
    			}
    			break;			
    		case 'i' :
    			switch(lower){
    				case 'a' : index = 45; break;
    				case 'd' : index = 46; break;
    				case 'k': index = 47; break;
    				case 'n': index = 48; break;				
    				case 's': index = 49; break;
    				case 't': index = 50; break;

    питушня на switch для распознавания какой-то фигни с буквами

    j123123, 30 Июля 2017

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

    +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
    #define SPLICE(a,b) a##b
    #define LL(a,b) SPLICE(a,b)
    #define M(name) LL(NS,name)
    
    
    #define NS ns1_
    
    void M(somefunction)(){
    }
    
    #undef NS
    
    
    #define NS ns2_
    
    void M(somefunction)(){
    }
    
    #undef NS
    
    
    #define NS ns3_
    
    void M(somefunction)(){
    }
    
    #undef NS

    неймспейсы в Си на препроцессоре

    j123123, 30 Июля 2017

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

    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
    #include <stdio.h>
    
    typedef int (*FUNC)();
    
    FUNC test (int a, int b){
        int ret(){
            return a + b;
        }
    
        return ret;
    }
    
    int main(){
        printf("%i\n", test(40, 2)());
        return 0;
    }
    
    
    /* Тоже самое на JS */
    function test(a, b){
        function ret(){
            return a + b;
        }
    
        return ret;
    }
    
    alert(test(40, 2)());
    
    
    # Тоже самое на Python
    def test(a, b):
        def ret():
            return a + b
    
        return ret
    
    print test(40, 2)()

    Странно работает компилятор, версия: gcc version 4.7.2

    $ gcc 1.c && ./a.out
    42
    $ gcc -O3 1.c && ./a.out
    Segmentation fault

    j1392184, 28 Июля 2017

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

    +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
    #include <stdio.h>
    #include <stdlib.h>
    #include <inttypes.h>
    #include <string.h>
    #include <stddef.h>
    
    #define INITARR(arr,...)                                                                                      \
    do                                                                                                            \
    {                                                                                                             \
      typedef struct {typeof(*arr) __tmp_arr[sizeof( (typeof(*arr)[]){__VA_ARGS__} ) / sizeof(*arr)];} __tmp_str; \
      *((__tmp_str *)arr) = (__tmp_str){{__VA_ARGS__}};                                                           \
    } while(0)
    
    
    
    int main(void)
    {
      uint8_t *test;
      test = malloc (sizeof (uint8_t[10]));
      INITARR(test,1,2,3,4,5,6,7,8,9,10);  
      for (size_t i = 0; i < 10; i++)
      {
        printf("%" PRIu8 ", ", test[i]);
      }
      return 0;
    }

    Для удобной инициализации массивов в хипе

    j123123, 23 Июля 2017

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    Сишечные строки для printf-подобной параши из прошивки ESP8266 (для веб-сервера):
    ....
    method="POST">Login: <INPUT size=10 NAME='login' value="%s"> Password: <INPUT size=10 NAME='pass' value="%s"></td></tr><br><INPUT TYPE='checkbox' NAME='fls'%s> Full Security.
    <input type="hidden" name="st" value=5><br>%s
    <hr><b>Config module:</b><br><div class="spH2"></div><form method="GET">Host name: <INPUT size=12 NAME='hn' value="%s">
    <input type="hidden" name="st" value=7><br>%s
    <hr><b>WiFi options:</b><br><div class="spH2"></div><form method="GET"><input type="radio" name="sm" value="0" %s>Station mode.<input type="radio" name="sm" value="7" %s>AP mode.<br>AP name: <input size=20 name="stname" value="%s"> <br>AP pass: <input size=20 type='password' name="stpass" value="%s"><br>
    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>%s</title><meta http-equiv="REFRESH" content="60"><meta name="viewport" content="width=480" /><meta name="mobile-web-app-capable" content="yes" /><link rel="stylesheet" href="main.css"></head><body><br><div style="text-align: center"><div style="display: inline-block"><div class="name fll">%s<div class="www">MaksMS <a href="http://wifi-iot.com" target="_blank">wifi-iot.com</a><br>

    ... и никакого пхп
    http://wifi-iot.com/ вот тут можно генерировать такие говнопрошивки

    j123123, 23 Июля 2017

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

    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
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <errno.h>
    #include <stdlib.h>
    
    int main(int argc, char *argv[])
    {
    	int sock = socket(AF_LOCAL, SOCK_STREAM, 0);
    	if(sock == -1)
    	   printf("Error\n");
    	
    	int enable=1;
    	int ret = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&enable, sizeof(enable));
    	if(ret==-1)
    	    perror("Error");
        else
            printf("Sucess\n");
    	
    	int optval;
    	int optlen;
    	ret = getsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &optval, &optlen);
    	if(ret==0)
    	{
           if(optval != 0)
               printf("SO_REUSEADDR enabled\n");
           else
               printf("SO_REUSEADDR disabled\n");
        }
    	else
    	{
    		if(errno==EBADF)
                printf("The argument sockfd is not a valid file descriptor.\n");
    		else if(errno==EFAULT)
    		    printf("The address pointed to by optval is not in a valid part of.the process address space.  For getsockopt(), this error may also be returned if optlen is not in a valid part of the process address space.\n");
    		else if(errno==EINVAL)
    		    printf("optlen invalid in setsockopt().  In some cases this error.can also occur for an invalid value in optval (e.g., for the IP_ADD_MEMBERSHIP option described in ip(7)).\n");
    		else if(errno==ENOPROTOOPT)
    		    printf("The option is unknown at the level indicated.\n");
    		else if(errno==ENOTSOCK)
    		    printf("The file descriptor sockfd does not refer to a socket.\n");
    	}
    	
    	char *name;
    	name="ccmni0";
    	if( (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, name, 6)) < 0)
    	   printf("SO_BINDTODEVICE error\n");
    	char *arr[7];
    	int ss = 7;
    	ret = getsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, &arr, &ss);
    	if(ret==0)
    	{
    		printf("SO_BINDTODEVICE: %s\n", arr);
    	}
    	else
    	{
    		if(errno==EBADF)
                printf("The argument sockfd is not a valid file descriptor.\n");
    		else if(errno==EFAULT)
    		    printf("The address pointed to by optval is not in a valid part of.the process address space.  For getsockopt(), this error may also be returned if optlen is not in a valid part of the process address space.\n");
    		else if(errno==EINVAL)
    		    printf("optlen invalid in setsockopt().  In some cases this error.can also occur for an invalid value in optval (e.g., for the IP_ADD_MEMBERSHIP option described in ip(7)).\n");
    		else if(errno==ENOPROTOOPT)
    		    printf("The option is unknown at the level indicated.\n");
    		else if(errno==ENOTSOCK)
    		    printf("The file descriptor sockfd does not refer to a socket.\n");
    	}
    }

    Посру малёха!

    botC, 21 Июля 2017

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