Skip to content

Simple Github API made with C. Requires cURL installed. Includes Base64 encryption, little JSON support, GithubAPI ( that needs cURL to work ) and strnstr function.

License

Notifications You must be signed in to change notification settings

DozenLimeStone/SimpleGithubAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple Github API made with C language.

Please do not do pull requests, rather comment in issues.
The code is in pretty bad structure. If you find any better solutions, do pull requests

It works briefly for now.

JSON support:
  - is in jsonfind.h header file
  - for now contains only two functions:
    - int jsonfindpairindex(const char* data, const char* key)
      - it finds pair index of given pair key
      - returns -1 if it can't find
    - char* jsongetpairvalue(const char* data, const int pairindex)
      - it finds pair value based on pair index
      - returns NULL if it doesn't succeed
  - I will add more function to jsonfind.h soon.

Base64 encryption:
  - is in base64.h header file
  - got from https://nachtimwald.com/2017/11/18/base64-encode-and-decode-in-c/, slightly modified
  - offers you some functions, important two are base64_encode() and base64_decode(), both accept char* as input. \

Github API:
  - is in githubapi.h header file
  - requires linking curl to work. if you want to lecture me on how to make a library out of my project,
    do comment in issues.
  - every function you need to pass a struct requestdata data type
    - struct requestdata contains:
      - char* token
      - char* link
  - provides you with some basic functions:
    - init ones:
      - void initrequest() initialization
      - void settoken(struct requestdata* data, const char ntoken[]) sets the authentication token,
        https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
      - void setlink(struct requestdata* data, const char nowner[], const char nrepo[]) sets owner and repo to write in
    - freeing ones:
      - void cleanrequest() cleans curl
      - void freetoken() frees token
      - void freelink() frees repo and owner
    - usage ones:
      - char* getfile(struct requestdata* data,const char* path)
      - char* createfile(struct requestdata* data, const char* path, const char* message, const char* content)
      - char* updatefile(struct requestdata* data, const char* path, const char* message, const char* content, const char* sha)
      - char* deletefile(struct requestdata* data, const char* path, const char* message, const char* sha)
      - additional sha argument is needed, you get it by using getfile() and then obtaining the sha value
        using jsonfind.h functions. it is shown in example main file

Strnstr:
  - we should not forget about that! it is licensed, I got it from somewhere
  - details in strnstr.h header file

That was it! Farther details are shown in example main file.
This project will get updated, fixed over time.

About

Simple Github API made with C. Requires cURL installed. Includes Base64 encryption, little JSON support, GithubAPI ( that needs cURL to work ) and strnstr function.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages