> `g_file_new_for_uri()` and `g_file_read()` (or 
> `g_file_read_async()/g_file_read_finish()`

It works...
```C

#include <gio/gio.h>
#include <stdio.h>

int main() {
  GFile *file = g_file_new_for_uri("https://geany.org/service/version/";);

  GError *error = NULL;
  GFileInputStream *stream = g_file_read(file, NULL, &error);

  if (!error) {
    printf("No error.\n");

    guint8 *buffer = NULL;
    gsize size = 0;

    buffer = (guint8 *)g_malloc(32);

    gboolean success = g_input_stream_read_all((GInputStream *)stream, buffer,
                                               32, &size, NULL, &error);

    if (success) {
      buffer[size] = '\0';
      printf("Data: %s\n", buffer);
    } else {
      printf("Error reading stream.\n");
    }

  } else {
    printf("Error reading uri.\n");
  }

  return 0;
}
```

```bash
$ gcc test.c -o test $(pkgconf --libs gio-2.0) $(pkgconf --cflags gio-2.0)

$ ./test
No error.
Data: 2.0.0
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/pull/1336#issuecomment-2078546850
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany-plugins/pull/1336/[email protected]>

Reply via email to