[BACK]Return to Event.c++ CVS log [TXT][DIR] Up to [Development] / fam / fam

Annotation of fam/fam/Event.c++, Revision 1.1.1.1

1.1       trev        1: //  Copyright (C) 1999 Silicon Graphics, Inc.  All Rights Reserved.
                      2: //
                      3: //  This program is free software; you can redistribute it and/or modify it
                      4: //  under the terms of version 2 of the GNU General Public License as
                      5: //  published by the Free Software Foundation.
                      6: //
                      7: //  This program is distributed in the hope that it would be useful, but
                      8: //  WITHOUT ANY WARRANTY; without even the implied warranty of
                      9: //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  Further, any
                     10: //  license provided herein, whether implied or otherwise, is limited to
                     11: //  this program in accordance with the express provisions of the GNU
                     12: //  General Public License.  Patent licenses, if any, provided herein do not
                     13: //  apply to combinations of this program with other product or programs, or
                     14: //  any other product whatsoever.  This program is distributed without any
                     15: //  warranty that the program is delivered free of the rightful claim of any
                     16: //  third person by way of infringement or the like.  See the GNU General
                     17: //  Public License for more details.
                     18: //
                     19: //  You should have received a copy of the GNU General Public License along
                     20: //  with this program; if not, write the Free Software Foundation, Inc., 59
                     21: //  Temple Place - Suite 330, Boston MA 02111-1307, USA.
                     22:
                     23: #include "Event.h"
                     24:
                     25: #include "Log.h"
                     26:
                     27: #include <assert.h>
                     28: #include <stdio.h>
                     29:
                     30: const Event Event::Changed     = Event(ChangedT);
                     31: const Event Event::Deleted     = Event(DeletedT);
                     32: const Event Event::Executing   = Event(ExecutingT);
                     33: const Event Event::Exited      = Event(ExitedT);
                     34: const Event Event::Created     = Event(CreatedT);
                     35: const Event Event::Acknowledge = Event(AcknowledgeT);
                     36: const Event Event::Exists      = Event(ExistsT);
                     37: const Event Event::EndExist    = Event(EndExistT);
                     38: const Event Event::Error       = Event(ErrorT);
                     39:
                     40:
                     41: const Event*
                     42: Event::getEventFromOpcode(char opcode)
                     43: {
                     44:     switch (opcode)
                     45:     {
                     46:     case 'c':
                     47:         return &Changed;
                     48:     case 'A':
                     49: 	return &Deleted;
                     50:     case 'X':
                     51: 	return &Executing;
                     52:     case 'Q':
                     53: 	return &Exited;
                     54:     case 'F':
                     55: 	return &Created;
                     56: //    case 'M':  /* M is unsupported */
                     57: //        return Moved;
                     58:     case 'G':
                     59: 	return &Acknowledge;
                     60:     case 'e':
                     61:         return &Exists;
                     62:     case 'P':
                     63: 	return &EndExist;
                     64:     default:
                     65: 	Log::error("unrecognized event opcode '%c' ('\0%o')",
                     66: 		   opcode, opcode & 0377);
                     67:         return &Error;
                     68:     }
                     69: }
                     70:
                     71: const char *
                     72: Event::name() const
                     73: {
                     74:     static char buf[40];
                     75:
                     76:     switch (which)
                     77:     {
                     78:     case ChangedT:
                     79: 	return "Changed";
                     80:
                     81:     case DeletedT:
                     82: 	return "Deleted";
                     83:
                     84:     case ExecutingT:
                     85: 	return "Executing";
                     86:
                     87:     case ExitedT:
                     88: 	return "Exited";
                     89:
                     90:     case CreatedT:
                     91: 	return "Created";
                     92:
                     93:     case MovedT:
                     94:         return "Moved";
                     95:
                     96:     case AcknowledgeT:
                     97: 	return "Acknowledge";
                     98:
                     99:     case ExistsT:
                    100: 	return "Exists";
                    101:
                    102:     case EndExistT:
                    103: 	return "EndExist";
                    104:
                    105:     default:
                    106: 	sprintf(buf, "UNKNOWN EVENT %d", which);
                    107: 	return buf;
                    108:     }
                    109: }
                    110:
                    111: char
                    112: Event::code() const
                    113: {
                    114:     // Map event to letter.
                    115:
                    116:     static const char codeletters[] = "?cAXQFMGeP";
                    117:     assert(which < sizeof codeletters - 1);
                    118:     char code = codeletters[which];
                    119:     assert(code != '?');
                    120:     return code;
                    121: }
                    122:
                    123:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>