project_files/frontlib/util/util.c
changeset 7275 15f722e0b96f
parent 7269 5b0aeef8ba2a
child 7314 6171f0bad318
--- a/project_files/frontlib/util/util.c	Mon Jun 25 15:21:18 2012 +0200
+++ b/project_files/frontlib/util/util.c	Wed Jun 27 18:02:45 2012 +0200
@@ -162,3 +162,27 @@
     char *shrunk = realloc(outbuf, outpos+1);
     return shrunk ? shrunk : outbuf;
 }
+
+bool flib_contains_dir_separator(const char *str) {
+	if(!log_badparams_if(!str)) {
+		for(;*str;str++) {
+			if(*str=='\\' || *str=='/') {
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
+int flib_gets(char *str, size_t strlen) {
+	if(fgets(str, strlen, stdin)) {
+		for(char *s=str; *s; s++) {
+			if(*s=='\r' || *s=='\n') {
+				*s = 0;
+				break;
+			}
+		}
+		return 0;
+	}
+	return -1;
+}