find_text.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : find_text                                                         *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *******************************************************************************
00007 * Copyright (c) 2004-$now By Author.  This program is free software; you can  *
00008 * redistribute it and/or modify it under the terms of the GNU General Public  *
00009 * License as published by the Free Software Foundation; either version 2 of   *
00010 * the License or (at your option) any later version.  This is online at:      *
00011 *     http://www.fsf.org/copyleft/gpl.html                                    *
00012 * Please send any updates to: fred@gruntose.com                               *
00013 \*****************************************************************************/
00014 
00015 #include <basis/function.h>
00016 #include <basis/istring.h>
00017 #include <opsystem/byte_filer.h>
00018 #include <loggers/console_logger.h>
00019 #include <data_struct/static_memory_gremlin.h>
00020 
00021 HOOPLE_STARTUP_CODE;
00022 
00023 console_logger out;
00024 
00025 int main(int argc, char *argv[])
00026 {
00027   if (argc < 3) {
00028     out.log("This program takes two arguments.  The first is a file name that will be");
00029     out.log("searched.  The second argument will be sought out in the file and the exit");
00030     out.log("value of this app will be zero if the text is found, or it will be non-zero");
00031     out.log("if the text is not found.");
00032     return 3;
00033   }
00034 
00035   istring search_filename(argv[1]);
00036 
00037   byte_filer edit_file(search_filename, "rb");
00038   if (!edit_file.good()) {
00039     out.log(istring("Could not find the logfile called ") + search_filename);
00040     return 4;
00041   }
00042   int file_len = int(edit_file.length());
00043   istring total_file;
00044   edit_file.read(total_file, file_len);
00045   edit_file.close();
00046 
00047   const istring to_find = argv[2];
00048 
00049   int last_indy = 0;
00050 
00051   // look for the item that needs to be found.
00052   int indy = total_file.find(to_find, last_indy);
00053   last_indy = indy;  // update our position.
00054   if (negative(indy)) return 23;  // not found.
00055   else return 0;  // was found.
00056 }
00057 
00058 #ifdef __BUILD_STATIC_APPLICATION__
00059   // static dependencies found by buildor_gen_deps.sh:
00060   #include <basis/array.cpp>
00061   #include <basis/byte_array.cpp>
00062   #include <basis/callstack_tracker.cpp>
00063   #include <basis/chaos.cpp>
00064   #include <basis/convert_utf.cpp>
00065   #include <basis/definitions.cpp>
00066   #include <basis/earth_time.cpp>
00067   #include <basis/guards.cpp>
00068   #include <basis/istring.cpp>
00069   #include <basis/log_base.cpp>
00070   #include <basis/memory_checker.cpp>
00071   #include <basis/mutex.cpp>
00072   #include <basis/object_base.cpp>
00073   #include <basis/outcome.cpp>
00074   #include <basis/packable.cpp>
00075   #include <basis/portable.cpp>
00076   #include <basis/sequence.cpp>
00077   #include <basis/set.cpp>
00078   #include <basis/utility.cpp>
00079   #include <basis/version_record.cpp>
00080   #include <data_struct/amorph.cpp>
00081   #include <data_struct/bit_vector.cpp>
00082   #include <data_struct/byte_hasher.cpp>
00083   #include <data_struct/configurator.cpp>
00084   #include <data_struct/hash_table.cpp>
00085   #include <data_struct/pointer_hash.cpp>
00086   #include <data_struct/stack.cpp>
00087   #include <data_struct/static_memory_gremlin.cpp>
00088   #include <data_struct/string_hash.cpp>
00089   #include <data_struct/string_hasher.cpp>
00090   #include <data_struct/string_table.cpp>
00091   #include <data_struct/symbol_table.cpp>
00092   #include <data_struct/table_configurator.cpp>
00093   #include <loggers/console_logger.cpp>
00094   #include <loggers/file_logger.cpp>
00095   #include <loggers/locked_logger.cpp>
00096   #include <loggers/null_logger.cpp>
00097   #include <loggers/program_wide_logger.cpp>
00098   #include <opsystem/byte_filer.cpp>
00099   #include <opsystem/command_line.cpp>
00100   #include <opsystem/critical_events.cpp>
00101   #include <opsystem/directory.cpp>
00102   #include <opsystem/filename.cpp>
00103   #include <opsystem/ini_config.cpp>
00104   #include <opsystem/ini_parser.cpp>
00105   #include <opsystem/path_configuration.cpp>
00106   #include <opsystem/rendezvous.cpp>
00107   #include <textual/byte_format.cpp>
00108   #include <textual/parser_bits.cpp>
00109   #include <textual/string_manipulation.cpp>
00110   #include <textual/tokenizer.cpp>
00111 #endif // __BUILD_STATIC_APPLICATION__
00112 

Generated on Fri Nov 21 04:29:05 2008 for HOOPLE Libraries by  doxygen 1.5.1