Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/uio.h>
- #define WASM_EXPORT __attribute__((visibility("default")))
- typedef struct Rgb {
- int r;
- int g;
- int b;
- char name[50];
- } RGB;
- typedef struct Person {
- char fname[30];
- char name[30];
- } People;
- WASM_EXPORT
- char * introduceYourself() {
- People Marc;
- strcpy(Marc.fname, "Marc");
- strcpy(Marc.name, "I");
- printf("Hello my name is %s \n", Marc.fname);
- People * Ly = malloc(sizeof(People));
- strcpy(Ly->fname, "Ly");
- return Ly->fname;
- }
- WASM_EXPORT
- int main() {
- char lol[50] = {'l','o','l'};
- printf("Value of lol %s \n", lol);
- RGB *sleep = malloc(sizeof(RGB));
- sleep->r = 100;
- sleep->g = 200;
- sleep->b = 255;
- strcpy(sleep->name, "Blue rose");
- printf("Value of r %i \n", sleep->r);
- printf("Name of this beautiful color %s \n", sleep->name);
- }
- /* External function that is implemented in JavaScript. */
- extern putc_js(char c);
- /* Basic implementation of the writev sys call. */
- WASM_EXPORT
- size_t writev_c(int fd, const struct iovec *iov, int iovcnt) {
- size_t cnt = 0;
- for (int i = 0; i < iovcnt; i++) {
- for (int j = 0; j < iov[i].iov_len; j++) {
- putc_js(((char *)iov[i].iov_base)[j]);
- }
- cnt += iov[i].iov_len;
- }
- return cnt;
- }
Add Comment
Please, Sign In to add comment