Пример #1
0
int main(int argc, char **argv) 
{
    if (argc != 4) {
        printf("Usage: %s <list.txt> <bundle.out> <output_path>\n", argv[0]);
        return 1;
    }
    
    char *list_file = argv[1];
    char *bundle_file = argv[2];
    char *output_path = argv[3];

    /* Read the bundle file */
    std::vector<camera_params_t> cameras;
    std::vector<point_t> points;
    std::vector<std::string> files;
    std::vector<std::string> files2;

    if (strcmp(list_file, "none") != 0)
        ReadListFile(list_file, files);

    ReadBundleFile(bundle_file, files2, cameras, points);

    if (files2.size() > 0)
        files = files2;

    assert(files.size() > 0);

    UndistortImages(output_path, files, cameras);
    WriteNewFiles(output_path, files, cameras, points);

    return 0;
}
Пример #2
0
int main(int argc, char **argv) 
{
    if (argc != 3) {
        printf("Usage: %s <list.txt> <fisheye.txt>\n", argv[0]);
        return 1;
    }
    
    char *list_file = argv[1];
    char *fisheye_file = argv[2];

    std::vector<image_t> images;

    fisheye_params_t fisheye_params;
    ReadFisheyeParameters(fisheye_file, fisheye_params);
    ReadListFile(list_file, images);
    UndistortImages(images, fisheye_params);

    return 0;
}
Пример #3
0
int main(int argc, char **argv) 
{
    if (argc != 3 && argc != 4) {
        printf("Usage: %s <list.txt> <bundle.out> [pmvs_output_path (default: pmvs)]\n", 
               argv[0]);
        return 1;
    }
    
    const char *list_file = argv[1];
    const char *bundle_file = argv[2];
    const char *output_path = "pmvs";

    if (argc == 4)
        output_path = argv[3];

    /* Read the list file */
    FILE *f = fopen(list_file, "r");
    if (f == NULL) {
        printf("Error opening file %s for reading\n", list_file);
        return 1;
    }

    std::vector<std::string> images;
    ReadListFile(list_file, images);

    /* Read the bundle file */
    std::vector<camera_params_t> cameras;
    std::vector<point_t> points;
    double bundle_version;
    ReadBundleFile(bundle_file, cameras, points, bundle_version);

    /* Write camera geometry in the PMVS file format */
    WritePMVS(output_path, list_file, bundle_file, images, cameras);

    printf("\n\n");
    printf("@@ Conversion complete, execute \"sh %s/prep_pmvs.sh\" to finalize\n", output_path);
    printf("@@ (you will first need to edit prep_pmvs.sh to specify your bundler path, \n");
    printf("@@  so that the script knows where to find your\n"
           "@@  RadialUndistort and Bundle2Vis binaries)\n");

    return 0;
}
Пример #4
0
bool CGerSyntaxOpt :: InitOptionsLanguageSpecific()
{
	//  reading adjektives
	string strFileName = GetSyntaxFilePath()+"adj_prp.txt";
	{
		if (!ReadListFile (strFileName.c_str(),(*m_pAdjPrp)))
			return false;
		// deleting valency information
		for (size_t i=0; i  < m_pAdjPrp->size(); i++)
		{
			string&  s = (*m_pAdjPrp)[i];
			int q = s.find("+");
			if (q != string::npos)
				s.erase(q);
			q = s.find(" ");
			if (q != string::npos)
				s.erase(q);
			RmlMakeUpper(s, morphGerman);
		};
		sort(m_pAdjPrp->begin(), m_pAdjPrp->end());

	};


	// reading formats
	
	strFileName = GetSyntaxFilePath()+"gformats.txt";
	m_FormatsGrammar.m_Language = morphGerman;
	m_FormatsGrammar.m_pGramTab = GetGramTab();
	m_FormatsGrammar.m_SourceGrammarFile = strFileName;
	if (!LoadGrammarForGLR(m_FormatsGrammar, true, false))
	{
		ErrorMessage(  Format("Cannot load %s\n", strFileName.c_str()));
		return false;
	};
	
	
	return true;
}
Пример #5
0
int main(int argc,char *argv[])
{
  struct GlobalVars *gv = &gvars;
  int i,j;
  char *buf;
  struct LibPath *libp;
  struct InputFile *ifn;
  bool stdlib = TRUE;
  int so_version = 0;   /* minum version for shared objects */
  uint16_t flags = 0;   /* input file flags */

  /* initialize and set default values */
  memset(gv,0,sizeof(struct GlobalVars));
  initlist(&gv->libpaths);
  initlist(&gv->rpaths);
  gv->dynamic = TRUE;  /* link with dynamic libraries first */
  gv->interp_path = DEFAULT_INTERP_PATH;
  gv->soname = NULL;
  gv->endianess = -1;  /* endianess is unknown */

  /* initialize targets */
  for (j=0; fff[j]; j++) {
    if (fff[j]->init)
      fff[j]->init(gv);
  }
#ifdef DEFTARGET
  for (j=0; fff[j]; j++) {
    if (!strcmp(fff[j]->tname,DEFTARGET)) {
      gv->dest_format = (uint8_t)j;
      break;
    }
  }
  if (fff[j] == NULL) {
    fprintf(stderr,"Configuration warning: Selected default target "
            "\"%s\" is not included.\nThe current default target "
            "is \"%s\".\n",DEFTARGET,fff[gv->dest_format]->tname);
    printf("\n");
  }
#endif

  initlist(&gv->inputlist);
  initlist(&gv->lnksec);
  gv->dest_name = "a.out";
  gv->maxerrors = DEF_MAXERRORS;
  gv->reloctab_format = RTAB_UNDEF;
  gv->osec_base_name = NULL;

  if (argc<2 || (argc==2 && *argv[1]=='?')) {
    show_usage();
    exit(EXIT_SUCCESS);
  }

  for (i=1; i<argc; i++) {

    if (*argv[i] == '-') {  /* option detected */
      switch (argv[i][1]) {

        case 'b':  
          if (!strcmp(&argv[i][2],"aseoff")) {  /* set base-relative offset */
            long bo;

            sscanf(get_arg(argc,argv,&i),"%li",&bo);
            fff[gv->dest_format]->baseoff = bo;
          }
          else {  /* select target format */
            if (buf = get_option_arg(argc,argv,&i)) {
              /* for compatibility with older vlink versions,
                 elf32amiga is automatically converted into elf32powerup
                 and amigaos into amigahunk */
              if (!strcmp(buf,"elf32amiga"))
                buf = "elf32powerup";
              else if (!strcmp(buf,"amigaos"))
                buf = "amigahunk";
              for (j=0; fff[j]; j++) {
                if (!strcmp(fff[j]->tname,buf))
                  break;
              }
              if (fff[j])
                gv->dest_format = (uint8_t)j;
              else
                error(9,buf);  /* invalid target format */
            }
          }
          break;

        case 'c':
          if (!strncmp(&argv[i][2],"lr-",3))
            flags &= ~(chk_flags(argv[i]));   /* -clr-flags */
          else
            error(2,argv[i]);  /* unrecognized option */
          break;

        case 'd':
          if (!argv[i][2] || argv[i][2]=='c' || argv[i][2]=='p')
            gv->alloc_common = TRUE;  /* force alloc. of common syms. */
          else if (argv[i][2] == 'a')
            gv->alloc_addr = TRUE;  /* force alloc. of address syms. */
          else
            error(2,argv[i]);  /* unrecognized option */
          break;

        case 'e':
          if (!strcmp(&argv[i][2],"xport-dynamic"))
            gv->dyn_exp_all = TRUE;  /* export all globals as dynamic */
          else  /* defines entry point */
            gv->entry_name = get_option_arg(argc,argv,&i);
          break;

        case 'f':
          if (!strcmp(&argv[i][2],"ixunnamed")) {
            gv->fix_unnamed = TRUE;  /* assign a name to unnamed sections */
          }
          else {  /* set a flavour */
            char *name,**fl;

            if (name = get_option_arg(argc,argv,&i)) {
              if (fl = gv->flavours.flavours) {
                char **tmp = alloc((gv->flavours.n_flavours+1)*sizeof(char *));

                memcpy(tmp,fl,gv->flavours.n_flavours*sizeof(char *));
                free(fl);
                fl = tmp;
              }
              else
                fl = alloc(sizeof(char *));
              fl[gv->flavours.n_flavours++] = name;
              gv->flavours.flavours = fl;
              gv->flavours.flavours_len += strlen(name) + 1;
            }
          }
          break;

        case 'g':
          if (!strcmp(&argv[i][2],"c-empty"))
            gv->gc_sects = GCS_EMPTY;
          else if (!strcmp(&argv[i][2],"c-all"))
            gv->gc_sects = GCS_ALL;
          else
            error(2,argv[i]);  /* unrecognized option */
          break;

        case 'h':
          if (!strcmp(&argv[i][2],"unkattr")) {
            struct SecAttrOvr *sao;
            char secname[64];
            lword val;

            val = get_assign_arg(argc,argv,&i,secname,64);
            sao = addsecattrovr(gv,secname,SAO_MEMFLAGS);
            sao->memflags = (uint32_t)val;
          }
          else {
            if (argv[i][2] == '\0') {
              show_usage();      /* help text */
              exit(EXIT_SUCCESS);
            }
            else
              error(2,argv[i]);  /* unrecognized option */
          }
          break;

        case 'i':
          if (!strcmp(&argv[i][2],"nterp"))
            gv->interp_path = get_arg(argc,argv,&i);
          else
            error(2,argv[i]);  /* unrecognized option */
          break;

        case 'k':
          gv->keep_sect_order = TRUE;
          break;

        case 'l':  /* library specifier */
          if (buf = get_option_arg(argc,argv,&i)) {
            ifn = alloc(sizeof(struct InputFile));
            ifn->name = buf;
            ifn->lib = TRUE;
            ifn->dynamic = gv->dynamic;
            ifn->so_ver = so_version;
            so_version = 0;
            ifn->flags = flags;
            addtail(&gv->inputlist,&ifn->n);
          }
          break;

        case 'm':
          if (!strcmp(&argv[i][2],"inalign")) {
            long a;

            sscanf(get_arg(argc,argv,&i),"%li",&a);
            gv->min_alignment = (uint8_t)a;
          }
          else if (!strcmp(&argv[i][2],"rel"))
            gv->auto_merge = TRUE;
          else if (!strcmp(&argv[i][2],"type"))
            gv->merge_same_type = TRUE;
          else if (!strcmp(&argv[i][2],"ultibase"))
            gv->multibase = TRUE;
          else
            error(2,argv[i]);  /* unrecognized option */
          break;

        case 'n':
          if (!argv[i][2])
            gv->no_page_align = TRUE;
          else if (!strcmp(&argv[i][2],"ostdlib"))
            stdlib = FALSE;
          else
            error(2,argv[i]);  /* unrecognized option */
          break;

        case 'o':  /* set output file name */
          if (!strncmp(&argv[i][2],"sec=",4) && argv[i][6]!='\0') {
            /* defines a base name of the sections to output */
            gv->osec_base_name = &argv[i][6];
            gv->output_sections = TRUE;  /* output each section as a file */
          }
          else if (!strcmp(&argv[i][2],"sec"))
            gv->output_sections = TRUE;  /* output each section as a file */
          else
            gv->dest_name = get_option_arg(argc,argv,&i);
          break;

        case 'q':  /* force relocations into final executable */
          gv->keep_relocs = TRUE;
          break;

        case 'r':  /* output is an relocatable object again */
          if (!argv[i][2]) {
            gv->dest_object = TRUE;
          }
          else if (!strcmp(&argv[i][2],"path")) {
            if (buf = get_arg(argc,argv,&i)) {
              libp = alloc(sizeof(struct LibPath));
              libp->path = buf;
              addtail(&gv->rpaths,&libp->n);
            }
          }
          else
            error(2,argv[i]);  /* unrecognized option */
          break;

        case 's':
          switch (argv[i][2]) {
            case '\0':  /* strip all symbols */
              gv->strip_symbols = STRIP_ALL;
              break;
            case 'c':   /* -sc force small code */
              gv->small_code = TRUE;
              break;
            case 'd':   /* -d force small data */
              gv->small_data = TRUE;
              break;
            case 'e':
              if (!strncmp(&argv[i][3],"t-",2))  /* -set-flags */
                flags |= chk_flags(argv[i]);
              else
                error(2,argv[i]);  /* unrecognized option */
              break;
            case 'h':   /* -shared */
              if (!strcmp(&argv[i][3],"ared"))
                gv->dest_sharedobj = TRUE;
              else
                error(2,argv[i]);  /* unrecognized option */
              break;
            case 'o':   /* -soname <real name> */
              if (!strcmp(&argv[i][3],"name"))
                gv->soname = get_arg(argc,argv,&i);
              else
                error(2,argv[i]);  /* unrecognized option */
              break;
            case 't':   /* -static */
              if (!strcmp(&argv[i][3],"atic"))
                gv->dynamic = FALSE;
              else
                error(2,argv[i]);  /* unrecognized option */
              break;
            default:
              error(2,argv[i]);  /* unrecognized option */
              break;
          }
          break;

        case 't':  /* trace file accesses */
          if (!strcmp(&argv[i][2],"extbaserel"))
            gv->textbaserel = TRUE;
          else if (!strncmp(&argv[i][2],"os-",3)) {
            /* -tos-options for targets ataritos and aoutmint */
            if (!strcmp(&argv[i][5],"flags")) {
              long fl;

              sscanf(get_arg(argc,argv,&i),"%li",&fl);
              gv->tosflags = fl;
            }
            else if (!strcmp(&argv[i][5],"fastload"))
              gv->tosflags |= 1;
            else if (!strcmp(&argv[i][5],"fastram"))
              gv->tosflags |= 2;
            else if (!strcmp(&argv[i][5],"fastalloc"))
              gv->tosflags |= 4;
            else if (!strcmp(&argv[i][5],"private"))
              gv->tosflags &= ~0x30;
            else if (!strcmp(&argv[i][5],"global"))
              gv->tosflags |= 0x10;
            else if (!strcmp(&argv[i][5],"super"))
              gv->tosflags |= 0x20;
            else if (!strcmp(&argv[i][5],"readable"))
              gv->tosflags |= 0x30;
            else if (!strcmp(&argv[i][5],"textbased"))
              gv->textbasedsyms = 1;
            else
              error(2,argv[i]);  /* unrecognized option */
          }
          else if (!argv[i][2])
            gv->trace_file = stderr;
          else
            error(2,argv[i]);  /* unrecognized option */
          break;

        case 'u':  /* mark symbol as undefined */
          if (buf = get_option_arg(argc,argv,&i))
            add_symnames(&gv->undef_syms,buf);
          break;

        case 'v':  /* show version and target info */
          show_version();
          printf("Standard library path: "
#ifdef LIBPATH
                 LIBPATH
#endif
                 "\nDefault target: %s\n"
                 "Supported targets:",fff[gv->dest_format]->tname);
          for (j=0; fff[j]; j++)
            printf(" %s",fff[j]->tname);
          printf("\n");
          exit(EXIT_SUCCESS);

        case 'w':  /* suppress warnings */
          gv->dontwarn = TRUE;
          break;

        case 'x':  /* discard all local symbols */
          gv->discard_local = DISLOC_ALL;
          break;

        case 'y':  /* trace all accesses on a specific symbol */
          if (gv->trace_syms == NULL)
            gv->trace_syms = alloc_hashtable(TRSYMHTABSIZE);
          if (buf = get_option_arg(argc,argv,&i)) {
            struct SymNames **chain = 
                            &gv->trace_syms[elf_hash(buf)%TRSYMHTABSIZE];
            while (*chain)
              chain = &(*chain)->next;
            *chain = alloczero(sizeof(struct SymNames));
            (*chain)->name = buf;
          }
          break;

        case 'B':  /* set link mode */
          if (buf = get_option_arg(argc,argv,&i)) {
            if (!strcmp(buf,"static")) {
              gv->dynamic = FALSE;
            }
            else if (!strcmp(buf,"dynamic")) {
              gv->dynamic = TRUE;
            }
            else if (!strcmp(buf,"shareable")) {
              gv->dest_sharedobj = TRUE;
            }
            else if (!strcmp(buf,"forcearchive")) {
              gv->whole_archive = TRUE;
            }
            else if (!strcmp(buf,"symbolic")) {
              ;  /* don't know, what this means... */
            }
            else {
              error(3,buf);  /* unknown link mode */
            }
          }
          break;

        case 'C':  /* select con-/destructor type */
          if (buf = get_option_arg(argc,argv,&i)) {
            if (!strcmp(buf,"gnu")) {
              gv->collect_ctors_type = CCDT_GNU;
            }
            else if (!strcmp(buf,"vbcc")) {
              gv->collect_ctors_type = CCDT_VBCC;
            }
            else if (!strcmp(buf,"vbccelf")) {
              gv->collect_ctors_type = CCDT_VBCC_ELF;
            }
            else if (!strcmp(buf,"sasc")) {
              gv->collect_ctors_type = CCDT_SASC;
            }
            else  /* @@@ print error message */
              gv->collect_ctors_type = CCDT_NONE;
          }
          break;

        case 'E':  /* set endianess */
          switch (argv[i][2]) {
            case 'B':
              gv->endianess = _BIG_ENDIAN_;
              break;
            case 'L':
              gv->endianess = _LITTLE_ENDIAN_;
              break;
            default:
              error(2,argv[i]);  /* unrecognized option */
              break;
          }
          break;

        case 'F':  /* read a file with object file names */
          if (buf = get_option_arg(argc,argv,&i))
            ReadListFile(gv,buf,flags);
          break;

        case 'L':  /* new library search path */
          if (buf = get_option_arg(argc,argv,&i)) {
            libp = alloc(sizeof(struct LibPath));
            libp->path = buf;
            addtail(&gv->libpaths,&libp->n);
          }
          break;

        case 'M':  /* mapping output */
          gv->map_file = stdout;
          break;

        case 'P':  /* protect symbol against stripping */
          if (buf = get_option_arg(argc,argv,&i))
            add_symnames(&gv->prot_syms,buf);
          break;

        case 'R':  /* use short form for relocations */
          if (buf = get_option_arg(argc,argv,&i)) {
            if (!strcmp(buf,"std"))
              gv->reloctab_format = RTAB_STANDARD;
            else if (!strcmp(buf,"add"))
              gv->reloctab_format = RTAB_ADDEND;
            else if (!strcmp(buf,"short"))
              gv->reloctab_format = RTAB_SHORTOFF;
            else
              error(123,buf);  /* unknown reloc table format ignored */
          }
          break;

        case 'S':  /* strip debugger symbols */
          gv->strip_symbols = STRIP_DEBUG;
          break;

        case 'T':  /* read linker script file or set text address */
          if (!strcmp(&argv[i][2],"text")) {
            if (i+1 < argc)
              sscanf(argv[++i],"%lli",&gv->start_addr);
            else
              error(5,'T');  /* option requires argument */
          }
          else if (buf = get_option_arg(argc,argv,&i)) {
            if (gv->ldscript = mapfile(buf))
              gv->scriptname = buf;
            else
              error(8,buf);
          }
          break;

        case 'V':  /* set minimum version for next shared object */
          if (buf = get_option_arg(argc,argv,&i))
            so_version = atoi(buf);
          break;

        case 'X':  /* discard temporary local symbols only */
          gv->discard_local = DISLOC_TMP;
          break;

        case 'Z':  /* keep trailing zero-bytes at end of section */
          gv->keep_trailing_zeros = TRUE;
          break;

        default:
          error(2,argv[i]);  /* unrecognized option */
          break;
      }
    }

    else {  /* normal input file name */
      ifn = alloc(sizeof(struct InputFile));
      ifn->name = argv[i];
      ifn->lib = FALSE;
      ifn->flags = flags;
      addtail(&gv->inputlist,&ifn->n);
    }
  }

  /* add default library search path at the end of the list */
  if (stdlib) {
#ifdef LIBPATH
    libp = alloc(sizeof(struct LibPath));
    libp->path = LIBPATH;  /* default search path */
    addtail(&gv->libpaths,&libp->n);
#endif
  }

  /* allocate flavour path buffer and sort flavours */
  gv->flavours.flavour_dir = alloc(gv->flavours.flavours_len + 1);
  if (gv->flavours.n_flavours > 1) {
    qsort((void *)gv->flavours.flavours, gv->flavours.n_flavours,
          sizeof(char **), flavours_cmp);
  }

  /* link them... */
  linker_init(gv);
  linker_load(gv);     /* load all objects and libraries and their symbols */
  linker_resolve(gv);  /* resolve symbol references */
  linker_relrefs(gv);  /* find all relative references between sections */
  linker_dynprep(gv);  /* prepare for dynamic linking */
  linker_sectrefs(gv); /* find all referenced sections from the start */
  linker_gcsects(gv);  /* section garbage collection (gc_sects) */
  linker_join(gv);     /* join sections with same name and type */
  linker_mapfile(gv);  /* mapfile output */
  linker_copy(gv);     /* copy section contents and fix symbol offsets */
  linker_delunused(gv);/* delete empty/unused sects. without relocs/symbols */
  linker_relocate(gv); /* relocate addresses in joined sections */
  linker_write(gv);    /* write output file in selected target format */
  linker_cleanup(gv);

  cleanup(gv);
  return 0;
}
Пример #6
0
int ReadFunction(FILE *f)
{
    int i = 0, j = 0, l = 0, type = 0, ftype = 0;
    char s[MAXLINE];
    char *words[MAXLINE];
    char *optwords[MAXLINE];
    IVAR ivar = 0;
    int nwords = 0, line1 = 0, inbas = 0, fline1 = 0, infor = 0, nopt = 0, out1 = 0;

    nVariable = 0;
    icre = 1;
    basfun->maxOpt = 0;
    basfun->NewMaxOpt = 0;
    line1 = 1;
    inbas = 0;
    fline1 = 0;
    infor = 0;
    out1 = 0;

    strcpy(s, "");

    while (fgets(s, MAXLINE, f) != NULL)
    {
        removeEOL(s);
        /* ignoring comments */
        if (s[0] == '/' && s[1] == '/' ) continue;

        /* analysis of one line */
        if (line1 != 1)
            nwords = ParseLine(s, words);
        else
            nwords = ParseScilabLine(s, words);
        /* empty definition at end of file */
        if (line1 == 1 && nwords == 0)
        {
            return 0;
        }
        /* end of description */
        if (words[0][0] == '*') return(1);
        if (line1 == 1)
        {
            /* SCILAB function description */
            if ((int)strlen(words[0]) > nlgh)
            {
                printf("SCILAB function name too long: \"%s\"\n", words[0]);
                exit(1);
            }
            basfun->name = (char *)malloc((unsigned)(strlen(words[0]) + 1));
            strcpy(basfun->name, words[0]);
            printf("**************************\n");
            printf("processing SCILAB function \"%s\"\n", words[0]);
            funNames[nFun] = basfun->name;
            i = nwords - 1;
            if (i > MAXARG)
            {
                printf("too may input arguments for SCILAB function\"%s\"\n",
                       words[0]);
                printf("  augment constant \"MAXARG\" and recompile intersci\n");
                exit(1);
            }
            basfun->nin = i;
            for (i = 0; i < basfun->nin ; i++)
            {
                if (words[i + 1][0] == '{')
                {
                    basfun->maxOpt++;
                    nopt = ParseLine(words[i + 1] + 1, optwords);
                    if (nopt != 2)
                    {
                        printf("Bad syntax for optional argument. Two variables needed\n");
                        exit(1);
                    }
                    ivar = GetVar(optwords[0], 1);
                    basfun->in[i] = ivar;
                    variables[ivar - 1]->opt_type = NAME;
                    variables[ivar - 1]->opt_name =
                        (char *)malloc((unsigned)(strlen(optwords[1]) + 1));
                    variables[ivar - 1]->stack_position = icre++;
                    strcpy(variables[ivar - 1]->opt_name, optwords[1]);
                    variables[ivar - 1]->is_sciarg = 1;
                }
                else if (words[i + 1][0] == '[')
                {
                    basfun->maxOpt++;
                    nopt = ParseLine(words[i + 1] + 1, optwords);
                    if (nopt != 2)
                    {
                        printf("Bad syntax for optional argument. Two variables needed\n");
                        exit(1);
                    }
                    ivar = GetVar(optwords[0], 1);
                    basfun->in[i] = ivar;
                    variables[ivar - 1]->opt_type = VALUE;
                    variables[ivar - 1]->opt_name =
                        (char *)malloc((unsigned)(strlen(optwords[1]) + 1));
                    strcpy(variables[ivar - 1]->opt_name, optwords[1]);
                    variables[ivar - 1]->stack_position = icre++;
                    variables[ivar - 1]->is_sciarg = 1;
                }
                else
                {
                    basfun->in[i] = GetVar(words[i + 1], 1);
                    variables[basfun->in[i] - 1]->stack_position = icre++;
                    variables[basfun->in[i] - 1]->is_sciarg = 1;
                }
            }
            line1 = 0;
            inbas = 1;
        }
        else if (inbas == 1)
        {
            if (nwords == 0)
            {
                /* end of SCILAB variable description */
                inbas = 0;
                fline1 = 1;
            }
            else
            {
                /* SCILAB variable description */
                ivar = GetVar(words[0], 1);
                i = ivar - 1;
                if ( variables[i]->is_sciarg == 0)
                {
                    /** we only fix stack_position for remaining arguments**/
                    variables[i]->stack_position = icre++;
                }
                if (nwords == 1)
                {
                    printf("type missing for variable \"%s\"\n", words[0]);
                    exit(1);
                }
                type = GetBasType(words[1]);
                variables[i]->type = type;
                switch (type)
                {
                    case SCALAR:
                    case ANY:
                    case SCIMPOINTER:
                    case SCISMPOINTER:
                    case SCILPOINTER:
                    case SCIBPOINTER:
                    case SCIOPOINTER:
                        break;
                    case COLUMN:
                    case ROW:
                    case STRING:
                    case WORK:
                    case VECTOR:
                        if (nwords != 3)
                        {
                            printf("bad type specification for variable \"%s\"\n", words[0]);
                            printf("only %d argument given and %d are expected\n", nwords, 3);
                            exit(1);
                        }
                        variables[i]->el[0] = GetVar(words[2], 1);
                        variables[i]->length++;
                        break;
                    case LIST:
                    case TLIST:
                        if (nwords != 3)
                        {
                            printf("bad type specification for variable \"%s\"\n", words[0]);
                            printf("only %d argument given and %d are expected\n", nwords, 3);
                            exit(1);
                        }
                        ReadListFile(words[2], words[0], i,
                                     variables[i]->stack_position);
                        break;
                    case POLYNOM:
                    case MATRIX:
                    case BMATRIX:
                    case STRINGMAT:
                        if (nwords != 4)
                        {
                            printf("bad type specification for variable \"%s\"\n", words[0]);
                            printf("%d argument given and %d are expected\n", nwords, 4);
                            exit(1);
                        }
                        variables[i]->el[0] = GetVar(words[2], 1);
                        variables[i]->el[1] = GetVar(words[3], 1);
                        variables[i]->length = 2;
                        break;
                    case IMATRIX:
                        if (nwords != 5)
                        {
                            printf("bad type specification for variable \"%s\"\n", words[0]);
                            printf("%d argument given and %d are expected\n", nwords, 4);
                            exit(1);
                        }
                        variables[i]->el[0] = GetVar(words[2], 1);
                        variables[i]->el[1] = GetVar(words[3], 1);
                        variables[i]->el[2] = GetVar(words[4], 1);
                        variables[i]->length = 3;
                        break;
                    case SPARSE:
                        if (nwords != 6)
                        {
                            printf("bad type specification for variable \"%s\"\n", words[0]);
                            printf("%d argument given and %d are expected\n", nwords, 6);
                            printf("name sparse m n nel it\n");
                            exit(1);
                        }
                        variables[i]->el[0] = GetVar(words[2], 1);
                        variables[i]->el[1] = GetVar(words[3], 1);
                        variables[i]->el[2] = GetVar(words[4], 1);
                        variables[i]->el[3] = GetVar(words[5], 1);
                        variables[i]->length = 4;
                        break;
                    case SEQUENCE:
                        printf("variable \"%s\" cannot have type \"SEQUENCE\"\n",
                               words[0]);
                        exit(1);
                        break;
                    case EMPTY:
                        printf("variable \"%s\" cannot have type \"EMPTY\"\n",
                               words[0]);
                        exit(1);
                        break;
                }
            }
        }
        else if (fline1 == 1)
        {
            /* FORTRAN subroutine description */
            forsub->name = (char *)malloc((unsigned)(strlen(words[0]) + 1));
            strcpy(forsub->name, words[0]);
            i = nwords - 1;
            if (i > MAXARG)
            {
                printf("too many argument for FORTRAN subroutine \"%s\"\n",
                       words[0]);
                printf("  augment constant \"MAXARG\" and recompile intersci\n");
                exit(1);
            }
            forsub->narg = i;
            for (i = 0; i < nwords - 1; i++)
            {
                forsub->arg[i] = GetExistVar(words[i + 1]);
            }
            fline1 = 0;
            infor = 1;
        }
        else if (infor == 1)
        {
            if (nwords == 0)
            {
                /* end of FORTRAN subroutine description */
                infor = 0;
                out1 = 1;
            }
            else
            {
                /* FORTRAN variable description */
                if (nwords == 1)
                {
                    printf("type missing for FORTRAN argument \"%s\"\n",
                           words[0]);
                    exit(1);
                }
                ivar = GetExistVar(words[0]);
                ftype = GetForType(words[1]);
                variables[ivar - 1]->for_type = ftype;
                if (ftype == EXTERNAL)
                {
                    strcpy((char *)(variables[ivar - 1]->fexternal), words[1]);
                    switch (variables[ivar - 1]->type)
                    {
                        case LIST :
                        case TLIST :
                        case SCALAR :
                        case SEQUENCE :
                        case WORK:
                        case EMPTY :
                        case ANY:
                        case SCIMPOINTER :
                        case SCISMPOINTER :
                        case SCILPOINTER :
                        case SCIBPOINTER :
                        case SCIOPOINTER :
                            printf("FORTRAN argument \"%s\" with external type \"%s\"\n",
                                   variables[ivar - 1]->name, words[1]);
                            printf("  cannot have a variable type of \"%s\"\n", SGetSciType(variables[ivar - 1]->type));
                            exit(1);
                            break;
                    }
                }
            }
        }
        else if (out1 == 1)
        {
            /* output variable description */
            if (nwords == 1)
            {
                printf("type missing for output variable \"out\"\n");
                exit(1);
            }
            ivar = GetOutVar(words[0]);
            basfun->out = ivar;
            i = ivar - 1;
            type = GetBasType(words[1]);
            variables[i]->type = type;
            switch (type)
            {
                case LIST:
                case TLIST:
                case SEQUENCE:
                    l = nwords - 2;
                    if (l > MAXEL)
                    {
                        printf("list or sequence too long for output variable \"out\"\n");
                        printf("  augment constant \"MAXEL\" and recompile intersci\n");
                        exit(1);
                    }
                    for (j = 0; j < l; j++)
                    {
                        int k = GetExistVar(words[j + 2]);
                        variables[i]->el[j] = k;
                        variables[k - 1]->out_position = j + 1;
                    }
                    variables[i]->length = l;
                    break;
                case EMPTY:
                    break;
                default:
                    printf("output variable \"out\" of SCILAB function\n");
                    printf("  must have type \"LIST\", \"TLIST\", \"SEQUENCE\" or\n");
                    printf("  \"EMPTY\"\n");
                    exit(1);
                    break;
            }
            out1 = 0;
        }
        else
        {
            /* possibly equal variables */
            ivar = GetExistVar(words[0]);
            i = ivar - 1 ;
            variables[i]->equal = GetExistVar(words[1]);
        }
        strcpy(s, "");
    }
    /* end of description file */
    return(0);
}