Library management project made for 1st year CS102 Lab course at BIT Mesra. Completely written in C.
Explanation of file structure :
main.cimplements basic application code.logger.handlogger.cprovide basic logging functionalities.fileops.handfileops.cprovide basic read write function for complex data to file. Used bybookandlibrarymodules.book.handbook.chandles read/write functionality for single book data.library.handlibrary.chandles create/read/update/delete (CRUD) functionality for whole library database.booklist.handbooklist.hhandles events for items in book list.addbook.handaddbook.chandles events for add book button.dialog.handdialog.cprovides a way to display messages like a popup.appstate.handappstate.cprovides a struct that can be accessed globally throught the project.menu.his not being used in project!
- Install
msys2for 64 bit on your system. Performpacman -Syyuin msys terminal to update repos and packages. - Install gtk4 for mingw.
- Install cmake.
- Confirm whether pkg-config and make are installed or not.
- Create build directory in cloned folder.
- Goto build directory in msys terminal and do
cmake .. -G "MinGW MakeFiles" && make -j2 - Copy all .ui files from ui directory in project root to build directory.
- Run
mainexecutable. - All Done!
- Install gtk4, cmake, make and other dependencies from your package manager.
- Create build directory in cloned folder.
- Goto build directory in terminal and run
cmake .. && make -j2 - Copy all .ui files from ui directory in project root to build directory.
- Run
mainexecutable. - All Done!
- When saving a string data in file, first we store the size of string by dumping a
size_tvariable that contains size of string and then the string is written to file. This makes it easier to determine the actual string size beforehand and we can allocate exact memory required to string to be loaded before reading it in memory. - Most of the memory allocations done are dynamic (use of
malloc). - Create and Destroy functions are implemented for structs like
LibraryandBookin order to handle automatic destruction in one call. - This means when a
Librarystruct is destroyed, allBookstructs and data inside theseBookstructs are destroyed. - Whenever reading/writing data from/to a file, always check the size of data read/written and compare with the actual data size. If the size does not match then raise an error by calling
LogError. - Before dumping a block of data, for e.g.
Bookdata, a signatureLIMSBOOKSTARTis written and in the end, end signatureLIMSBOOKENDis written. This is to mark the start and end of aBookdata block. Although this is not necessary, this can give hints whether the data is altered/tampered or not. Similary when dumping library data,LIMSLIBDBSTARTandLIMSLIBDBENDsignatures are used. - There is a global appstate maintained throught the project. This struct is used to access data that can be required by any function and is hard to pass in callback functions.
The code is heavily commented itself and with a little effort it'll be easy to understand what's being done and why it's being done that way!

To the extent possible under law,
Siddharth Mishra
has waived all copyright and related or neighboring rights to
Library Management System.
This work is published from:
India.
