1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net: fix warnings due to uppercase consts

This commit is contained in:
Delyan Angelov 2020-05-24 07:39:44 +03:00
parent 85d19dd253
commit 06540f0e91

View File

@ -292,14 +292,14 @@ pub fn (s Socket) close() ?int {
} }
pub const ( pub const (
CRLF = '\r\n' crlf = '\r\n'
MAX_READ = 400 max_read = 400
MSG_PEEK = 0x02 msg_peek = 0x02
) )
// write - write a string with CRLF after it over the socket s // write - write a string with CRLF after it over the socket s
pub fn (s Socket) write(str string) ?int { pub fn (s Socket) write(str string) ?int {
line := '$str$CRLF' line := '$str$crlf'
res := C.send(s.sockfd, line.str, line.len, msg_nosignal) res := C.send(s.sockfd, line.str, line.len, msg_nosignal)
if res < 0 { if res < 0 {
return error('net.write: failed with $res') return error('net.write: failed with $res')
@ -309,11 +309,11 @@ pub fn (s Socket) write(str string) ?int {
// read_line - retrieves a line from the socket s (i.e. a string ended with \n) // read_line - retrieves a line from the socket s (i.e. a string ended with \n)
pub fn (s Socket) read_line() string { pub fn (s Socket) read_line() string {
mut buf := [MAX_READ]byte // where C.recv will store the network data mut buf := [max_read]byte // where C.recv will store the network data
mut res := '' // The final result, including the ending \n. mut res := '' // The final result, including the ending \n.
for { for {
mut line := '' // The current line. Can be a partial without \n in it. mut line := '' // The current line. Can be a partial without \n in it.
n := C.recv(s.sockfd, buf, MAX_READ - 1, MSG_PEEK) n := C.recv(s.sockfd, buf, max_read - 1, msg_peek)
if n == -1 { if n == -1 {
return res return res
} }
@ -347,7 +347,7 @@ pub fn (s Socket) read_line() string {
// recv returned a buffer without \n in it . // recv returned a buffer without \n in it .
C.recv(s.sockfd, buf, n, 0) C.recv(s.sockfd, buf, n, 0)
res += line res += line
res += CRLF res += crlf
break break
} }
return res return res
@ -355,10 +355,10 @@ pub fn (s Socket) read_line() string {
// TODO // TODO
pub fn (s Socket) read_all() string { pub fn (s Socket) read_all() string {
mut buf := [MAX_READ]byte // where C.recv will store the network data mut buf := [max_read]byte // where C.recv will store the network data
mut res := '' // The final result, including the ending \n. mut res := '' // The final result, including the ending \n.
for { for {
n := C.recv(s.sockfd, buf, MAX_READ - 1, 0) n := C.recv(s.sockfd, buf, max_read - 1, 0)
if n == -1 { if n == -1 {
return res return res
} }