Posts

Showing posts with the label c programming

randomlib-1.0.1

The random number generator function in the C lib is quite predictable. My friends at LUG@VITU, wrote this function which generates a random number by utilizing the noise level from the devices from a file in /proc . I have made small changes to the make file to create a library when compiled and thus the lib can be directly installed . I have also added make install support to the code .The code is available at : http://www.filekeeper.org/download/eerpini/random_lib-1.0.1.tar.gz

endswith v1.2

the next version of the endswith program which i had started a few weeks ago , is out, this release contains a library function implementation of the endsWith program called iendswith() , a header file has been included in the source code, including this header file and after compiling the library , the function iendwith can be used in regular C programs , ........ unlike the actuall endwith binary, iendswith only returns the number of matches for the given pattern in the given directory ..... i am presently working on a library function implementation which could return the matching file names in the form of a string stype structure, .... but that needs some work,... the included library function is just a rework of the original program. More changes have actually gone into the Makefile , just running make compiles only the binary as usual . Running 'make library' compiles the library function and creates the endswith.a library . A test driver function has also been included...

worries with the main logic of endswith !

reference : http://satisheerpini.blogspot.com/2008/04/endswith-function-in-c.html i have been having enough problems getting the main logic of the endswith function right, .... the code for the main loop in the program which does the string matching is as follows : ____________________________________________________________________________________ for(i=0;i dir_recd_len;i++){ if(i continue ; else{ /* * the first error lay here , i forgot to give the * brackets at (85,19) and (85,45), that gave negative values * during iterations , which was disastrous */ if(argv[2][i-(dir_recd_len-comp_str_len)]==dir_recd->d_name[i]){ flag=1; } else{ flag=0; /* * could not use exit(0) or bre...

endsWith() function in C

well this function already exists in Java , so i just wanted to write a similar thing in C , it was pretty simple work , the source code can be downloaded from , http://filekeeper.org/download/eerpini/endswith-1.0.tar.gz and a lot of things are yet to be added , which can be found in the TO-DO file .

Helper Functions Library in C

A small project has been planned at the LUG@VITU , it consists of coding a simple C library having helper functions which are not available in the standard C library .More details about the project and how to contribute to it can be found here : http://220.225.214.101/node/115

retrieving deleted files from ext3 partitions : ext3grep

ext3grep seems to be one awesome of a creation . It was a result of, what drives most work in this world, ' a personal itch ' . The description and details given by the creator Carlo Wood are too great for me to provide a new definition over here , so take a look at the HOWTO here, http://www.xs4all.nl/~carlo17/howto/undelete_ext3.html , the page has a really good explanation of how ext3 works and how actually ext3grep retrieves the files . You can have a look at the various releases of the utility //code.google.com/p/ext3grep/downloads/list and one can download the latest release from http://ext3grep.googlecode.com/files/ext3grep-0.5.0.tar.gz i bet it is one thing every linux user should have at hand , because as Carlo says , it happens to everyone sooner or later . The utility still need s a lot of testing and improving i guess, so joining the mailing lists would be a great idea .

The __LINE__ macro

i never actually knew that there was a macro provided by ANSI C which contains the current line number of execution , it is the __LINE__ macro here is a sample program to show its usage and after that follows the ouput : int main (){ int a; printf("\nHello testing the use of the __LINE__macro \n"); a=__LINE__; printf("The current line number is 5 \n and the value of __LINE__ is :%d \n",a); return 0 ; } Output: Hello testing the use of the __LINE__macro The current line number is 5 and the value of __LINE__ is :5 the preprocessor directives such as #include do not come under program lines so i have not included them here ....

An app for desgin planning !!

this actually has been rolling in my mind for a long time now , how would it be to design an app, which would make it a click's work to plan for the design and coding of a project or a software application, which would produce text like what i have posted below for the 'diff'ing and'patch'ing application , and along with that also the deadlines, and sort of provide the functionality for adding new goals and decisions dynamically, ? that would be great , i guess, a lot more thinking and discussion has to go in there, but it would be awesome and highly customizable !!!

yum : rollback facility

well actually this concept was first proposed to me by one of my seniors in the following post http://220.225.214.101/node/76 , in short yum is a software manager used in RPM based systems , if u are new to this world u can get more on yum at : http://fedoraproject.org/wiki/Tools/yum what we propose to do here is provide a functionality which rollbacks all the software modifications done by yum to a particular date following are two basic ideas for doing exactly that the first one was what i thought of and the second one a little more innovative was the one suggested by my friend : 1 . parse the contents of the yum.log created by yum and issue a recursive command " rpm -e [package name] --nodeps " , where the user enters a date to rollback to and the [package name] stands for all packages that were installed after that date , this will recursively remove all the files after that date without checking for dependencies , and i planned to do this all in a C program . 2. this ...

a modification to 'make' ??

i was thinking about the way make works , when i had this thought ,..... could i make an entry in the makefile , which would indicate the directory containing the project source code and running make from anywhere with that file as the make file would compile and install binaries from the project directory , so that user who downloads the source code of an utility may not have to always go and run make from that particular directory ,..... especially for a novice user ? what say ? but i am not sure if such a functionality of 'make' already exists or not !!!!

when i started making things with 'make' and makefiles ...........

i was recently coding a sample Qt based widget in C++ whic contained a button and gave an output to the terminal when ever it was clicked ,. .... and had to work with the header which had to be compiled using the MOC ( meta object compiler ) , which i suppose is for working out with the SLOTs and SIGNALs . ....... i then implemented the whole thing with make , that was pretty cool , and in a short time i was using make to do the installation too after my compilation ,..... ( though i wud suggest u first go through some shell scripting before doing this .. if u don wanna confuse yourself wih all the weird '['s and '@'s ...)................ now that is what is called 'making ' made easy !!!