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

# HG changeset patch
# User boris
# Date 1284646114 -14400
# Node ID dc0471ad84e2f3807b15d1ec7b79c2dc562af214
# Parent 90767fa9bff91802c57e2bc1cbda0f53bfe4fc6f
salt -> mktemp

diff -r 90767fa9bff9 -r dc0471ad84e2 blocks3d/wt/blocks3d-wt-widget.C
--- a/blocks3d/wt/blocks3d-wt-widget.C Thu Sep 16 15:51:42 2010 +0400
+++ b/blocks3d/wt/blocks3d-wt-widget.C Thu Sep 16 18:08:34 2010 +0400
@@ -1,7 +1,7 @@

#include "config.h"
#include "blocks3d-wt-widget.h"
-#include "salt.h"
+#include "mktemp_string.h"

#include
#include
@@ -16,7 +16,7 @@
#include
#include
#include
-#include
+#include

Blocks3DWidget::Blocks3DWidget(Wt::WContainerWidget *parent) :
Wt::WContainerWidget(parent)
@@ -185,18 +185,11 @@
return;
}

- std::string r = generateSalt();
-
- tempfile_alignment =
- str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_alignment);
- tempfile_conformity =
- str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_conformity);
- tempfile_html =
- str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_html);
- tempfile_check =
- str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_check);
- tempfile_sh =
- str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_sh);
+ tempfile_alignment = mktemp_string(Malakite::temp_mkstemp_path);
+ tempfile_conformity = mktemp_string(Malakite::temp_mkstemp_path);
+ tempfile_html = mktemp_string(Malakite::temp_mkstemp_path);
+ tempfile_check = mktemp_string(Malakite::temp_mkstemp_path);
+ tempfile_sh = mktemp_string(Malakite::temp_mkstemp_path);

std::ofstream alignment_file;
alignment_file.open(tempfile_alignment.c_str());
diff -r 90767fa9bff9 -r dc0471ad84e2 blocks3d/wt/blocks3d-wt.pro
--- a/blocks3d/wt/blocks3d-wt.pro Thu Sep 16 15:51:42 2010 +0400
+++ b/blocks3d/wt/blocks3d-wt.pro Thu Sep 16 18:08:34 2010 +0400
@@ -1,7 +1,7 @@
TARGET = blocks3d-wt.exe

SOURCES += config.C
-SOURCES += salt.C
+SOURCES += mktemp_string.C
SOURCES += blocks3d-wt.C
SOURCES += blocks3d-wt-widget.C
SOURCES += work-time.C
diff -r 90767fa9bff9 -r dc0471ad84e2 blocks3d/wt/config.C
--- a/blocks3d/wt/config.C Thu Sep 16 15:51:42 2010 +0400
+++ b/blocks3d/wt/config.C Thu Sep 16 18:08:34 2010 +0400
@@ -10,13 +10,14 @@
const char* python_path = "python";
const char* blocks3d_path = "/home/boris/my-code/Blocks3D/Blocks3D_v5/Blocks3D.py";
const char* temp_path = "/tmp";
+const char* temp_mkstemp_path = "/tmp/XXXXXX";

const char* main_url = "/";

-const char* tempfile_alignment = "in_aln.fasta";
-const char* tempfile_conformity = "in_conf.fasta";
-const char* tempfile_html = "out.html";
-const char* tempfile_check = "check.lock";
+//~ const char* tempfile_alignment = "in_aln.fasta";
+//~ const char* tempfile_conformity = "in_conf.fasta";
+//~ const char* tempfile_html = "out.html";
+//~ const char* tempfile_check = "check.lock";
const char* tempfile_sh = "run.sh";

namespace defaults
diff -r 90767fa9bff9 -r dc0471ad84e2 blocks3d/wt/config.h
--- a/blocks3d/wt/config.h Thu Sep 16 15:51:42 2010 +0400
+++ b/blocks3d/wt/config.h Thu Sep 16 18:08:34 2010 +0400
@@ -10,13 +10,14 @@
extern const char* python_path;
extern const char* blocks3d_path;
extern const char* temp_path;
+extern const char* temp_mkstemp_path;

extern const char* main_url;

-extern const char* tempfile_alignment;
-extern const char* tempfile_conformity;
-extern const char* tempfile_html;
-extern const char* tempfile_check;
+//~ extern const char* tempfile_alignment;
+//~ extern const char* tempfile_conformity;
+//~ extern const char* tempfile_html;
+//~ extern const char* tempfile_check;
extern const char* tempfile_sh;

namespace defaults
diff -r 90767fa9bff9 -r dc0471ad84e2 blocks3d/wt/mktemp_string.C
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/mktemp_string.C Thu Sep 16 18:08:34 2010 +0400
@@ -0,0 +1,12 @@
+
+#include "mktemp_string.h"
+
+std::string mktemp_string(const char* templ)
+{
+ char* tmpname = strdup(templ);
+ mktemp(tmpname);
+ std::string r = std::string(tmpname);
+ delete tmpname;
+ return r;
+}
+
diff -r 90767fa9bff9 -r dc0471ad84e2 blocks3d/wt/mktemp_string.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/mktemp_string.h Thu Sep 16 18:08:34 2010 +0400
@@ -0,0 +1,8 @@
+#ifndef MKTEMP_STRING_H_
+#define MKTEMP_STRING_H_
+
+#include
+
+std::string mktemp_string(const char* templ);
+
+#endif // MKTEMP_STRING_H_
diff -r 90767fa9bff9 -r dc0471ad84e2 blocks3d/wt/salt.C
--- a/blocks3d/wt/salt.C Thu Sep 16 15:51:42 2010 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-
-#include "salt.h"
-
-std::string generateSalt() {
- /* Salt generation from glibc manual */
- unsigned long seed[2];
- char salt[] = "_1_........";
- const char *const seedchars =
- "./0123456789ABCDEFGHIJKLMNOPQRST"
- "UVWXYZabcdefghijklmnopqrstuvwxyz";
-
- /* Generate a (not very) random seed. */
- seed[0] = time(NULL);
- seed[1] = getpid() ^ (seed[0] >> 14 & 0x30000);
-
- /* Turn it into printable characters from `seedchars'. */
- for (int i = 0; i < 8; i++)
- salt[3+i] = seedchars[(seed[i/5] >> (i%5)*6) & 0x3f];
-
- return salt;
-}
diff -r 90767fa9bff9 -r dc0471ad84e2 blocks3d/wt/salt.h
--- a/blocks3d/wt/salt.h Thu Sep 16 15:51:42 2010 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-#ifndef SALT_H_
-#define SALT_H_
-
-#include
-
-std::string generateSalt();
-
-#endif // SALT_H_