Skip to content

๐Ÿ—ž๏ธ Header only lib for opening web links with C

License

Notifications You must be signed in to change notification settings

ionutrogojan/weblink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Weblink

A header only library for opening links with C.

Works on Linux, MacOS and Windows.

Usage

/*
Both openLink() & openLinks() use a buffered char[] to format the appropriate shell command to open URLs
The URL open command length differs on each OS but 2048 seems to be a safe average size that should work on all of the supported OS
If you decide to define your own size, make sure to place the definition above the include header statement
*/

//#define BUFFER_SIZE 10    // This will work. The header will check for this and use it instead of the default 2048

#include <stdio.h>
#include "weblink.h"

//#define BUFFER_SIZE 10    // This will not work. It will warn as a redefinition

int main(void) {
	char *link = "https://example.com/";
	int res = openLink(link);
	printf("Weblink\n  Status: %d,\n  Url: %s\n", res, link);
	return 0;
}
#include <stdio.h>
#include "weblink.h"

int main(void) {
    // All link arrays must be NULL terminated
	const char *links[] = {
		"https://www.example.com",
		"https://www.youtube.com",
		"https://www.twitter.com",
        NULL
	};
	int res = openLinks(links);
	printf("Weblink\n  Status: %d\n", res);
}

// gcc main.c -o main

About

๐Ÿ—ž๏ธ Header only lib for opening web links with C

Resources

License

Stars

Watchers

Forks

Languages