?login_element?

Subversion Repositories NedoOS

Rev

Rev 1777 | Rev 1786 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <intrz80.h>
  4. #include <stdlib.h>
  5. #include <oscalls.h>
  6. #include <terminal.c>
  7. #include <tcp.h>
  8. #include <osfs.h>
  9. #include <intrz80.h>
  10. #include <ctype.h>
  11. #include <math.h>
  12.  
  13. unsigned char is_atm;
  14. unsigned int errn;
  15. unsigned long contLen;
  16. unsigned char saveFlag, saveBak;
  17. unsigned char crlf[2] = {13, 10};
  18. unsigned long bytecount, downloaded;
  19. unsigned char status, key, curFormat;
  20. struct sockaddr_in targetadr;
  21. struct readstructure readStruct;
  22. FILE *fp2;
  23.  
  24. struct window
  25. {
  26.         unsigned char x;
  27.         unsigned char y;
  28.         unsigned char w;
  29.         unsigned char h;
  30.         unsigned char text;
  31.         unsigned char back;
  32.         unsigned char tittle[80];
  33.  
  34. } cw;
  35. unsigned char kernelName[32];
  36. unsigned char machineName[32];
  37. unsigned char kernelLink[256];
  38.  
  39. unsigned int bufSize = 2000;
  40. unsigned char netbuf[2048];
  41. unsigned char netbuf2[2048];
  42.  
  43. void clearStatus(void)
  44. {
  45.         AT(1, 24);
  46.         printf("                                                                                ");
  47. }
  48.  
  49. void printTable(void)
  50. {
  51.         unsigned int cycle;
  52.  
  53.         for (cycle = 32; cycle < 256; cycle++)
  54.         {
  55.                 printf("%03u:", cycle);
  56.                 putchar(cycle);
  57.                 printf(" ");
  58.                 if (cycle % 10 == 0)
  59.                 {
  60.                         printf("\r\n");
  61.                 }
  62.         }
  63. }
  64.  
  65. void delay(unsigned long counter)
  66. {
  67.         unsigned long start, finish;
  68.         counter = counter / 20;
  69.         if (counter < 1)
  70.         {
  71.                 counter = 1;
  72.         }
  73.         start = time();
  74.         finish = start + counter;
  75.  
  76.         while (start < finish)
  77.         {
  78.                 start = time();
  79.         }
  80. }
  81.  
  82. void drawWindow(struct window w)
  83. {
  84.         unsigned char wcount, tempx, tittleStart;
  85.  
  86.         AT(w.x, w.y - 1);
  87.         tittleStart = w.x + (w.w / 2) - (strlen(w.tittle) / 2) + 1;
  88.         BOX(w.x, w.y, w.w + 1, w.h, w.back, 32);
  89.         AT(w.x, w.y);
  90.         ATRIB(w.text);
  91.         putchar(201);
  92.         for (wcount = 0; wcount < w.w; wcount++)
  93.         {
  94.                 putchar(205);
  95.         }
  96.         putchar(187);
  97.  
  98.         AT(w.x, w.y + w.h);
  99.         putchar(200);
  100.         for (wcount = 0; wcount < w.w; wcount++)
  101.         {
  102.                 putchar(205);
  103.         }
  104.         putchar(188);
  105.  
  106.         tempx = w.x + w.w + 1;
  107.         for (wcount = 1; wcount < w.h; wcount++)
  108.         {
  109.                 AT(w.x, w.y + wcount);
  110.                 putchar(186);
  111.                 AT(tempx, w.y + wcount);
  112.                 putchar(186);
  113.         }
  114.  
  115.         AT(w.x, w.y + 2);
  116.         putchar(199);
  117.         for (wcount = 0; wcount < w.w; wcount++)
  118.         {
  119.                 putchar(196);
  120.         }
  121.         putchar(182);
  122.  
  123.         AT(tittleStart, w.y + 1);
  124.         printf("%s", w.tittle);
  125. }
  126.  
  127. void fatalError(unsigned char *message)
  128. {
  129.         strcpy(cw.tittle, "FATAL ERROR!");
  130.  
  131.         if (strlen(message) > strlen(cw.tittle))
  132.         {
  133.                 cw.w = strlen(message) + 2;
  134.         }
  135.         else
  136.                 cw.w = strlen(cw.tittle) + 2;
  137.         cw.x = 80 / 2 - cw.w / 2;
  138.         cw.y = 11;
  139.         cw.h = 4;
  140.         cw.text = 97;
  141.         cw.back = 41;
  142.  
  143.         drawWindow(cw);
  144.         AT(cw.x + 2, cw.y + 3);
  145.         printf(message);
  146.         AT(1, 1);
  147.         getchar();
  148.         exit(0);
  149. }
  150.  
  151. void infoBox(unsigned char *message)
  152. {
  153.         strcpy(cw.tittle, "nedoOS system updater 0.1");
  154.  
  155.         if (strlen(message) > strlen(cw.tittle))
  156.         {
  157.                 cw.w = strlen(message) + 2;
  158.         }
  159.         else
  160.                 cw.w = strlen(cw.tittle) + 2;
  161.         cw.x = 80 / 2 - cw.w / 2;
  162.         cw.y = 15;
  163.         cw.h = 4;
  164.         cw.text = 97;
  165.         cw.back = 42;
  166.  
  167.         drawWindow(cw);
  168.         AT(cw.x + 2, cw.y + 3);
  169.         printf(message);
  170.         AT(1, 1);
  171. }
  172.  
  173. unsigned char OS_SHELL(unsigned char *command)
  174. {
  175.         unsigned char fileName[] = "cmd.com";
  176.         unsigned char appCmd[128] = "cmd.com ";
  177.         unsigned char diskBuf[1024];
  178.         unsigned int shellSize, loaded, loop;
  179.         unsigned char pgbak;
  180.         union APP_PAGES shell_pg;
  181.         union APP_PAGES main_pg;
  182.         unsigned char curPath[256];
  183.  
  184.         main_pg.l = OS_GETMAINPAGES();
  185.         pgbak = main_pg.pgs.window_0;
  186.  
  187.         OS_GETPATH((unsigned int)&curPath);
  188.         strcat(appCmd, command);
  189.         OS_SETSYSDRV();
  190.         fp2 = OS_OPENHANDLE(fileName, 0x80);
  191.         if (((int)fp2) & 0xff)
  192.         {
  193.                 clearStatus();
  194.                 AT(1, 24);
  195.                 printf(fileName);
  196.                 printf(" not found.");
  197.                 getchar();
  198.                 exit(0);
  199.         }
  200.         shellSize = OS_GETFILESIZE(fp2);
  201.         OS_CHDIR(curPath);
  202.         OS_NEWAPP((unsigned int)&shell_pg);
  203.         SETPG32KHIGH(shell_pg.pgs.window_3);
  204.         memcpy((char *)(0xC080), &appCmd, sizeof(appCmd));
  205.         for (loop = 0; loop < shellSize; loop = loop + loaded)
  206.         {
  207.                 loaded = OS_READHANDLE(diskBuf, fp2, sizeof(diskBuf));
  208.                 memcpy((char *)(0xC100 + loop), &diskBuf, loaded);
  209.         }
  210.         OS_CLOSEHANDLE(fp2);
  211.         SETPG32KHIGH(pgbak);
  212.  
  213.         clearStatus();
  214.         AT(1, 24);
  215.         printf("Running shell [pId:%u][%s][%s]", shell_pg.pgs.pId, curPath, appCmd);
  216.         YIELD();
  217.         delay(250);
  218.  
  219.         OS_RUNAPP(shell_pg.pgs.pId);
  220.         OS_WAITPID(shell_pg.pgs.pId);
  221.         return shell_pg.pgs.pId;
  222. }
  223.  
  224. // #include <network.c>
  225.  
  226. void errorPrint(unsigned int error)
  227. {
  228.         clearStatus();
  229.         AT(1, 24);
  230.         switch (error)
  231.         {
  232.         case 2:
  233.                 printf("02 SHUT_RDWR");
  234.                 break;
  235.         case 4:
  236.                 printf("04 ERR_INTR");
  237.                 break;
  238.         case 23:
  239.                 printf("23 ERR_NFILE");
  240.                 break;
  241.         case 35:
  242.                 printf("35 ERR_EAGAIN");
  243.                 break;
  244.         case 37:
  245.                 printf("37 ERR_ALREADY");
  246.                 break;
  247.         case 38:
  248.                 printf("38 ERR_NOTSOCK");
  249.                 break;
  250.         case 40:
  251.                 printf("40 ERR_EMSGSIZE");
  252.                 break;
  253.         case 41:
  254.                 printf("41 ERR_PROTOTYPE");
  255.                 break;
  256.         case 47:
  257.                 printf("47 ERR_AFNOSUPPORT");
  258.                 break;
  259.         case 53:
  260.                 printf("53 ERR_ECONNABORTED");
  261.                 break;
  262.         case 54:
  263.                 printf("54 ERR_CONNRESET");
  264.                 break;
  265.         case 57:
  266.                 printf("57 ERR_NOTCONN");
  267.                 break;
  268.         case 65:
  269.                 printf("65 ERR_HOSTUNREACH");
  270.                 break;
  271.         default:
  272.                 printf("[%u] UNKNOWN ERROR", error);
  273.                 break;
  274.         }
  275.         YIELD();
  276.         do
  277.         {
  278.                 key = _low_level_get();
  279.         } while (key == 0);
  280. }
  281.  
  282. unsigned char OpenSock(unsigned char family, unsigned char protocol)
  283. {
  284.         unsigned char socket;
  285.         unsigned int todo;
  286.         todo = OS_NETSOCKET((family << 8) + protocol);
  287.         if (todo > 32767)
  288.         {
  289.                 clearStatus();
  290.                 AT(1, 24);
  291.                 printf("OS_NETSOCKET: ");
  292.                 errorPrint(todo & 255);
  293.                 exit(0);
  294.         }
  295.         else
  296.         {
  297.                 socket = ((todo & 65280) >> 8);
  298.         }
  299.         return socket;
  300. }
  301.  
  302. unsigned char netConnect(unsigned char socket)
  303. {
  304.         unsigned int todo;
  305.  
  306.         targetadr.family = AF_INET;
  307.         targetadr.porth = 00;
  308.         targetadr.portl = 80;
  309.         targetadr.b1 = 31;
  310.         targetadr.b2 = 31;
  311.         targetadr.b3 = 65;
  312.         targetadr.b4 = 35;
  313.  
  314.         todo = OS_NETCONNECT(socket, &targetadr);
  315.         if (todo > 32767)
  316.         {
  317.                 clearStatus();
  318.                 AT(1, 24);
  319.                 printf("OS_NETCONNECT: ");
  320.                 errorPrint(todo & 255);
  321.                 exit(0);
  322.         }
  323.         return 0;
  324. }
  325.  
  326. unsigned int tcpRead(unsigned char socket)
  327. {
  328.         unsigned char retry = 250;
  329.         unsigned int err, todo;
  330.         readStruct.socket = socket;
  331.         readStruct.BufAdr = (unsigned int)&netbuf;
  332.         readStruct.bufsize = bufSize;
  333.         readStruct.protocol = SOCK_STREAM;
  334. wizread:
  335.         todo = OS_WIZNETREAD(&readStruct);
  336.         if (todo > 32767)
  337.         {
  338.                 if (retry == 0)
  339.                 {
  340.                         err = todo & 255;
  341.                         clearStatus();
  342.                         AT(1, 24);
  343.                         printf("OS_WIZNETREAD: ");
  344.                         errorPrint(err);
  345.  
  346.                         if (err == 35)
  347.                         {
  348.                                 return 0;
  349.                         }
  350.                         fatalError("ERROR CONNECTION TO SERVER");
  351.                 }
  352.                 retry--;
  353.                 YIELD();
  354.                 YIELD();
  355.                 delay(300);
  356.                 YIELD();
  357.                 YIELD();
  358.                 goto wizread;
  359.         }
  360.         return todo;
  361. }
  362.  
  363. unsigned int netShutDown(unsigned char socket)
  364. {
  365.         unsigned int todo;
  366.         todo = OS_NETSHUTDOWN(socket);
  367.         if (todo > 32767)
  368.         {
  369.                 printf("OS_NETSHUTDOWN: ");
  370.                 errorPrint(todo & 255);
  371.                 return 255;
  372.         }
  373.  
  374.         return 0;
  375. }
  376.  
  377. unsigned int cutHeader(unsigned int todo)
  378. {
  379.         unsigned int q, headlng;
  380.         unsigned char *count;
  381.         count = strstr(netbuf, "Content-Length:");
  382.         if (count == NULL)
  383.         {
  384.                 clearStatus();
  385.                 AT(1, 24);
  386.                 printf("Content-Length:  not found.");
  387.                 contLen = 0;
  388.         }
  389.         else
  390.         {
  391.                 contLen = atol(count + 15);
  392.                 bytecount = contLen;
  393.                 //    AT (1,24);
  394.                 //      printf("=> Dlinna  soderzhimogo = %lu \n\r", bytecount);
  395.         }
  396.  
  397.         count = strstr(netbuf, "\r\n\r\n");
  398.         headlng = ((unsigned int)count - (unsigned int)netbuf + 4);
  399.         q = todo - headlng;
  400.         memcpy(&netbuf, count + 4, q);
  401.         return q;
  402. }
  403.  
  404. unsigned char saveBuf(unsigned char *fileNamePtr, unsigned char operation, unsigned int sizeOfBuf)
  405. {
  406.         unsigned char fileName[255];
  407.  
  408.         if (operation == 00)
  409.         {
  410.                 strcpy(fileName, fileNamePtr);
  411.                 fp2 = OS_CREATEHANDLE(fileName, 0x80);
  412.                 if (((int)fp2) & 0xff)
  413.                 {
  414.                         clearStatus();
  415.                         AT(1, 24);
  416.                         printf(fileName);
  417.                         printf(" creating error.");
  418.                         exit(0);
  419.                 }
  420.                 OS_CLOSEHANDLE(fp2);
  421.                 fp2 = OS_OPENHANDLE(fileName, 0x80);
  422.                 if (((int)fp2) & 0xff)
  423.                 {
  424.                         clearStatus();
  425.                         AT(1, 24);
  426.                         printf(fileName);
  427.                         printf(" opening error.");
  428.  
  429.                         exit(0);
  430.                 }
  431.                 AT(1, 24);
  432.                 return 0;
  433.         }
  434.  
  435.         if (operation == 01)
  436.         {
  437.                 OS_WRITEHANDLE(netbuf, fp2, sizeOfBuf);
  438.                 downloaded = downloaded + sizeOfBuf;
  439.                 return 0;
  440.         }
  441.  
  442.         if (operation == 02)
  443.         {
  444.                 OS_CLOSEHANDLE(fp2);
  445.                 return 0;
  446.         }
  447.         return 0;
  448. }
  449.  
  450. unsigned int tcpSend(unsigned char socket, unsigned int messageadr, unsigned int size)
  451. {
  452.         unsigned char retry = 20;
  453.         unsigned int todo;
  454.         readStruct.socket = socket;
  455.         readStruct.BufAdr = messageadr;
  456.         readStruct.bufsize = size;
  457.         readStruct.protocol = SOCK_STREAM;
  458.  
  459. wizwrite:
  460.         todo = OS_WIZNETWRITE(&readStruct);
  461.         if (todo > 32767)
  462.         {
  463.                 clearStatus();
  464.                 AT(1, 24);
  465.                 printf("OS_WIZNETWRITE: ");
  466.                 errorPrint(todo & 255);
  467.                 if (retry == 0)
  468.                 {
  469.                         exit(0);
  470.                 }
  471.                 retry--;
  472.                 YIELD();
  473.                 delay(250);
  474.                 goto wizwrite;
  475.         }
  476.  
  477.         return todo;
  478. }
  479. unsigned char getFile(unsigned char *fileLink, unsigned char *fileNamePtr)
  480. {
  481.         unsigned int todo;
  482.         unsigned char cmdlist1[] = " HTTP/1.1\r\nHost: nedoos.ru\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE5.01; NedoOS)\r\n\r\n\0";
  483.         unsigned char socket;
  484.         unsigned int bytes2read, headskip;
  485.         strcpy(netbuf, "GET ");
  486.         strcat(netbuf, fileLink);
  487.         strcat(netbuf, cmdlist1);
  488.         clearStatus();
  489.         socket = OpenSock(AF_INET, SOCK_STREAM);
  490.         todo = netConnect(socket);
  491.         todo = tcpSend(socket, (unsigned int)&netbuf, strlen(netbuf));
  492.         headskip = 0;
  493.         bytecount = 255;
  494.         downloaded = 0;
  495.         saveBuf(fileNamePtr, 00, 0);
  496.         AT(1, 24);
  497.         printf(" %s ", fileNamePtr);
  498.         while (bytecount != 0)
  499.         {
  500.                 todo = tcpRead(socket);
  501.                 if (todo == 0)
  502.                 {
  503.                         break;
  504.                 }
  505.                 bytes2read = todo;
  506.                 if (headskip == 0)
  507.                 {
  508.                         headskip = 1;
  509.                         bytes2read = cutHeader(todo);
  510.                 }
  511.                 AT(34, 24);
  512.                 printf("%lu of %lu kb", downloaded / 1024, contLen / 1024);
  513.  
  514.                 saveBuf(fileNamePtr, 01, bytes2read);
  515.                 bytecount = bytecount - bytes2read;
  516.  
  517.                 key = _low_level_get();
  518.                 if (key == 27)
  519.                 {
  520.                         saveBuf(fileNamePtr, 02, 00);
  521.                         fatalError("File download aborted!");
  522.                 }
  523.         }
  524.         saveBuf(fileNamePtr, 02, 00);
  525.         netShutDown(socket);
  526.         if (downloaded != contLen)
  527.         {
  528.                 fatalError("File download error!");
  529.         }
  530.         return 0;
  531. }
  532. ////////////////////////////////////////////////////
  533. unsigned char getConfig(void)
  534. {
  535.         is_atm = (unsigned char)OS_GETCONFIG();
  536.         // H=system drive, L= 1-Evo 2-ATM2 3-ATM3 6-p2.666 ;E=pgsys(system page) D= TR-DOS page
  537.         switch ((is_atm))
  538.         {
  539.         case 1:
  540.                 strcpy(machineName, "ZX-Evolution");
  541.                 strcpy(kernelName, "sd_boot.$C");
  542.                 strcpy(kernelLink, "/svn/dl.php?repname=NedoOS&path=%2Frelease%2Fsd_boot.%24C");
  543.                 break;
  544.         case 2:
  545.                 strcpy(machineName, "TURBO 2+");
  546.                 strcpy(kernelName, "osatm2hd.$C");
  547.                 strcpy(kernelLink, "/svn/dl.php?repname=NedoOS&path=%2Frelease%2Fosatm2hd.%24C");
  548.  
  549.                 break;
  550.  
  551.         case 3: // SD HDD versions
  552.                 strcpy(machineName, "TURBO 3 [SD]");
  553.                 strcpy(kernelName, "osatm3hd.$C");
  554.                 strcpy(kernelLink, "/svn/dl.php?repname=NedoOS&path=%2Frelease%2Fosatm3hd.%24C");
  555.                 break;
  556.         case 6: // SD HDD versions
  557.                 strcpy(machineName, "P2.666 [SD]");
  558.                 strcpy(kernelName, "osp26sd.$C");
  559.                 strcpy(kernelLink, "/svn/dl.php?repname=NedoOS&path=%2Frelease%2Fosp26sd.%24C");
  560.                 break;
  561.  
  562.         default:
  563.                 strcpy(machineName, "NOT DETECED (ZX-Evo)");
  564.                 strcpy(kernelName, "sd_boot.$C");
  565.                 strcpy(kernelLink, "/svn/dl.php?repname=NedoOS&path=%2Frelease%2Fsd_boot.%24C");
  566.                 break;
  567.         }
  568.         return is_atm;
  569. }
  570.  
  571. void getTools(void)
  572. {
  573.         unsigned char pkunzipLink[] = "/svn/dl.php?repname=NedoOS&path=%2Frelease%2Fbin%2Fpkunzip.com";
  574.         unsigned char tarLink[] = "/svn/dl.php?repname=NedoOS&path=%2Frelease%2Fbin%2Ftar.com";
  575.         unsigned char cmdLink[] = "/svn/dl.php?repname=NedoOS&path=%2Frelease%2Fbin%2Fcmd.com";
  576.         unsigned char termLink[] = "/svn/dl.php?repname=NedoOS&path=%2Frelease%2Fbin%2Fterm.com";
  577.         unsigned char updLink[] = "/svn/dl.php?repname=NedoOS&path=%2Frelease%2Fbin%2Fupdater.com";
  578.         errn = OS_MKDIR("bin");
  579.         ATRIB(cw.text);
  580.         ATRIB(cw.back);
  581.         errn = getFile(pkunzipLink, "bin/pkunzip.com");
  582.         errn = getFile(tarLink, "bin/tar.com");
  583.         errn = getFile(cmdLink, "bin/cmd.com");
  584.         errn = getFile(termLink, "bin/term.com");
  585.         errn = getFile(updLink, "bin/updater.com");
  586. }
  587.  
  588. void deleteWorkFiles(void)
  589. {
  590.         OS_DELETE("bin.zip");
  591.         OS_DELETE("bin.tar");
  592.         OS_DELETE("bin.old"); // deleting not empty folders not supported
  593.         OS_DELETE("bin.r17");
  594.         OS_DELETE("bin.r18");
  595.         OS_DELETE("bin.r19");
  596.         OS_DELETE("bin.r20");
  597. }
  598.  
  599. void deleteTempBin(void)
  600. {
  601.         OS_DELETE("bin/pkunzip.com");
  602.         OS_DELETE("bin/tar.com");
  603.         OS_DELETE("bin/cmd.com");
  604.         OS_DELETE("bin/term.com");
  605.         OS_DELETE("bin/updater.com");
  606.         OS_DELETE("bin");
  607. }
  608.  
  609. void fullUpdate(void)
  610. {
  611.         unsigned char relLink[] = "http://nedoos.ru/images/release.zip";
  612.  
  613.         BOX(1, 1, 80, 25, 40, 176);
  614.         cw.x = 20;
  615.         cw.y = 5;
  616.         cw.w = 40;
  617.         cw.h = 10;
  618.         cw.text = 97;
  619.         cw.back = 45;
  620.         strcpy(cw.tittle, "nedoOS FULL updater 0.1");
  621.  
  622.         getConfig();
  623.  
  624.         OS_SETSYSDRV();
  625.         errn = OS_CHDIR("..");
  626.  
  627.         strcat(cw.tittle, " (");
  628.         strcat(cw.tittle, machineName);
  629.         strcat(cw.tittle, ")");
  630.         drawWindow(cw);
  631.  
  632.         OS_DELETE("release.zip");
  633.         OS_DELETE("bin.old");
  634.         OS_DELETE("doc.old");
  635.         OS_DELETE("nedodemo.old");
  636.         OS_DELETE("nedogame.old");
  637.  
  638.         clearStatus();
  639.         AT(cw.x + 2, cw.y + 3);
  640.         printf("Downloading file: release.zip");
  641.  
  642.         errn = getFile(relLink, "release.zip"); //  Downloading the file
  643.  
  644.         clearStatus();
  645.         AT(cw.x + 2, cw.y + 4);
  646.         printf("Backuping old system.\r\n");
  647.         errn = OS_RENAME("bin", "bin.old");
  648.         errn = OS_RENAME("doc", "doc.old");
  649.         errn = OS_RENAME("nedodemo", "nedodemo.old");
  650.         errn = OS_RENAME("nedogame", "nedogame.old");
  651.  
  652.         clearStatus();
  653.         AT(cw.x + 2, cw.y + 5);
  654.         printf("Downloading tools.\r\n");
  655.  
  656.         getTools();
  657.  
  658.         BOX(1, 1, 80, 25, 40, 32);
  659.         AT(1, 1);
  660.         printf("Depacking release. Its take about 10 hours. Please wait.\r\n");
  661.         YIELD();
  662.         OS_SHELL("pkunzip.com release.zip");
  663.         // BOX(1, 1, 80, 25, 40, 176);
  664.         // drawWindow(cw);
  665.         infoBox("System Updated successfully.");
  666.         getchar();
  667.         ATRIB(40);
  668.         ATRIB(32);
  669.         exit(0);
  670. }
  671.  
  672. void binUpdate(void)
  673. {
  674.         unsigned char binLink[] = "/svn/dl.php?repname=NedoOS&path=%2Frelease%2Fbin%2F&isdir=1";
  675.         BOX(1, 1, 80, 25, 40, 176);
  676.         cw.x = 20;
  677.         cw.y = 5;
  678.         cw.w = 40;
  679.         cw.h = 10;
  680.         cw.text = 97;
  681.         cw.back = 44;
  682.         strcpy(cw.tittle, "nedoOS BIN updater 0.1");
  683.         getConfig();
  684.         strcat(cw.tittle, " (");
  685.         strcat(cw.tittle, machineName);
  686.         strcat(cw.tittle, ")");
  687.         drawWindow(cw);
  688.  
  689.         OS_SETSYSDRV();
  690.         errn = OS_CHDIR("..");
  691.  
  692.         deleteWorkFiles();
  693.  
  694.         clearStatus();
  695.         AT(cw.x + 2, cw.y + 3);
  696.         printf("Downloading bin.zip");
  697.  
  698.         errn = getFile(binLink, "bin.zip"); //  Downloading the file
  699.        
  700.         clearStatus();
  701.         AT(cw.x + 2, cw.y + 4);
  702.         printf("Downloading tools...");
  703.         getTools();
  704.         BOX(1, 1, 80, 25, 40, 32);
  705.         AT(1, 1);
  706.         printf("Depacking release. Its take about 10 minutes. Please wait.\r\n");
  707.         YIELD();
  708.  
  709.         OS_SHELL("pkunzip.com bin.zip");
  710.         BOX(1, 1, 80, 25, 40, 176);
  711.         drawWindow(cw);
  712.  
  713.         AT(cw.x + 2, cw.y + 3);
  714.         ATRIB(cw.text);
  715.         ATRIB(cw.back);
  716.         printf("Renaming bin.r?? to bin.tar");
  717.  
  718.         errn = OS_RENAME("bin.r17", "bin.tar"); // Masks not supported. Just some bad hardcode.
  719.         errn = OS_RENAME("bin.r18", "bin.tar");
  720.         errn = OS_RENAME("bin.r19", "bin.tar");
  721.         errn = OS_RENAME("bin.r20", "bin.tar");
  722.  
  723.         AT(cw.x + 2, cw.y + 4);
  724.         ATRIB(cw.text);
  725.         ATRIB(cw.back);
  726.         printf("Untaring bin.tar, please wait");
  727.  
  728.         OS_SHELL("tar.com bin.tar");
  729.  
  730.         AT(cw.x + 2, cw.y + 5);
  731.         ATRIB(cw.text);
  732.         ATRIB(cw.back);
  733.         printf("Backuping old bin to bin.old");
  734.         errn = OS_RENAME("bin", "bin.old");
  735.  
  736.         AT(cw.x + 2, cw.y + 6);
  737.         ATRIB(cw.text);
  738.         ATRIB(cw.back);
  739.         printf("Renaming NEW BIN.");
  740.        
  741.         deleteTempBin();
  742.        
  743.         errn = OS_RENAME("bin.r17", "bin"); // Masks not supported. Just some bad hardcode.
  744.         errn = OS_RENAME("bin.r18", "bin");
  745.         errn = OS_RENAME("bin.r19", "bin");
  746.         errn = OS_RENAME("bin.r20", "bin");
  747.        
  748.         AT(cw.x + 2, cw.y + 7);
  749.         ATRIB(cw.text);
  750.         ATRIB(cw.back);
  751.         printf("Deleting zip & tar.");
  752.  
  753.         deleteWorkFiles();
  754.  
  755.         AT(cw.x + 2, cw.y + 8);
  756.         ATRIB(cw.text);
  757.         ATRIB(cw.back);
  758.         printf("Downloading kernel: %s", machineName);
  759.  
  760.         errn = getFile(kernelLink, kernelName); //  Downloading the file
  761.  
  762. //      clearStatus();
  763. //      ATRIB(cw.text);
  764. //      ATRIB(cw.back);
  765. //      AT(cw.x + 2, cw.y + 9);
  766. //      printf("Updating kernel [%s]", kernelName);
  767.  
  768. //      OS_DELETE(kernelName);
  769. //      errn = OS_RENAME("kernel.tmp", kernelName);
  770.  
  771. //      strcpy(kernelLink, "ren kernel.tmp ");
  772. //      strcat(kernelLink, kernelName);
  773. //      OS_SHELL(kernelLink);
  774.  
  775.  
  776.         clearStatus();
  777.         infoBox("System Updated successfully");
  778.         getchar();
  779.         ATRIB(40);
  780.         ATRIB(32);
  781.         exit(0);
  782. }
  783.  
  784. C_task main(int argc, char *argv[])
  785. {
  786.         os_initstdio();
  787.  
  788.         if (argc > 1)
  789.         {
  790.                 if (argv[1] == "F")
  791.                 {
  792.                         fullUpdate();
  793.                 }
  794.                 else
  795.                 {
  796.                         fatalError("Use 'F' key to FULL update");
  797.                 }
  798.         }
  799.         else
  800.         {
  801.                 binUpdate();
  802.         }
  803. }
  804.  
  805. /*
  806. [BIN]
  807. [DOC]
  808. [NEDODEMO]
  809. [NEDOGAME]
  810. [kernel]
  811.  
  812. full release http://nedoos.ru/images/release.zip
  813.  
  814. Clean install
  815.  - Переименовать выбранные папки
  816.  - Создать новые папки
  817.  - Скачать архив выбранной папки
  818.  - Распаковать все содержимое.
  819. Clean install config restore
  820.  - восстановление из old конфигов
  821. */