logtool.c-Dateireferenz

#include <properties.h>
#include <wizlevels.h>
#include <defines.h>
#include <moving.h>
Include-Abhängigkeitsdiagramm für logtool.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define SAVEFILE   "/players/"+geteuid()+"/.logtool"
#define allowed()   (!process_call() && PL==RPL && geteuid()==getuid(RPL))

Funktionen

static void check_logs ()
void create ()
void reset ()
varargs int move (mixed dest, int method)
varargs string long ()
static int aktualisieren (string str)
static int read_log (string str)
static int add_log ()
static int del_log (string str)

Variablen

inherit std secure_thing
mapping logs

Makro-Dokumentation

 
#define allowed (  )     (!process_call() && PL==RPL && geteuid()==getuid(RPL))
#define SAVEFILE   "/players/"+geteuid()+"/.logtool"

Dokumentation der Funktionen

static int add_log (  )  [static]

Definiert in Zeile 120 der Datei logtool.c.

00121 {
00122   string key, path, str;
00123   str=PL->_unparsed_args();  
00124   if (!allowed() || !str || sscanf(str, "%s %s", key, path)!=2) {
00125     notify_fail("Syntax: AddLog <key> <path>\n");
00126     return 0;
00127   }
00128   key=lower_case(key);
00129   if (logs[key]) {
00130     notify_fail("Es gibt schon ein Logfile mit diesem Key in der Liste.\n");
00131     return 0;
00132   }
00133   logs+=([ key: path; 0; 0 ]);
00134   AddCmd(key, "read_log");
00135   save_object(SAVEFILE);
00136   write("Logfile <"+key+"> in die Liste aufgenommen.\n");
00137   return 1;
00138 }

static int aktualisieren ( string  str  )  [static]

Definiert in Zeile 77 der Datei logtool.c.

00078 {
00079   if (!allowed()) return 0;
00080   if (str && str!="") {
00081     if (!logs[str]) {
00082       notify_fail("Ein solches Logfile ist nicht in der Liste enthalten.\n");
00083       return 0;
00084     }
00085     logs[str, 1]=file_size(logs[str, 0]);
00086     logs[str, 2]=file_time(logs[str, 0]);
00087   }
00088   else filter(m_indices(logs), lambda( ({ 'x }),({#', ,
00089    ({#'=, ({#'[, logs, 'x, 1}), ({#'file_size, ({#'[, logs, 'x, 0}) }) }),
00090    ({#'=, ({#'[, logs, 'x, 2}), ({#'file_time, ({#'[, logs, 'x, 0}) })})})));
00091   write("Done!\n");
00092   save_object(SAVEFILE);
00093   return 1;
00094 }

static void check_logs (  )  [static]

Definiert in Zeile 17 der Datei logtool.c.

Benutzt logs und x.

00018 {
00019   filter(sort_array(m_indices(logs), #'>), lambda( ({ 'x }), ({#'?, 
00020     ({#'!=, ({#'[, logs, 'x, 2}), ({#'file_time, ({#'[, logs, 'x, 0}) }) }),
00021        ({#'tell_object, ({#'environment }), ({#'sprintf,
00022        "Neue Eintraege in <%s>.\n", 'x }) }), 0})));
00023 }

void create (  ) 

Definiert in Zeile 25 der Datei logtool.c.

00026 {
00027   if (!clonep(ME)) return;
00028   ::create();
00029   if (!restore_object(SAVEFILE)) {
00030     logs=([ "repfile": sprintf("/log/report/%s.rep", geteuid()); 0; 0 ]);
00031     if (IS_ARCH(geteuid()))
00032       logs+=(["snooplog": "/log/SNOOP"; 0; 0, "killer": "/log/KILLER"; 0; 0]);
00033   }
00034   SetProp(P_SHORT, geteuid()+"s Logtool");
00035   SetProp(P_NAME, QueryProp(P_SHORT));
00036   SetProp(P_NODROP, 0);
00037   SetProp(P_NEVERDROP, 0);
00038   SetProp(P_AUTOLOADOBJ, 1);
00039   AddId("logtool");
00040   AddCmd("mark", "aktualisieren");
00041   AddCmd(m_indices(logs), "read_log");
00042   AddCmd("AddLog", "add_log");
00043   AddCmd("DelLog", "del_log");
00044 }

static int del_log ( string  str  )  [static]

Definiert in Zeile 140 der Datei logtool.c.

00141 {
00142   if (!allowed() || !str) {
00143     notify_fail("WELCHES Logfile soll aus der Liste entfernt werden?\n");
00144     return 0;
00145   }
00146   if (!logs[str]) {
00147     notify_fail("Logfile nicht in Liste enthalten.\n");
00148     return 0;
00149   }
00150   logs=m_delete(logs,str);
00151   RemoveCmd(str);
00152   save_object(SAVEFILE);
00153   write("Logfile <"+str+"> aus Liste entfernt.\n");
00154   return 1;
00155 }

varargs string long (  ) 

Definiert in Zeile 65 der Datei logtool.c.

Benutzt logs und x.

00066 {
00067    return "Folgende Logfiles werden derzeit von Deinem Logtool verwaltet:\n\n"
00068          +implode(map(sort_array(m_indices(logs), #'>),
00069           lambda( ({ 'x }), ({#'sprintf, " %1s %-14s - %s", ({#'?, ({#'!=,
00070           ({#'[,logs,'x, 2}), ({#'file_time,({#'[,logs,'x, 0})})}),"*",""}),
00071           ({#'sprintf, "<%s>", 'x}), ({#'[, logs, 'x, 0})}) ) ), "\n")
00072          +"\n\nMit <mark> koennen alle Eintraege als gelesen markiert und "
00073          +"mit Add- und\nDelLog Logfiles in die Liste aufgenommen bzw. aus "
00074          +"der Liste entfernt werden.\n";
00075 }

varargs int move ( mixed  dest,
int  method 
)

Definiert in Zeile 53 der Datei logtool.c.

00054 {
00055   int i;
00056   if (!objectp(dest)) dest=find_object(dest);
00057   if (!dest || !interactive(dest) || getuid(dest)!=geteuid()) 
00058     return ME_CANT_BE_TAKEN;
00059   i=::move(dest, method);
00060   if (i!=1) return i;
00061   if (environment()) call_out("check_logs", 0);
00062   return 1;
00063 }

static int read_log ( string  str  )  [static]

Definiert in Zeile 96 der Datei logtool.c.

00097 {
00098   int si;
00099   if (!allowed()) return 0;
00100   si=file_size(logs[query_verb(),0]);
00101   if (str)
00102     PL->more(logs[query_verb(),0]);
00103   else {
00104     if (si<0 || file_time(logs[query_verb(), 0])==logs[query_verb(), 2])
00105       write("Keine neuen Eintraege in <"+query_verb()+">.\n");
00106     else {
00107       write("Folgendes ist neu in <"+query_verb()+">.\n");
00108       if (si<logs[query_verb(),1])
00109         PL->more(logs[query_verb(),0]);
00110       else PL->More(read_bytes(logs[query_verb(),0],
00111                     logs[query_verb(),1],si-logs[query_verb(),1]));
00112     }
00113   }
00114   logs[query_verb(), 1]=si;
00115   logs[query_verb(), 2]=file_time(logs[query_verb(), 0]);
00116   save_object(SAVEFILE);
00117   return 1;
00118 }

void reset ( void   ) 

Definiert in Zeile 46 der Datei logtool.c.

00047 {
00048   ::reset();
00049   if (!clonep(ME) || !environment()) return;
00050   call_out("check_logs", 0);
00051 }


Variablen-Dokumentation

mapping logs

Definiert in Zeile 15 der Datei logtool.c.

Wird benutzt von check_logs() und long().

inherit std secure_thing

Definiert in Zeile 3 der Datei logtool.c.

Erzeugt am Thu Jun 3 14:39:51 2010 für MorgenGrauen Mudlib von  doxygen 1.6.3