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

    +127

    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
    UINT32 GetHostName(char *hostName, UINT32 hostNameBufSize)
    {
            if (hostName == NULL ){
                    OSALTRACE(OSAL_ERROR, ("Error: Input parameter hostName(null)."));
                    return -1;
            }
    
            FILE *fp = NULL;
            static char buffer[512];
            char tag[64];
    
            // hope this size will be OK for one line to read from the fileOB
            char line[1000];
            char *linep=line;
    
            int buffSize = sizeof(buffer);
    
            int found = 0;
    
    
            fp = fopen("/etc/resolv.conf", "r");
    
            if ( fp == NULL)
            {
    
                    OSALTRACE(OSAL_ERROR, ("failed to open resolver config file."));
                    return -1;
            }
    
            while ( ((*linep=getc(fp)) != EOF) && !found )
            {
                    if (*linep++ == '\n')
                    {
                            *linep = '\0';
                            sscanf(line, "%s %s", tag, buffer);
                            if (tag[0] && (!strcmp(tag, "search") || !strcmp(tag, "domain") ) ) {
                                    found = 1;
                                    break;
                            }
                            linep = line;
                    }
            }
    
            fclose(fp);
    
            if ( found )
            {
                    strcpy(hostName,buffer);
                    OSALTRACE(OSAL_DEBUG, ("DHCP domain is  %s.", buffer));
            }
            else
            {
                    OSALTRACE(OSAL_ERROR, ("Could not find dhcp domain in resolv.conf."));
                    return -1;
            }
    
            return !found;
    }

    Intel WiMAX Network Service, не какая-то пионерская поделка...

    raorn, 13 Сентября 2010

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

    +144

    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
    if ( found )
            {
                    strcpy(hostName,buffer);
                    OSALTRACE(OSAL_DEBUG, ("DHCP domain is  %s.", buffer));
            }
            else
            {
                    OSALTRACE(OSAL_ERROR, ("Could not find dhcp domain in resolv.conf."));
                    return -1;
            }
    
            return !found;
    }

    Intel WiMAX Network Service, не какая-то пионерская поделка...

    raorn, 13 Сентября 2010

    Комментарии (1)
  3. Куча / Говнокод #4234

    +120

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    define ('DRINK_FROM_TIME',	22118400-1);	// 256*24*60*60
    	define ('DRINK_TO_TIME',	22204800); 	// 257*24*60*60
    	
    	$time=time();
    	$time=$time - mktime(0, 0, 0, 1, 0, date("Y", $time) );
    	
    	$desktop -> displayShedule ( ( $time > DRINK_FROM_TIME && $time < DRINK_TO_TIME )?  "C днём программиста!.." : "{SCHEDULE_FOR_TODAY}" );

    --- no comments...

    istem, 12 Сентября 2010

    Комментарии (8)
  4. Куча / Говнокод #4233

    +139

    1. 1
    <input type="hidden" class="form" TYPE="checkbox" id="xxx" value="0"  onclick="if(this.value==1) {this.value} else {this.value=1}">

    И как они хотят, чтобы на скрытый элемент нажимали?)

    Nerd, 12 Сентября 2010

    Комментарии (11)
  5. Pascal / Говнокод #4232

    +105

    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
    implementation
    uses Unit1,Unit2,Unit3,Unit4,Unit5,Unit6,Unit7,Unit8;
    {$R *.dfm}
    var
    k,Zst,zk,Vm12,Vm23,Vm34,Vm45,Vm56,Z2pr,Z3pr,Z4pr,Z5pr,Z6pr,Lm12,Lm23,Lm34,Lm45,Lm56,Vk,Vst,Q,q11,q2ob,q3ob,q4ob,q5ob,q6ob,
    Sst,P1st,P2st,p0k,p12k,p23k,p34k,p45k,p56k,L0,Dk,Dst,H,Hst: real;
    J0,j, i: integer;
    const a=1.1; g=9.81; Y=0.03; x1=605; Y1=48; X2=772; Y2=104;
    x3=627; Y3=107; X4=646; Y4=379;
    x5=X3; Y5=194; X6=576; Y6=200;
    x7=582; Y7=193; X8=576;
    x9=X3; Y9=285; X10=526; Y10=291;
    x11=532; Y11=284; X12=X10;
    x13=650; Y13=380; X14=395; Y14=399;
    x15=479; Y15=377; X16=473;
    x17=394; Y17=Y13; X18=314; Y18=Y14;
    x19=398; Y19=Y15; X20=392;
    x21=314; Y21=Y13; X22=233; Y22=Y14;
    x23=317; Y23=Y15; X24=311;
    x25=233; Y25=Y13; X26=152; Y26=Y14;
    x27=235; Y27=Y15; X28=229;
    x29=152; Y29=Y13; X30=70; Y30=Y14;
    x31=154 ; Y31=Y15; X32=148;
    X33=70;Y33=Y13;X34=3;Y34=Y14;
    X35=72;Y35=Y15;X36=66;
    procedure TForm9.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
    Form9.visible:=false;
    end;

    куча Паскаля

    bugmenot, 12 Сентября 2010

    Комментарии (109)
  6. PHP / Говнокод #4231

    +144

    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
    
    <?xml version='1.0' encoding='utf-8'?>
    <rss version="2.0">
       <channel>
          <title>behistory - живая история</title>
           <link>http://behistory.ru/</link>
           <lastBuildDate>Sun, 12 Sep 2010 13:17:59 +0300</lastBuildDate>
           <language>ru</language>
    
                  <item>
                    <title>О роли балтского субстрата в истории славянских племен верхнего Поднепровья</title>
                     <link>ololo</link>
                     <description>&lt;html&gt;
    &lt;p style=&quot;text-align: justify;&quot;&gt;В статье большое внимание уделяется роли балтов в истории славянских племен верхнего Днепра. Автор проводит тщательный анализ основных тезисов В.В. Седова, которые сводятся в своей основе к следующему - балтский субстрат был основным при образовании белорусской народности, т. е. при образовании трех летописных племен: кривичей, дреговичей и радимичей. В подтверждение этого он приводит целый ряд лингвистических, этнографических и археологических данных. Автор не согласна с данной позицией и оспаривает выводы В.В. Седова.&lt;/p&gt;
    &lt;/html&gt;</description>
    
                     <pubDate>2009-07-27 03:44:11</pubDate>
                  </item>
                  <item>

    aslikeyou, 12 Сентября 2010

    Комментарии (13)
  7. Java / Говнокод #4230

    +78

    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
    public class ServiceRunner implements Runnable {
        
        Thread thread = null;
        ServiceUI service;
        public ServiceRunner(ServiceUI service) {       
            this.service = service;
        }
        
        public void start() {
            this.thread = new Thread(this);
            this.thread.start();
        }
    
        public void run() {        
            while (true) {            
                this.service.receiveMessages();            
                try {
    	 	this.thread.sleep(CommonConst.INTERVAL_SERVICE * 1000);
    	    } catch (java.lang.InterruptedException e) {
                    Log.log(Log.ERROR,this,e);
    	}
            this.service.sendMessages();        
            try {
    	       this.thread.sleep(CommonConst.INTERVAL_SERVICE *1000);
    	} catch (java.lang.InterruptedException e) {
                   Log.log(Log.ERROR,this,e);
    	}
        }
        
    }

    очень удивляют предыдущие разрабочтики продукта своими понятиями о потоках в Java

    qnikst, 12 Сентября 2010

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

    +118

    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
    SqlCommand command = new SqlCommand ();
    command.Connection = connection;
    command.CommandText = "select data from filestorage where id=@id;";            
    command.Parameters.AddWithValue ("@id", fileId);
    command.CommandType = CommandType.Text;
    
    byte [] data = (byte []) command.ExecuteScalar ();
    
    System.IO.Stream outStream = Response.OutputStream;
    
    Response.ContentType = "Application/octet-stream";
    Response.AppendHeader ("Connection", "keep-alive");
    
    Response.AppendHeader ("Content-Disposition", " attachment; filename = \"" + fName+"\"" );
    
    outStream.Write (data, 0, data.Length);
    Response.End ();

    продолжение http://govnokod.ru/4227

    akai_mirror, 12 Сентября 2010

    Комментарии (16)
  9. PHP / Говнокод #4228

    +165

    1. 1
    2. 2
    $res = explode(" ", $price);		
    $price = trim(str_replace(".", "", str_replace(",", "", substr(trim($res[0]), 0, strlen(trim($res[0])) - 2))));

    Изначально в переменной $price строка такого вида: 144.07 РУБ.
    Судя по всему автор хотел таким образом получить из нее целое значение

    partizan22, 12 Сентября 2010

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

    +125

    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
    command = new System.Data.SqlClient.SqlCommand();
    command.Connection = connection;
    
    command.CommandText = "select data from filestorage where id=@id;";            
    command.Parameters.AddWithValue("@id", fileId);
    command.CommandType = CommandType.Text;
    byte[] data = (byte[])command.ExecuteScalar();
    
    command.CommandText = "select filename from filestorage where id=@id;";
    string fName = (string)command.ExecuteScalar();
    
    command.CommandText = "select sizebytes from filestorage where id=@id;";
    long lngFileSize = (int)command.ExecuteScalar();
    
    command.CommandText = "select foldername from filestorage where id=@id;";
    string store= command.ExecuteScalar().ToString();

    akai_mirror, 11 Сентября 2010

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