mini_telnetneg.c-Dateireferenz

#include <properties.h>
#include <telnet.h>
Include-Abhängigkeitsdiagramm für mini_telnetneg.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define NEED_PROTOTYPES

Funktionen

private void InitProps ()
varargs mixed Query (string str, int type)
varargs mixed Set (string str, mixed value, int type)
mapping query_telnet_neg ()
private int send_telnet_neg (int *arr)
string * query_terminals ()
static void modify_prompt ()
void telnet_neg (int command, int option, int *optargs)

Variablen

static mapping prop
static mapping TN
static string * Terminals
static string last_received_termtype

Makro-Dokumentation

#define NEED_PROTOTYPES

Definiert in Zeile 17 der Datei mini_telnetneg.c.


Dokumentation der Funktionen

private void InitProps (  ) 

Definiert in Zeile 32 der Datei mini_telnetneg.c.

Benutzt P_TTY_COLS, P_TTY_ROWS und prop.

Wird benutzt von Query() und Set().

00033 {
00034     prop = ([ P_TTY_COLS:0, P_TTY_ROWS:0 ]);
00035 }

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static void modify_prompt (  )  [static]

Definiert in Zeile 107 der Datei mini_telnetneg.c.

Benutzt DO, EOR, IAC, P_PROMPT, Query(), TELOPT_EOR, text() und TN.

Wird benutzt von telnet_neg().

00108 {
00109     string text;
00110     if ( function_exists("renew_prompt", this_object()) )
00111         this_object()->renew_prompt();
00112     else {
00113         if ( !(text = Query( P_PROMPT )) || text == "" )
00114             text = "> ";
00115                 
00116         if ( mappingp(TN) && mappingp(TN["received"])
00117              && (TN["received"][TELOPT_EOR,1] == DO) )
00118             set_prompt( lambda( ({}),
00119                                 ({ #'efun::binary_message/*'*/,
00120                                         ({ #'+/*'*/,
00121                                                 ({ #'to_array/*'*/,
00122                                                         text }),
00123                                                 ({ #'({/*'*/, IAC, EOR }) })
00124                                         })
00125                                 ), this_object()
00126                         );
00127         else
00128             set_prompt( text, this_object() );
00129     }
00130 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

varargs mixed Query ( string  str,
int  type 
)

Definiert in Zeile 38 der Datei mini_telnetneg.c.

Benutzt InitProps() und prop.

00039 {
00040     if ( !mappingp(prop) )
00041         InitProps();
00042     
00043     return prop[str];
00044 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

mapping query_telnet_neg (  ) 

Definiert in Zeile 57 der Datei mini_telnetneg.c.

Benutzt TN.

Wird benutzt von _set_currentdir().

00058 {
00059     if ( !mappingp(TN) || !TN )
00060         TN = ([]);
00061 
00062     return TN;
00063 }

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

string* query_terminals (  ) 

Definiert in Zeile 100 der Datei mini_telnetneg.c.

Benutzt Terminals.

00101 { 
00102     return Terminals;
00103 }

private int send_telnet_neg ( int *  arr  ) 

Definiert in Zeile 67 der Datei mini_telnetneg.c.

Benutzt DO, DONT, IAC, SB, TN, WILL und WONT.

Wird benutzt von telnet_neg().

00068 {
00069     int res;
00070     
00071     if ( sizeof(arr) < 3 )
00072         return efun::binary_message(arr);
00073     
00074     if ( !TN["sent"] )
00075         TN["sent"] = m_allocate(3,3);
00076     
00077     if ( arr[0] == IAC ){
00078         switch (arr[1]){
00079         case DO:
00080         case DONT:
00081             TN["sent"][arr[2],1] = arr[1];
00082             break;
00083         case WILL:
00084         case WONT:
00085             TN["sent"][arr[2],0] = arr[1];
00086             break;
00087         case SB:
00088             TN["sent"][arr[2],2] = arr[1..];
00089             break;
00090         default:
00091             break;  
00092         }
00093     }
00094     
00095     return efun::binary_message(arr);
00096 }

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

varargs mixed Set ( string  str,
mixed  value,
int  type 
)

Definiert in Zeile 47 der Datei mini_telnetneg.c.

Benutzt InitProps() und prop.

Wird benutzt von _check_immortality(), _query_age(), _query_currentdir(), _query_hands(), _query_known_potionrooms(), _query_lep(), _query_potionrooms(), _query_questpoints(), _query_race(), _query_team_attack_cmd(), _query_team_autofollow(), _query_total_ac(), _query_total_wc(), _query_u_req(), _RemovePursued(), _set_adjectives(), _set_alcohol(), _set_align(), _set_amount(), _set_armour_type(), _set_armours(), _set_article(), _set_currentdir(), _set_dam_type(), _set_defend_func(), _set_die_hook(), _set_disable_attack(), _set_drink(), _set_earmuffs(), _set_exits(), _set_extern_attributes_modifier(), _set_extern_health_modifier(), _set_food(), _set_fraternitasdonoarchmagorum(), _set_frog(), _set_gender(), _set_hands(), _set_hit_func(), _set_hp(), _set_ids(), _set_ignore(), _set_inpc_walk_delay(), _set_item_damaged(), _set_last_xp(), _set_level(), _set_light(), _set_max_hp(), _set_max_sp(), _set_name(), _set_nr_hands(), _set_poison(), _set_questpoints(), _set_resistance(), _set_sp(), _set_store_consume(), _set_vulnerability(), _set_weight(), _set_wimpy(), _set_xp(), _SetPursued(), AddAction(), AddAdjective(), AddExit(), AddExp(), AddExtraLook(), AddId(), AddPlant(), AddPluralId(), AddResistanceModifier(), AddScore(), AddSingularId(), AddSpell(), Attack(), catch_up_hbs(), check_clean_count(), checkConsistency(), CheckDailyPlaytime(), clean_up(), create(), Damage(), DeleteQuest(), desc_check(), GiveQuest(), heart_beat(), ignoriere(), init(), InitSkills(), InsertSingleEnemy(), make_immortal(), mnpc_create(), mnpc_init(), mnpc_move(), NetDead(), RemoveAdjective(), RemoveExit(), RemoveId(), RemovePluralId(), RemoveResistanceModifier(), RemoveSingularId(), set_location(), SetCoinsPerUnits(), SetGramsPerUnits(), SetProp(), spieldauer(), startup_telnet_negs(), telnet_neg() und UpdateResistanceStrengths().

00048 {
00049     if ( !mappingp(prop) )
00050         InitProps();
00051     
00052     return prop[str] = value;
00053 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

void telnet_neg ( int  command,
int  option,
int *  optargs 
)

Definiert in Zeile 134 der Datei mini_telnetneg.c.

Benutzt break_string(), c, DO, DONT, EOR, i, IAC, LM_FORWARDMASK, LM_MODE, MODE_EDIT, modify_prompt(), old_explode(), P_TTY_COLS, P_TTY_ROWS, P_TTY_SHOW, P_TTY_TYPE, Query(), SB, SE, send_telnet_neg(), Set(), TELOPT_ENVIRON, TELOPT_LINEMODE, TELOPT_NAWS, TELOPT_NEWENV, TELOPT_TSPEED, TELOPT_TTYPE, TELOPT_XDISPLOC, TELQUAL_IS, TELQUAL_SEND, Terminals, TN, WILL, WONT und xx.

00135 {
00136     mapping recd, sent;
00137     int i, l, c;
00138     mixed *xx;
00139     string tmpterminal;
00140     string text, text2;
00141     int tmpxx;
00142 
00143     l = 0;
00144     c = 0;
00145 
00146   //hmm. WILL/WONT DO/DONT SB_IS 
00147     if ( !mappingp(TN) || !TN )
00148         TN=([]);
00149     
00150     if ( !TN["received"] )
00151         TN["received"] = m_allocate(3,3);
00152     
00153     if ( !TN["sent"] )
00154         TN["sent"] = m_allocate(3,3);
00155 
00156     recd = (mapping) TN["received"];
00157     sent = (mapping) TN["sent"];
00158 
00159     if ( command == WILL || command == WONT ){
00160         recd[option,0] = command;
00161         
00162         if ( !sent[option,1] && command == WILL ){
00163             //we support everything. (yeah ;)
00164             efun::binary_message(({IAC, DO, option}));
00165             sent[option,1] = DO;
00166         }
00167         
00168         if ( command == WILL ){
00169             switch (option){
00170             case TELOPT_NAWS: 
00171                 break;//no more things needed.
00172                 
00173             case TELOPT_LINEMODE:
00174                 send_telnet_neg(({ IAC, SB, option, LM_MODE, MODE_EDIT, IAC,
00175                                        SE }));
00176                 //flush on 0d and 0a...
00177                 send_telnet_neg(({ IAC, SB, option, DO, LM_FORWARDMASK, 0,
00178                                       0x40|0x08, IAC, SE }));
00179                 sent[TELOPT_LINEMODE,2] = MODE_EDIT;
00180                 break;
00181 
00182             case TELOPT_TTYPE:
00183                 send_telnet_neg(({ IAC, SB, TELOPT_TTYPE, TELQUAL_SEND, IAC,
00184                                        SE }));
00185                 sent[TELOPT_TTYPE,2] = TELQUAL_SEND;
00186                 break;
00187 
00188             case TELOPT_TSPEED:
00189                 send_telnet_neg(({ IAC, SB, TELOPT_TSPEED, TELQUAL_SEND, IAC,
00190                                        SE }));
00191                 sent[TELOPT_TTYPE,2] = TELQUAL_SEND;
00192                 break;
00193                 
00194             case TELOPT_NEWENV:
00195             case TELOPT_ENVIRON:
00196                 efun::binary_message(({ IAC, SB, option, TELQUAL_SEND, IAC,
00197                                             SE }));
00198                 sent[option,2] = TELQUAL_SEND;
00199                 break;
00200                 
00201             case TELOPT_XDISPLOC:
00202                 send_telnet_neg(({ IAC, SB, TELOPT_XDISPLOC, TELQUAL_SEND, IAC,
00203                                        SE }));
00204                 break;
00205                 
00206             default:
00207                 break;
00208             }
00209         }
00210         
00211         return;
00212     }
00213     
00214     if ( command == DONT || command == DO ){
00215         //wir machen nix als telnet client...jedenfalls in der lib.
00216         recd[option,1] = command;
00217         
00218         if ( !sent[option,0] && command == DO ){
00219             if ( option == TELOPT_EOR){
00220                 sent[option,0] = WILL;
00221                 efun::binary_message(({IAC, WILL, option}));
00222             }
00223             else{
00224                 sent[option,0] = WONT;
00225                 efun::binary_message(({IAC, WONT, option}));
00226             }
00227         }
00228 
00229         //der Aufruf in base.c kommt fuer Magier meist zu frueh
00230         // (und fuer Spieler gar nicht ;-)
00231         if ( option == TELOPT_EOR && command == DO ){
00232             efun::binary_message( ({ IAC, EOR }) );
00233             modify_prompt();
00234         }
00235         
00236 
00237         return;
00238     }
00239     
00240     if ( command == SB ){
00241         switch (option){
00242         case TELOPT_NAWS:
00243             recd[option,2] = optargs;
00244             if ( sizeof(optargs) != 4 ){ 
00245                 break_string( sprintf("Dein Client hat einen Fehler beim"
00246                                       +"Aushandeln der TELOPT_NAWS - er hat"
00247                                       +"IAC SB %O IAC SE gesendet!\n",
00248                                       optargs), 78,
00249                               "Der GameDriver teilt Dir mit: " );
00250                 break;
00251             }
00252             
00253             if ( interactive(this_object()) ){
00254                 if ( !optargs[1] )
00255                     c = optargs[0];
00256                 else
00257                     c = optargs[1] + optargs[0] * 256;
00258 
00259                 if ( c < 20 ){
00260                     if (Query(P_TTY_SHOW))
00261                         tell_object( this_object(),
00262                                  break_string("Dein Fenster ist schmaler als"
00263                                               +" 20 Zeichen? Du scherzt. ;-)"
00264                                               +" Ich benutze den Standardwert"
00265                                               +" von 80 Zeichen.\n", 78,
00266                                               "Der GameDriver teilt Dir mit: ")
00267                                  );
00268                     c = 80;
00269                 }
00270                 
00271                 if ( !optargs[3] )
00272                     l = optargs[2];
00273                 else
00274                     l = 256 * optargs[2] + optargs[3];
00275                 
00276                 if ( l > 100 ){
00277                     l = 100;
00278                     if (Query(P_TTY_SHOW))
00279                         tell_object( this_object(),
00280                                  break_string("Tut mir leid, aber ich kann"
00281                                               +" nur bis zu 100 Zeilen"
00282                                               +" verwalten.\n", (c ? c-2 : 78),
00283                                               "Der GameDriver teilt Dir mit: " )
00284                                  );
00285                 }
00286                 
00287                 if ( l < 3 ){
00288                     if (Query(P_TTY_SHOW))
00289                         tell_object( this_object(),
00290                                  break_string("Du willst weniger als drei"
00291                                               +" Zeilen benutzen? Glaub ich"
00292                                               +" Dir nicht - ich benutze den"
00293                                               +" Standardwert von 24"
00294                                               +" Zeilen.\n", (c ? c-2 : 78),
00295                                               "Der GameDriver teilt Dir mit: " )
00296                                  );
00297                     l = 24;
00298                 }
00299 
00300                 if ( ((int) Query(P_TTY_ROWS) != l) ||
00301                      ((int) Query(P_TTY_COLS) != c) ){
00302                     Set( P_TTY_ROWS, l );
00303                     Set( P_TTY_COLS, c );
00304                     
00305                     if (Query(P_TTY_SHOW))
00306                         tell_object( this_object(),
00307                                  break_string("Du hast Deine Fenstergroesse auf"
00308                                               +" "+l+" Zeilen und "+c+
00309                                               " Spalten geaendert.\n", c-2,
00310                                               "Der GameDriver teilt Dir mit: ")
00311                                  );
00312                 }
00313             }
00314             break;
00315             
00316         case TELOPT_TTYPE:
00317             //NOTE: We do not do multiple SB SENDs due to some weird
00318             //bugs in IBM3270 emulating telnets which crash if we
00319             //do that.
00320             if ( sizeof(optargs) < 1 )
00321                 break;
00322 
00323             if ( optargs[0] != TELQUAL_IS )
00324                 break;
00325 
00326             tmpterminal = lower_case( to_string(optargs[1..]) );
00327             if ( !Terminals )
00328                 Terminals = ({ tmpterminal });
00329             else
00330                 Terminals += ({ tmpterminal });
00331             
00332             if ( Query(P_TTY_TYPE) )
00333                 Set( P_TTY_TYPE, Terminals[0] );
00334             
00335             recd[option,2] = Terminals;
00336             break;
00337             
00338         case TELOPT_TSPEED:
00339             if ( sizeof(optargs) < 2 )
00340                 break;
00341             
00342             if ( optargs[0] != TELQUAL_IS )
00343                 break;
00344             
00345             recd[option,2] = to_string( optargs[1..] );
00346             break;
00347             
00348     case TELOPT_ENVIRON:
00349     case TELOPT_NEWENV:
00350         if ( sizeof(optargs) < 3 )
00351             break;
00352         
00353         if ( optargs[0] != TELQUAL_IS )
00354         break;
00355         
00356         optargs = optargs[2..]; //first kill the TELQUAL_IS
00357         recd[option,2] = ([]);
00358         text = "";
00359         text2 = 0;
00360         
00361       for ( i = 0; i < sizeof(optargs) ; i++ ){
00362           tmpxx = optargs[i];
00363           
00364           if ( tmpxx < 5 ){
00365               if ( text && text2 ){
00366                   recd[option,2][text] = text2;
00367                   text2 = 0;
00368                   text = "";
00369               }
00370               else
00371                   text2 = "";
00372           }
00373           else
00374               if ( text2 )
00375                   text2 += sprintf("%c", tmpxx);
00376               else
00377                   text += sprintf("%c", tmpxx);
00378       }
00379       
00380       if ( text && text2 )
00381           recd[option,2][text] = text2;
00382 
00383       text = implode( old_explode(sprintf("%O\n", recd[option,2]), "\n"), "" )
00384           +"\n";
00385 
00386       /*
00387       if ( find_player("marcus") )
00388           tell_object( find_player("marcus"), text );
00389       else
00390           log_file( "marcus.rep", text );
00391       */
00392       break;
00393       
00394     case TELOPT_XDISPLOC:
00395         if ( optargs[0] != TELQUAL_IS )
00396             recd[TELOPT_XDISPLOC,2] = optargs;
00397         else
00398             recd[TELOPT_XDISPLOC,2] = lower_case( to_string(optargs[1..]) );
00399         break;
00400         
00401         case TELOPT_LINEMODE:
00402             break;
00403             
00404         default:
00405             //printf( "TELOPT:%d %d %O\n", command, option, optargs );
00406             break;
00407         }
00408         return;
00409     }
00410 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:


Variablen-Dokumentation

string last_received_termtype [static]

Definiert in Zeile 29 der Datei mini_telnetneg.c.

mapping prop [static]

Definiert in Zeile 26 der Datei mini_telnetneg.c.

Wird benutzt von InitProps(), Query() und Set().

string* Terminals [static]

Definiert in Zeile 28 der Datei mini_telnetneg.c.

Wird benutzt von query_terminals() und telnet_neg().

mapping TN [static]
Erzeugt am Thu Jun 3 14:41:43 2010 für MorgenGrauen Mudlib von  doxygen 1.6.3