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

fileutil.c File Reference

#include "lcconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "lcintl.h"
#include "lcstring.h"
#include "ldsvgui.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <ctype.h>
#include "common.h"
#include "lctypes.h"
#include "lin-city.h"
#include "cliglobs.h"
#include "engglobs.h"
#include "fileutil.h"

Go to the source code of this file.

Defines

#define dirent   direct
#define NAMLEN(dirent)   (dirent)->d_namlen
#define DEBUG_PRINTF_TO_FILE   0

Functions

void debug_printf (char *fmt,...)
void dump_screen (void)
void verify_package (void)
const char * guess_category_value (int category, const char *categoryname)
int execute_command (char *cmd, char *p1, char *p2, char *p3)
void copy_file (char *f1, char *f2)
void gunzip_file (char *f1, char *f2)
FILE * fopen_read_gzipped (char *fn)
void fclose_read_gzipped (FILE *fp)
int directory_exists (char *dir)
int file_exists (char *filename)
void find_libdir (void)
void lincity_nl_find_language (char *name)
void find_localized_paths (void)
void init_path_strings (void)
void make_savedir (void)
void check_savedir (void)
void malloc_failure (void)
char * load_graphic (char *s)
void load_lincityrc (void)
void save_lincityrc (void)
void undosify_string (char *s)

Variables

char LIBDIR [LC_PATH_MAX]
char * lc_save_dir
int lc_save_dir_len
char * lc_temp_filename
char given_scene [LC_PATH_MAX]
char colour_pal_file [LC_PATH_MAX]
char opening_pic [LC_PATH_MAX]
char graphic_path [LC_PATH_MAX]
char fontfile [LC_PATH_MAX]
char opening_path [LC_PATH_MAX]
char help_path [LC_PATH_MAX]
char message_path [LC_PATH_MAX]
char lc_textdomain_directory [LC_PATH_MAX]
char lincityrc_file [LC_PATH_MAX]


Define Documentation

#define DEBUG_PRINTF_TO_FILE   0
 

Definition at line 88 of file fileutil.c.

#define dirent   direct
 

Definition at line 53 of file fileutil.c.

#define NAMLEN dirent   )     (dirent)->d_namlen
 

Definition at line 54 of file fileutil.c.


Function Documentation

void check_savedir void   ) 
 

Definition at line 607 of file fileutil.c.

00608 {
00609     int i = 0, j, k, r, l;
00610 
00611     if (!directory_exists (lc_save_dir)) {
00612         make_savedir ();
00613 #if defined (commentout)
00614         l = lc_save_dir_len;
00615         if (l > 160) {
00616             i = l - 160;
00617             l = 160;
00618         }
00619         askdir_lines = l / 40 + ((l % 40) ? 1 : 0);
00620         r = l / askdir_lines + ((l % askdir_lines) ? 1 : 0);
00621         for (j = 0; j < askdir_lines; j++) {
00622             if ((askdir_path[j] = (char *) malloc (r + 1)) == 0)
00623                 malloc_failure ();
00624             for (k = 0; k < r; k++, i++)
00625                 *(askdir_path[j] + k) = lc_save_dir[i];
00626             *(askdir_path[j] + k) = 0;
00627         }
00628         return;
00629 #endif
00630     }
00631 #if defined (commentout)
00632     make_dir_ok_flag = 0;               /* don't load the ask-dir */
00633 #endif
00634 }

void copy_file char *  f1,
char *  f2
 

Definition at line 169 of file fileutil.c.

00170 {
00171   int ret_value = execute_command ("cp", f1, f2, "");
00172   if (ret_value != 0)
00173     {
00174       /* GCS FIX:  Need to make do_error into var_args fn? */
00175       printf ("Tried to cp %s %s\n", f1, f2);
00176       do_error ("Can't copy requested file");
00177     }
00178 }

void debug_printf char *  fmt,
  ...
 

Definition at line 787 of file fileutil.c.

00788 {
00789 #if (DEBUG_PRINTF_TO_FILE)
00790     static int initialized = 0;
00791     char* filename = "debug.txt";
00792     FILE* fp;
00793 #endif
00794     va_list argptr;
00795 
00796 #if (DEBUG_PRINTF_TO_FILE)
00797     va_start (argptr, fmt);
00798     fp = fopen(filename, "a");
00799     if (!initialized) {
00800         initialized = 1;
00801         fprintf (fp, "=========================\n");
00802     }
00803     vfprintf (fp, fmt, argptr);
00804 #endif
00805 
00806     if (command_line_debug) {
00807 #if (!DEBUG_PRINTF_TO_FILE)
00808       va_start (argptr, fmt);
00809 #endif
00810       vprintf (fmt, argptr);
00811 #if (!DEBUG_PRINTF_TO_FILE)
00812       va_end (argptr);
00813 #endif
00814     }
00815 
00816 #if (DEBUG_PRINTF_TO_FILE)
00817     va_end (argptr);
00818     fclose (fp);
00819 #endif
00820 }

int directory_exists char *  dir  ) 
 

Definition at line 241 of file fileutil.c.

00242 {
00243 #if defined (WIN32)
00244     if (_chdir (dir) == -1) {
00245         _chdir (LIBDIR);                /* go back... */
00246         return 0;
00247     }
00248     _chdir (LIBDIR);            /* go back... */
00249 #else /* UNIX */
00250     DIR *dp;
00251     if ((dp = opendir (dir)) == NULL) {
00252         return 0;
00253     }
00254     closedir (dp);
00255 #endif
00256     return 1;
00257 }

void dump_screen void   ) 
 

Definition at line 2583 of file screen.c.

02584 {
02585 #if !defined (LC_X11) && !defined (WIN32)
02586     int x, y, r, g, b;
02587     FILE *outf;
02588     if ((outf = fopen ("screendump.raw", "wb")) == NULL)
02589         do_error ("Can't open screendump.raw");
02590     for (y = 0; y < 480; y++)
02591         for (x = 0; x < 640; x++)
02592         {
02593             gl_getpixelrgb (x, y, &r, &g, &b);
02594             fputc (r, outf);
02595             fputc (g, outf);
02596             fputc (b, outf);
02597         }
02598     fclose (outf);
02599 #endif
02600 }

int execute_command char *  cmd,
char *  p1,
char *  p2,
char *  p3
 

Definition at line 152 of file fileutil.c.

00153 {
00154   char *sys_cmd = (char *) malloc (strlen (cmd) + strlen (p1) + strlen (p2)
00155                                    + strlen (p3) + 4);
00156   int ret_value;
00157 
00158   if (sys_cmd == 0) {
00159     malloc_failure ();
00160   }
00161   sprintf (sys_cmd, "%s %s %s %s", cmd, p1, p2, p3);
00162   ret_value = system (sys_cmd);
00163 /* fprintf(stderr, "system(%s)=%i\n", sys_cmd, ret_value); */
00164   free (sys_cmd);
00165   return ret_value;
00166 }

void fclose_read_gzipped FILE *  fp  ) 
 

Definition at line 228 of file fileutil.c.

00229 {
00230 #if defined (HAVE_GZIP) && defined (HAVE_POPEN)
00231     pclose (fp);
00232 #elif defined (HAVE_GZIP) && !defined (HAVE_POPEN)
00233     fclose (fp);
00234     remove (lc_temp_filename);
00235 #else
00236     fclose (fp);
00237 #endif
00238 }

int file_exists char *  filename  ) 
 

Definition at line 260 of file fileutil.c.

00261 {
00262     FILE* fp;
00263     fp = fopen (filename,"rb");
00264     if (fp == NULL) {
00265         return 0;
00266     }
00267     fclose (fp);
00268     return 1;
00269 }

void find_libdir void   ) 
 

Definition at line 307 of file fileutil.c.

00308 {
00309     const char searchfile[] = "colour.pal";
00310     char *home_dir, *cwd;
00311     char cwd_buf[LC_PATH_MAX];
00312     char filename_buf[LC_PATH_MAX];
00313 
00314     /* Check 1: environment variable */
00315     home_dir = getenv ("LINCITY_HOME");
00316     if (home_dir) {
00317         snprintf (filename_buf, LC_PATH_MAX, "%s%c%s", 
00318                   home_dir, PATH_SLASH, searchfile);
00319         if (file_exists(filename_buf)) {
00320             strncpy (LIBDIR, home_dir, LC_PATH_MAX);
00321             return;
00322         }
00323     }
00324 
00325     /* Check 2: current working directory */
00326     cwd = getcwd (cwd_buf, LC_PATH_MAX);
00327     if (cwd) {
00328         snprintf (filename_buf, LC_PATH_MAX, "%s%c%s", 
00329                   cwd_buf, PATH_SLASH, searchfile);
00330         if (file_exists(filename_buf)) {
00331             strncpy (LIBDIR, cwd_buf, LC_PATH_MAX);
00332             return;
00333         }
00334     }
00335 
00336     /* Check 3: default (configuration) directory */
00337     snprintf (filename_buf, LC_PATH_MAX, "%s%c%s", 
00338               DEFAULT_LIBDIR, PATH_SLASH, searchfile);
00339     if (file_exists(filename_buf)) {
00340         strncpy (LIBDIR, DEFAULT_LIBDIR, LC_PATH_MAX);
00341         return;
00342     }
00343 
00344     /* Finally give up */
00345     HandleError (_("Error. Can't find LINCITY_HOME"), FATAL);
00346 }

void find_localized_paths void   ) 
 

Definition at line 410 of file fileutil.c.

00411 {
00412   int messages_done = 0;
00413   int help_done = 0;
00414 
00415   const char* intl_suffix = "";
00416   char intl_lang[128];
00417 
00418   /* First, try the locale "as is" */
00419 #if defined (ENABLE_NLS) && defined (HAVE_LC_MESSAGES)
00420   intl_suffix = guess_category_value(LC_MESSAGES,"LC_MESSAGES");
00421 #else
00422   intl_suffix = guess_category_value(0,"LC_MESSAGES");
00423 #endif
00424   debug_printf ("GUESS 1 -- intl_suffix is %s\n", intl_suffix);
00425   if (strcmp(intl_suffix,"C") && strcmp(intl_suffix,"")) {
00426     sprintf (message_path, "%s%c%s%c%s%c", LIBDIR, PATH_SLASH, "messages",
00427              PATH_SLASH, intl_suffix, PATH_SLASH);
00428     debug_printf ("Trying Message Path %s\n", message_path);
00429     if (directory_exists(message_path)) {
00430       debug_printf ("Set Message Path %s\n", message_path);
00431       messages_done = 1;
00432     }
00433     sprintf (help_path, "%s%c%s%c%s%c", LIBDIR, PATH_SLASH, "help",
00434              PATH_SLASH, intl_suffix, PATH_SLASH);
00435     debug_printf ("Trying Help Path %s\n", help_path);
00436     if (directory_exists(help_path)) {
00437       debug_printf ("Set Help Path %s\n", help_path);
00438       help_done = 1;
00439     }
00440   }
00441   if (messages_done && help_done) return;
00442 
00443   /* Next, try stripping off the country suffix */
00444   strncpy (intl_lang, intl_suffix, 128);
00445   intl_lang[127] = '\0';
00446   lincity_nl_find_language (intl_lang);
00447   intl_suffix = intl_lang;
00448   debug_printf ("GUESS 2 -- intl_suffix is %s\n", intl_suffix);
00449   if (strcmp(intl_suffix,"C") && strcmp(intl_suffix,"")) {
00450     if (!messages_done) {
00451       sprintf (message_path, "%s%c%s%c%s%c", LIBDIR, PATH_SLASH, "messages",
00452                PATH_SLASH, intl_suffix, PATH_SLASH);
00453       debug_printf ("Trying Message Path %s\n", message_path);
00454       if (directory_exists(message_path)) {
00455         debug_printf ("Set Message Path %s\n", message_path);
00456         messages_done = 1;
00457       }
00458     }
00459     if (!help_done) {
00460       sprintf (help_path, "%s%c%s%c%s%c", LIBDIR, PATH_SLASH, "help",
00461                PATH_SLASH, intl_suffix, PATH_SLASH);
00462       debug_printf ("Trying Help Path %s\n", help_path);
00463       if (directory_exists(help_path)) {
00464         debug_printf ("Set Help Path %s\n", help_path);
00465         help_done = 1;
00466       }
00467     }
00468   }
00469   if (messages_done && help_done) return;
00470     
00471   /* Finally, settle for default English messages */
00472   if (!messages_done) {
00473     sprintf (message_path, "%s%c%s%c", LIBDIR, PATH_SLASH, "messages",
00474              PATH_SLASH);
00475     debug_printf ("Settling for message Path %s\n", message_path);
00476   }
00477   if (!help_done) {
00478     sprintf (help_path, "%s%c%s%c", LIBDIR, PATH_SLASH, "help",
00479              PATH_SLASH);
00480     debug_printf ("Settling for help Path %s\n", help_path);
00481   }
00482 }

FILE* fopen_read_gzipped char *  fn  ) 
 

Definition at line 193 of file fileutil.c.

00194 {
00195     FILE* fp;
00196 
00197 #if defined (HAVE_GZIP) && defined (HAVE_POPEN)
00198 #ifdef __EMX__
00199     const char* cmd_str = "gzip -d -c < %s 2> nul";
00200 #else
00201     const char* cmd_str = "gzip -d -c < %s 2> /dev/null";
00202 #endif
00203     char *cmd = (char*) malloc (strlen (cmd_str) + strlen (fn) + 1);
00204     
00205     sprintf (cmd, cmd_str, fn);
00206 #ifdef __EMX__
00207     fp=popen(cmd,"rb");
00208 #else
00209     fp=popen(cmd,"r");
00210 #endif
00211     if (fp==NULL) {
00212        fprintf(stderr, "Failed to open pipe cmd: %s\n", cmd);
00213     }
00214     free(cmd);
00215 
00216 #elif defined (HAVE_GZIP) && !defined (HAVE_POPEN)
00217     gunzip_file (fn, lc_temp_filename);
00218     fp = fopen (lc_temp_filename, "rb");
00219 
00220 #else /* No gzip */
00221     fp = fopen (fn, "rb");
00222 #endif
00223 
00224     return fp;
00225 }

const char * guess_category_value int  category,
const char *  categoryname
[static]
 

Definition at line 355 of file fileutil.c.

00356 {
00357     const char *retval;
00358 
00359     /* The highest priority value is the `LANGUAGE' environment
00360        variable.  This is a GNU extension.  */
00361     retval = getenv ("LANGUAGE");
00362     if (retval != NULL && retval[0] != '\0')
00363         return retval;
00364 
00365     /* `LANGUAGE' is not set.  So we have to proceed with the POSIX
00366        methods of looking to `LC_ALL', `LC_xxx', and `LANG'.  On some
00367        systems this can be done by the `setlocale' function itself.  */
00368 #if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
00369     retval = setlocale (category, NULL);
00370     if (retval != NULL)
00371       return retval;
00372     else
00373       return "C";
00374 #else
00375     /* Setting of LC_ALL overwrites all other.  */
00376     retval = getenv ("LC_ALL");
00377     if (retval != NULL && retval[0] != '\0')
00378         return retval;
00379 
00380     /* Next comes the name of the desired category.  */
00381     retval = getenv (categoryname);
00382     if (retval != NULL && retval[0] != '\0')
00383         return retval;
00384 
00385     /* Last possibility is the LANG environment variable.  */
00386     retval = getenv ("LANG");
00387     if (retval != NULL && retval[0] != '\0')
00388         return retval;
00389 
00390     /* We use C as the default domain.  POSIX says this is implementation
00391        defined.  */
00392     return "C";
00393 #endif
00394 }

void gunzip_file char *  f1,
char *  f2
 

Definition at line 181 of file fileutil.c.

00182 {
00183   int ret_value = execute_command ("gzip -c -d", f1, ">", f2);
00184   if (ret_value != 0)
00185     {
00186       /* GCS FIX:  Need to make do_error into var_args fn? */
00187       printf ("Tried to gzip -c -d %s > %s\n", f1, f2);
00188       do_error ("Can't gunzip requested file");
00189     }
00190 }

void init_path_strings void   ) 
 

Definition at line 486 of file fileutil.c.

00487 {
00488     char* homedir = NULL;
00489     const char* intl_suffix = "";
00490     char* dm = NULL;
00491     char* td = NULL;
00492 
00493     find_libdir ();
00494 
00495 #if defined (WIN32)
00496     homedir = LIBDIR;
00497 #elif defined (__EMX__)
00498     homedir = getenv ("HOME");
00499 #else
00500     homedir = getenv ("HOME");
00501 #endif
00502 
00503     /* Various dirs and files */
00504     lc_save_dir_len = strlen (homedir) + strlen (LC_SAVE_DIR) + 1;
00505     if ((lc_save_dir = (char *) malloc (lc_save_dir_len + 1)) == 0)
00506         malloc_failure ();
00507     sprintf (lc_save_dir, "%s%c%s", homedir, PATH_SLASH, LC_SAVE_DIR);
00508     sprintf (colour_pal_file, "%s%c%s", LIBDIR, PATH_SLASH, "colour.pal");
00509     sprintf (opening_path, "%s%c%s", LIBDIR, PATH_SLASH, "opening");
00510 #if defined (WIN32)
00511     sprintf (opening_pic, "%s%c%s",opening_path,PATH_SLASH,"open.tga");
00512 #else
00513     sprintf (opening_pic, "%s%c%s",opening_path,PATH_SLASH,"open.tga.gz");
00514 #endif
00515     sprintf (graphic_path, "%s%c%s%c", LIBDIR, PATH_SLASH, "icons",
00516              PATH_SLASH);
00517     sprintf (lincityrc_file, "%s%c%s", homedir, PATH_SLASH, 
00518         LINCITYRC_FILENAME);
00519 
00520     /* Paths for message & help files, etc */
00521     find_localized_paths ();
00522 
00523     /* Font stuff */
00524     sprintf (fontfile, "%s%c%s", opening_path, PATH_SLASH,
00525              "iso8859-1-8x8.raw");
00526 #if defined (WIN32)
00527     /* GCS: Use windows font for extra speed */
00528     strcpy (windowsfontfile, LIBDIR);
00529 #if defined (commentout)
00530     if (!pix_double)
00531         strcat (windowsfontfile, "\\opening\\iso8859-1-8x8.fnt");
00532     else
00533         strcat (windowsfontfile, "\\opening\\iso8859-1-9x15.fnt");
00534 #endif
00535     if (!pix_double)
00536         strcat (windowsfontfile, "\\opening\\winfont_8x8.fnt");
00537     else
00538         strcat (windowsfontfile, "\\opening\\winfont_16x16.fnt");
00539 #endif
00540 
00541     /* Temp file for results */
00542     lc_temp_filename = (char *) malloc (lc_save_dir_len + 16);
00543     if (lc_temp_filename == 0) {
00544         malloc_failure ();
00545     }
00546     sprintf (lc_temp_filename, "%s%c%s", lc_save_dir, PATH_SLASH, "tmp-file");
00547 
00548     /* Path for localization */
00549 #if defined (ENABLE_NLS)
00550 #if defined (WIN32)
00551     sprintf (lc_textdomain_directory, "%s%c%s", LIBDIR, PATH_SLASH, "locale");
00552 #else
00553     strcpy (lc_textdomain_directory, LOCALEDIR);
00554 #endif
00555     dm = bindtextdomain (PACKAGE, lc_textdomain_directory);
00556     debug_printf ("Bound textdomain directory is %s\n", dm);
00557     td = textdomain (PACKAGE);
00558     debug_printf ("Textdomain is %s\n", td);
00559 #endif
00560 }

void lincity_nl_find_language char *  name  )  [static]
 

Definition at line 399 of file fileutil.c.

00400 {
00401   while (name[0] != '\0' && name[0] != '_' && name[0] != '@'
00402          && name[0] != '+' && name[0] != ',')
00403     ++name;
00404 
00405   *name = '\0';
00406 }

char* load_graphic char *  s  ) 
 

Definition at line 644 of file fileutil.c.

00645 {
00646     int x,l;
00647     char ss[LC_PATH_MAX],*graphic;
00648     FILE *inf;
00649     strcpy(ss,graphic_path);
00650     strcat(ss,s);
00651     if ((inf=fopen(ss,"rb"))==NULL)
00652     {
00653         strcat(ss," -- UNABLE TO LOAD");
00654         do_error(ss);
00655     }
00656     fseek(inf,0L,SEEK_END);
00657     l=ftell(inf);
00658     fseek(inf,0L,SEEK_SET);
00659     graphic=(char *)malloc(l);
00660     for (x=0;x<l;x++)
00661         *(graphic+x)=fgetc(inf);
00662     fclose(inf);
00663     return(graphic);
00664 }

void load_lincityrc void   ) 
 

Definition at line 667 of file fileutil.c.

00668 {
00669     FILE *fp;
00670     int arg;
00671     char buf[128];
00672 
00673     if ((fp = fopen (lincityrc_file, "r")) == 0) {
00674         save_lincityrc();
00675         return;
00676     }
00677     while (fgets (buf,128,fp)) {
00678         if (sscanf(buf,"overwrite_transport=%d",&arg)==1) {
00679             overwrite_transport_flag = !!arg;
00680             continue;
00681         }
00682         if (sscanf(buf,"no_init_help=%d",&arg)==1) {
00683             /* Careful here ... */
00684             no_init_help = !!arg;
00685             continue;
00686         }
00687         if (sscanf(buf,"skip_splash_screen=%d",&arg)==1) {
00688             skip_splash_screen = !!arg;
00689             continue;
00690         }
00691         if (sscanf(buf,"suppress_firsttime_module_help=%d",&arg)==1) {
00692             suppress_firsttime_module_help = !!arg;
00693             continue;
00694         }
00695         if (sscanf(buf,"suppress_popups=%d",&arg)==1) {
00696             suppress_popups = !!arg;
00697             continue;
00698         }
00699         if (sscanf(buf,"time_multiplex_stats=%d",&arg)==1) {
00700             time_multiplex_stats = !!arg;
00701             continue;
00702         }
00703         if (sscanf(buf,"x_confine_pointer=%d",&arg)==1) {
00704             confine_flag = !!arg;
00705             continue;
00706         }
00707     }
00708     fclose (fp);
00709 }

void make_savedir void   ) 
 

Definition at line 573 of file fileutil.c.

00574 {
00575 #if !defined (WIN32)
00576     DIR *dp;
00577 #endif
00578 
00579 #if defined (commentout)
00580     if (make_dir_ok_flag == 0)
00581         return;
00582 #endif
00583 
00584 #if defined (WIN32)
00585     if (_mkdir (lc_save_dir)) {
00586         printf (_("Couldn't create the save directory %s\n"), lc_save_dir);
00587         exit (-1);
00588     }
00589 #else
00590     mkdir (lc_save_dir, 0755);
00591     chown (lc_save_dir, getuid (), getgid ());
00592     if ((dp = opendir (lc_save_dir)) == NULL)
00593     {
00594         /* change this to a screen message. */
00595         printf (_("Couldn't create the save directory %s\n"), lc_save_dir);
00596         exit (1);
00597     }
00598     closedir (dp);
00599 #endif
00600 
00601 #if defined (commentout)
00602     make_dir_ok_flag = 0;
00603 #endif
00604 }

void malloc_failure void   ) 
 

Definition at line 637 of file fileutil.c.

00638 {
00639   printf (_("Out of memory: malloc failure\n"));
00640   exit (1);
00641 }

void save_lincityrc void   ) 
 

Definition at line 712 of file fileutil.c.

00713 {
00714     FILE *fp;
00715 
00716     if ((fp = fopen (lincityrc_file, "w")) == 0) {
00717         return;
00718     }
00719 
00720     fprintf (fp, 
00721         "# Set this if you want to be able to overwrite one\n"
00722         "# kind of transport with another.\n"
00723         "overwrite_transport=%d\n\n",
00724         overwrite_transport_flag);
00725     fprintf (fp, 
00726         "# Set this if you don't want the opening help screen.\n"
00727         "no_init_help=%d\n\n",
00728         no_init_help
00729         );
00730     fprintf (fp,
00731         "# Set this if you don't want the opening splash screen.\n"
00732         "skip_splash_screen=%d\n\n",
00733         skip_splash_screen
00734         );
00735     fprintf (fp,
00736         "# Set this if you don't want help the first time you\n"
00737         "# click to place an item.\n"
00738         "suppress_firsttime_module_help=%d\n\n", 
00739         suppress_firsttime_module_help
00740         );
00741     fprintf (fp,
00742         "# Set this if don't want modal dialog boxes which you\n"
00743         "# are required to click OK.  Instead, report the dialog\n"
00744         "# box information to the message area.\n"
00745         "suppress_popups=%d\n\n",
00746         suppress_popups
00747         );
00748     fprintf (fp,
00749         "# Set this if want the different statistic windows to cycle\n"
00750         "# through the right panel.\n"
00751         "time_multiplex_stats=%d\n\n",
00752         time_multiplex_stats
00753         );
00754     fprintf (fp,
00755         "# (X Windows only) Set this if you want to confine the pointer\n"
00756         "# to within the window.\n"
00757         "x_confine_pointer=%d\n\n",
00758         confine_flag
00759         );
00760 
00761     fclose (fp);
00762 }

void undosify_string char *  s  ) 
 

Definition at line 765 of file fileutil.c.

00766 {
00767     /* Convert '\r\n' to '\n' in string */
00768     char prev_char = 0;
00769     char *p = s, *q = s;
00770     while (*p) {
00771         if (*p != '\r') {
00772             if (prev_char == '\r' && *p != '\n') {
00773                 *q++ = '\n';
00774             }
00775             *q++ = *p;
00776         }
00777         prev_char = *p;
00778         p++;
00779     }
00780     if (prev_char == '\r') {
00781         *q++ = '\n';
00782     }
00783     *q = '\0';
00784 }

void verify_package void   ) 
 

Definition at line 563 of file fileutil.c.

00564 {
00565     FILE *fp = fopen (colour_pal_file,"rb");
00566     if (!fp) {
00567         do_error (_("Error verifying package. Can't find colour.pal."));
00568     }
00569     fclose (fp);
00570 }


Variable Documentation

char colour_pal_file[LC_PATH_MAX]
 

Definition at line 109 of file fileutil.c.

char fontfile[LC_PATH_MAX]
 

Definition at line 112 of file fileutil.c.

char given_scene[LC_PATH_MAX]
 

Definition at line 108 of file fileutil.c.

char graphic_path[LC_PATH_MAX]
 

Definition at line 111 of file fileutil.c.

char help_path[LC_PATH_MAX]
 

Definition at line 114 of file fileutil.c.

char* lc_save_dir
 

Definition at line 104 of file fileutil.c.

int lc_save_dir_len
 

Definition at line 105 of file fileutil.c.

char* lc_temp_filename [static]
 

Definition at line 106 of file fileutil.c.

char lc_textdomain_directory[LC_PATH_MAX]
 

Definition at line 116 of file fileutil.c.

char LIBDIR[LC_PATH_MAX]
 

Definition at line 102 of file fileutil.c.

char lincityrc_file[LC_PATH_MAX]
 

Definition at line 117 of file fileutil.c.

char message_path[LC_PATH_MAX]
 

Definition at line 115 of file fileutil.c.

char opening_path[LC_PATH_MAX]
 

Definition at line 113 of file fileutil.c.

char opening_pic[LC_PATH_MAX]
 

Definition at line 110 of file fileutil.c.


Generated on Sun Dec 26 11:23:28 2004 for lincity by  doxygen 1.3.9.1