File: lrsdriver.c

package info (click to toggle)
lrslib 0.73-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,888 kB
  • sloc: ansic: 20,893; sh: 279; makefile: 252; perl: 97; csh: 51
file content (85 lines) | stat: -rwxr-xr-x 1,907 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* This file contains functions and variables that should not be duplicated per arithmetic */

#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <stdlib.h>
#include <limits.h>
#include <sys/time.h>
#include "lrsdriver.h"

/* Globals; these need to be here, rather than lrsdriver.h, so they are
   not multiply defined. */

FILE *lrs_cfp;			/* output file for checkpoint information       */
FILE *lrs_ifp;			/* input file pointer       */
FILE *lrs_ofp;			/* output file pointer      */

char** makenewargv(int *argc,char** argv,char *tmp)
{
  int i;
  char** newargv;

  newargv = (char**) malloc((*argc+3) * sizeof *newargv);
  for(i = 0; i < *argc; ++i)
    {
      if (i != 1)
       {
        size_t length = strlen(argv[i])+1;
        newargv[i] = (char *) malloc(length);
        strcpy(newargv[i], argv[i]);
       }
    }
/* make tmp the new input file */
   size_t length = strlen(tmp)+1;
   newargv[1] = (char *)malloc(length);
   strcpy(newargv[1], tmp);
   if(*argc == 1)         /* input was stdin*/
       *argc = 2;
   newargv[*argc] = NULL;
   return newargv;
}


lrs_restart_dat*
lrs_alloc_restart()
{
  int i;

  lrs_restart_dat *R;

  R = (lrs_restart_dat *) malloc (sizeof (lrs_restart_dat));
  if (R == NULL)
    return R;  
  
  R->overide=0;     /* do not overide Q */
  R->restart=0;     /* do not do a restart */
  R->facet=NULL;    /* this will be allocated later when we know its size */
  R->d=0;
  R->maxcobases=0;
  R->maxdepth=-1;  /* will be set to MAXD in lrs*_main */
  R->mindepth=0;
  R->maxcobases=0;
  for(i=0;i<10;i++)
    R->count[i]=0;
  R->depth=0;
  R->lrs=1;
  R->redund=0;
  R->messages=0;
  R->fel=0;
  R->testlin = 0;
  R->redundphase = 0;
  R->redineq = NULL;
  R->rank = 0;
  R->size = 0;
  return R;
}

char *lrs_basename(char *str)
{
   int i = strlen(str);
   while (i>=0 && str[i]!='/' && str[i]!='\\')
     i--;
   return str+i+1;
}