Hi! Finished working on an interface beetwen the database and my server code, it was really too messy earlier. So i made an interface that manages caching and retrieving the data, the only downside is that the data it returns (pointers to the cache) is completely immutable outside of the interface, so for every update you necessarily need to call update_user or update_channel or appropriate caching functions, other than that it should work pretty well and i made my previous example 1000 times simpler (in the photos I’ll provide a before and after).
How i made it
So while coding this new interface I encountered some problems, first of all I’m gonna remind myself to never use databases in C, i really hate all that boilerplate :d. I decided to make the interface pretty specific on users and channels, if i ever need to add anything to my database it’s gonna be a pain but I dont plan to do that (outside of files but those will come later), I also decided to use arena’s to manage memory in the cached user and channel struct because it’s cleaner cleanup. For last I was going to make a check_credentials function for log in but i decided to do that later as I need to implement hashing and md5 and that will be another dependancy. I think the next feature I’m gonna work on is probably making a decent client, if I continue the server I’m gonna have a functioning server without a client to serve. Later guys!