Main Page | Class List | File List | Class Members | File Members

input.h File Reference

Go to the source code of this file.

Functions

int exist (char *fn)
void banner (char *message)
void hdr (char *msg)
void hdr2 (char *msg)
void prompt (char *s)
void read_line1 (char *s)
int strip_comments (char *s)
void strip_ending_whitespace (char *s)
void read_line (char *s)
char upper (char c)
int equals (char *s1, char *s2)
int get_int (void)
double get_real (void)
void get_str (char *s)
char * text (int x)
void open_input_file (char *fn)
int eof_input_file ()
void close_input_file (void)


Function Documentation

void banner char *  message  ) 
 

Definition at line 37 of file input.c.

00038 {
00039   int i;
00040   int x = (75 - strlen(message)) / 2;
00041 
00042   printf("+-----------------------------------------------------------------------------+\n");
00043   printf(": ");
00044   for (i=0; i<x; i++)
00045     putchar(' ');
00046   printf(message);
00047   if (((75 - strlen(message)) % 2) == 1)
00048     putchar(' ');
00049   for (i=0; i<x; i++)
00050     putchar(' ');  
00051   printf(" :\n");
00052   printf("+-----------------------------------------------------------------------------+\n");
00053 }

void close_input_file void   ) 
 

Definition at line 290 of file input.c.

References input_file.

Referenced by set_config().

00291 {
00292   if ((input_file != stdin) && (input_file != NULL))
00293     fclose(input_file);
00294   input_file = stdin;
00295 }

int eof_input_file  ) 
 

Definition at line 298 of file input.c.

References input_file.

Referenced by audio_config(), channel_config(), control_config(), get_config(), mux_config(), mux_table_config(), side_config(), and video_config().

00299 {
00300   return (feof(input_file));
00301 }

int equals char *  s1,
char *  s2
 

Definition at line 186 of file input.c.

00190 {
00191   int i=0;
00192   while ((s1[i]!='\0') && (s2[i]!='\0') && (upper(s1[i])==upper(s2[i])))
00193     i++;
00194   if (s1[i]==s2[i])
00195     return 1;
00196   else
00197     return 0;
00198 }

int exist char *  fn  ) 
 

Definition at line 23 of file input.c.

00027 {
00028   int x = open(fn);
00029   if (x != -1) {
00030     close(x);
00031     x = 1;
00032   } else
00033     x = 0;
00034   return (x);
00035 }

int get_int void   ) 
 

Definition at line 201 of file input.c.

References input_file, and read_line().

00205 {
00206   char s[STRLEN];
00207   int x;
00208 
00209   read_line(s);
00210   x = atoi(s);
00211   if (input_file != stdin)
00212     printf("%d\n", x);
00213   return(x);
00214 }

double get_real void   ) 
 

Definition at line 217 of file input.c.

References input_file, and read_line().

00221 {
00222   char s[STRLEN];
00223   double x;
00224   read_line(s);
00225   x = atof(s);
00226   if (input_file != stdin)
00227     printf("%f\n", x);
00228   return(x);
00229 }

void get_str char *  s  ) 
 

Definition at line 233 of file input.c.

References input_file, and read_line().

Referenced by audio_config(), channel_config(), control_config(), get_config(), mux_config(), mux_table_config(), side_config(), and video_config().

00237 {
00238   read_line(s);
00239   if ((input_file != stdin) && (debug))
00240     printf("%s\n", s);
00241 }

void hdr char *  msg  ) 
 

Definition at line 64 of file input.c.

00065 {
00066   printf("              ##################################################\n");
00067   printf("              # %-46s #\n", msg);
00068   printf("              ##################################################\n");
00069 }

void hdr2 char *  msg  ) 
 

Definition at line 72 of file input.c.

00073 {
00074   printf("          +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+\n");
00075   printf("          | %-55s |\n", msg);
00076   printf("          +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+\n");
00077 }

void open_input_file char *  fn  ) 
 

Definition at line 276 of file input.c.

References error(), input_file, input_filename, and line_number.

Referenced by set_config().

00277 {
00278   if ((input_file != stdin) && (input_file != NULL))
00279     fclose(stdin);
00280   input_file = fopen(fn, "r");
00281   if (input_file != NULL) {
00282     line_number = 0;
00283   }
00284   else {
00285     error("open_input_file", "Couldn't open config file");
00286   }
00287   strcpy(input_filename, fn);
00288 }

void prompt char *  s  ) 
 

Definition at line 79 of file input.c.

References right(), and up().

00080 {
00081   printf("+-----------------------------------------------------------------------------+\n");
00082   printf(":                                                                             :\n");
00083   printf("+-----------------------------------------------------------------------------+\n");
00084   up(2);
00085   right(2);
00086   printf(s);
00087   fflush(stdout);
00088 }

void read_line char *  s  )  [static]
 

Referenced by get_int(), get_real(), and get_str().

void read_line1 char *  s  )  [static]
 

Referenced by read_line().

int strip_comments char *  s  )  [static]
 

Referenced by read_line().

void strip_ending_whitespace char *  s  )  [static]
 

Referenced by read_line().

char* text int  x  ) 
 

Definition at line 244 of file input.c.

00248 {
00249   static char sx[STRLEN];
00250   switch(x) {
00251     case 0: return("Zero");
00252     case 1: return("One");
00253     case 2: return("Two");
00254     case 3: return("Three");
00255     case 4: return("Four");
00256     case 5: return("Five");
00257     case 6: return("Six");
00258     case 7: return("Seven");
00259     case 8: return("Eight");
00260     case 9: return("Nine");
00261     case 10: return("Ten");
00262     case 11: return("Eleven");
00263     case 12: return("Twelve");
00264     case 13: return("Thirteen");
00265     case 14: return("Fourteen");
00266     case 15: return("Fifteen");
00267     case 16: return("Sixteen");
00268     case 17: return("Seventeen");
00269     case 18: return("Eighteen");
00270     case 19: return("Nineteen");
00271     case 20: return("Twenty");
00272     default: sprintf(sx, "%d", x); return(sx);
00273   }
00274 }

char upper char  c  ) 
 

Definition at line 174 of file input.c.

Referenced by equals().

00179 {
00180   if ((c >= 'a') && (c <= 'z'))
00181     return (c - 'a' + 'A');
00182   else
00183     return c;
00184 }


Generated on Sun Jul 16 16:27:47 2006 by  doxygen 1.3.9.1