summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJohannes Schauer <josch@debian.org>2015-04-29 18:43:22 +0200
committerJohannes Schauer <josch@debian.org>2015-04-29 18:43:22 +0200
commit118880912438aa219d100a85ec54ac461741b3ba (patch)
tree7e94c61a00446a229b492196669f60aa56e4a594 /include
ldraw-parts (1402+ds-1) unstable; urgency=medium
* New upstream release * Replace my email address in Maintainer field by josch@debian.org * bump standards version to 3.9.6 # imported from the archive
Diffstat (limited to 'include')
-rw-r--r--include/alloc.h9
-rw-r--r--include/conio.h23
-rw-r--r--include/dir.h72
3 files changed, 104 insertions, 0 deletions
diff --git a/include/alloc.h b/include/alloc.h
new file mode 100644
index 000000000..7eb47373d
--- /dev/null
+++ b/include/alloc.h
@@ -0,0 +1,9 @@
+#ifndef ALLOC_H
+#define ALLOC_H
+
+#define farmalloc(n) malloc((n))
+#define farrealloc(i,j) realloc((i),(j))
+#define farcoreleft() (0)
+
+#endif /* ALLOC_H */
+
diff --git a/include/conio.h b/include/conio.h
new file mode 100644
index 000000000..820295756
--- /dev/null
+++ b/include/conio.h
@@ -0,0 +1,23 @@
+#ifndef CONIO_H
+#define CONIO_H
+
+#define getch() getc(stdin)
+
+int stricmp(const char *str1, const char *str2)
+{
+ const unsigned char * ptr1 = (unsigned char *) str1;
+ const unsigned char * ptr2 = (unsigned char *) str2;
+ unsigned char c1, c2;
+
+ while ((c1 = toupper(*ptr1++)) == (c2 = toupper(*ptr2++)))
+ {
+ if (!c1)
+ {
+ return(0); // end of both strings reached, so they match
+ }
+ }
+ // first non-matching char was reached, including possibly 0 on one or the other string
+ return(c1 - c2);
+}
+
+#endif /* CONIO_H */
diff --git a/include/dir.h b/include/dir.h
new file mode 100644
index 000000000..0e7585dda
--- /dev/null
+++ b/include/dir.h
@@ -0,0 +1,72 @@
+#ifndef DIR_H
+#define DIR_H
+
+# include <dirent.h>
+# include <sys/stat.h>
+# include <unistd.h>
+
+struct ffblk
+{
+ char *ff_name;
+};
+
+#if defined(MAC)
+ char separator = ':';
+# define SEPSTR ":"
+#else
+ char separator = '/';
+# define SEPSTR "/"
+#endif
+
+DIR *dirp;
+struct dirent *dir;
+char directory[300];
+
+int findnext(struct ffblk *ffb)
+{
+ struct stat statbuf;
+ char filename[300];
+
+ for (dir = readdir(dirp); dir; dir = readdir(dirp))
+ {
+ ffb->ff_name = dir->d_name;
+ strcpy(filename, directory);
+ strcat(filename, SEPSTR);
+ strcat(filename, dir->d_name);
+ stat(filename,&statbuf);
+ if ((statbuf.st_mode & S_IFDIR) == 0) // Skip directories
+ return 0; // not done
+ }
+ return 1; // done
+}
+
+int findfirst(char *path, struct ffblk *ffb, int first)
+{
+ int i;
+ char *ptr;
+
+ /* Localize Directory Separators */
+ for(i=0; i<strlen(path); i++)
+ {
+ if ((path[i] == '/') || (path[i] == '\\'))
+ {
+ path[i] = separator;
+ }
+ else
+ path[i] = tolower(path[i]);
+ }
+
+ strcpy(directory,path);
+ /* Remove any trailing separators (and anything after them) */
+ if ( (ptr = strrchr(directory, separator)) )
+ *ptr = 0;
+
+ dirp = opendir(directory);
+ if (!dirp)
+ return 1; // done
+
+ return findnext(ffb);
+}
+
+#endif /* DIR_H */
+