Beispiel #1
0
/**
 * @brief get i_node from filepath
 * @param inono inode no (out parameter)
 * @param hnd_fsmdl
 * @param s_path filepath
 * @return i_node
 */
struct one_inode* te2fm_namei(int* inono, SuperFS* hnd_fsmdl,
		char* s_path) {
	char* s_cur_path;
	char s_path_buf[TFL_MAX_PATHSTR+1];
	Block* blkcell;
	struct ext2_dir_entry* p_dirent;
	struct one_inode* p_inode;
	int idx_slash;
	char name[16];
	unsigned int dir_blkno;

	strcpy(s_path_buf, s_path);

	s_cur_path = s_path_buf;

	if (!strcmp(s_cur_path, "/")) {	// ルートディレクトリであったら
		*inono = 2;
		return hnd_fsmdl->root_inode;
	}

	s_cur_path++;	// 最初のスラッシュは除く

	//TODO search all block. only block[0] searching at the moment.
	dir_blkno = hnd_fsmdl->root_inode->i_block[0];

	idx_slash = stridx(s_cur_path, '/');

	while(idx_slash >= 0) {
		strncpy(name, s_cur_path, idx_slash);
		name[idx_slash] = 0;
		s_cur_path += idx_slash + 1;

		blkcell = tblbm_get_blkcell(dir_blkno);

		p_dirent = te2fs_lookup_dirent(name, blkcell->blk, hnd_fsmdl->hnd_fs.sz_block);
		if (!p_dirent)
			return 0;

		p_inode = tflm_get_inode_by_dirent(p_dirent);

		dir_blkno = p_inode->i_block[0];

		// stridx is not standard library.
		// stridx must be implemented in mystring.h.
		idx_slash = stridx(s_cur_path, '/');
	}

	blkcell = tblbm_get_blkcell(dir_blkno);

	p_dirent = te2fs_lookup_dirent(s_cur_path, blkcell->blk, hnd_fsmdl->hnd_fs.sz_block);	// Something Wrong Here!
	return 0;
	// if (!p_dirent)
	// 	return 0;
	// *inono = p_dirent->inode;
	//
	// p_inode = tflm_get_inode_by_dirent(p_dirent);
	//
	// return p_inode;
}
Beispiel #2
0
static int _shalg_priv_crypt(int alg, shalg_t ret_key, unsigned char *data, size_t data_len)
{
  unsigned char raw[128];
  unsigned char hash[128];
  char cr_salt[64];
  size_t len;
  int idx;
  int of;
  int i;

  memset(ret_key, 0, sizeof(ret_key));

  memset(cr_salt, 0, sizeof(cr_salt));
  if (alg == SHALG_CRYPT256) {
    if (data_len > 4 && 0 == strncmp(data, "$5$", 3)) {
      idx = stridx(data + 3, '$');
      if (idx != -1)
        strncpy(cr_salt, data + 3, idx);
      else
        strncpy(cr_salt, data + 3, sizeof(cr_salt)-1);
    }
  } else if (alg == SHALG_CRYPT512) {
    if (data_len > 4 && 0 == strncmp(data, "$6$", 3)) {
      char cr_salt[32];

      memset(cr_salt, 0, sizeof(cr_salt));
      idx = stridx(data + 3, '$');
      if (idx != -1)
        strncpy(cr_salt, data + 3, idx);
      else
        strncpy(cr_salt, data + 3, sizeof(cr_salt)-1);
    }
  } else {
    return (SHERR_OPNOTSUPP);
  }

  if (!*cr_salt) {
    memset(raw, 0, sizeof(raw));
    sh_sha224(data, data_len, hash);
    for (i = 0; i < 28; i++) {
      of = (i/3);
      raw[of] = raw[of] ^ hash[i]; 
    }
    shcrypt_b64_encode(cr_salt, raw, 9);
  }

  len = ((strlen(cr_salt) / 4) + 1) * 4;
  memcpy((char *)ret_key, cr_salt, len);
  shalg_size(ret_key) = len;

  return (0);
}
Beispiel #3
0
main ()
{
  t_text  cmds;			/* Unix shell commands file */
  t_text  fof;			/* file of file names file */
  FILE    *fopen ();		/* file open function */
  int     index;
  char    name [ MAX_LINE ];	/* list file name */
  char    name2 [ MAX_LINE ];	/* file name suffix */


  printf ( "This is the Script program.\n\n" );

  /* Prompt for the input file name. */
  prompt_file ( &fof, "What is the name of the list of file names?" );

  strcpy ( cmds.name, "cmds" );
  cmds.data = fopen ( "cmds", "w" );

  /* Process the names. */
  while ( fof.eof != TRUE )
  {
    strcpy ( name, fof.line );
    name [ stridx ( name, "\n" ) ] = '\0';

    if ( ( fof.eof != TRUE ) && ( cmds.data != NULL ) )

      fprintf ( cmds.data, "rm '%s'\n", name );

    /* Get the next name. */
    get_line ( &fof );
  }  /* while */

  fclose ( cmds.data );
  fclose ( fof.data );
}  /* main */
Beispiel #4
0
int strridx(const string s1,const string s2) {
    int pos;
    string r1;
    string r2;
    int l1;
    int l2;

    if(s1==NULL) return -1;
    if(s2==NULL) return -1;

    l1=strlen(s1);
    l2=strlen(s2);
    if(l1<l2) return -1;
    if(l1==l2) {
        if(strcmp(s1,s2)==0) return 0;
        return -1;
    }

    r1=strrev(strdup(s1));
    r2=strrev(strdup(s2));
    pos=stridx(r1,r2);
    free(r1);
    free(r2);

    if(pos==-1) {
        return -1;
    }
    else {
        return (l1 - l2 - pos);
    }

}
void reboot_main(void)
{
  int types[] = {RB_AUTOBOOT, RB_HALT_SYSTEM, RB_POWER_OFF},
      sigs[] = {SIGTERM, SIGUSR1, SIGUSR2}, idx;

  if (!(toys.optflags & FLAG_n)) sync();

  idx = stridx("hp", *toys.which->name)+1;
  if (toys.optflags & FLAG_f) toys.exitval = reboot(types[idx]);
  else toys.exitval = kill(1, sigs[idx]);
}
Beispiel #6
0
main ()
{
  t_text  fof;			/* file of filenames */
  t_text  in;			/* input DNA sequence file */
  t_text  repeat;		/* repeat list for FATAL: errors */
  t_text  results;		/* Summary of Blast results */
  t_text  trace;		/* trace report */
  FILE    *fopen ();		/* file open function */


  printf ( "This is the Blast e-mail response output parsing program.\n\n" );

  /* Open the commands file. */
  results.data = fopen ( "results", "w" );

  /* Open the repeat list for FATAL: errors. */
  repeat.data = fopen ( "repeat", "w" );

  /* Open debug trace file. */
  trace.data = fopen ( "trace", "w" );

  /* Prompt for the input file name. */
  prompt_file ( &fof, "What is the list of sequences file name?" );

  /* Process the sequences. */
  while ( fof.eof != TRUE )
  {
    /* Open the sequence output file. */
    strcpy ( in.name, fof.line );
    in.name [ stridx ( in.name, "\n" ) ] = '\0';

    /* Open the DNA sequence file for reading. */
    open_text_file ( &in );

    /* Process the BLAST results file. */
    if ( fof.eof != TRUE )

      process_blast ( &in, &results, &repeat, &trace );

    /* Get the next file name. */
    get_line ( &fof );
 
    /* Close the BLAST results file. */ 
    fclose ( in.data );
  }  /* while */

  /* Close the commands file. */
  fclose ( fof.data );
  fclose ( results.data );
  fclose ( repeat.data );
  fclose ( trace.data );

  printf ( "\nEnd of program.\n" );
}  /* main */
Beispiel #7
0
/*
 * match_parm() does parsing for ide_setup():
 *
 * 1. the first char of s must be '='.
 * 2. if the remainder matches one of the supplied keywords,
 *     the index (1 based) of the keyword is negated and returned.
 * 3. if the remainder is a series of no more than max_vals numbers
 *     separated by commas, the numbers are saved in vals[] and a
 *     count of how many were saved is returned.  Base10 is assumed,
 *     and base16 is allowed when prefixed with "0x".
 * 4. otherwise, zero is returned.
 */
static int __init match_parm (char *s, const char *keywords[], int vals[], int max_vals)
{
	static const char *decimal = "0123456789";
	static const char *hex = "0123456789abcdef";
	int i, n;

	if (*s++ == '=') {
		/*
		 * Try matching against the supplied keywords,
		 * and return -(index+1) if we match one
		 */
		if (keywords != NULL) {
			for (i = 0; *keywords != NULL; ++i) {
				if (!strcmp(s, *keywords++))
					return -(i+1);
			}
		}
		/*
		 * Look for a series of no more than "max_vals"
		 * numeric values separated by commas, in base10,
		 * or base16 when prefixed with "0x".
		 * Return a count of how many were found.
		 */
		for (n = 0; (i = stridx(decimal, *s)) >= 0;) {
			vals[n] = i;
			while ((i = stridx(decimal, *++s)) >= 0)
				vals[n] = (vals[n] * 10) + i;
			if (*s == 'x' && !vals[n]) {
				while ((i = stridx(hex, *++s)) >= 0)
					vals[n] = (vals[n] * 0x10) + i;
			}
			if (++n == max_vals)
				break;
			if (*s == ',' || *s == ';')
				++s;
		}
		if (!*s)
			return n;
	}
	return 0;	/* zero = nothing matched */
}
Beispiel #8
0
void test_stridx()
{
	clear_all();
	//non-empty char
	char l='g';
	a[0]='1';
	a[1]='g';
	a[2]='g';
	int idx=stridx(l,a);
	assert(idx==1);
	//accepted
}
Beispiel #9
0
static _shalg_ver_crypt(int alg, shalg_t pub_key, shalg_t sig_key, unsigned char *data, size_t data_len)
{
  unsigned char hash[128];
  char hash_str[256];
  char cr_salt[256];
  shalg_t cmp_sig;
  size_t sig_len;
  char *cr_key;
  char *sig;
  int err;
  int of;

  if (strlen(data) == data_len) {
    /* presume ascii */
    cr_key = (char *)data;
  } else {
    /* presume binary */
    memset(hash, 0, sizeof(hash));
    sh_sha512(data, data_len, hash);

    memset(hash_str, 0, sizeof(hash_str));
    shcrypt_b64_encode(hash_str, hash, 64);
    cr_key = hash_str;
  }

  sig = NULL;
  memset(cr_salt, 0, sizeof(cr_salt));
  shcrypt_b64_encode(cr_salt, pub_key, shalg_size(pub_key));
  if (alg == SHALG_CRYPT256) {
    sig = shcrypt_sha256(cr_key, cr_salt);
  } else if (alg == SHALG_CRYPT512) {
    sig = shcrypt_sha512(cr_key, cr_salt);
  }
  if (!sig || strlen(sig) < 3)
    return (SHERR_INVAL);

  of = stridx(sig + 3, '$');
  if (of == -1)
    return (SHERR_INVAL);

  of += 4;
  memset(cmp_sig, 0, sizeof(cmp_sig));
  shcrypt_b64_decode(sig + of, (unsigned char *)cmp_sig, &sig_len); 
  shalg_size(cmp_sig) = sig_len;
  if (sig_len != shalg_size(sig_key))
    return (SHERR_ACCESS);
  if (0 != memcmp(sig_key, cmp_sig, sig_len))
    return (SHERR_ACCESS);

  return (0);
}
Beispiel #10
0
Datei: test.c Projekt: badcodes/c
int main(int argc,char** argv) {
	if(argc<4) return 1;

	printf("stridx(%s,%s)=%d\n",argv[1],argv[2],stridx(argv[1],argv[2]));
	printf("strridx(%s,%s)=%d\n",argv[1],argv[2],strridx(argv[1],argv[2]));

	printf("dstrrpl(%s, %s , %s) = %s\n",
		argv[1],argv[2],argv[3],
		dstrrpl(argv[1],argv[2],argv[3])
		);

	return 0;

}
Beispiel #11
0
string dstrrpl(const string str,const string txt,const string cs3) {
    int l_str,l_txt,l_rpl;
    string result;
    int match;
    int* apos;
    int i,o1,o2;
    string rpl = cs3;

    if(str==NULL) return str;
    if(txt==NULL) return str;
    if(rpl==NULL) rpl="";
    if(strcmp(txt,rpl)==0) return str;

    l_str = strlen(str);
    l_txt = strlen(txt);
    match = l_str / l_txt;
    if(match < 1) return str;

    apos = (int*)(malloc(sizeof(int)*match + 1));
    apos[0] = -l_txt;
    match = 0;
    o2 = 0;
    while((i = stridx(str + o2,txt)) > -1) {
        apos[++match] = i;
        o2 += apos[match] + l_txt;
    }
    if(match==0) return str;

    l_rpl = strlen(rpl);
    result = (char*)(malloc(sizeof(char)*(l_str - (l_txt - l_rpl)*match +1)));
    apos[0] = -l_txt;
    o1=0;
    o2=0;
    for(i=1;i<=match;i++) {
        memcpy(result+o1,str+o2,apos[i]);
        o1 = o1 + apos[i];
        o2 = o2 + apos[i];
        memcpy(result+o1,rpl,l_rpl);
        o1 = o1 + l_rpl;
        o2 = o2 + l_txt;
    }
    memcpy(result + o1,str+o2,l_str - o2 + 1);
    result[o1 + l_str - o2 + 1]=0;
    return result;
}
Beispiel #12
0
static int _shalg_sign_crypt(int alg, shalg_t priv_key, shalg_t ret_sig, unsigned char *data, size_t data_len)
{
  unsigned char hash[128];
  char hash_str[256];
  char *cr_salt;
  char *cr_key;
  char *sig;
  size_t sig_len;
  int err;
  int of;

  if (strlen(data) == data_len) {
    /* presume ascii */
    cr_key = (char *)data;
  } else {
    /* presume binary */
    memset(hash, 0, sizeof(hash));
    sh_sha512(data, data_len, hash);

    memset(hash_str, 0, sizeof(hash_str));
    shcrypt_b64_encode(hash_str, hash, 64);
    cr_key = hash_str;
  }

  sig = NULL;
  cr_salt = (char *)priv_key;
  if (alg == SHALG_CRYPT256) {
    sig = shcrypt_sha256(cr_key, cr_salt);
  } else if (alg == SHALG_CRYPT512) {
    sig = shcrypt_sha512(cr_key, cr_salt);
  }
  if (!sig || strlen(sig) < 3)
    return (SHERR_INVAL);

  of = stridx(sig + 3, '$');
  if (of == -1)
    return (SHERR_INVAL);

  of += 4;
  shcrypt_b64_decode(sig + of, (unsigned char *)ret_sig, &sig_len); 
  shalg_size(ret_sig) = sig_len;

  return (0);
}
Beispiel #13
0
main ()
{
  t_text  cmds;			/* Unix shell commands file */
  t_text  fof;			/* file of file names file */
  FILE    *fopen ();		/* file open function */
  int     index;
  char    name [ MAX_LINE ];	/* list file name */
  char    name2 [ MAX_LINE ];	/* file name suffix */


  printf ( "This is the GENSCAN mail Script program.\n\n" );

  /* Prompt for the input file name. */
  prompt_file ( &fof, "What is the name of the list of file names?" );

  strcpy ( cmds.name, "cmds" );
  cmds.data = fopen ( "cmds", "w" );

  /* Process the names. */
  while ( fof.eof != TRUE )
  {
    strcpy ( name, fof.line );
    name [ stridx ( name, "\n" ) ] = '\0';

    if ( ( fof.eof != TRUE ) && ( cmds.data != NULL ) )
    {
      fprintf ( cmds.data, "mail [email protected] < %s\n", name );
      fprintf ( cmds.data, "echo Sending %s\n", name );
      fprintf ( cmds.data, "sleep 300\n" );
      fprintf ( cmds.data, "\n" );
    }  /* if */

    /* Get the next name. */
    get_line ( &fof );
  }  /* while */

  fclose ( cmds.data );

}  /* main */
void inotifyd_main(void)
{
  struct pollfd fds;
  char *prog_args[5], **ss = toys.optargs;
  char *masklist ="acew0rmyndDM uox";

  fds.events = POLLIN;

  *prog_args = *toys.optargs;
  prog_args[4] = 0;
  if ((fds.fd = inotify_init()) == -1) perror_exit(0);

  // Track number of watched files. First one was program to run.
  toys.optc--;

  while (*++ss) {
    char *path = *ss, *masks = strchr(*ss, ':');
    int i, mask = 0;

    if (!masks) mask = 0xfff; // default to all
    else{
      *masks++ = 0;
      for (*masks++ = 0; *masks; masks++) {
        i = stridx(masklist, *masks);;
        if (i == -1) error_exit("bad mask '%c'", *masks);
        mask |= 1<<i;
      }
    }

    // This returns increasing numbers starting from 1, which coincidentally
    // is the toys.optargs position of the file. (0 is program to run.)
    if (inotify_add_watch(fds.fd, path, mask) < 0) perror_exit_raw(path);
  }

  for (;;) {
    int ret = 0, len;
    void *buf = 0;
    struct inotify_event *event;

    // Read next event(s)
    ret = poll(&fds, 1, -1);
    if (ret < 0 && errno == EINTR) continue;
    if (ret <= 0) break;
    xioctl(fds.fd, FIONREAD, &len);
    event = buf = xmalloc(len);
    len = readall(fds.fd, buf, len);

    // Loop through set of events.
    for (;;) {
      int left = len - (((char *)event)-(char *)buf),
          size = sizeof(struct inotify_event);

      // Don't dereference event if ->len is off end of bufer
      if (left >= size) size += event->len;
      if (left < size) break;

      if (event->mask) {
        char *s = toybuf, *m;

        for (m = masklist; *m; m++)
          if (event->mask & (1<<(m-masklist))) *s++ = *m;
        *s = 0;

        if (**prog_args == '-' && !prog_args[0][1]) {
          xprintf("%s\t%s\t%s\n" + 3*!event->len, toybuf,
              toys.optargs[event->wd], event->name);
        } else {
          prog_args[1] = toybuf;
          prog_args[2] = toys.optargs[event->wd];
          prog_args[3] = event->len ? event->name : 0;
          xrun(prog_args);
        }

        if (event->mask & IN_IGNORED) {
          if (--toys.optc <= 0) {
            free(buf);

            goto done;
          }
          inotify_rm_watch(fds.fd, event->wd);
        }
      }
      event = (void*)(size + (char*)event);
    }
    free(buf);
  }

done:
  toys.exitval = !!toys.signal;
}
Beispiel #15
0
main ()
{
  long    end;		/* end of DNA sequence segment */
  t_text  in;		/* input DNA sequence file */
  long    index;        /* line index */
  t_text  trapped;	/* trapped exons sequence file */
  t_seq   seq;          /* DNA sequence */
  t_text  sequence;	/* trapped exon sequence */
  long    start;	/* start of DNA sequence segment */
  int     version;      /* DNA segment number */
  char    version_str [ MAX_LINE ];	/* ascii version number */
  FILE    *fopen ();	/* file open function */


  printf ( "This is the Sequence files --> DNA sequence program.\n\n" );

  /* Prompt for the input file name. */
  prompt_file ( &trapped, "What is the list of sequences file name?" );

  /* Process the sequences. */
  while ( trapped.eof != TRUE )
  {
    /* Open the sequence output file. */
    strcpy ( in.name, trapped.line );
    in.name [ stridx ( in.name, "\n" ) ] = '\0';

    /* Open the DNA sequence file for reading. */
    open_text_file ( &in );

    /* Read in the DNA sequence. */
    read_DNA_seq ( &in, &seq );
    fclose ( in.data );

/* printf ( "DNA length = %d\n", seq.total ); */

    version = 0;
    start = 0;
    end = 999;
    trapped.line [ stridx ( trapped.line, "\n" ) ] = '\0';

    /* Segment the DNA sequence in blocks of 1000 bp. */
    while ( start + MIN_SEQ < seq.total )
    {
      /* Truncate source name at first period. */
      strcpy ( sequence.name, trapped.line );
      sequence.name [ stridx ( sequence.name, "." ) ] = '\0';
      strcat ( sequence.name, "." );
      itoa   ( version, version_str );
      strcat ( sequence.name, version_str );
      sequence.data = fopen ( sequence.name, "w" );

      if ( ( trapped.eof != TRUE ) && ( sequence.data != NULL ) )
      {
        /* Check for end of sequence. */
        if ( end > seq.total )  end = seq.total;

        /* Write out the DNA sequence. */
        write_DNA_seq ( &seq, start, end, &sequence );

        fclose ( sequence.data );
        version++;
        start += 1000;
        end += 1000;
      }  /* if */
    }  /* while */

    /* Get the trapped exon name and sequence. */
    get_line ( &trapped );
  }  /* while */
}  /* main */
Beispiel #16
0
void test_main(void)
{
  int id, not;
  char *s, *err_fmt = "Bad flag '%s'";

  toys.exitval = 2;
  if (!strcmp("[", toys.which->name))
    if (!strcmp("]", toys.optargs[--toys.optc])) error_exit("Missing ']'");
  if (!strcmp("!", toys.optargs[0])) {
    not = 1;
    toys.optargs++;
    toys.optc--;
  }
  if (!toys.optc) toys.exitval = 0;
  else if (toys.optargs[0][0] == '-') {
    id = stridx("bcdefghLpSsurwxznt", toys.optargs[0][1]);
    if (id == -1 || toys.optargs[0][2]) error_exit(err_fmt, toys.optargs[0]);
    if (id < 12) {
      struct stat st;
      int nolink;

      toys.exitval = 1;
      if (lstat(toys.optargs[1], &st) == -1) return;
      nolink = !S_ISLNK(st.st_mode);
      if (!nolink && (stat(toys.optargs[1], &st) == -1)) return;

      if (id == 0) toys.exitval = !S_ISBLK(st.st_mode); // b
      else if (id == 1) toys.exitval = !S_ISCHR(st.st_mode); // c
      else if (id == 2) toys.exitval = !S_ISDIR(st.st_mode); // d
      else if (id == 3) toys.exitval = 0; // e
      else if (id == 4) toys.exitval = !S_ISREG(st.st_mode); // f
      else if (id == 5) toys.exitval = !(st.st_mode & S_ISGID); // g
      else if ((id == 6) || (id == 7)) toys.exitval = nolink; // hL
      else if (id == 8) toys.exitval = !S_ISFIFO(st.st_mode); // p
      else if (id == 9) toys.exitval = !S_ISSOCK(st.st_mode); // S
      else if (id == 10) toys.exitval = st.st_size == 0; // s
      else toys.exitval = !(st.st_mode & S_ISUID); // u
    }
    else if (id < 15) // rwx
      toys.exitval = access(toys.optargs[1], 1 << (id - 12)) == -1;
    else if (id < 17) // zn
      toys.exitval = toys.optargs[1] && !*toys.optargs[1] ^ (id - 15);
    else { // t
      struct termios termios;
      toys.exitval = tcgetattr(atoi(toys.optargs[1]), &termios) == -1;
    }
  }
  else if (toys.optc == 1) toys.exitval = *toys.optargs[0] == 0;
  else if (toys.optc == 3) {
    if (*toys.optargs[1] == '-') {
      long a = atol(toys.optargs[0]), b = atol(toys.optargs[2]);
      
      s = toys.optargs[1] + 1;
      if (!strcmp("eq", s)) toys.exitval = a != b;
      else if (!strcmp("ne", s)) toys.exitval = a == b;
      else if (!strcmp("gt", s)) toys.exitval = a < b;
      else if (!strcmp("ge", s)) toys.exitval = a <= b;
      else if (!strcmp("lt", s)) toys.exitval = a > b;
      else if (!strcmp("le", s)) toys.exitval = a >= b;
      else error_exit(err_fmt, toys.optargs[1]);
    }
    else {
      int result = strcmp(toys.optargs[0], toys.optargs[2]);

      s = toys.optargs[1];
      if (!strcmp("=", s)) toys.exitval = !!result;
      else if (!strcmp("!=", s)) toys.exitval = !result;
      else error_exit(err_fmt, toys.optargs[1]);
    }
  }
  toys.exitval ^= not;
  return;
}
Beispiel #17
0
main ()
{
  long    end;			/* end of DNA sequence segment */
  t_text  in;			/* input DNA sequence file */
  int     index;		/* commands files index */
  t_text  library;		/* library of DNA sequences */
  t_text  names;		/* file of sequence names file */
  t_seq   seq;         		/* DNA sequence */
  long    start;		/* start of DNA sequence segment */
  int     version;     		/* DNA segment number */
  char    version_str [ MAX_LINE ];	/* ascii version number */
  FILE    *fopen ();		/* file open function */


  printf ( "This is the Sequence files --> Fasta format program.\n\n" );

  /* Prompt for the input file name. */
  prompt_file ( &names, "What is the list of TIGR Assembler alignment sequences file name?" );

  /* Open the DNA library output file. */
  strcpy ( library.name, names.name );
  library.name [ stridx ( library.name, "\n" ) ] = '\0';
  library.name [ stridx ( library.name, "." ) ] = '\0';
  strcat ( library.name, ".Library" );
  library.data = fopen ( library.name, "w" );

  /* Process the sequences. */
  while ( names.eof != TRUE )
  {
    /* Open the sequence output file. */
    strcpy ( in.name, names.line );
    in.name [ stridx ( in.name, "\n" ) ] = '\0';

printf ( "%s\n", in.name );

    /* Open the DNA sequence file for reading. */
    open_text_file ( &in );

    /* Ignore the name line. */
    get_line ( &in );

    /* Read in the DNA sequence. */
    read_DNA_seq ( &in, &seq );
    fclose ( in.data );

    names.line [ stridx ( names.line, "\n" ) ] = '\0';
    strcpy ( seq.name, names.line );

    seq.name [ stridx ( seq.name, ".align" ) ] = '\0';

    /* Write out the library name line. */
    write_fasta_name ( library, seq.name, 1, seq.total, seq.total );

    /* Write out the library DNA sequence. */
    write_DNA_seq ( seq, 0, seq.total - 1, library );

    /* Get the next name. */
    get_line ( &names );
  }  /* while */

  fclose ( library.data );

  printf ( "\nEnd of DNA Sequences -> Fasta format program.\n" );
}  /* main */