Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

nanomud-strings.c File Reference

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <windows.h>
#include <winsock.h>
#include <richedit.h>
#include <assert.h>
#include "NanoMud.h"

Include dependency graph for nanomud-strings.c:

Include dependency graph

Go to the source code of this file.

Defines

#define MAX_BUF   512

Functions

void create_s_table (void)
int get_fore (int i, int j)
char * one_argument (char *argument, char *arg_first)
char * script_strip (char *argument, char *arg_first)
BOOL simple_str_match (char *input, char *pattern)
char * str_dup (const char *str)
int str_ret (const char *str)
BOOL str_search (const char *str)
BOOL string_compare (const char *ostr, const char *tstr)
void strip_junk (char *str)
bool strprefix (const char *astr, const char *bstr)

Variables

char str_empty [1]
char * string_space
char * top_string


Define Documentation

#define MAX_BUF   512
 

Definition at line 37 of file nanomud-strings.c.


Function Documentation

void create_s_table void   ) 
 

Definition at line 323 of file nanomud-strings.c.

References get_fore().

00324 {
00325     FILE *fp;
00326     int i,j,k=0;
00327     char buf[200];
00328     if ((fp = fopen("sequence.txt", "w")) == NULL)
00329         return;
00330     fprintf(fp, "struct ansi_table a_table[] = \n{\n");
00331     fprintf(fp, "    {\"\e[0m\", 0, 0},\n");
00332     
00333     for (i=0;i<=1;i++)
00334         for (j=30;j<=37;j++)
00335         {
00336             sprintf(buf, "    {\"\e[%d;%dm\", %d, %d},\n", i,j, get_fore(i,j), i == 7 ? 1 : 0 );
00337             
00338             fprintf(fp,buf);
00339         }
00340         
00341     for (i=0;i<=1;i++)
00342         for (j=0;j<=1;j++)
00343             for(k=30;k<=37;k++)
00344             {
00345                 if (i == j)
00346                     continue;
00347                 sprintf(buf, "    {\"\e[%d;%d;%dm\", %d, %d},\n", i,j,k, get_fore(i,k), i == 7 ? 1 : 0 );
00348                 fprintf(fp,buf);
00349             }
00350     for (i=7;i<8;i++)
00351         for (j=30;j<=37;j++)
00352         {
00353             sprintf(buf, "    {\"\e[%d;%dm\", %d, %d},\n", i,j, get_fore(i,j), i == 7 ? 1 : 0 );
00354             
00355             fprintf(fp,buf);
00356         }
00357         
00358     for (i=7;i<8;i++)
00359         for (j=0;j<=1;j++)
00360             for(k=30;k<=37;k++)
00361             {
00362                 if (i == j)
00363                     continue;
00364                 sprintf(buf, "    {\"\e[%d;%d;%dm\", %d, %d},\n", i,j,k, get_fore(j,k), i == 7 ? 1 : 0 );
00365                 fprintf(fp,buf);
00366             }
00367     for (i=0;i<=1;i++)
00368         for (j=7;j<8;j++)
00369             for(k=30;k<=37;k++)
00370             {
00371                 if (i == j)
00372                     continue;
00373                 sprintf(buf, "    {\"\e[%d;%d;%dm\", %d, %d},\n", i,j,k, get_fore(i,k), i == 7 ? 1 : 0 );
00374                 fprintf(fp,buf);
00375             }
00376 
00377     
00378     fprintf(fp,"    {NULL,0,0}\n};\n");
00379     
00380    fclose(fp);         
00381     
00382 }

Here is the call graph for this function:

int get_fore int  i,
int  j
 

Definition at line 283 of file nanomud-strings.c.

References LOG().

Referenced by create_s_table().

00284 {
00285     LOG("%d, %d", i,j);
00286     switch(i)
00287     {
00288         case 0:
00289             switch(j)
00290             {
00291                 
00292                 case 30: return BLACK; break;
00293                 case 31: return C_RED;   break;
00294                 case 32: return C_GREEN; break;
00295                 case 33: return C_YELLOW; break;
00296                 case 34: return C_BLUE;  break;
00297                 case 35: return C_MAGENTA; break;
00298                 case 36: return C_CYAN;    break;
00299                 case 37: return C_WHITE;   break;
00300                 default: return GREY;   break;
00301             }
00302 
00303         case 1:
00304             switch(j)
00305             {
00306                 case 30: return BLACK; break;
00307                 case 31: return RED;   break;
00308                 case 32: return GREEN; break;
00309                 case 33: return YELLOW; break;
00310                 case 34: return BLUE;  break;
00311                 case 35: return MAGENTA; break;
00312                 case 36: return CYAN;    break;
00313                 case 37: return WHITE;   break;
00314                 default: return GREY;   break;
00315             }
00316             break;
00317         case 4: case 5: case 7: case 8: return 0; break;
00318     }
00319 }

Here is the call graph for this function:

char* one_argument char *  argument,
char *  arg_first
 

Definition at line 162 of file nanomud-strings.c.

References LOWER.

Referenced by check_alias(), check_path(), and handle_input().

00163 {
00164     char cEnd;
00165 
00166     while (isspace (*argument))
00167         argument++;
00168 
00169     cEnd = ' ';
00170     if (*argument == '\'' || *argument == '"')
00171         cEnd = *argument++;
00172 
00173     while (*argument != '\0')
00174     {
00175         if (*argument == cEnd)
00176         {
00177             argument++;
00178             break;
00179         }
00180         *arg_first = LOWER (*argument);
00181         arg_first++;
00182         argument++;
00183     }
00184     *arg_first = '\0';
00185 
00186     while (isspace (*argument))
00187         argument++;
00188 
00189     return argument;
00190 }

char* script_strip char *  argument,
char *  arg_first
 

Definition at line 191 of file nanomud-strings.c.

Referenced by handle_aliases(), handle_class(), handle_path(), handle_triggers(), and handle_var().

00192 {
00193     char cEnd;
00194 
00195     while (isspace (*argument))
00196         argument++;
00197 
00198     cEnd = '{';
00199     if (*argument == '{' || *argument == '}')
00200         cEnd = *argument++;
00201 
00202     while (*argument != '\0')
00203     {
00204         if (*argument == cEnd || *argument == '}')
00205         {
00206             argument++;
00207             break;
00208         }
00209         
00210         *arg_first = *argument;
00211         arg_first++;
00212         argument++;
00213     }
00214     *arg_first = '\0';
00215 
00216     while (isspace (*argument))
00217         argument++;
00218     while (*argument == '{' || *argument == '}')
00219         argument++;
00220 
00221     return argument;
00222 }

BOOL simple_str_match char *  input,
char *  pattern
 

Definition at line 224 of file nanomud-strings.c.

References BOOL.

00224                                                   {
00225     char *inputPtr = input;
00226     char *whereInput = input;
00227     char *wherePattern = pattern;
00228     
00229     for ( ; inputPtr != '\0' ; inputPtr++) {
00230         whereInput = inputPtr;
00231         wherePattern = pattern;
00232         
00233         if (*whereInput == *wherePattern) {
00234             for ( ; wherePattern != '\0' ; wherePattern++) {
00235                 whereInput++;
00236                 
00237                 if (*whereInput != *wherePattern) {
00238                     break;
00239                 }
00240             }
00241             
00242             return TRUE;
00243         }
00244     }
00245     
00246     return FALSE;
00247 }

char* str_dup const char *  str  ) 
 

Definition at line 57 of file nanomud-strings.c.

Referenced by add_term(), check_url(), chop_line(), do_nasty(), get_line(), handle_aliases(), handle_class(), handle_input(), handle_path(), handle_set_options(), handle_triggers(), handle_var(), init_scripts(), log_html(), and ParseLines().

00058 {
00059     char *str_new;
00060     
00061     str_new = strdup(str);
00062     return str_new;
00063     /*char *str_new;
00064 
00065 
00066 
00067     if (str[0] == '\0')
00068         return &str_empty[0];
00069 
00070     if (str >= string_space && str < top_string)
00071         return (char *) str;
00072 
00073     str_new = malloc(strlen (str) + 1);
00074     strcpy (str_new, str);
00075     return str_new;*/
00076     
00077 }

int str_ret const char *  str  ) 
 

Definition at line 107 of file nanomud-strings.c.

00108 {
00109     const char *point=str;
00110     int i;
00111     for (i=0;*point;point++,i++)
00112     {
00113         if (*point == '\e')
00114             return i;
00115     }
00116     return 0;
00117 }

BOOL str_search const char *  str  ) 
 

Definition at line 80 of file nanomud-strings.c.

References BOOL.

Referenced by add_term().

00081 {
00082     
00083     const char *point = str;
00084 
00085 
00086     BOOL efound=FALSE;
00087     BOOL mfound=FALSE;
00088     if (str == NULL)
00089         return FALSE;
00090     for (;;point++)
00091     {
00092         if (*point == '\e')
00093             efound = TRUE;
00094         if (*point == 'm')
00095             mfound = TRUE;
00096         if (!*point)
00097             break;
00098         
00099     }
00100     if (efound && !mfound)
00101         return FALSE;
00102     else
00103         return TRUE;
00104         
00105     
00106 }

BOOL string_compare const char *  ostr,
const char *  tstr
 

Definition at line 41 of file nanomud-strings.c.

References BOOL, and LOWER.

Referenced by handle_aliases(), handle_path(), and handle_triggers().

00042 {
00043     if (ostr == NULL || tstr == NULL)
00044     {
00045         return FALSE;
00046     }
00047     for (;*ostr||*tstr;ostr++,tstr++)
00048     {
00049         if (LOWER(*ostr) != LOWER(*tstr))
00050             
00051             return FALSE;
00052     
00053     }
00054     return TRUE;
00055 }

void strip_junk char *  str  ) 
 

Definition at line 118 of file nanomud-strings.c.

00119 {
00120    
00121     const char *point;
00122     char fleh[8000];
00123     char *buf;
00124     buf = fleh;
00125     char buffer[5000];
00126     if (str == NULL)
00127         return;
00128     point = str;
00129      for (point=str;*point;point++)
00130     {
00131 //        if (*point >= 'A' && *point <= 'Z')
00132         if (*point != '\e')
00133         {
00134            *buf = *point;
00135            *++buf ='\0';
00136         }
00137         
00138     }
00139     *++buf = '\0';
00140     str = buf;
00141     return;
00142 }

bool strprefix const char *  astr,
const char *  bstr
 

Definition at line 146 of file nanomud-strings.c.

References LOWER.

Referenced by handle_input(), and handle_set_options().

00147 {
00148 
00149     if (astr == NULL)
00150         return TRUE;
00151     if (bstr == NULL)
00152         return TRUE;
00153     for (; *astr || *bstr && *astr != '\0'; astr++, bstr++)
00154     {
00155         if (LOWER (*astr) != LOWER (*bstr))
00156             return TRUE;
00157     }
00158 
00159     return FALSE;
00160 }


Variable Documentation

char str_empty[1]
 

Definition at line 32 of file nanomud-strings.c.

char* string_space
 

Definition at line 33 of file nanomud-strings.c.

char* top_string
 

Definition at line 34 of file nanomud-strings.c.


Generated on Sun Dec 26 17:22:54 2004 for mudclient by  doxygen 1.3.9.1