Subversion Repositories Kolibri OS

Rev

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

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