
{"id":7023,"date":"2012-04-02T12:36:14","date_gmt":"2012-04-02T12:36:14","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=7023"},"modified":"2012-04-02T12:36:14","modified_gmt":"2012-04-02T12:36:14","slug":"search-algorithm-for-gnu-source-installer","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2012\/04\/02\/search-algorithm-for-gnu-source-installer\/","title":{"rendered":"search algorithm for GNU source installer"},"content":{"rendered":"<pre>\n\/* Search API Algorithm  Copyright (c) 2012 Jeffrin Jose\n\n\n This program is free software; you can redistribute it and\/or modify\n     it under the terms of the GNU General Public License as published by\n the Free Software Foundation; either version 3 of the License, or\n     (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n     but WITHOUT ANY WARRANTY; without even the implied warranty of\n     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n     GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n     along with this program (look for the file called COPYING);\n     if not, write to the Free Software Foundation, Inc.,\n         51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n     You can contact the author (Jeffrin Jose) by sending a mail\n     to jeffrin@rocketmail.com\n*\/\n\n#include&lt;stdio.h&gt;\n#include&lt;sys\/stat.h&gt;\n#include&lt;sys\/types.h&gt;\n#include&lt;pwd.h&gt;\n#include&lt;unistd.h&gt;\n#include&lt;string.h&gt;\n#include&lt;errno.h&gt;\n#include&lt;dirent.h&gt;\n#include&lt;stdbool.h&gt;\n\n\nint main(int argc, char *argv[]) {\nint i =0;\nchar *p;\nFILE *sfile;\nchar buffer[200];\nchar *sword = \"htop\"; \/* word to search *\/\nbool found = false;\nstruct passwd *pw = getpwuid(getuid());\n\nchar *homedir = pw-&gt;pw_dir;\nconst char *plocation = \"\/.sourceinstall\/packages\";\n\/* printf(\"%sn\",homedir); *\/\nconst char *npath = strcat(homedir,plocation);\nint value = chdir(npath);\nDIR *opendirp = opendir(npath);\nstruct dirent *d;\nwhile ((d = readdir(opendirp)) != NULL )\n\/* for (i=0;id_name,\"r\");\nwhile (!found &amp;&amp; (fgets(buffer, sizeof(buffer), sfile ) != 0))\n{\nfound = strstr(buffer,sword);\n}\n\/* printf(\"%dn\",found); *\/\nif (found == 1)\nprintf(\"found in: %sn\",d-&gt;d_name);\nfclose(sfile);\n\n\/* printf(\"%d %dn\",value,errno); *\/\n\/* printf(\"%sn\",d-&gt;d_name); *\/\n}\nclosedir(opendirp);\n\nreturn 0;\n}\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/* 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 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2012\/04\/02\/search-algorithm-for-gnu-source-installer\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;search algorithm for GNU source installer&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/7023"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=7023"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/7023\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=7023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=7023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=7023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}