Subversion Repositories NedoOS

Rev

Rev 1776 | 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 netbuf[1452];
  14. unsigned char crlf[2] = {13, 10};
  15. unsigned long bytecount, downloaded;
  16. unsigned char status, key, curFormat;
  17. struct sockaddr_in targetadr;
  18. struct readstructure readStruct;
  19. unsigned long contLen;
  20. long count;
  21. unsigned char saveFlag, saveBak, rptFlag;
  22. unsigned char logFlag = 0;
  23. FILE *fp2;
  24.  
  25. struct window
  26. {
  27.         unsigned char x;
  28.         unsigned char y;
  29.         unsigned char w;
  30.         unsigned char h;
  31.         unsigned char text;
  32.         unsigned char back;
  33.         unsigned char tittle[80];
  34.  
  35. } cw;
  36.  
  37. void printTable(void)
  38. {
  39.         unsigned int cycle;
  40.         // OS_RENAME((unsigned int)&"doc",(unsigned int)&"doc.new");
  41.  
  42.         for (cycle = 32; cycle < 256; cycle++)
  43.         {
  44.                 printf("%03u:", cycle);
  45.                 putchar(cycle);
  46.                 printf(" ");
  47.                 if (cycle % 10 == 0)
  48.                 {
  49.                         printf("\r\n");
  50.                 }
  51.         }
  52. }
  53.  
  54. void drawWindow(struct window w)
  55. {
  56.         unsigned char wcount, tempx, tittleStart;
  57.  
  58.         AT(w.x, w.y - 1);
  59.         tittleStart = w.x + (w.w / 2) - (strlen(w.tittle) / 2) + 1;
  60.         BOX(w.x, w.y, w.w + 1, w.h, w.back, 32);
  61.         AT(w.x, w.y);
  62.         ATRIB(w.text);
  63.         putchar(201);
  64.         for (wcount = 0; wcount < w.w; wcount++)
  65.         {
  66.                 putchar(205);
  67.         }
  68.         putchar(187);
  69.  
  70.         AT(w.x, w.y + w.h);
  71.         putchar(200);
  72.         for (wcount = 0; wcount < w.w; wcount++)
  73.         {
  74.                 putchar(205);
  75.         }
  76.         putchar(188);
  77.  
  78.         tempx = w.x + w.w + 1;
  79.         for (wcount = 1; wcount < w.h; wcount++)
  80.         {
  81.                 AT(w.x, w.y + wcount);
  82.                 putchar(186);
  83.                 AT(tempx, w.y + wcount);
  84.                 putchar(186);
  85.         }
  86.  
  87.         AT(w.x, w.y + 2);
  88.         putchar(199);
  89.         for (wcount = 0; wcount < w.w; wcount++)
  90.         {
  91.                 putchar(196);
  92.         }
  93.         putchar(182);
  94.  
  95.         AT(tittleStart, w.y + 1);
  96.         printf("%s", w.tittle);
  97. }
  98.  
  99. void fatalError(unsigned char *message)
  100. {
  101.         strcpy(cw.tittle, "FATAL ERROR!");
  102.  
  103.         if (strlen(message) > strlen(cw.tittle))
  104.         {
  105.                 cw.w = strlen(message) + 2;
  106.         }
  107.         else
  108.                 cw.w = strlen(cw.tittle) + 2;
  109.         cw.x = 80 / 2 - cw.w / 2;
  110.         cw.y = 11;
  111.         cw.h = 4;
  112.         cw.text = 97;
  113.         cw.back = 41;
  114.  
  115.         drawWindow(cw);
  116.         AT(cw.x + 2, cw.y + 3);
  117.         printf(message);
  118.         AT(1, 1);
  119.         getchar();
  120.         exit(0);
  121. }
  122.  
  123. unsigned char OS_SHELL(unsigned char *command)
  124. {
  125.         FILE *fp2;
  126.         unsigned char fileName[] = "cmd.com";
  127.         unsigned char appCmd[128] = "cmd.com ";
  128.         unsigned long shellSize, loaded, loop;
  129.         unsigned char pgbak;
  130.         union APP_PAGES shell_pg;
  131.         union APP_PAGES main_pg;
  132.         unsigned char curPath[256];
  133.  
  134.         OS_GETPATH((unsigned int)&curPath);
  135.  
  136.         strcat(appCmd, command);
  137.         shell_pg.l = OS_GETMAINPAGES();
  138.         pgbak = main_pg.pgs.window_0;
  139.         loaded = 0;
  140.         OS_SETSYSDRV();
  141.         fp2 = OS_OPENHANDLE(fileName, 0x80);
  142.         if (((int)fp2) & 0xff)
  143.         {
  144.                 AT(1, 25);
  145.                 printf(fileName);
  146.                 printf(" not found.               ");
  147.                 exit(0);
  148.         }
  149.         shellSize = OS_GETFILESIZE(fp2);
  150.         //OS_CHDIR((unsigned int)&curPath);
  151.         OS_NEWAPP((unsigned int)&shell_pg);
  152.         SETPG32KHIGH(shell_pg.pgs.window_3);
  153.         memcpy((char *)(0xC080), &appCmd, sizeof(appCmd));
  154.         for (loop = 0; loop < shellSize; loop = loop + loaded)
  155.         {
  156.                 loaded = OS_READHANDLE(netbuf, fp2, sizeof(netbuf));
  157.                 memcpy((char *)(0xC100 + loop), &netbuf, loaded);
  158.         }
  159.         OS_CLOSEHANDLE(fp2);
  160.         AT(1, 1);
  161.         printf("Running shell [%s][%s] ", curPath, command);
  162.         OS_RUNAPP(shell_pg.pgs.pId);
  163.         OS_WAITPID(shell_pg.pgs.pId);
  164.         SETPG32KHIGH(pgbak);
  165.         return shell_pg.pgs.pId;
  166. }
  167.  
  168. #include <network.c>
  169.  
  170. C_task main(int argc, char *argv[])
  171. {
  172.         unsigned char key;
  173.         unsigned int errn;
  174.         unsigned long test, count;
  175.         os_initstdio();
  176.         BOX(1, 1, 80, 25, 40, 176);
  177.         cw.x = 20;
  178.         cw.y = 5;
  179.         cw.w = 40;
  180.         cw.h = 15;
  181.         cw.text = 97;
  182.         cw.back = 44;
  183.         strcpy(cw.tittle, "nedoOS system updater 0.1");
  184.         drawWindow(cw);
  185.         AT(cw.x + 1, cw.y + 3);
  186.         printf("File:bin.zip Downloaded:");
  187.  
  188.         OS_SETSYSDRV();
  189.         OS_CHDIR((unsigned int)&"../downloads");
  190.         OS_SHELL("dir");
  191.        
  192.         fatalError("LETS JUMP!");
  193.         // OS_DELETE((unsigned int)&"bin.zip");
  194.  
  195.         errn = getFile("bin.zip"); // Downloading the file
  196.         if (downloaded != contLen)
  197.         {
  198.                 fatalError("File download error!");
  199.         }
  200.  
  201.         AT(cw.x + 1, cw.y + 5);
  202.         printf("Download finished.");
  203.  
  204.         do
  205.         {
  206.                 key = _low_level_get();
  207.         } while (key == 0);
  208.         exit(0);
  209. }
  210.  
  211. /*
  212. [BIN]
  213. [DOC]
  214. [NEDODEMO]
  215. [NEDOGAME]
  216. [kernel]
  217.  
  218.  
  219.  
  220. Clean install
  221.  - Переименовать выбранные папки
  222.  - Создать новые папки
  223.  - Скачать архив выбранной папки
  224.  - Распаковать все содержимое.
  225. Clean install config restore
  226.  - восстановление из old конфигов
  227.  
  228.  
  229.  
  230. http://svn.zxevo.ru/filedetails.php?repname=pentevo&path=%2Fcfgs%2Fstandalone_base_trdemu%2Ftrunk%2Fzxevo_fw.bin
  231.  
  232. http://nedoos.ru/svn/filedetails.php?repname=NedoOS&path=%2Frelease%2F&#a624589277887c546d3fb998aee08482f
  233.  
  234. http://nedoos.ru/svn/filedetails.php?repname=NedoOS&path=%2Frelease%2Fdoc%2F3ws.txt
  235.  
  236. http://nedoos.ru/svn/dl.php?repname=NedoOS&path=%2Frelease%2F&isdir=1&rev=1766&peg=1766
  237.  
  238. http://nedoos.ru/svn/dl.php?repname=NedoOS&path=%2Frelease%2Fbin%2F&isdir=1
  239.  
  240. */