"Fossies" - the Fresh Open Source Software Archive

Member "statist-1.4.2/src/statist.h" (21 Dec 2009, 9110 Bytes) of package /linux/privat/old/statist-1.4.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "statist.h" see the Fossies "Dox" file reference documentation.

    1 /* This file is part of statist
    2 **
    3 ** It is distributed under the GNU General Public License.
    4 ** See the file COPYING for details.
    5 **
    6 ** (c) 1997 Dirk Melcher
    7 ** old email address: Dirk.Melcher@usf.Uni-Osnabrueck.DE
    8 **
    9 ** adaptions for StatistX: Andreas Beyer, 1999, abeyer@usf.uni-osnabrueck.de
   10 **
   11 ** published by Bernhard Reiter  http://www.usf.Uni-Osnabrueck.DE/~breiter
   12 ** $Id: statist.h,v 1.41 2009/12/10 13:17:03 jakson Exp $
   13 ***************************************************************/
   14 
   15 #include <stdio.h>
   16 
   17 #include "gettext.h"
   18 #include "memory_handling.h"
   19 
   20 
   21 /* next two defines are important for gettext */
   22 #define PACKAGE "statist"
   23 /* LOCALEDIR should be set by Makefile, this is a fallback  */
   24 #ifndef LOCALEDIR
   25 #  define LOCALEDIR "/usr/share/locale"
   26 #endif
   27 
   28 
   29 #define _STATIST_VERSION_NUMBER "1.4.2"
   30 #define VERSION_INFO N_("\nSTATIST --- Version %s\n " \
   31 "(C) Dirk Melcher 1997-1999\n \
   32 (C) Bernhard Reiter 1998-2009\n \
   33 (C) Jakson Aquino 2005-2009\n \
   34 STATIST comes with ABSOLUTELY NO WARRANTY; it is Free Software under GNU GPL.\n\
   35  Read the file COPYING for details.\n\n")
   36 
   37 #define STATIST_VERSION "statist -- version " _STATIST_VERSION_NUMBER
   38 
   39 #ifdef MSDOS
   40   /* change the MSDOS_FIXED_TMP_FILE, if you want statist to create
   41     the temporary files at a different place on MSDOS
   42     "%i"  must be in the string once, to replaced by an (integer) number
   43    */
   44 #ifndef MSDOS_FIXED_TMP_FILE
   45 #define MSDOS_FIXED_TMP_FILE "c:\\tmp\\stat%i.tmp"
   46 #endif
   47 #endif
   48 
   49 
   50 /* others may define TRUE & FALSE, too! */
   51 #ifndef TRUE
   52 #define TRUE 1
   53 #endif
   54 #ifndef FALSE
   55 #define FALSE 0
   56 #endif
   57 
   58 #define CRASH -1
   59 #define CHAR_OFFSET 97  /* 'a' position in ASCII-Code */
   60 #define QUIT 0
   61 #define COMMENT '#'  /* Symbol that indicates commentary in data files */
   62 #define _ALL_ N_("all")  /* alias for: "all columns" */
   63 #define MCLASS 60    /* Max. number of classes on normal distribution test */
   64 #define MPOLY 20     /* Maximum degree of polynomial */
   65 #define MOPT  24     /* Total number of options */
   66 #define MLINE 255    /* Maximum number of chars for standard line variable */
   67 
   68 #define WAR 0   /* Error - Warning */
   69 #define ERR 1   /* Normal Error */
   70 #define FAT 2   /* Fatal Error */
   71 #define MAT 3   /* Math Error */
   72 #define MWA 4   /* Math Warning */
   73 
   74 #define SQR(x) ((x) * (x))
   75 
   76 #define GETRLINE  fgets((line), (MLINE-1), (stdin));    \
   77           if (strlen(line) <=1) {       \
   78             empty = TRUE;           \
   79             return;                 \
   80           }                 \
   81           else {                \
   82             line[strlen(line)-1]='\0';      \
   83             empty = FALSE;          \
   84           }
   85 
   86 #define GETNLINE  fgets((line), (MLINE-1), (stdin));    \
   87           if (strlen(line) <=1) {       \
   88             empty = TRUE;           \
   89           }                 \
   90           else {                \
   91             line[strlen(line)-1]='\0';      \
   92             empty = FALSE;          \
   93           }
   94 
   95 #define GETBLINE fgets((line), (MLINE-1), (stdin)); \
   96           if (strlen(line) <=1) {       \
   97             empty = TRUE;           \
   98             break;              \
   99           }                 \
  100           else {                \
  101             line[strlen(line)-1]='\0';      \
  102             empty = FALSE;          \
  103           }
  104 
  105 #ifdef SUNOS
  106 extern char *sys_errlist[];
  107 #define STRERROR(errn) sys_errlist[errn]
  108 #else
  109 #define STRERROR(errn) strerror(errn)
  110 #endif
  111 
  112 #ifdef DEBUG
  113 #define ERR_LINE __LINE__
  114 #define ERR_FILE __FILE__
  115 #else
  116 #define ERR_LINE 0
  117 #define ERR_FILE ""
  118 #endif
  119 
  120 
  121 #define FOPEN(name, mode, fp)                   \
  122   if ((fp = fopen((name), (mode)))==NULL) {         \
  123     out_err(FAT, ERR_FILE, ERR_LINE,                \
  124     _(" System reports error while opening file %s:\n   %s"),   \
  125        name, STRERROR(errno));                  \
  126   }
  127 
  128 #define FWRITE(ptr, size, nmemb, fp)                \
  129   if (fwrite((ptr), (size), (nmemb), (fp)) != (nmemb)) {    \
  130     out_err(FAT,ERR_FILE, ERR_LINE,             \
  131     _(" System reports error while writing with fwrite:\n %s"), \
  132           STRERROR(errno));                 \
  133   }
  134 
  135 #define FREAD(ptr, size, nmemb, fp)                 \
  136   if (fread((ptr), (size), (nmemb), (fp)) != (nmemb)) {         \
  137     if (feof(fp)) {                         \
  138       out_err(FAT, ERR_FILE, ERR_LINE,                  \
  139     _(" Error while reading with fread: Unexpected end of file") ); \
  140     }                                   \
  141     else {                              \
  142       out_err(FAT, ERR_FILE, ERR_LINE,                  \
  143       _("System reports error while reading with fread:\n %s"), \
  144           STRERROR(errno));                     \
  145     }                                   \
  146   }
  147 
  148 #define FGETS(line, size, fp)                       \
  149   if (fgets((line), (size), (fp))==NULL) {              \
  150     if (feof(fp)) {                         \
  151       out_err(FAT, ERR_FILE, ERR_LINE,                  \
  152     _("   Error while reading with fgets: Unexpected end of file\n") );\
  153     }                                   \
  154     else {                              \
  155       out_err(FAT, ERR_FILE, ERR_LINE,                  \
  156     _(" System reports error while reading with fgets:\n   %s"),    \
  157           STRERROR(errno));                     \
  158     }                                   \
  159   }
  160 
  161 #define FCLOSE(fp)                          \
  162   if (fclose(fp) != 0) {                        \
  163     out_err(ERR, ERR_FILE, ERR_LINE,                    \
  164     _("System reports error while attempting to close file:\n  %s"),    \
  165         STRERROR(errno));                       \
  166   }
  167 
  168 #define DIV(r, c, d)                        \
  169    if ((d)==0.0) {                      \
  170      out_err(MAT, ERR_FILE, ERR_LINE, _("Division by 0!") );    \
  171      return;                            \
  172    }                                \
  173    else {                           \
  174      r = (c)/(d);                       \
  175    }
  176 
  177 #define RDIV(r, c, d)                       \
  178    if ((d)==0.0) {                      \
  179      out_err(MAT, ERR_FILE, ERR_LINE, _("Division by 0!") );    \
  180      return REAL_MIN;                       \
  181    }                                \
  182    else {                           \
  183      r = (c)/(d);                       \
  184    }
  185 
  186 #define SQRT(y, x)                      \
  187   if ((x) < 0.0) {                      \
  188      out_err(MAT, ERR_FILE, ERR_LINE,               \
  189         _("Square root with negative argument!") );     \
  190      return;                            \
  191   }                             \
  192   else {                            \
  193      y = sqrt(x);                       \
  194   }
  195 
  196 #define RSQRT(y, x)                     \
  197   if ((x) < 0.0) {                      \
  198      out_err(MAT, ERR_FILE, ERR_LINE,               \
  199         _("Square root with negative argument!") );     \
  200      return REAL_MIN;                       \
  201   }                             \
  202   else {                            \
  203      y = sqrt(x);                       \
  204   }
  205 
  206 
  207 #define REAL_EPSILON DBL_EPSILON
  208 #define REAL_MAX     DBL_MAX
  209 #define REAL_MIN    (-DBL_MAX)
  210 
  211 typedef short int BOOLEAN;
  212 typedef double REAL;
  213 typedef REAL* PREAL;
  214 
  215 typedef struct {
  216   REAL val, rank;
  217   int ind;
  218 } SORTREC;
  219 
  220 
  221 #include <errno.h>
  222 extern void mywait();
  223 extern BOOLEAN myexist(char *name);
  224 #ifdef STATIST_X
  225 extern void out_start(); /* start results output  */
  226 extern void out_end();   /* end results output    */
  227 #else
  228 #   define out_start()
  229 #   define out_end()
  230 #endif
  231 extern void out_d(char *fmt, ...);
  232 extern void out_i(char *fmt, ...);
  233 extern void out_r(char *fmt, ...);
  234 extern void out_err(int errn, char *modul, int lno, char *fmt, ...);
  235 extern void print_histo(REAL x[], int y[], int n);
  236 extern void finish();
  237 extern BOOLEAN ls();
  238 extern void save_prefs();
  239 
  240 extern void set_winsize();
  241 extern size_t stringLen(char *s);
  242 extern int SCRLINES, SCRCOLS, rcols, rlines, MRESULT;
  243 extern REAL SYSMIS; /* 'M's are put in tempfiles with this value */
  244 extern char *NODATA;   /* Symbol that indicates missing values in data files */
  245 extern char *sourcename;
  246 extern char sep; /* Field separator in csv files */
  247 extern char dec; /* Decimal delimiter in data files */
  248 extern PREAL  *yy, tempcol;
  249 extern int MCOL;  /* Max. number of columns that can be loaded before
  250              reallocating memory */
  251 extern int *ny;
  252 
  253 typedef struct { 
  254   char *clabel; /* The column label as it appears in the datafile */
  255   char *ctitle; /* A longer name for the column (can contain spaces) */
  256   int n;    /* Number of value labels for this column */
  257   REAL *v;  /* List of values with labels */
  258   char **l; /* List of value labels */
  259   void *next;
  260 } Labels;
  261 
  262 extern Labels **names; /* Pointer to labels for specific columns */
  263 extern Labels *first_labels, /* The first one in a linked list of labels */
  264        *old_first_labels; /* Will store first_labels if the user chooses do not
  265                  show labels */
  266 
  267 /* "struct" COLUMN */
  268 extern PREAL  *xx;      /* column data */
  269 extern char **alias;    /* column label */
  270 extern FILE **tmpptr;  /* pointers to temporary files */
  271 extern int *nn,  /* number of data points in tempfile (total) */
  272     *vn;     /* number of (valid) data points in ram */
  273 extern BOOLEAN *x_read; /* is the column already in ram? */
  274 
  275 extern BOOLEAN empty, gnupl_open, verbose;
  276 extern int     ncol, /* number of columns in the entire database */
  277            *acol, /* list of columns currently in ram */
  278            status;
  279 extern char    line[MLINE];
  280 extern FILE    *logfile;
  281 extern BOOLEAN silent, noplot, help, log_set, nofile, nobell, thist, bernhard,
  282        has_header, noheader, color, quoted;
  283 
  284 extern FILE   *pipef;
  285 
  286 extern char *ls_cmd, *gtprefix, *gplt_default_term, *gplt_png;
  287 extern BOOLEAN system_ls, format_columns_out, detect_header, ask_fileformat, int_as_int;
  288 extern BOOLEAN is_utf8; /* Is the user locale set to UTF-8 ?*/
  289 #ifdef MSDOS
  290 extern char msdos_temp_dir[255];
  291 #endif
  292 /* These macros are used because Gnuplot has problems to
  293    deal with other locales than the standard C-locale. */
  294 #ifndef NO_GETTEXT
  295 extern char *saved_locale, *old_locale;
  296 #define SET_C_LOCALE    \
  297     old_locale = setlocale (LC_NUMERIC, NULL); \
  298     saved_locale = mymalloc(strlen(old_locale)+1); \
  299     strcpy(saved_locale, old_locale); \
  300     setlocale(LC_NUMERIC, "C");
  301 
  302 #define RESET_LOCALE \
  303     setlocale (LC_NUMERIC, saved_locale); \
  304     free(saved_locale); saved_locale = NULL;
  305 #endif
  306 
  307 
  308 void colorize(int cl);
  309 #define ClDefault 0
  310 #define ClError 1
  311 #define ClErrorD 2
  312 #define ClInstr 3
  313 #define ClHeader 4
  314 #define ClLineNum 5
  315 #define ClMenuSep 6
  316