search algorithm for GNU source installer

/* Search API Algorithm  Copyright (c) 2012 Jeffrin Jose

 This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
     (at your option) any later version.

 This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
     along with this program (look for the file called COPYING);
     if not, write to the Free Software Foundation, Inc.,
         51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

     You can contact the author (Jeffrin Jose) by sending a mail


int main(int argc, char *argv[]) {
int i =0;
char *p;
FILE *sfile;
char buffer[200];
char *sword = "htop"; /* word to search */
bool found = false;
struct passwd *pw = getpwuid(getuid());

char *homedir = pw->pw_dir;
const char *plocation = "/.sourceinstall/packages";
/* printf("%sn",homedir); */
const char *npath = strcat(homedir,plocation);
int value = chdir(npath);
DIR *opendirp = opendir(npath);
struct dirent *d;
while ((d = readdir(opendirp)) != NULL )
/* for (i=0;id_name,"r");
while (!found && (fgets(buffer, sizeof(buffer), sfile ) != 0))
found = strstr(buffer,sword);
/* printf("%dn",found); */
if (found == 1)
printf("found in: %sn",d->d_name);

/* printf("%d %dn",value,errno); */
/* printf("%sn",d->d_name); */

return 0;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s