mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-21 16:31:39 +00:00
resolved system.nim conflicts
This commit is contained in:
@@ -7,19 +7,19 @@
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module implements a simple HTTP-Server.
|
||||
## This module implements a simple HTTP-Server.
|
||||
##
|
||||
## Example:
|
||||
## Example:
|
||||
##
|
||||
## .. code-block:: nimrod
|
||||
## import strutils, sockets, httpserver
|
||||
##
|
||||
##
|
||||
## var counter = 0
|
||||
## proc handleRequest(client: TSocket, path, query: string): bool {.procvar.} =
|
||||
## inc(counter)
|
||||
## client.send("Hallo for the $#th time." % $counter & wwwNL)
|
||||
## client.send("Hello for the $#th time." % $counter & wwwNL)
|
||||
## return false # do not stop processing
|
||||
##
|
||||
##
|
||||
## run(handleRequest, TPort(80))
|
||||
##
|
||||
|
||||
@@ -47,7 +47,7 @@ proc cannotExec(client: TSocket) =
|
||||
sendTextContentType(client)
|
||||
send(client, "<P>Error prohibited CGI execution." & wwwNL)
|
||||
|
||||
proc headers(client: TSocket, filename: string) =
|
||||
proc headers(client: TSocket, filename: string) =
|
||||
# XXX could use filename to determine file type
|
||||
send(client, "HTTP/1.0 200 OK" & wwwNL)
|
||||
send(client, ServerSig)
|
||||
@@ -60,16 +60,16 @@ proc notFound(client: TSocket) =
|
||||
send(client, "<html><title>Not Found</title>" & wwwNL)
|
||||
send(client, "<body><p>The server could not fulfill" & wwwNL)
|
||||
send(client, "your request because the resource specified" & wwwNL)
|
||||
send(client, "is unavailable or nonexistent." & wwwNL)
|
||||
send(client, "is unavailable or nonexistent.</p>" & wwwNL)
|
||||
send(client, "</body></html>" & wwwNL)
|
||||
|
||||
proc unimplemented(client: TSocket) =
|
||||
send(client, "HTTP/1.0 501 Method Not Implemented" & wwwNL)
|
||||
send(client, ServerSig)
|
||||
sendTextContentType(client)
|
||||
send(client, "<html><head><title>Method Not Implemented" &
|
||||
send(client, "<html><head><title>Method Not Implemented" &
|
||||
"</title></head>" &
|
||||
"<body><p>HTTP request method not supported." &
|
||||
"<body><p>HTTP request method not supported.</p>" &
|
||||
"</body></HTML>" & wwwNL)
|
||||
|
||||
# ----------------- file serving ---------------------------------------------
|
||||
@@ -78,7 +78,7 @@ proc discardHeaders(client: TSocket) = skip(client)
|
||||
|
||||
proc serveFile(client: TSocket, filename: string) =
|
||||
discardHeaders(client)
|
||||
|
||||
|
||||
var f: TFile
|
||||
if open(f, filename):
|
||||
headers(client, filename)
|
||||
@@ -109,7 +109,7 @@ proc executeCgi(client: TSocket, path, query: string, meth: TRequestMethod) =
|
||||
case meth
|
||||
of reqGet:
|
||||
discardHeaders(client)
|
||||
|
||||
|
||||
env["REQUEST_METHOD"] = "GET"
|
||||
env["QUERY_STRING"] = query
|
||||
of reqPost:
|
||||
@@ -122,16 +122,16 @@ proc executeCgi(client: TSocket, path, query: string, meth: TRequestMethod) =
|
||||
var i = len("content-length:")
|
||||
while L[i] in Whitespace: inc(i)
|
||||
contentLength = parseInt(copy(L, i))
|
||||
|
||||
|
||||
if contentLength < 0:
|
||||
badRequest(client)
|
||||
return
|
||||
|
||||
env["REQUEST_METHOD"] = "POST"
|
||||
env["CONTENT_LENGTH"] = $contentLength
|
||||
|
||||
|
||||
send(client, "HTTP/1.0 200 OK" & wwwNL)
|
||||
|
||||
|
||||
var process = startProcess(command=path, env=env)
|
||||
if meth == reqPost:
|
||||
# get from client and post to CGI program:
|
||||
@@ -139,7 +139,7 @@ proc executeCgi(client: TSocket, path, query: string, meth: TRequestMethod) =
|
||||
if recv(client, buf, contentLength) != contentLength: OSError()
|
||||
var inp = process.inputStream
|
||||
inp.writeData(inp, buf, contentLength)
|
||||
|
||||
|
||||
var outp = process.outputStream
|
||||
while running(process) or not outp.atEnd(outp):
|
||||
var line = outp.readLine()
|
||||
@@ -165,11 +165,11 @@ proc acceptRequest(client: TSocket) =
|
||||
meth = reqPost
|
||||
else:
|
||||
unimplemented(client)
|
||||
|
||||
|
||||
var path = data[1]
|
||||
if path[path.len-1] == '/' or existsDir(path):
|
||||
path = path / "index.html"
|
||||
|
||||
|
||||
if not ExistsFile(path):
|
||||
discardHeaders(client)
|
||||
notFound(client)
|
||||
@@ -193,15 +193,15 @@ type
|
||||
port: TPort
|
||||
client*: TSocket ## the socket to write the file data to
|
||||
path*, query*: string ## path and query the client requested
|
||||
|
||||
proc open*(s: var TServer, port = TPort(80)) =
|
||||
|
||||
proc open*(s: var TServer, port = TPort(80)) =
|
||||
## creates a new server at port `port`. If ``port == 0`` a free port is
|
||||
## aquired that can be accessed later by the ``port`` proc.
|
||||
## acquired that can be accessed later by the ``port`` proc.
|
||||
s.socket = socket(AF_INET)
|
||||
if s.socket == InvalidSocket: OSError()
|
||||
bindAddr(s.socket, port)
|
||||
listen(s.socket)
|
||||
|
||||
|
||||
if port == TPort(0):
|
||||
s.port = getSockName(s.socket)
|
||||
else:
|
||||
@@ -209,12 +209,12 @@ proc open*(s: var TServer, port = TPort(80)) =
|
||||
s.client = InvalidSocket
|
||||
s.path = ""
|
||||
s.query = ""
|
||||
|
||||
proc port*(s: var TServer): TPort =
|
||||
## get the port number the server has aquired.
|
||||
|
||||
proc port*(s: var TServer): TPort =
|
||||
## get the port number the server has acquired.
|
||||
result = s.port
|
||||
|
||||
proc next*(s: var TServer) =
|
||||
|
||||
proc next*(s: var TServer) =
|
||||
## proceed to the first/next request.
|
||||
s.client = accept(s.socket)
|
||||
headers(s.client, "")
|
||||
@@ -236,13 +236,13 @@ proc close*(s: TServer) =
|
||||
## closes the server (and the socket the server uses).
|
||||
close(s.socket)
|
||||
|
||||
proc run*(handleRequest: proc (client: TSocket, path, query: string): bool,
|
||||
proc run*(handleRequest: proc (client: TSocket, path, query: string): bool,
|
||||
port = TPort(80)) =
|
||||
## encapsulates the server object and main loop
|
||||
var s: TServer
|
||||
open(s, port)
|
||||
#echo("httpserver running on port ", s.port)
|
||||
while true:
|
||||
while true:
|
||||
next(s)
|
||||
if handleRequest(s.client, s.path, s.query): break
|
||||
close(s.client)
|
||||
@@ -252,8 +252,8 @@ when isMainModule:
|
||||
var counter = 0
|
||||
proc handleRequest(client: TSocket, path, query: string): bool {.procvar.} =
|
||||
inc(counter)
|
||||
client.send("Hallo, Andreas for the $#th time." % $counter & wwwNL)
|
||||
client.send("Hello, Andreas, for the $#th time." % $counter & wwwNL)
|
||||
return false # do not stop processing
|
||||
|
||||
|
||||
run(handleRequest, TPort(80))
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ proc execCmd*(command: string): int
|
||||
proc executeCommand*(command: string): int {.deprecated.} =
|
||||
## **Deprecated since version 0.8.2**: Use `execCmd` instead.
|
||||
result = execCmd(command)
|
||||
|
||||
|
||||
|
||||
proc startProcess*(command: string,
|
||||
workingDir: string = "",
|
||||
@@ -115,7 +115,7 @@ when defined(macosx) or defined(bsd):
|
||||
a: var int, b: pointer, c: int): cint {.
|
||||
importc: "sysctl", header: "<sys/sysctl.h>".}
|
||||
|
||||
proc countProcessors*(): int =
|
||||
proc countProcessors*(): int =
|
||||
## returns the numer of the processors/cores the machine has.
|
||||
## Returns 0 if it cannot be determined.
|
||||
when defined(windows):
|
||||
@@ -186,7 +186,7 @@ proc execProcesses*(cmds: openArray[string],
|
||||
inc(i)
|
||||
if i > high(cmds): break
|
||||
for i in 0..m-1:
|
||||
result = max(waitForExit(q[i]), result)
|
||||
result = max(waitForExit(q[i]), result)
|
||||
else:
|
||||
for i in 0..high(cmds):
|
||||
var p = startProcessAux(cmds[i], options=options)
|
||||
@@ -243,7 +243,7 @@ when defined(Windows):
|
||||
if a == 0 and br != 0: OSError()
|
||||
s.atTheEnd = br < bufLen
|
||||
result = br
|
||||
|
||||
|
||||
proc hsWriteData(s: PFileHandleStream, buffer: pointer, bufLen: int) =
|
||||
var bytesWritten: int32
|
||||
var a = winlean.writeFile(s.handle, buffer, bufLen, bytesWritten, nil)
|
||||
@@ -256,10 +256,10 @@ when defined(Windows):
|
||||
result.atEnd = hsAtEnd
|
||||
result.readData = hsReadData
|
||||
result.writeData = hsWriteData
|
||||
|
||||
|
||||
proc buildCommandLine(a: string, args: openarray[string]): cstring =
|
||||
var res = quoteIfContainsWhite(a)
|
||||
for i in 0..high(args):
|
||||
for i in 0..high(args):
|
||||
res.add(' ')
|
||||
res.add(quoteIfContainsWhite(args[i]))
|
||||
result = cast[cstring](alloc0(res.len+1))
|
||||
@@ -324,7 +324,7 @@ when defined(Windows):
|
||||
result.inputHandle = si.hStdInput
|
||||
result.outputHandle = si.hStdOutput
|
||||
result.errorHandle = si.hStdError
|
||||
|
||||
|
||||
var cmdl: cstring
|
||||
if false: # poUseShell in options:
|
||||
cmdl = buildCommandLine(getEnv("COMSPEC"), @["/c", command] & args)
|
||||
@@ -337,13 +337,13 @@ when defined(Windows):
|
||||
if poEchoCmd in options: echo($cmdl)
|
||||
success = winlean.CreateProcess(nil,
|
||||
cmdl, nil, nil, 1, NORMAL_PRIORITY_CLASS, e, wd, SI, ProcInfo)
|
||||
|
||||
|
||||
if poParentStreams notin options:
|
||||
FileClose(si.hStdInput)
|
||||
FileClose(si.hStdOutput)
|
||||
if poStdErrToStdOut notin options:
|
||||
FileClose(si.hStdError)
|
||||
|
||||
|
||||
if e != nil: dealloc(e)
|
||||
dealloc(cmdl)
|
||||
if success == 0: OSError()
|
||||
@@ -382,7 +382,7 @@ when defined(Windows):
|
||||
proc errorStream(p: PProcess): PStream =
|
||||
result = newFileHandleStream(p.errorHandle)
|
||||
|
||||
proc execCmd(command: string): int =
|
||||
proc execCmd(command: string): int =
|
||||
var
|
||||
SI: TStartupInfo
|
||||
ProcInfo: TProcessInformation
|
||||
@@ -535,7 +535,7 @@ else:
|
||||
|
||||
proc csystem(cmd: cstring): cint {.nodecl, importc: "system".}
|
||||
|
||||
proc execCmd(command: string): int =
|
||||
proc execCmd(command: string): int =
|
||||
result = csystem(command)
|
||||
|
||||
when isMainModule:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,12 +9,12 @@
|
||||
|
||||
## This module implements Nimrod's support for the ``variant`` datatype.
|
||||
## `TVariant` shows how the flexibility of dynamic typing is achieved
|
||||
## within a static type system.
|
||||
## within a static type system.
|
||||
|
||||
type
|
||||
TVarType* = enum
|
||||
vtNone,
|
||||
vtBool,
|
||||
vtBool,
|
||||
vtChar,
|
||||
vtEnum,
|
||||
vtInt,
|
||||
@@ -31,7 +31,7 @@ type
|
||||
of vtString: vstring: string
|
||||
of vtSet, vtSeq: q: seq[TVariant]
|
||||
of vtDict: d: seq[tuple[key, val: TVariant]]
|
||||
|
||||
|
||||
iterator objectFields*[T](x: T, skipInherited: bool): tuple[
|
||||
key: string, val: TVariant] {.magic: "ObjectFields"}
|
||||
|
||||
@@ -74,10 +74,10 @@ proc `?`* [T: object](x: T): TVariant {.magic: "ToVariant".}
|
||||
|
||||
proc `><`*[T](v: TVariant, typ: T): T {.magic: "FromVariant".}
|
||||
|
||||
?[?5, ?67, ?"hallo"]
|
||||
?[?5, ?67, ?"hello"]
|
||||
myVar?int
|
||||
|
||||
|
||||
|
||||
proc `==`* (x, y: TVariant): bool =
|
||||
if x.vtype == y.vtype:
|
||||
case x.vtype
|
||||
@@ -139,7 +139,7 @@ proc `[]=`* (a, b, c: TVariant) =
|
||||
a.d[b.vint].val = c
|
||||
variantError()
|
||||
else: variantError()
|
||||
|
||||
|
||||
proc `[]`* (a: TVariant, b: int): TVariant {.inline} = return a[?b]
|
||||
proc `[]`* (a: TVariant, b: string): TVariant {.inline} = return a[?b]
|
||||
proc `[]=`* (a: TVariant, b: int, c: TVariant) {.inline} = a[?b] = c
|
||||
@@ -154,9 +154,9 @@ proc `+`* (x, y: TVariant): TVariant =
|
||||
else:
|
||||
case y.vtype
|
||||
of vtBool, vtChar, vtEnum, vtInt:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vint: int64
|
||||
of vtFloat: vfloat: float64
|
||||
of vtString: vstring: string
|
||||
@@ -171,11 +171,11 @@ proc `mod`* (x, y: TVariant): TVariant
|
||||
proc `&`* (x, y: TVariant): TVariant
|
||||
proc `$`* (x: TVariant): string =
|
||||
# uses JS notation
|
||||
|
||||
|
||||
proc parseVariant*(s: string): TVariant
|
||||
proc `<`* (x, y: TVariant): bool
|
||||
proc `<=`* (x, y: TVariant): bool
|
||||
|
||||
proc hash*(x: TVariant): int =
|
||||
|
||||
|
||||
|
||||
|
||||
19
lib/system.nim
Executable file → Normal file
19
lib/system.nim
Executable file → Normal file
@@ -10,7 +10,7 @@
|
||||
## The compiler depends on the System module to work properly and the System
|
||||
## module depends on the compiler. Most of the routines listed here use
|
||||
## special compiler magic.
|
||||
## Each module implicitly imports the System module; it may not be listed
|
||||
## Each module implicitly imports the System module; it must not be listed
|
||||
## explicitly. Because of this there cannot be a user-defined module named
|
||||
## ``system``.
|
||||
|
||||
@@ -45,7 +45,7 @@ type
|
||||
## a type description (for templates)
|
||||
|
||||
proc defined*[T](x: T): bool {.magic: "Defined", noSideEffect.}
|
||||
## Special comile-time procedure that checks whether `x` is
|
||||
## Special compile-time procedure that checks whether `x` is
|
||||
## defined. `x` has to be an identifier or a qualified identifier.
|
||||
## This can be used to check whether a library provides a certain
|
||||
## feature or not:
|
||||
@@ -57,7 +57,7 @@ proc defined*[T](x: T): bool {.magic: "Defined", noSideEffect.}
|
||||
|
||||
proc definedInScope*[T](x: T): bool {.
|
||||
magic: "DefinedInScope", noSideEffect.}
|
||||
## Special comile-time procedure that checks whether `x` is
|
||||
## Special compile-time procedure that checks whether `x` is
|
||||
## defined in the current scope. `x` has to be an identifier.
|
||||
|
||||
proc `not` *(x: bool): bool {.magic: "Not", noSideEffect.}
|
||||
@@ -65,11 +65,11 @@ proc `not` *(x: bool): bool {.magic: "Not", noSideEffect.}
|
||||
|
||||
proc `and`*(x, y: bool): bool {.magic: "And", noSideEffect.}
|
||||
## Boolean ``and``; returns true iff ``x == y == true``.
|
||||
## Evaluation is short-circuited: This means that if ``x`` is false,
|
||||
## Evaluation is short-circuited: this means that if ``x`` is false,
|
||||
## ``y`` will not even be evaluated.
|
||||
proc `or`*(x, y: bool): bool {.magic: "Or", noSideEffect.}
|
||||
## Boolean ``or``; returns true iff ``not (not x and not y)``.
|
||||
## Evaluation is short-circuited: This means that if ``x`` is true,
|
||||
## Evaluation is short-circuited: this means that if ``x`` is true,
|
||||
## ``y`` will not even be evaluated.
|
||||
proc `xor`*(x, y: bool): bool {.magic: "Xor", noSideEffect.}
|
||||
## Boolean `exclusive or`; returns true iff ``x != y``.
|
||||
@@ -165,7 +165,7 @@ type
|
||||
EOS* = object of ESystem ## raised if an operating system service failed.
|
||||
EInvalidLibrary* = object of EOS ## raised if a dynamic library
|
||||
## could not be loaded.
|
||||
ERessourceExhausted* = object of ESystem ## raised if a ressource request
|
||||
EResourceExhausted* = object of ESystem ## raised if a resource request
|
||||
## could not be fullfilled.
|
||||
EArithmetic* = object of ESynch ## raised if any kind of arithmetic
|
||||
## error occured.
|
||||
@@ -962,7 +962,7 @@ proc `$` *(x: Cstring): string {.magic: "CStrToStr", noSideEffect.}
|
||||
proc `$` *(x: string): string {.magic: "StrToStr", noSideEffect.}
|
||||
## The stingify operator for a string argument. Returns `x`
|
||||
## as it is. This operator is useful for generic code, so
|
||||
## that ``$expr`` also works if ``expr`` already is a string.
|
||||
## that ``$expr`` also works if ``expr`` is already a string.
|
||||
|
||||
proc `$` *[T](x: ordinal[T]): string {.magic: "EnumToStr", noSideEffect.}
|
||||
## The stingify operator for an enumeration argument. This works for
|
||||
@@ -1191,6 +1191,11 @@ proc each*[T, S](data: openArray[T], op: proc (x: T): S): seq[S] {.
|
||||
newSeq(result, data.len)
|
||||
for i in 0..data.len-1: result[i] = op(data[i])
|
||||
|
||||
proc each*[T](data: openArray[T], op: proc (x: T)) =
|
||||
## The well-known ``map`` operation from functional programming. Applies
|
||||
## `op` to every item in `data`.
|
||||
for i in 0..data.len-1: op(data[i])
|
||||
|
||||
|
||||
# ----------------- FPU ------------------------------------------------------
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ proc addChar(s: NimString, c: char): NimString {.compilerProc.} =
|
||||
|
||||
# These routines should be used like following:
|
||||
# <Nimrod code>
|
||||
# s &= "hallo " & name & " how do you feel?"
|
||||
# s &= "Hello " & name & ", how do you feel?"
|
||||
#
|
||||
# <generated C code>
|
||||
# {
|
||||
@@ -115,7 +115,7 @@ proc addChar(s: NimString, c: char): NimString {.compilerProc.} =
|
||||
# }
|
||||
#
|
||||
# <Nimrod code>
|
||||
# s = "hallo " & name & " how do you feel?"
|
||||
# s = "Hello " & name & ", how do you feel?"
|
||||
#
|
||||
# <generated C code>
|
||||
# {
|
||||
@@ -180,8 +180,8 @@ proc incrSeq(seq: PGenericSeq, elemSize: int): PGenericSeq {.compilerProc.} =
|
||||
result = cast[PGenericSeq](newSeq(extGetCellType(seq), s))
|
||||
genericSeqAssign(result, seq, XXX)
|
||||
#copyMem(result, seq, seq.len * elemSize + GenericSeqSize)
|
||||
inc(result.len)
|
||||
else:
|
||||
inc(result.len)
|
||||
else:
|
||||
result = seq
|
||||
if result.len >= result.space:
|
||||
result.space = resize(result.space)
|
||||
@@ -214,7 +214,7 @@ proc setLengthSeq(seq: PGenericSeq, elemSize, newLen: int): PGenericSeq {.
|
||||
# we need to decref here, otherwise the GC leaks!
|
||||
when not defined(boehmGC) and not defined(nogc):
|
||||
for i in newLen..result.len-1:
|
||||
forAllChildrenAux(cast[pointer](cast[TAddress](result) +%
|
||||
forAllChildrenAux(cast[pointer](cast[TAddress](result) +%
|
||||
GenericSeqSize +% (i*%elemSize)),
|
||||
extGetCellType(result).base, waZctDecRef)
|
||||
# and set the memory to nil:
|
||||
|
||||
197
lib/windows/psapi.nim
Normal file
197
lib/windows/psapi.nim
Normal file
@@ -0,0 +1,197 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
# PSAPI interface unit
|
||||
|
||||
# Contains the definitions for the APIs provided by PSAPI.DLL
|
||||
|
||||
import # Data structure templates
|
||||
Windows
|
||||
|
||||
proc EnumProcesses*(lpidProcess: ptr DWORD, cb: DWORD, cbNeeded: ptr DWORD): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "EnumProcesses".}
|
||||
proc EnumProcessModules*(hProcess: HANDLE, lphModule: ptr HMODULE, cb: DWORD, lpcbNeeded: LPDWORD): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "EnumProcessModules".}
|
||||
|
||||
proc GetModuleBaseNameA*(hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetModuleBaseNameA".}
|
||||
proc GetModuleBaseNameW*(hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetModuleBaseNameW".}
|
||||
when defined(winUnicode):
|
||||
proc GetModuleBaseName*(hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetModuleBaseNameW".}
|
||||
else:
|
||||
proc GetModuleBaseName*(hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetModuleBaseNameA".}
|
||||
|
||||
proc GetModuleFileNameExA*(hProcess: HANDLE, hModule: HMODULE, lpFileNameEx: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetModuleFileNameExA".}
|
||||
proc GetModuleFileNameExW*(hProcess: HANDLE, hModule: HMODULE, lpFileNameEx: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetModuleFileNameExW".}
|
||||
when defined(winUnicode):
|
||||
proc GetModuleFileNameEx*(hProcess: HANDLE, hModule: HMODULE, lpFileNameEx: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetModuleFileNameExW".}
|
||||
else:
|
||||
proc GetModuleFileNameEx*(hProcess: HANDLE, hModule: HMODULE, lpFileNameEx: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetModuleFileNameExA".}
|
||||
|
||||
type
|
||||
MODULEINFO* {.final.} = object
|
||||
lpBaseOfDll*: LPVOID
|
||||
SizeOfImage*: DWORD
|
||||
EntryPoint*: LPVOID
|
||||
LPMODULEINFO* = ptr MODULEINFO
|
||||
|
||||
proc GetModuleInformation*(hProcess: HANDLE, hModule: HMODULE, lpmodinfo: LPMODULEINFO, cb: DWORD): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetModuleInformation".}
|
||||
proc EmptyWorkingSet*(hProcess: HANDLE): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "EmptyWorkingSet".}
|
||||
proc QueryWorkingSet*(hProcess: HANDLE, pv: PVOID, cb: DWORD): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "QueryWorkingSet".}
|
||||
proc QueryWorkingSetEx*(hProcess: HANDLE, pv: PVOID, cb: DWORD): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "QueryWorkingSetEx".}
|
||||
proc InitializeProcessForWsWatch*(hProcess: HANDLE): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "InitializeProcessForWsWatch".}
|
||||
|
||||
type
|
||||
PSAPI_WS_WATCH_INFORMATION* {.final.} = object
|
||||
FaultingPc*: LPVOID
|
||||
FaultingVa*: LPVOID
|
||||
PPSAPI_WS_WATCH_INFORMATION* = ptr PSAPI_WS_WATCH_INFORMATION
|
||||
|
||||
proc GetWsChanges*(hProcess: HANDLE, lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION, cb: DWORD): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetWsChanges".}
|
||||
|
||||
proc GetMappedFileNameA*(hProcess: HANDLE, lpv: LPVOID, lpFilename: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetMappedFileNameA".}
|
||||
proc GetMappedFileNameW*(hProcess: HANDLE, lpv: LPVOID, lpFilename: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetMappedFileNameW".}
|
||||
when defined(winUnicode):
|
||||
proc GetMappedFileName*(hProcess: HANDLE, lpv: LPVOID, lpFilename: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetMappedFileNameW".}
|
||||
else:
|
||||
proc GetMappedFileName*(hProcess: HANDLE, lpv: LPVOID, lpFilename: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetMappedFileNameA".}
|
||||
|
||||
proc EnumDeviceDrivers*(lpImageBase: LPVOID, cb: DWORD, lpcbNeeded: LPDWORD): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "EnumDeviceDrivers".}
|
||||
|
||||
proc GetDeviceDriverBaseNameA*(ImageBase: LPVOID, lpBaseName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetDeviceDriverBaseNameA".}
|
||||
proc GetDeviceDriverBaseNameW*(ImageBase: LPVOID, lpBaseName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetDeviceDriverBaseNameW".}
|
||||
when defined(winUnicode):
|
||||
proc GetDeviceDriverBaseName*(ImageBase: LPVOID, lpBaseName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetDeviceDriverBaseNameW".}
|
||||
else:
|
||||
proc GetDeviceDriverBaseName*(ImageBase: LPVOID, lpBaseName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetDeviceDriverBaseNameA".}
|
||||
|
||||
proc GetDeviceDriverFileNameA*(ImageBase: LPVOID, lpFileName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetDeviceDriverFileNameA".}
|
||||
proc GetDeviceDriverFileNameW*(ImageBase: LPVOID, lpFileName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetDeviceDriverFileNameW".}
|
||||
when defined(winUnicode):
|
||||
proc GetDeviceDriverFileName*(ImageBase: LPVOID, lpFileName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetDeviceDriverFileNameW".}
|
||||
else:
|
||||
proc GetDeviceDriverFileName*(ImageBase: LPVOID, lpFileName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetDeviceDriverFileNameA".}
|
||||
|
||||
type
|
||||
PROCESS_MEMORY_COUNTERS* {.final.} = object
|
||||
cb*: DWORD
|
||||
PageFaultCount*: DWORD
|
||||
PeakWorkingSetSize: SIZE_T
|
||||
WorkingSetSize: SIZE_T
|
||||
QuotaPeakPagedPoolUsage: SIZE_T
|
||||
QuotaPagedPoolUsage: SIZE_T
|
||||
QuotaPeakNonPagedPoolUsage: SIZE_T
|
||||
QuotaNonPagedPoolUsage: SIZE_T
|
||||
PagefileUsage: SIZE_T
|
||||
PeakPagefileUsage: SIZE_T
|
||||
PPROCESS_MEMORY_COUNTERS* = ptr PROCESS_MEMORY_COUNTERS
|
||||
|
||||
type
|
||||
PROCESS_MEMORY_COUNTERS_EX* {.final.} = object
|
||||
cb*: DWORD
|
||||
PageFaultCount*: DWORD
|
||||
PeakWorkingSetSize: SIZE_T
|
||||
WorkingSetSize: SIZE_T
|
||||
QuotaPeakPagedPoolUsage: SIZE_T
|
||||
QuotaPagedPoolUsage: SIZE_T
|
||||
QuotaPeakNonPagedPoolUsage: SIZE_T
|
||||
QuotaNonPagedPoolUsage: SIZE_T
|
||||
PagefileUsage: SIZE_T
|
||||
PeakPagefileUsage: SIZE_T
|
||||
PrivateUsage: SIZE_T
|
||||
PPROCESS_MEMORY_COUNTERS_EX* = ptr PROCESS_MEMORY_COUNTERS_EX
|
||||
|
||||
proc GetProcessMemoryInfo*(hProcess: HANDLE, ppsmemCounters: PPROCESS_MEMORY_COUNTERS, cb: DWORD): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetProcessMemoryInfo".}
|
||||
|
||||
type
|
||||
PERFORMANCE_INFORMATION* {.final.} = object
|
||||
cb*: DWORD
|
||||
CommitTotal: SIZE_T
|
||||
CommitLimit: SIZE_T
|
||||
CommitPeak: SIZE_T
|
||||
PhysicalTotal: SIZE_T
|
||||
PhysicalAvailable: SIZE_T
|
||||
SystemCache: SIZE_T
|
||||
KernelTotal: SIZE_T
|
||||
KernelPaged: SIZE_T
|
||||
KernelNonpaged: SIZE_T
|
||||
PageSize: SIZE_T
|
||||
HandleCount*: DWORD
|
||||
ProcessCount*: DWORD
|
||||
ThreadCount*: DWORD
|
||||
PPERFORMANCE_INFORMATION* = ptr PERFORMANCE_INFORMATION
|
||||
# Skip definition of PERFORMACE_INFORMATION...
|
||||
|
||||
proc GetPerformanceInfo*(pPerformanceInformation: PPERFORMANCE_INFORMATION, cb: DWORD): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetPerformanceInfo".}
|
||||
|
||||
type
|
||||
ENUM_PAGE_FILE_INFORMATION* {.final.} = object
|
||||
cb*: DWORD
|
||||
Reserved*: DWORD
|
||||
TotalSize: SIZE_T
|
||||
TotalInUse: SIZE_T
|
||||
PeakUsage: SIZE_T
|
||||
PENUM_PAGE_FILE_INFORMATION* = ptr ENUM_PAGE_FILE_INFORMATION
|
||||
|
||||
# Callback procedure
|
||||
type
|
||||
PENUM_PAGE_FILE_CALLBACKW* = proc (pContext: LPVOID, pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, lpFilename: LPCWSTR): WINBOOL{.stdcall.}
|
||||
PENUM_PAGE_FILE_CALLBACKA* = proc (pContext: LPVOID, pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, lpFilename: LPCSTR): WINBOOL{.stdcall.}
|
||||
|
||||
#TODO
|
||||
proc EnumPageFilesA*(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "EnumPageFilesA".}
|
||||
proc EnumPageFilesW*(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "EnumPageFilesW".}
|
||||
when defined(winUnicode):
|
||||
proc EnumPageFiles*(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "EnumPageFilesW".}
|
||||
type PENUM_PAGE_FILE_CALLBACK* = proc (pContext: LPVOID, pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, lpFilename: LPCWSTR): WINBOOL{.stdcall.}
|
||||
else:
|
||||
proc EnumPageFiles*(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID): WINBOOL {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "EnumPageFilesA".}
|
||||
type PENUM_PAGE_FILE_CALLBACK* = proc (pContext: LPVOID, pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, lpFilename: LPCSTR): WINBOOL{.stdcall.}
|
||||
|
||||
proc GetProcessImageFileNameA*(hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetProcessImageFileNameA".}
|
||||
proc GetProcessImageFileNameW*(hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetProcessImageFileNameW".}
|
||||
when defined(winUnicode):
|
||||
proc GetProcessImageFileName*(hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetProcessImageFileNameW".}
|
||||
else:
|
||||
proc GetProcessImageFileName*(hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: "psapi.dll", importc: "GetProcessImageFileNameA".}
|
||||
47812
lib/windows/windows.nim
47812
lib/windows/windows.nim
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user