Linux Sample Programs

Logging Mechanism and support for Variable Number of Arguments

September 10th, 2008  |  by  |  published in Linux Sample Programs

// Author : Amit Sahrawat // Test program – Allows logging for three types – Error, Info and Warning. Each type // of message can be enabled and disable at the compile time by defining their respective flags // Also each can be controlled at the run time by not setting the bit for the […]

Delete a directory recursively – Linux sample program

September 5th, 2008  |  by  |  published in Linux Sample Programs

// Author : Amit Sahrawat #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h>   #ifdef DEBUG #define TRC_SYSMNGR printf #else #define TRC_SYSMNGR  #endif #include <dirent.h> int deletepath(char *path) {  struct dirent *d = NULL; DIR *dir = NULL; /* pointer to directory head*/ char buf[64]={0}; /* buffer to store the complete file/dir name*/ struct stat […]

TCP Server-Client : Echo string from client

September 4th, 2008  |  by  |  published in Linux Sample Programs

// Author : Amit Sahrawat // Client Program #include <stdio.h> #include <sys/socket.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <netinet/in.h> #define BUFFSIZE 256 #define SERVER_PORT 6401 int main(int argc, char** argv) { int sock; struct sockaddr_in echoserver; char buffer[BUFFSIZE]={0}; unsigned int echolen; int received =0; if(argc<3) { printf(“Usage : cli <serverip> <String> \n”); exit(1); } […]

Subscribe

Get articles in your inbox.

Enter your email address:

Join Us

Twitter Chatter


Recommendations

Archives

Categories