Back to index

texmacs  1.0.7.15
handler.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : handler.cpp
00004 * DESCRIPTION: Shows how to deal with cerr
00005 * COPYRIGHT  : (C) 2003  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #include <iostream>
00013 using namespace std;
00014 
00015 #define DATA_BEGIN   ((char) 2)
00016 #define DATA_END     ((char) 5)
00017 #define DATA_ESCAPE  ((char) 27)
00018 
00019 int
00020 main () {
00021   cout << DATA_BEGIN << "verbatim:";
00022   cout << "Type commands ending with ';'";
00023   cout << DATA_END;
00024   cout.flush ();
00025 
00026   while (1) {
00027     char buffer[100];
00028     cin.getline (buffer, 100, '\n');
00029     cout << DATA_BEGIN << "verbatim:";
00030     if (buffer[strlen(buffer)-1] == ';')
00031       cout << "You typed " << buffer;
00032     else {
00033       cerr << DATA_BEGIN << "verbatim:";
00034       cerr << "Commands have to end with ';'";
00035       cerr << DATA_END;
00036     }
00037     cout << DATA_END;
00038     cout.flush ();
00039   }
00040   return 0;
00041 }