]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/util.c
proxmark3 refactoring command line parameters (#417)
[proxmark3-svn] / client / util.c
index 86e8c502043921c1a20dbddc5224bc11ffd2909c..8357f60137a5234007df335578656615e469cb65 100644 (file)
@@ -623,7 +623,28 @@ void clean_ascii(unsigned char *buf, size_t len) {
   }
 }
 
+// replace \r \n to \0
+void strcleanrn(char *buf, size_t len) {
+       strcreplace(buf, len, '\n', '\0');
+       strcreplace(buf, len, '\r', '\0');
+}
 
+// replace char in buffer
+void strcreplace(char *buf, size_t len, char from, char to) {
+  for (size_t i = 0; i < len; i++) {
+    if (buf[i] == from)
+      buf[i] = to;
+  }
+}
+
+char *strmcopy(char *buf) {
+       char * str = NULL;
+       if ((str = (char*) malloc(strlen(buf) + 1)) != NULL) {
+               memset(str, 0, strlen(buf) + 1);
+               strcpy(str, buf);
+       }       
+       return str;
+}
 
 
 // determine number of logical CPU cores (use for multithreaded functions)
Impressum, Datenschutz