Skip to content

Commit

Permalink
Fixes MUptime module. Now use Library "libc:6" sysinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
eloaders committed Oct 21, 2016
1 parent 8437493 commit 10dfbcc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
2 changes: 1 addition & 1 deletion I-Nex/i-nex/.src/MAIN/Finfosys.class
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ Public Sub dospam_uptime()

Try ProgressBar1.Value = (MemTotal - (MemFree + Buffers + Cached)) / MemTotal
Try ProgressBar4.Value = (SwapTotal - SwapFree) / SwapTotal

Try MUptime.Main()
End

Public Sub battery_info()
Expand Down
54 changes: 33 additions & 21 deletions I-Nex/i-nex/.src/System/MUptime.module
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
' Gambas module file

Public Sub _inits()
Dim sLine As String
Dim iPos As Integer
Dim SUptime As String
Dim SIdle As String
Dim UPTIME_FILE As File

If IsNull(UPTIME_FILE) = True Then
UPTIME_FILE = Open "/proc/uptime"
Endif

For Each sLine In UPTIME_FILE.Lines
sLine = Trim(sLine)
If Not sLine Then Continue
Print Left$(sLine, (InStr(sLine, ".") - 1)) / 60
Print Left$(sLine, (InStr(sLine, ".") - 1)) / 60 / 60
Print (4319 / 60) / 60
Next
'Print Time(00, 00, 3600)
Close #UPTIME_FILE
'awk '{printf("%d:%02d:%02d:%02d",($1/60/60/24),($1/60/60%24),($1/60%60),($1%60))}' /proc/uptime
Library "libc:6"

Public Struct sysinfo
uptime As Long
loads[3] As Long
totalram As Long
freeram As Long
sharedram As Long
bufferram As Long
totalswap As Long
freeswap As Long
procs As Short
pad As Short
totalhigh As Long
freehigh As Long
mem_unit As Integer
End Struct

' int sysinfo (struct sysinfo *__info)
' Returns information on overall system statistics.
Private Extern sysinfo(info As Sysinfo) As Integer
Public Logs As New Logger

Public Sub Main()

Dim si As New Sysinfo
Dim err As Integer

err = sysinfo(si)
If err < 0 Then
Logs("Libc6 Sysinfo Error", Logger.Error)
Else
Finfosys.TextBox58.Text = "Uptime: " & Date(0, 0, 0, 0, 0, 0, CInt(si.uptime * 1000))
Endif
End

0 comments on commit 10dfbcc

Please sign in to comment.