READMEのCASL II仕様書へのリンクを修正
[YACASL2.git] / include / cmem.h
index 85cb720..2411980 100644 (file)
@@ -1,6 +1,11 @@
 #ifndef YACASL2_CMEM_H_INCLUDED
 #define YACASL2_CMEM_H_INCLUDED
+
+#include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <stdbool.h>
 
 /**
  * @brief 配列のサイズを返すマクロ
@@ -26,7 +31,7 @@
  * @param size メモリーのサイズ
  * @param tag エラーメッセージなどで表示されるタグ
  */
-void *malloc_chk(size_t size, char *tag);
+void *malloc_chk(size_t size, const char *tag);
 
 /**
  * @brief 領域の数とサイズを指定してメモリーを確保するcallocを実行する
@@ -39,7 +44,7 @@ void *malloc_chk(size_t size, char *tag);
  * @param size 領域1個あたりのメモリーサイズ
  * @param tag エラーメッセージなどで表示されるタグ
  */
-void *calloc_chk(size_t nmemb, size_t size, char *tag);
+void *calloc_chk(size_t nmemb, size_t size, const char *tag);
 
 /**
  * @brief malloc_chkを実行してメモリを確保し、コピーした文字列を返す
@@ -49,6 +54,44 @@ void *calloc_chk(size_t nmemb, size_t size, char *tag);
  * @param s 文字列
  * @param tag エラーメッセージなどで表示されるタグ
  */
-char *strdup_chk(const char *s, char *tag);
+char *strdup_chk(const char *s, const char *tag);
+
+/**
+ * @brief malloc_chkを実行してメモリを確保し、コピーした文字列の指定した長さの部分を返す
+ *
+ * @return コピーした文字列
+ *
+ * @param s 文字列
+ * @param len 文字列の長さ
+ * @param tag エラーメッセージなどで表示されるタグ
+ */
+char *strndup_chk(const char *s, size_t len, const char *tag);
+
+/**
+ * @brief 文字列の末尾から、改行と空白とタブを削除する
+ *
+ * @return なし
+ *
+ * @param s 文字列
+ */
+void strip_end(char *s);
+
+/**
+ * @brief 文字列から「'」以降の文字列をCASL IIのコメントとして削除する。「''」の場合は除く
+ *
+ * @return なし
+ *
+ * @param s 文字列
+ */
+void strip_casl2_comment(char *s);
+
+/**
+ * @brief 逆にした文字列を返す
+ *
+ * @return 逆にしたした文字列
+ *
+ * @param s 文字列
+ */
+char *strrev(const char *s);
 
 #endif