Faster C coding thanks to utilities?
I recently had to implement a deep copy for a cascade of C structs. Structs in structs are easy; structs containing variable length arrays of structs are tougher - you actually need to find the length of the array and copy the structs individually - because those structs also contain arrays of structs.
I did it by running all the C source code through a grep script that pulled out the struct definitions. Within struct definitions I put comments by the arrays I wanted copied and made gawk assemble these into structname_copy() functions - and structname_memdup and structname_memfree functions but that's a side issue. It worked fine but it felt unsatisfactory. The gawk relied on my code being written consistently - it didn't use a C parser, so had I changed my coding style but once the code would have broken. Maintenance is going to be hell.
Are there utilities for doing general parsing of C files, extracting chunks of code and similar? It would be nice to be able to have a set of C utilities that make this sort of thing as easy as running grep on a one-record-per-line data file. That way I gould generate the copy commands in a makefile and be confident that the code it creates will be good, no matter who else has monkeyed with the code in the meantime.