Trunk-based Development vs. Git Flow

2017-12-18 12 min read C Programs
In order to develop quality software, we need to be able to track all changes and reverse them if necessary. Version control systems fill that role by tracking project history and helping to merge changes made by multiple people. They greatly speed up work and give us the ability to find bugs more easily. Moreover, working in distributed teams is possible mainly thanks to these tools. They enable several people to work on different parts of a project at the same time and later join their results into a single product. Continue reading

web services in c with cgi

2016-06-13 2 min read C Programs
I was trying to setup a simply webservice to reply to POST requests. Earlier this was being done in tomcat which seem a little overkill to me since I already had a webserver up and running. So, a quick c program to respond to request is all that I needed. And here is the result. /* * ===================================================================================== * * Filename: Login.cpp * * Description: * * Version: 1.0 * Revision: none * Compiler: gcc * * Author: Amit Agarwal (), * Organization: * * == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == = */ #include <stdio . Continue reading

C program to get the ascii string from a string

2012-07-25 1 min read C Programs
Example diagram of the printf function in the C programming language (Photo credit: Wikipedia) Lot of times, you would like to get the complete string in hex or ascii format and if you are one of them then this is something that will be helpful for you 🙂 Example output: lp-amita[d=~/bin]> ./ascii aamit String – aamit, Length – 5 String : aamit Hex : 0x61616d6974 Dec : 9797109105116 And the source code: Continue reading

colorgcc – Color your compiler output on Fedora

2012-07-11 2 min read C Programs Fedora
Lets start with installing colorgcc : sudo yum install colorgcc Now once that is done, you will need to ensure that the call to g++, gcc and others that you want to use, you will need to create a link in the “~/bin” directory, like so: for i in g++ gcc c++ cc do ln -s $(which colorgcc) ~/bin/$i done The one liner above will create the links for colorgcc as **** your favourite compiler in your homedir. Continue reading

Convert string to hex.

2012-04-13 1 min read C Programs
If you want to use snoop or tcpdump with advanced search in the packet, then you would need to convert the string to hex string. For this, either you can use a web search and find some web application to do that or you can use a simple C program like this 🙂 /* * ===================================================================================== * * Filename: ascii.c * * Description: ascii to dec * * Version: 1.0 * Ceated: 03/02/2012 12:08:49 PM * Revision: none * Compiler: gcc * * Author: Amit Agarwal (aka), amit. Continue reading

Inotify Example - Introduction to Inotify with a C Program Example

2010-05-24 1 min read C Programs Learning Linux
<a href="http://www.thegeekstuff.com/2010/04/inotify-c-program-example/">Inotify Example: Introduction to Inotify with a C Program Example: <a class="zem_slink freebase/en/inotify" href="http://en.wikipedia.org/wiki/Inotify" title="Inotify" rel="wikipedia">inotify utility is an effective tool to monitor and notify <a class="zem_slink freebase/en/file_system" href="http://en.wikipedia.org/wiki/File_system" title="File system" rel="wikipedia">filesystem changes. You can specify a list of files and directories that needs to be monitored by inotify. This <a class="zem_slink freebase/guid/9202a8c04000641f8000000000023d0f" href="http://en.wikipedia.org/wiki/Library" title="Library" rel="wikipedia">library is used by various other programs. For example, <a class="zem_slink freebase/en/cpan" href="http://www.cpan.org/" title="CPAN" rel="homepage">CPAN module Linux::Inotify is developed based on this library. Continue reading

Last access time for file

2010-02-03 1 min read C Programs Linux
The C program will print the last access time for the file. This is quite helpfull program when you want to find old files. Modifying the source to take the filename as argument and take multiple arguments is left as an exercise. #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <time.h> #include <stdlib.h> int main(void) { char datestring[80]; struct stat a; //int fd = open("ak",O_RDONLY); if (stat ("iptc.c", &a) == -1) { Continue reading