?login_element?

Subversion Repositories NedoOS

Rev

Rev 1664 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <oscalls.h>
  4. #include <tcp.h>
  5. #include <intrz80.h>
  6. #include <stdlib.h>
  7.  
  8. no_init unsigned char ipadress[4];
  9. no_init unsigned int ip16[4];
  10.  
  11. const unsigned char help[] = "View and set system DNS server\r\nUsage: dns.com [ip-adress]\r\n\0";
  12.  
  13. void get_dns(void)
  14. {
  15.         printf("Current DNS-server: ");
  16.         OS_GETDNS(ipadress);
  17.         printf("%d.%d.%d.%d\r\n", ipadress[0], ipadress[1], ipadress[2], ipadress[3]);
  18. }
  19.  
  20. void setdns(const char * strIP)
  21. {
  22.    
  23.     if( sscanf(strIP,"%d.%d.%d.%d", ip16, ip16+1,ip16+2,ip16+3) == 4 )
  24.     {
  25.         ipadress[0] = ip16[0];
  26.         ipadress[1] = ip16[1];
  27.         ipadress[2] = ip16[2];
  28.         ipadress[3] = ip16[3];
  29.         OS_SETDNS(ipadress);
  30.     }
  31.     else
  32.     {
  33.         printf("Wrong parameter\r\n");
  34.     }
  35.        
  36. }
  37.  
  38. C_task main(int argc, char *argv[])
  39. {
  40.         os_initstdio();
  41.  
  42.         if (argc == 1)
  43.         {
  44.                 puts(help);
  45.         }
  46.         else if (argc == 2)
  47.         {
  48.                 setdns(argv[1]);
  49.         }
  50.    
  51.         get_dns();
  52. }
  53.