summaryrefslogtreecommitdiff
path: root/server/src/journal_commit.cc
diff options
context:
space:
mode:
authordeva <deva>2010-06-21 13:24:53 +0000
committerdeva <deva>2010-06-21 13:24:53 +0000
commitd23cdd88012b230692ba115471855031240db9eb (patch)
tree09cc4da0ba672b62de45c6f54f765ffb01804f06 /server/src/journal_commit.cc
parent6e5274045d2fb060d9ee437a254a0eb32036f281 (diff)
Split journal code into modules. Fix bug, when user is changed in the middle of an active session.
Diffstat (limited to 'server/src/journal_commit.cc')
-rw-r--r--server/src/journal_commit.cc65
1 files changed, 4 insertions, 61 deletions
diff --git a/server/src/journal_commit.cc b/server/src/journal_commit.cc
index 56e7baf..9d76c8f 100644
--- a/server/src/journal_commit.cc
+++ b/server/src/journal_commit.cc
@@ -52,66 +52,6 @@
#include "template.h"
#include "templateparser.h"
-#if 0
-static inline bool iswhitespace(char c)
-{
- return c == ' ' || c == '\n' || c == '\t';
-}
-
-/**
- * Remove all spaces, tabs and newline trailing the string.
- */
-static std::string stripTrailingWhitepace(std::string str)
-{
- if(str == "") return str;
-
- ssize_t end = str.size() - 1;
-
- while(end && iswhitespace(str[end])
- && (end>0 && str[end-1] & 0x80) == false // Make sure we are not in a utf8 character.
- ) {
- end--;
- }
- end++;
-
- return str.substr(0, end);
-}
-
-/**
- * Find all lines longer than 'width', and insert a newline in the
- * first backward occurring space.
- */
-static std::string addNewlines(std::string str, size_t width)
-{
- std::string output;
-
- std::string fraction;
- size_t linelen = 0;
- for(size_t i = 0; i < str.size(); i++) {
-
- fraction += str[i];
-
- if(iswhitespace(str[i])
- && (i>0 && str[i-1] & 0x80) == false // Make sure we are not in a utf8 character.
- ) {
- if(linelen + fraction.size() > width) {
- output[output.size() - 1] = '\n';
- linelen = 0;
- }
- output += fraction;
- linelen += fraction.size();
- fraction = "";
- }
-
- if(str[i] == '\n') linelen = 0;
-
- }
- output += fraction;
-
- return output;
-}
-#endif
-
static int mwrite(int sock, const char *fmt, ...)
{
int l = 0;
@@ -125,7 +65,8 @@ static int mwrite(int sock, const char *fmt, ...)
va_end(args);
if(sock != -1 && write(sock, buffer, l) != l) {
- PRACRO_ERR_LOG(journal, "write did not write all the bytes in the buffer.\n");
+ PRACRO_ERR_LOG(journal,
+ "write did not write all the bytes in the buffer.\n");
}
PRACRO_DEBUG(journal, "%s", buffer);
@@ -173,6 +114,8 @@ int journal_commit(const char *cpr, const char *user,
perror(":");
return -1;
}
+#else
+ sock = open("/tmp/pracro_journal.log", O_CREAT | O_WRONLY | O_TRUNC);
#endif/*WITHOUT_UPLOADSERVER*/
// send header