Subversion Repositories Kolibri OS

Rev

Rev 802 | Rev 2288 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. ;-------------------------------------------------------------------------
  9. ;Loading configuration from ini file
  10. ;    {SPraid.simba}
  11. ;-------------------------------------------------------------------------
  12.  
  13. $Revision: 1276 $
  14.  
  15. iglobal
  16. conf_path_sect: db 'path',0
  17.  
  18. conf_fname db '/sys/sys.conf',0
  19. endg
  20. ; set soke kernel configuration
  21. proc set_kernel_conf
  22.         locals
  23.           par db 30 dup(?)
  24.         endl
  25.  
  26.         pushad
  27. ;[gui]
  28. ;mouse_speed
  29.  
  30.         lea eax,[par]
  31.         push eax
  32.         invoke ini.get_str,conf_fname, ugui, ugui_mouse_speed,\
  33.               eax,30, ugui_mouse_speed_def
  34.         pop eax
  35.         stdcall strtoint,eax
  36.         mov     [mouse_speed_factor], ax
  37.  
  38. ;mouse_delay
  39.         lea eax,[par]
  40.         push eax
  41.         invoke ini.get_str,conf_fname, ugui, ugui_mouse_delay,\
  42.                eax,30, ugui_mouse_delay_def
  43.         pop eax
  44.         stdcall strtoint,eax
  45.         mov     [mouse_delay], eax
  46.  
  47.  
  48. ;midibase
  49.         lea eax,[par]
  50.         push eax
  51.         invoke ini.get_str,conf_fname, udev, udev_midibase, eax,30, udev_midibase_def
  52.         pop eax
  53.         stdcall strtoint,eax
  54.  
  55.         cmp     eax, 0x100
  56.         jb      @f
  57.         cmp     eax, 0x10000
  58.         jae     @f
  59.         mov     [midi_base], ax
  60.         mov     [mididp], eax
  61.         inc     eax
  62.         mov     [midisp], eax
  63. @@:
  64.         popad
  65.         ret
  66. endp
  67. iglobal
  68. ugui db 'gui',0
  69. ugui_mouse_speed db 'mouse_speed',0
  70. ugui_mouse_speed_def db '2',0
  71. ugui_mouse_delay db 'mouse_delay',0
  72. ugui_mouse_delay_def db '0x00A',0
  73.  
  74. udev db 'dev',0
  75. udev_midibase db 'midibase',0
  76. udev_midibase_def db '0x320',0
  77. endg
  78. ;set up netvork configuration
  79. proc set_network_conf
  80. locals
  81.   par db 30 dup(?)
  82. endl
  83.   pushad
  84.  
  85.   ;[net]
  86.   ;active
  87.   lea eax,[par]
  88.   invoke ini.get_int,conf_fname, unet, unet_active, 0
  89.   or eax,eax
  90.   jz .do_not_set_net
  91.         mov     eax, [stack_config]
  92.         and     eax, 0xFFFFFF80
  93.         add     eax, 3
  94.         mov     [stack_config], eax
  95.         call    ash_eth_enable
  96.  
  97.   ;addr
  98.   lea eax,[par]
  99.   push eax
  100.   invoke ini.get_str,conf_fname, unet, unet_addr, eax,30, unet_def
  101.   pop eax
  102.   stdcall do_inet_adr,eax
  103.         mov     [stack_ip], eax
  104.  
  105.   ;mask
  106.   lea eax,[par]
  107.   push eax
  108.   invoke ini.get_str,conf_fname, unet, unet_mask, eax,30, unet_def
  109.   pop eax
  110.   stdcall do_inet_adr,eax
  111.         mov     [subnet_mask], eax
  112.  
  113.   ;gate
  114.   lea eax,[par]
  115.   push eax
  116.   invoke ini.get_str,conf_fname, unet, unet_gate, eax,30, unet_def
  117.   pop eax
  118.   stdcall do_inet_adr,eax
  119.         mov     [gateway_ip], eax
  120. .do_not_set_net:
  121.   popad
  122.   ret
  123.  
  124.  
  125. endp
  126. iglobal
  127. unet db 'net',0
  128. unet_active db 'active',0
  129. unet_addr db 'addr',0
  130. unet_mask db 'mask',0
  131. unet_gate db 'gate',0
  132. unet_def db 0
  133. endg
  134. ; convert string to DWord
  135. proc strtoint stdcall,strs
  136.   pushad
  137.  
  138.   mov eax,[strs]
  139.   inc eax
  140.   mov bl,[eax]
  141.   cmp bl,'x'
  142.   je .hex
  143.   cmp bl,'X'
  144.   je .hex
  145.   jmp .dec
  146. .hex:
  147.   inc eax
  148.   stdcall strtoint_hex,eax
  149.   jmp .exit
  150. .dec:
  151.   dec eax
  152.   stdcall strtoint_dec,eax
  153. .exit:
  154.   mov [esp+28],eax
  155.   popad
  156.   ret
  157. endp
  158.  
  159. ; convert string to DWord for decimal value
  160. proc strtoint_dec stdcall,strs
  161.   pushad
  162.   xor edx,edx
  163.   ; ¯®¨áª ª®­æ 
  164.   mov esi,[strs]
  165. @@:
  166.   lodsb
  167.   or al,al
  168.   jnz @b
  169.   mov ebx,esi
  170.   mov esi,[strs]
  171.   dec ebx
  172.   sub ebx,esi
  173.   mov ecx,1
  174.  
  175. @@:
  176.   dec ebx
  177.   or ebx,ebx
  178.   jz @f
  179.   imul ecx,ecx,10  ; ¯®à冷ª
  180.   jmp @b
  181. @@:
  182.  
  183.  xchg ebx,ecx
  184.  
  185.  
  186.   xor ecx,ecx
  187.  
  188.  
  189. @@:
  190.   xor eax,eax
  191.   lodsb
  192.   cmp al,0
  193.   je .eend
  194.  
  195.   sub al,30h
  196.   imul ebx
  197.   add ecx,eax
  198.   push ecx
  199.   xchg eax,ebx
  200.   mov ecx,10
  201.   div ecx
  202.   xchg eax,ebx
  203.   pop ecx
  204.   jmp @b
  205.  
  206. .eend:
  207.   mov [esp+28],ecx
  208.   popad
  209.   ret
  210. endp
  211.  
  212. ;convert string to DWord for hex value
  213. proc strtoint_hex stdcall,strs
  214.   pushad
  215.   xor edx,edx
  216.  
  217.   mov esi,[strs]
  218.   mov ebx,1
  219.   add esi,1
  220.  
  221. @@:
  222.   lodsb
  223.   or al,al
  224.   jz @f
  225.   shl ebx,4
  226.   jmp @b
  227. @@:
  228.   xor ecx,ecx
  229.   mov esi,[strs]
  230.  
  231. @@:
  232.   xor eax,eax
  233.   lodsb
  234.   cmp al,0
  235.   je .eend
  236.  
  237.   cmp al,'a'
  238.   jae .bm
  239.   cmp al,'A'
  240.   jae .bb
  241.   jmp .cc
  242. .bm:    ; 57h
  243.   sub al,57h
  244.   jmp .do
  245.  
  246. .bb:    ; 37h
  247.   sub al,37h
  248.   jmp .do
  249.  
  250. .cc:    ; 30h
  251.   sub al,30h
  252.  
  253. .do:
  254.   imul ebx
  255.   add ecx,eax
  256.   shr ebx,4
  257.  
  258.   jmp @b
  259.  
  260. .eend:
  261.   mov [esp+28],ecx
  262.   popad
  263.   ret
  264. endp
  265.  
  266.  
  267. ; convert string to DWord for IP addres
  268. proc do_inet_adr stdcall,strs
  269.   pushad
  270.  
  271.   mov esi,[strs]
  272.   mov ebx,0
  273. .next:
  274.   push esi
  275. @@:
  276.   lodsb
  277.   or al,al
  278.   jz @f
  279.   cmp al,'.'
  280.   jz @f
  281.   jmp @b
  282. @@:
  283.   mov cl, al
  284.   mov [esi-1],byte 0
  285.   ;pop eax
  286.   call strtoint_dec
  287.   rol eax,24
  288.   ror ebx,8
  289.   add ebx,eax
  290.   or cl,cl
  291.   jz @f
  292.   jmp .next
  293. @@:
  294.   mov [esp+28],ebx
  295.   popad
  296.   ret
  297. endp
  298.