diff options
author | Araq <rumpf_a@web.de> | 2011-07-28 00:53:52 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-07-28 00:53:52 +0200 |
commit | 2f066395baf0dd290bfdbb8ee47a64a17c932b14 (patch) | |
tree | 3cab7059beb39e763e64521b2c0f84983e64deb9 /lib | |
parent | e7135c449d065eaf3ea6d2ed06fd33cb62e5e44f (diff) | |
download | Nim-2f066395baf0dd290bfdbb8ee47a64a17c932b14.tar.gz |
bugfixes; step one for 'var T' as return type support
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/pure/smtp.nim | 12 | ||||
-rwxr-xr-x | lib/pure/streams.nim | 2 | ||||
-rwxr-xr-x | lib/pure/strtabs.nim | 10 | ||||
-rwxr-xr-x | lib/wrappers/gtk/glib2.nim | 2 |
4 files changed, 19 insertions, 7 deletions
diff --git a/lib/pure/smtp.nim b/lib/pure/smtp.nim index bddcdfb04..0dd9f3eca 100755 --- a/lib/pure/smtp.nim +++ b/lib/pure/smtp.nim @@ -1,7 +1,7 @@ # # # Nimrod's Runtime Library -# (c) Copyright 2010 Dominik Picheta +# (c) Copyright 2011 Dominik Picheta # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -87,7 +87,7 @@ proc checkReply(smtp: TSMTP, reply: string) = proc connect*(address: string, port = 25, ssl = false, debug = false): TSMTP = ## Establishes a connection with a SMTP server. - ## May fail with EInvalidReply or with a socket errors. + ## May fail with EInvalidReply or with a socket error. if not ssl: result.sock = socket() @@ -125,7 +125,6 @@ proc sendmail*(smtp: TSMTP, fromaddr: string, ## Sends `msg` from `fromaddr` to `toaddr`. ## Messages may be formed using ``createMessage`` by converting the ## TMessage into a string. - ## This function sends the QUIT command when finished. smtp.debugSend("MAIL FROM:<" & fromaddr & ">\c\L") smtp.checkReply("250") @@ -139,8 +138,9 @@ proc sendmail*(smtp: TSMTP, fromaddr: string, smtp.debugSend(msg & "\c\L") smtp.debugSend(".\c\L") smtp.checkReply("250") - - # quit + +proc close*(smtp: TSMTP) = + ## Disconnects from the SMTP server and closes the socket. smtp.debugSend("QUIT\c\L") if not smtp.ssl: smtp.sock.close() @@ -201,6 +201,6 @@ when isMainModule: smtp.auth("someone", "password") smtp.sendmail("someone@gmail.com", @["someone@yahoo.com", "someone@gmail.com"], $msg) - + smtp.close() diff --git a/lib/pure/streams.nim b/lib/pure/streams.nim index 242e40d83..62cb385d4 100755 --- a/lib/pure/streams.nim +++ b/lib/pure/streams.nim @@ -1,7 +1,7 @@ # # # Nimrod's Runtime Library -# (c) Copyright 2009 Andreas Rumpf +# (c) Copyright 2011 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. diff --git a/lib/pure/strtabs.nim b/lib/pure/strtabs.nim index 2028daa50..584282fbc 100755 --- a/lib/pure/strtabs.nim +++ b/lib/pure/strtabs.nim @@ -92,6 +92,14 @@ proc `[]`*(t: PStringTable, key: string): string {.rtl, extern: "nstGet".} = if index >= 0: result = t.data[index].val else: result = "" +proc modGet*(t: PStringTable, key: string): var string {. + rtl, extern: "nstTake".} = + ## retrieves the location at ``t[key]``. If `key` is not in `t`, the + ## ``EInvalidValue`` exception is raised. + var index = RawGet(t, key) + if index >= 0: result = t.data[index].val + else: raise newException(EInvalidValue, "key does not exist: " & key) + proc hasKey*(t: PStringTable, key: string): bool {.rtl, extern: "nst$1".} = ## returns true iff `key` is in the table `t`. result = rawGet(t, key) >= 0 @@ -213,4 +221,6 @@ when isMainModule: assert x["k"] == "v" assert x["11"] == "22" assert x["565"] == "67" + x.modGet("11") = "23" + assert x["11"] == "23" diff --git a/lib/wrappers/gtk/glib2.nim b/lib/wrappers/gtk/glib2.nim index acb85c194..9947e2a4b 100755 --- a/lib/wrappers/gtk/glib2.nim +++ b/lib/wrappers/gtk/glib2.nim @@ -4505,3 +4505,5 @@ proc G_TYPE_GSTRING*(): GType = proc g_thread_init*(vtable: pointer) {. cdecl, dynlib: gobjectlib, importc: "g_thread_init".} +proc g_timeout_add*(interval: guint, function, data: gpointer): guint {. + cdecl, dynlib: gliblib, importc: "g_timeout_add".} |