{"id":21418395,"url":"https://github.com/catmengi/dynamicrpc","last_synced_at":"2025-07-14T05:31:00.972Z","repository":{"id":249689015,"uuid":"832248312","full_name":"catmengi/DynamicRPC","owner":"catmengi","description":"C rpc server and client library","archived":false,"fork":false,"pushed_at":"2024-11-14T17:32:32.000Z","size":4756,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-14T18:21:52.193Z","etag":null,"topics":["c","libffi","linux","posix","pure-c","rpc","rpc-client","rpc-framework","rpc-server"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/catmengi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-22T16:09:05.000Z","updated_at":"2024-11-14T17:32:35.000Z","dependencies_parsed_at":"2024-08-25T23:38:52.350Z","dependency_job_id":"cb4a006d-2ca4-4cfd-ae14-c266ec01a022","html_url":"https://github.com/catmengi/DynamicRPC","commit_stats":null,"previous_names":["catmengi/crpc","catmengi/libcrpc","catmengi/dynamicrpc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catmengi%2FDynamicRPC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catmengi%2FDynamicRPC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catmengi%2FDynamicRPC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catmengi%2FDynamicRPC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/catmengi","download_url":"https://codeload.github.com/catmengi/DynamicRPC/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225951826,"owners_count":17550438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","libffi","linux","posix","pure-c","rpc","rpc-client","rpc-framework","rpc-server"],"created_at":"2024-11-22T19:20:45.061Z","updated_at":"2024-11-22T19:20:45.662Z","avatar_url":"https://github.com/catmengi.png","language":"C","readme":"#DynamicRPC\n\n**DynamicRPC** is a pure-c rpc client-server framework, designed to be expandable and doesnt require IDL. Made with libffi to call functions by pointers without know their prototypes at runtime\n\n------------\n\n\n#Build\n\n If you want server-client build you could use something like this\n \n `gcc -c rpc*.c aes.c hashtable.c/hashtable.c tqueque/tqueque.c `\n \n and then link they with your .o files and libffi and pthread\n \n** OR**\n \n `gcc -o some_project rpc*.c aes.c hashtable.c/hashtable.c tqueque.c/tqueque.c -lffi -pthread`\n \n------------\n\n\n#API\n\n**Type system**: \nAll type-system stuff are in [rpctypes.h](http://github.com/catmengi/DynamicRPC/blob/master/rpctypes.h \"rpctypes.h\")\nMost of the types are binding for native C types: **CHAR, STR, UINT16..64, INT16..64, VOID**\n\nOther types are combination of C types or custom types designed to handle structures or \nmulti-dimensional arrays like: **SIZEDBUF, RPCBUFF, RPCSTRUCT**\n\nAlso there are some special types like **PSTORAGE, INTERFUNC, FINGERPRINT**  (DOESNT exist for client side (not passed from client side))\nfor them refer to [rpctypes.h](http://github.com/catmengi/DynamicRPC/blob/master/rpctypes.h \"rpctypes.h\")\n\nAll this types are declared in **enum rpctypes**\nExample of its usage:  `enum rpctypes proto[] = {UINT64, STR, RPCBUFF}`\n\n**NOTE: SIZEDBUF is declared different for server and client, on server it SHOULD be declared with UINT64 in front of it, on client it SHOULD be standalone(without required UINT64), example:**\n\n`enum rpctypes server[] = {SIZEDBUF,UINT64}`\n\n`enum rpctypes client[] = {SIZEDBUF}`\n \n \nexamples of function prototype by server and client\n\nclient:   `enum rpctypes Pread[] = {INT32,SIZEDBUF};`\n\nserver:   `enum rpctypes Pread[] = {INT32,SIZEDBUF,UINT64};`\n\n\n**Note №2: SIZEDBUF is not returnable!**\n------------\n\n\n**RPCBUFF API**\n\n`struct rpcbuff* rpcbuff_create(uint64_t* dimsizes,uint64_t dimsizes_len)`\n\nCreates multi-dimensional array with specified dimension sizes by **dimsizes** and ammount of dimension by **dimsizes_len**, returns ready to use rpcbuff\n\nArguments can be NULL for 1 element rpcbuff\n\n------------\n\n\n`void rpcbuff_free(struct rpcbuff* rpcbuff)`\n\nFree rpcbuff\n\n------------\n\n\n`int rpcbuff_getfrom(struct  rpcbuff* rpcbuff, uint64_t* index, size_t index_len,void* raw,uint64_t* otype_len,enum rpctypes type)`\n\nGet type that matches **type** at **index** with len of **index_len** and unpacks it to **raw** (**SHOULD** be pointer to pointer in case with **SIZEDBUF, STR, RPCBUFF, RPCSTRUCT**)\nreturn 0 on success\n\n------------\n\n\n`int rpcbuff_pushto(struct rpcbuff* rpcbuff, uint64_t* index, size_t index_len, void* ptype,uint64_t type_len,enum rpctypes type)`\n\nPacks and pushes **ptype**( pointer only) with **type** and **type_len** as len (if type is  **SIZEDBUF**)  to an **index** with len of **index len**\nreturn 0 on success\n\n**NOTE** : **RPCBUFF,RPCSTRUCT,STR,SIZEDBUF** are stored by pointers and their modifications will be applyed without rpcbuff_pushto\n\n**NOTE №2** : **STR (also SIZEDBUF)** is copyed on rpcbuff_pushto but not packed, since this, it doesnt need to be freed after rpcbuff_getlast and modifications on pointer got by rpcbuff_getlast will be applyed immidiatly\n\n------------\n\n\n`void rpcbuff_remove(struct rpcbuff* rpcbuff, uint64_t* index, size_t index_len)`\n\nRemove type at **index** with len of **index_len**\n\n------------\n\n\n`void rpcbuff_unlink(struct rpcbuff* rpcbuff, uint64_t* index, size_t index_len)`\n\nMarks type at specified **index** with len of **index_len** to NOT be freed by `rpcbuff_free`\n\n\n\n**RPCSTRUCT API**\n\n  NOT DONE YET, please refer to [rpctypes.h](http://github.com/catmengi/DynamicRPC/blob/master/rpctypes.h \"rpctypes.h\")\n  \n  \n  \n\n------------\n\n**Server API**\n\n`struct rpcserver* rpcserver_create(uint16_t port)` \n\ncreates new server at specified **port**; return struct rpcserver* at success\n\n------------\n\n\n`void rpcserver_start(struct rpcserver* rpcserver)`  starts server main thread\n\n`void rpcserver_free(struct rpcserver* serv); `        stops and free server\n\n`void rpcserver_stop(struct rpcserver* serv); `        stops but doesnt free\n\n------------\n\n\n`int rpcserver_register_fn(struct rpcserver* serv, void* fn, char* fn_name,\n                          enum rpctypes rtype, enum rpctypes* fn_arguments,\n                          uint8_t fn_arguments_len, void* pstorage,int perm)`\n\t\t\t\t\t\t\t\t\t   \nThis function registers function pointer **fn** with **fn_name**, return type specified by **rtype**,\nprototype specified by **fn_arguments** and ammount of them specified by **fn_arguments_len**.\nAlso it sets pointer that will be used in **PSTORAGE** type (can be NULL), and minimal permission to call it by **perm**\n\n`void rpcserver_add_key(struct rpcserver* serv, char* key, int perm);`\nAdds a key with a permission **perm** into a server\n\n\n------------\n\n`void rpcserver_set_interfunc(struct rpcserver* self, void* interfunc);`\nSet pointer for INTERFUNC type\n\n------------\n\n**there are also some APIs not covered here** refer to [rpcserver.h](https://github.com/catmengi/DynamicRPC/blob/master/rpcserver.h \"rpcserver.h\") for them\n\n------------\n\n**Client API**\n\n`struct rpcclient* rpcclient_connect(char* host,int portno,char* key)`\n\nconnects to a server by address **host**, at port **portno** with **key** as password\nreturn **struct rpcclient** pointer on success or NULL on failures\n\n\n\n\n`int rpcclient_call(struct rpcclient* self,char* fn,enum rpctypes* fn_prototype,char* flags, uint8_t fn_prototype_len,void* fnret,...)`\n\nCalls a function with name **fn**, with prototype **fn_prototype**, flags **flags**, len of prototype and flags is **fn_prototype_len**, **fnret** is a pointer to a memory where function result will be placed. Function arguments will be in **variable arguments** of a rpcclient_call\n\nFlags stand for should this argument will be resened to a client, it supports folowing type:\n**SIZEDBUF,STR,RPCBUFF,RPCSTRUCT**. If flags is NULL none of arguments will be resended.\n\nArguments are passed like in printf, but with folowing exceptions\n1. **SIZEDBUF** is passed as char*,uint64_t\n\n\n**NOTE** : currently return will be ALWAYS SEPARATED and in DIFFERENT chunk of memory than ANY arguments (even if on server side function returns passed argument with pointer type) because current rpc protocol doesnt know is return are one of arguments\n\n\n\n\n`void rpcclient_disconnect(struct rpcclient* self)` \nDisconnects from server\n\n\n------------\n\n\n`char* rpcclient_get_fingerprint(struct rpcclient* self)`\n\nGet unique string of client, same as FINGERPRINT type on server\n\n\n**there are also some APIs not covered here** refer to [rpcclient.h](https://github.com/catmengi/DynamicRPC/blob/master/rpcclient.h \"rpcclient.h\") for them\n\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatmengi%2Fdynamicrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatmengi%2Fdynamicrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatmengi%2Fdynamicrpc/lists"}