about summary refs log tree commit diff stats
path: root/adapter
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-07-18 17:54:17 +0200
committerbptato <nincsnevem662@gmail.com>2024-07-18 17:54:17 +0200
commit78274acde82186f1062acbf24c96e977e152b184 (patch)
tree1722281a1f97a689326f1f6279897b810683ca84 /adapter
parentc8d7a2a27720056fc60a5d67b56f515af4442cf4 (diff)
downloadchawan-78274acde82186f1062acbf24c96e977e152b184.tar.gz
stbi: fix incompatible function pointer type
clang complains about this
Diffstat (limited to 'adapter')
-rw-r--r--adapter/img/stbi.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/adapter/img/stbi.nim b/adapter/img/stbi.nim
index f32c7f77..f4a5faa2 100644
--- a/adapter/img/stbi.nim
+++ b/adapter/img/stbi.nim
@@ -13,7 +13,7 @@ import utils/twtstr
 {.push header: "stb_image.h".}
 
 type stbi_io_callbacks {.importc.} = object
-  read: proc(user: pointer; data: ptr uint8; size: cint): cint {.cdecl.}
+  read: proc(user: pointer; data: ptr char; size: cint): cint {.cdecl.}
   skip: proc(user: pointer; n: cint) {.cdecl.}
   eof: proc(user: pointer): cint {.cdecl.}
 
@@ -30,7 +30,7 @@ proc stbi_image_free(retval_from_stbi_load: pointer) {.importc.}
 
 {.pop.}
 
-proc myRead(user: pointer; data: ptr uint8; size: cint): cint {.cdecl.} =
+proc myRead(user: pointer; data: ptr char; size: cint): cint {.cdecl.} =
   return cint(stdin.readBuffer(data, size))
 
 proc mySkip(user: pointer; n: cint) {.cdecl.} =
59' href='#n159'>159 160 161 162 163 164 165 166 167
<!DOCTYPE html>
<html dir="ltr" lang="en">
    <head>
	<meta charset='utf-8'>
	<title>Libraries</title>
    </head>
    <body>
	<a href="../index.html">Development Index</a>


	<h1>Libraries</h1>

	<h2>Basic</h2>

	<dl>
	    <dt>include &lt;unistd.h&gt;</dt>
	    <dd>fork, pipe and I/O primitives (read, write, close, etc.)
	    + primitve types like uid_t, pid_t etc</dd>

	    <dt>#include &lt;stdlib.h&gt;</dt>
	    <dd>Standard lib, contains primitves for number conversion
	    and memory allocation</dd>
	    <dt>#include &lt;stdio.h&gt;</dt>
	    <dd>Basic i/o lib: printf etc</dd>

	    <dt>#include &lt;string.h&gt;</dt>
	    <dd>String manipulations</dd>

	    <dt>#include &lt;time.h&gt;</dt>
	    <dd>Time related functions</dd>

	    <dt>#include &lt;signal.h&gt;</dt>
	    <dd>Signal handling</dd>

	    <dt>#include &lt;stdbool.h&gt;</dt>
	    <dd>Boolean type</dd>

	    <dt>#include &lt;math.h&gt;</dt>
	    <dd>Math functions</dd>
	</dl>

	<h2>Advanced</h2>
	<dl>
	    <dt>#include &lt;sys/socket.h&gt;</dt>
	    <dd> socket connections</dd>
	    <dt>#include &lt;sys/types.h&gt;</dt>
	    <dd> primitive types like uid_t, pid_t etc</dd>

	    <dt>#include &lt;netinet/in.h&gt;</dt>
	    <dd> internet address family</dd>

	    <dt>#include &lt;arpa/inet.h&gt;</dt>
	    <dd> definitions for internet operations</dd>

	    <dt>#include &lt;pthread.h&gt;</dt>
	    <dd> threads</dd>

	    <dt>#include &lt;stdatomic.h&gt;</dt>
	    <dd> mutual exclusion locks</dd>

	</dl>

	<h2>Stdio</h2>

	<h3>File Modes</h3>

	<pre>
	mode    Description
	"r"     Opens a file for reading. The file must exist.
	"w"     Creates an empty file for writing. If a file with the same name already exists, its content is erased and the file is considered as a new empty file.
	"a"     Appends to a file. Writing operations, append data at the end of the file. The file is created if it does not exist.
	"r"     Opens a file to update both reading and writing. The file must exist.
	"w"     Creates an empty file for both reading and writing.
	"a"     Opens a file for reading and appending.
	</pre>

	<pre>
	// ERROR: result == NULL (also when EOF is reached)
	char *fgets(char *str, int strlen, FILE *stream);

	// ERROR: result == NULL
	FILE *fopen(const char *filename, const char *mode);

	// result == EOF when finished reading the stream
	// SUCCESS: number of matched items on success
	int fscanf(FILE *stream, const char *format, ...);

	// ERROR: result == EOF
	// SUCCESS: result == 0
	int fclose(FILE *stream);

	// ERROR: result == -1
	// SUCCESS: number of bytes written
	ssize_t write(int fildes, const void *buf, size_t nbyte);

	// ERROR: result == -1
	// EOF when finished reading
	// SUCCESS: number of bytes read
	ssize_t read(int fildes, void *buf, size_t nbyte);

	// SUCCESS: result > 0
	// ERROR: result == EOF
	int fputs(const char *restrict s, FILE *restrict stream);
	</pre>

	<h2>Strings</h2>

	<pre>
	// SUCCESS: pointer to destination string
	char *strcpy(char *dest, const char *src);

	// result == 0 -&gt; strings are equal
	// result &lt; 0 -&gt; str1 less than str2
	// result &gt; 0 -&gt; str2 less than str1
	int strcmp(const char *str1, const char *str2);;


	// result == NULL -&gt; no tokens left to retrieve
	// else: pointer to last token found
	char *strtok(char *str, const char *delim);

	// NULL if no match
	// else: pointer to first occurence in string
	char *strstr(const char *string, const char *substring);

	// ERROR: result == 0
	int atoi(const char *str);
	</pre>

	<h2>Networking</h2>

	<pre>
	// ERROR: result == -1
	// example: sock = socket(AF_INET, SOCK_STREAM, 0);
	int socket(int domain, int type, int protocol);

	// sockaddr_in struct (man ip 4)
	struct sockaddr_in server;
	server.sin_family = PF_INET;
	server.sin_addr.s_addr = INADDR_ANY;
	server.sin_port = htons(8080);

	// ERROR: result &lt; 0
	// SUCCESS: result == 0
	// example: bind(sock, (struct sockaddr *) &server, sizeof(server))
	int bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen);

	// ERROR: result &lt; 0
	// SUCCESS: filedeskriptor for accepted socket
	// example: fd = accept(sock, (struct sockaddr *) &client, &client_len);
	int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);

	// SUCCESS: result == 0
	// ERROR: result == -1
	int listen(int socket, int backlog);
	</pre>

	<a href="../index.html">Development Index</a>

	<p>
	This is part of the c9-doc Manual.
	Copyright (C) 2018
	c9 team.
	See the file <a href="../../fdl-1.3-standalone.html">Gnu Free Documentation License</a>
	for copying conditions.</p>
    </body>
</html>