#include <daemon/mand.h>
gehe zum Quellcode dieser Datei
Makrodefinitionen | |
| #define | DEBUGGER "mandragon" |
| #define | DEBUG(x) |
Funktionen | |
| static string | glob2regexp (string str) |
| void | cache_entry (string entry, string dir, string file) |
| static void | load_synonyms (string dir) |
| static void | cache_directory (string dir) |
| void | update_cache () |
| void | create () |
| void | reset () |
| string * | locate (string str, int match) |
Variablen | |
| static private mapping | pages |
| static private string * | keys |
| static private mapping | pages_case |
| static private string * | keys_case |
| #define DEBUG | ( | x | ) |
if (find_player(DEBUGGER)) \ tell_object(find_player(DEBUGGER),x+"\n")
| static void cache_directory | ( | string | dir | ) | [static] |
Definiert in Zeile 82 der Datei mand.c.
Benutzt cache_entry(), file(), i, load_synonyms() und MAND_DOCDIR.
Wird benutzt von update_cache().
00083 { 00084 string file; 00085 int i,j; 00086 mixed *files; 00087 00088 files = get_dir(MAND_DOCDIR+dir+"/*",3)||({}); 00089 i=sizeof(files); 00090 for (j=0;j<i;) 00091 { 00092 file=files[j++]; 00093 if (file[0]=='.') 00094 { 00095 j++; 00096 continue; 00097 } 00098 if (files[j++]==-2) 00099 { 00100 cache_directory(dir+"/"+file); 00101 continue; 00102 } 00103 cache_entry(file,dir,file); 00104 } 00105 load_synonyms(dir); 00106 }


| void cache_entry | ( | string | entry, | |
| string | dir, | |||
| string | file | |||
| ) |
Definiert in Zeile 36 der Datei mand.c.
Benutzt data, keys, keys_case, pages und pages_case.
Wird benutzt von cache_directory() und load_synonyms().
00037 { 00038 string *data; 00039 int j; 00040 00041 if (m_contains(&data,pages,lower_case(entry))) 00042 { 00043 j=sizeof(data); 00044 while(j--) data[--j]=data[j]; 00045 pages[lower_case(entry)]=data+({ dir+"/"+file, dir+"/"+file}); 00046 } 00047 else 00048 { 00049 pages[lower_case(entry)]=({entry,dir+"/"+file}); 00050 keys+=({lower_case(entry)}); 00051 } 00052 if (m_contains(&data,pages_case,entry)) 00053 { 00054 j=sizeof(data); 00055 while(j--) data[--j]=data[j]; 00056 pages_case[entry]=data+({ dir+"/"+file, dir+"/"+file}); 00057 } 00058 else 00059 { 00060 pages_case[entry]=({entry,dir+"/"+file}); 00061 keys_case+=({entry}); 00062 } 00063 return; 00064 }

| void create | ( | ) |
Definiert in Zeile 131 der Datei mand.c.
Benutzt set_next_reset() und update_cache().
00132 { 00133 seteuid(getuid()); 00134 update_cache(); 00135 set_next_reset(10080); //Einmal pro Woche langt 00136 return; 00137 }

| static string glob2regexp | ( | string | str | ) | [static] |
Definiert in Zeile 29 der Datei mand.c.
Wird benutzt von locate().
00030 { 00031 str=regreplace(str,"([\\.\\^\\$\\[\\]\\(\\)])","\\\\\\1",1); 00032 str=regreplace(str,"\\*",".*",1); 00033 return regreplace("^"+str+"$","?",".",1); 00034 }

| static void load_synonyms | ( | string | dir | ) | [static] |
Definiert in Zeile 66 der Datei mand.c.
Benutzt cache_entry() und MAND_DOCDIR.
Wird benutzt von cache_directory().
00067 { 00068 string filedata,*syn; 00069 00070 if (file_size(MAND_DOCDIR+dir+"/.synonym")<=0) return; 00071 if (!(filedata=read_file(MAND_DOCDIR+dir+"/.synonym"))) return; 00072 syn=regexplode(filedata, "([ \t][ \t]*|\n)")-({""}); 00073 syn-=regexp(syn,"^([ \t][ \t]*|\n)$"); 00074 while(sizeof(syn)) 00075 { 00076 cache_entry(syn[0],dir,syn[1]); 00077 syn=syn[2..]; 00078 } 00079 return; 00080 }


| string* locate | ( | string | str, | |
| int | match | |||
| ) |
Definiert in Zeile 152 der Datei mand.c.
Benutzt glob2regexp(), keys, keys_case, pages und pages_case.
00153 { 00154 string *matches,*ret,str2; 00155 int i; 00156 00157 if (!match&&member(keys_case,str)!=-1) return pages_case[str]; 00158 str=lower_case(str); 00159 if (match==1) str=glob2regexp(str); 00160 if (match) matches=regexp(keys,str); 00161 else if (member(keys,str)!=-1) matches=({ str }); 00162 else return ({}); 00163 00164 ret=({}); 00165 i=sizeof(matches); 00166 while(i--) 00167 ret+=pages[matches[i]]; 00168 return ret; 00169 }

| void reset | ( | void | ) |
Definiert in Zeile 139 der Datei mand.c.
Benutzt set_next_reset() und update_cache().
00140 { 00141 update_cache(); 00142 set_next_reset(10080); 00143 return; 00144 }

| void update_cache | ( | ) |
Definiert in Zeile 108 der Datei mand.c.
Benutzt cache_directory(), i, keys, keys_case, MAND_DOCDIR, MAND_EXCLUDE, pages und pages_case.
Wird benutzt von create() und reset().
00109 { 00110 int i; 00111 string *docdirs; 00112 mixed *tmp; 00113 00114 tmp=get_dir(MAND_DOCDIR "*",3); 00115 docdirs=({}); 00116 pages=([]); 00117 pages_case=([]); 00118 keys_case=({}); 00119 keys=({}); 00120 i=sizeof(tmp); 00121 while(i--) 00122 if (tmp[i]==-2) 00123 docdirs+=({ tmp[(i--)-1] }); 00124 docdirs-=({".",".."}); 00125 docdirs-=MAND_EXCLUDE; 00126 i=sizeof(docdirs); 00127 while(i--) cache_directory(docdirs[i]); 00128 return; 00129 }


private string* keys [static] |
Definiert in Zeile 25 der Datei mand.c.
Wird benutzt von _cl(), add(), cache_entry(), DumpMiniQuests(), DumpNPCs(), GetFunc(), GetKeys(), GetNewsTime(), Load_NumKey(), locate(), mixed_to_string(), notifyExpiredModifiers(), Query_Keys(), Query_Quests(), reset(), sbanish(), update_cache() und update_header_file().
private string* keys_case [static] |
Definiert in Zeile 27 der Datei mand.c.
Wird benutzt von cache_entry(), locate() und update_cache().
private mapping pages [static] |
Definiert in Zeile 24 der Datei mand.c.
Wird benutzt von cache_entry(), locate(), udp_man(), update_cache() und zeige_seite().
private mapping pages_case [static] |
Definiert in Zeile 26 der Datei mand.c.
Wird benutzt von cache_entry(), locate() und update_cache().
1.6.3