I had a rather useful day yesterday. I started working on involving myself in Glib as this is a cross platform library not dissimilar to my own(only more feature rich, stable and mature) and includes some interesting and useful constructs notably the wide ranging data structures, regular expression support(yay!), and cross platform IPC mechanisms among other things. I did notice that the similarities include a command line parsing routine, file utilities, string utilities, a .ini style configuration file parser, threading support(albeit mine is simplistic). It doesn’t however have any specific support for networking sockets but I suspect that's because they don't think its necessary due to native BSD Sockets being implemented in all OSs.
Another interesting omission is encryption and compression routines, again I suspect that's because their are better solutions out there already namely libssl and gxip/bzip etc. Still, I like the idea of my library having some ‘small’ support for these – like in the future perhaps support for ceaser cipher or ROT ciphers – that sort of thing – weak but still something to protect text. I think basically glib is the library that mine is trying to be though it will never compete unless it really focuses on issues not already achieved by glib.
I looked at implementing RSA in C using libssl and was surprised to realise that one cannot encrypt anything larger than the size of the key used, say 2048-bit. The idea makes sense in as much as you’d only encrypt using RSA a special key that you then transmit insecurely. That key obviously being a symmetric key used for the encryption/decryption of the data being sent. But prior to that public/private keys are used to encrypt this symmetric key (which again can’t be bigger than the RFA key size used for the public/private key combination).
Here is a autotools recipe to build glib linked apps under a posix environment (I’m using autotools for cross platform compatibility but initially used MinGW under Windows 10).
AC_PREREQ([2.67]) AC_INIT([glib_test], [0.1], [email@example.com]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_SRCDIR() AC_CONFIG_HEADERS([config.h]) # Checks for programs. AC_PROG_CC PKG_PROG_PKG_CONFIG([0.27]) PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.26.0]) # Checks for libraries. AC_SUBST([GLIB_CFLAGS]) AC_SUBST([GLIB_LIBS]) # Checks for header files. # Checks for typedefs, structures, and compiler characteristics. # Checks for library functions. AC_CONFIG_FILES([Makefile]) AC_OUTPUT
I basically downloaded the Windows binary of the GTK+ drawing library because it includes glib (cunning indeed) and its this that actually guided me through the process.
In other news I did read up on book about ANSI SQL, a book by Ben Forta called “SQL in 10 Minutes” – you can get it from Amazon here if you’d also like to read it.
It basically took me most of the afternoon to read, in between the Scotland-Ireland(Scotland nipped a win) and England/France(England won) rugby matches incidentally. Of the content of the book a few concepts were welcome additions to my knowledge: Transaction managment such as the statements:
BEGIN TRANSACTION -- Do stuff SAVE TRANSACTION point1 -- Do more stuff ROLLBACK TRANSACTION point1 -- Do more stuff after rollback COMMIT TRANSACTION
Which is all about dealing with errors and partial commits. Then the aspects around Group By’s HAVING syntax in contrast to WHERE syntax, where the former is about filtering groups down and the latter about filtering rows down(has no concept of groups). I also learned about check constraints which I’d never touched on before. I finally figured out why CURSOR constructs are used though, I’m not sure I like the amount of work one has to do with them. All in all a good book I’d say – to the point, concise and covering most of what you need to know to be a generalist SQL programmer.