Merge release-5-0 into master
[alexxy/gromacs.git] / src / gromacs / utility / cstringutil.h
index 8cba1a370ba72e093654ecad493318788812a77b..fabe7788246016d7b5def483380800882c3ca9cf 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 #define GMX_UTILITY_CSTRINGUTIL_H
 
 #include <stdio.h>
-#include <time.h>
 
-#include "../legacyheaders/types/simple.h"
-
-#include "gmx_header_config.h"
+#include "gromacs/utility/basedefinitions.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -61,6 +58,8 @@ extern "C" {
 #define CONTINUE    '\\'
 /** Comment sign to use. */
 #define COMMENTSIGN ';'
+/** Standard size for char* string buffers. */
+#define STRLEN 4096
 
 /*! \brief
  * Strip trailing spaces and if s ends with a ::CONTINUE remove that too.
@@ -72,9 +71,9 @@ int continuing(char *s);
 /*! \brief
  * Reads a line from a stream.
  *
- * This routine reads a string from stream of max length n
- * and zero terminated, without newlines.
- * \p s should be long enough (>= \p n)
+ * This routine reads a string from stream of max length n, including
+ * \0 and zero terminated, without newlines.  \p s should be long
+ * enough (>= \p n)
  */
 char *fgets2(char *s, int n, FILE *stream);
 
@@ -93,9 +92,6 @@ void rtrim(char *str);
 /** Remove leading and trailing whitespace from a string. */
 void trim(char *str);
 
-/** Portable version of ctime_r. */
-char *gmx_ctime_r(const time_t *clock, char *buf, int n);
-
 /** Prints creation time stamp and user information into a file as comments. */
 void nice_header(FILE *out, const char *fn);
 
@@ -183,9 +179,17 @@ char *wrap_lines(const char *buf, int line_width, int indent,
  */
 gmx_int64_t str_to_int64_t(const char *str, char **endptr);
 
-#ifdef GMX_NATIVE_WINDOWS
-#define snprintf _snprintf
-#endif
+/** Minimum size of buffer to pass to gmx_step_str(). */
+#define STEPSTRSIZE 22
+
+/*! \brief
+ * Prints a gmx_int64_t value in buf and returns the pointer to buf.
+ *
+ * buf should be large enough to contain i: STEPSTRSIZE (22) chars.
+ * When multiple gmx_int64_t values are printed in the same printf call,
+ * be sure to call gmx_step_str with different buffers.
+ */
+char *gmx_step_str(gmx_int64_t i, char *buf);
 
 /*! \brief Construct an array of digits found in the input string
  *