hi forthers,
I am trying to do a (very simple and naive) http-request
with gforth (current from git):
[...]
okflo@teletyp.ist writes:
- I use global variables (in the dictionary) for curl-data and
response-code. What would be the right way to do this locally in
http-request? The usual locals are on a stack IMHO - so I would need
to allocate cells?
- What is the best way, to convert an sstring to a cstring? I was
wondering, that there is a cstring>sstring in gforth, but not the
other way sstring>cstring?
: >cstring ( addr u -- c-string-addr )
[ s\" \0" ] 2literal s+ drop ;
s" GET" >cstring constant method-get
s" POST" >cstring constant method-post
s" PUT" >cstring constant method-put
s" DELETE" >cstring constant method-delete
s" PATCH" >cstring constant method-patch
okflo@teletyp.ist writes:
okflo@teletyp.ist writes:
- I use global variables (in the dictionary) for curl-data and
response-code. What would be the right way to do this locally in
http-request? The usual locals are on a stack IMHO - so I would need
to allocate cells?
It seems to me that variable-flavoured locals would work here, i.e.:
: http-request ( method url-addr url-len -- status content-addr content-len )
{: w^ curl-data w^ response-code :}
anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
okflo@teletyp.ist writes:
okflo@teletyp.ist writes:
- I use global variables (in the dictionary) for curl-data and
response-code. What would be the right way to do this locally in
http-request? The usual locals are on a stack IMHO - so I would need
to allocate cells?
It seems to me that variable-flavoured locals would work here, i.e.:
: http-request ( method url-addr url-len -- status content-addr content-len ) >> {: w^ curl-data w^ response-code :}
Actually:
: http-request ( method url-addr url-len -- status content-addr content-len )
0 0 {: w^ curl-data w^ response-code :}
- anton
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,075 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 88:10:13 |
| Calls: | 13,797 |
| Files: | 186,989 |
| D/L today: |
4,538 files (1,290M bytes) |
| Messages: | 2,438,141 |