Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/dc0471ad84e2
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 00:15:47 2012
Кодировка:
allpy: dc0471ad84e2

allpy

changeset 64:dc0471ad84e2

salt -> mktemp
author boris <bnagaev@gmail.com>
date Thu, 16 Sep 2010 18:08:34 +0400
parents 90767fa9bff9
children 371a9ddf1658
files blocks3d/wt/blocks3d-wt-widget.C blocks3d/wt/blocks3d-wt.pro blocks3d/wt/config.C blocks3d/wt/config.h blocks3d/wt/mktemp_string.C blocks3d/wt/mktemp_string.h blocks3d/wt/salt.C blocks3d/wt/salt.h
diffstat 8 files changed, 38 insertions(+), 52 deletions(-) [+]
line diff
     1.1 --- a/blocks3d/wt/blocks3d-wt-widget.C	Thu Sep 16 15:51:42 2010 +0400
     1.2 +++ b/blocks3d/wt/blocks3d-wt-widget.C	Thu Sep 16 18:08:34 2010 +0400
     1.3 @@ -1,7 +1,7 @@
     1.4  
     1.5  #include "config.h"
     1.6  #include "blocks3d-wt-widget.h"
     1.7 -#include "salt.h"
     1.8 +#include "mktemp_string.h"
     1.9  
    1.10  #include <Wt/WText>
    1.11  #include <Wt/WBreak>
    1.12 @@ -16,7 +16,7 @@
    1.13  #include <fstream>
    1.14  #include <iostream>
    1.15  #include <boost/format.hpp>
    1.16 -#include <stdlib.h>
    1.17 +#include <cstdlib>
    1.18  
    1.19  Blocks3DWidget::Blocks3DWidget(Wt::WContainerWidget *parent) :
    1.20  	Wt::WContainerWidget(parent)
    1.21 @@ -185,18 +185,11 @@
    1.22  		return;
    1.23  	}
    1.24  	
    1.25 -	std::string r = generateSalt();
    1.26 -	
    1.27 -	tempfile_alignment = 
    1.28 -	str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_alignment);
    1.29 -	tempfile_conformity = 
    1.30 -	str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_conformity);
    1.31 -	tempfile_html = 
    1.32 -	str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_html);
    1.33 -	tempfile_check = 
    1.34 -	str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_check);
    1.35 -	tempfile_sh = 
    1.36 -	str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_sh);
    1.37 +	tempfile_alignment = mktemp_string(Malakite::temp_mkstemp_path);
    1.38 +	tempfile_conformity = mktemp_string(Malakite::temp_mkstemp_path);
    1.39 +	tempfile_html = mktemp_string(Malakite::temp_mkstemp_path);
    1.40 +	tempfile_check = mktemp_string(Malakite::temp_mkstemp_path);
    1.41 +	tempfile_sh = mktemp_string(Malakite::temp_mkstemp_path);
    1.42  	
    1.43  	std::ofstream alignment_file;
    1.44  	alignment_file.open(tempfile_alignment.c_str());
     2.1 --- a/blocks3d/wt/blocks3d-wt.pro	Thu Sep 16 15:51:42 2010 +0400
     2.2 +++ b/blocks3d/wt/blocks3d-wt.pro	Thu Sep 16 18:08:34 2010 +0400
     2.3 @@ -1,7 +1,7 @@
     2.4  TARGET = blocks3d-wt.exe
     2.5  
     2.6  SOURCES += config.C
     2.7 -SOURCES += salt.C
     2.8 +SOURCES += mktemp_string.C
     2.9  SOURCES += blocks3d-wt.C
    2.10  SOURCES += blocks3d-wt-widget.C
    2.11  SOURCES += work-time.C
     3.1 --- a/blocks3d/wt/config.C	Thu Sep 16 15:51:42 2010 +0400
     3.2 +++ b/blocks3d/wt/config.C	Thu Sep 16 18:08:34 2010 +0400
     3.3 @@ -10,13 +10,14 @@
     3.4  const char* python_path = "python";
     3.5  const char* blocks3d_path = "/home/boris/my-code/Blocks3D/Blocks3D_v5/Blocks3D.py";
     3.6  const char* temp_path = "/tmp";
     3.7 +const char* temp_mkstemp_path = "/tmp/XXXXXX";
     3.8  
     3.9  const char* main_url = "/";
    3.10  
    3.11 -const char* tempfile_alignment = "in_aln.fasta";
    3.12 -const char* tempfile_conformity = "in_conf.fasta";
    3.13 -const char* tempfile_html = "out.html";
    3.14 -const char* tempfile_check = "check.lock";
    3.15 +//~ const char* tempfile_alignment = "in_aln.fasta";
    3.16 +//~ const char* tempfile_conformity = "in_conf.fasta";
    3.17 +//~ const char* tempfile_html = "out.html";
    3.18 +//~ const char* tempfile_check = "check.lock";
    3.19  const char* tempfile_sh = "run.sh";
    3.20  
    3.21  namespace defaults
     4.1 --- a/blocks3d/wt/config.h	Thu Sep 16 15:51:42 2010 +0400
     4.2 +++ b/blocks3d/wt/config.h	Thu Sep 16 18:08:34 2010 +0400
     4.3 @@ -10,13 +10,14 @@
     4.4  extern const char* python_path;
     4.5  extern const char* blocks3d_path;
     4.6  extern const char* temp_path;
     4.7 +extern const char* temp_mkstemp_path;
     4.8  
     4.9  extern const char* main_url;
    4.10  
    4.11 -extern const char* tempfile_alignment;
    4.12 -extern const char* tempfile_conformity;
    4.13 -extern const char* tempfile_html;
    4.14 -extern const char* tempfile_check;
    4.15 +//~ extern const char* tempfile_alignment;
    4.16 +//~ extern const char* tempfile_conformity;
    4.17 +//~ extern const char* tempfile_html;
    4.18 +//~ extern const char* tempfile_check;
    4.19  extern const char* tempfile_sh;
    4.20  
    4.21  namespace defaults
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/blocks3d/wt/mktemp_string.C	Thu Sep 16 18:08:34 2010 +0400
     5.3 @@ -0,0 +1,12 @@
     5.4 +
     5.5 +#include "mktemp_string.h"
     5.6 +
     5.7 +std::string mktemp_string(const char* templ)
     5.8 +{
     5.9 +	char* tmpname = strdup(templ);
    5.10 +	mktemp(tmpname);
    5.11 +	std::string r = std::string(tmpname);
    5.12 +	delete tmpname;
    5.13 +	return r;
    5.14 +}
    5.15 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/blocks3d/wt/mktemp_string.h	Thu Sep 16 18:08:34 2010 +0400
     6.3 @@ -0,0 +1,8 @@
     6.4 +#ifndef MKTEMP_STRING_H_
     6.5 +#define MKTEMP_STRING_H_
     6.6 +
     6.7 +#include <string>
     6.8 +
     6.9 +std::string mktemp_string(const char* templ);
    6.10 +
    6.11 +#endif // MKTEMP_STRING_H_
     7.1 --- a/blocks3d/wt/salt.C	Thu Sep 16 15:51:42 2010 +0400
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,21 +0,0 @@
     7.4 -
     7.5 -#include "salt.h"
     7.6 -
     7.7 -std::string generateSalt() {
     7.8 -	/* Salt generation from glibc manual */
     7.9 -	unsigned long seed[2];
    7.10 -	char salt[] = "_1_........";
    7.11 -	const char *const seedchars =
    7.12 -		"./0123456789ABCDEFGHIJKLMNOPQRST"
    7.13 -		"UVWXYZabcdefghijklmnopqrstuvwxyz";
    7.14 -	 
    7.15 -	/* Generate a (not very) random seed. */
    7.16 -	seed[0] = time(NULL);
    7.17 -	seed[1] = getpid() ^ (seed[0] >> 14 & 0x30000);
    7.18 -	 
    7.19 -	/* Turn it into printable characters from `seedchars'. */
    7.20 -	for (int i = 0; i < 8; i++)
    7.21 -		salt[3+i] = seedchars[(seed[i/5] >> (i%5)*6) & 0x3f];
    7.22 -
    7.23 -	return salt;
    7.24 -}
     8.1 --- a/blocks3d/wt/salt.h	Thu Sep 16 15:51:42 2010 +0400
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,8 +0,0 @@
     8.4 -#ifndef SALT_H_
     8.5 -#define SALT_H_
     8.6 -
     8.7 -#include <string>
     8.8 -
     8.9 -std::string generateSalt();
    8.10 -
    8.11 -#endif // SALT_H_