Mac binaries
[jabaws.git] / website / archive / binaries / mac / src / muscle / typetostr.cpp
diff --git a/website/archive/binaries/mac/src/muscle/typetostr.cpp b/website/archive/binaries/mac/src/muscle/typetostr.cpp
new file mode 100644 (file)
index 0000000..2c0afdd
--- /dev/null
@@ -0,0 +1,58 @@
+#include "muscle.h"\r
+#include <stdio.h>\r
+\r
+const char *SecsToStr(unsigned long Secs)\r
+       {\r
+       static char Str[16];\r
+       long hh, mm, ss;\r
+\r
+       hh = Secs/(60*60);\r
+       mm = (Secs/60)%60;\r
+       ss = Secs%60;\r
+\r
+       sprintf(Str, "%02ld:%02ld:%02ld", hh, mm, ss);\r
+       return Str;\r
+       }\r
+\r
+const char *BoolToStr(bool b)\r
+       {\r
+       return b ? "True" : "False";\r
+       }\r
+\r
+const char *ScoreToStr(SCORE Score)\r
+       {\r
+       if (MINUS_INFINITY >= Score)\r
+               return "       *";\r
+// Hack to use "circular" buffer so when called multiple\r
+// times in a printf-like argument list it works OK.\r
+       const int iBufferCount = 16;\r
+       const int iBufferLength = 16;\r
+       static char szStr[iBufferCount*iBufferLength];\r
+       static int iBufferIndex = 0;\r
+       iBufferIndex = (iBufferIndex + 1)%iBufferCount;\r
+       char *pStr = szStr + iBufferIndex*iBufferLength;\r
+       sprintf(pStr, "%8g", Score);\r
+       return pStr;\r
+       }\r
+\r
+// Left-justified version of ScoreToStr\r
+const char *ScoreToStrL(SCORE Score)\r
+       {\r
+       if (MINUS_INFINITY >= Score)\r
+               return "*";\r
+// Hack to use "circular" buffer so when called multiple\r
+// times in a printf-like argument list it works OK.\r
+       const int iBufferCount = 16;\r
+       const int iBufferLength = 16;\r
+       static char szStr[iBufferCount*iBufferLength];\r
+       static int iBufferIndex = 0;\r
+       iBufferIndex = (iBufferIndex + 1)%iBufferCount;\r
+       char *pStr = szStr + iBufferIndex*iBufferLength;\r
+       sprintf(pStr, "%.3g", Score);\r
+       return pStr;\r
+       }\r
+\r
+const char *WeightToStr(WEIGHT w)\r
+       {\r
+       return ScoreToStr(w);\r
+       }\r