Made cfs-based webserver example compatible with 8.3 file systems.
[contiki-2.x.git] / tools / mknmlist
blob3bd5615c52ec6e954490f0636aa0e4d61e7af5fe
1 function sort(V, N,                             tmp, i, j) {
2   V[-1] = ""; # Used as a sentinel before V[0].
3   for (i = 1; i < N; i++)
4     for (j = i; V[j - 1] > V[j]; j--) {
5       tmp = V[j];
6       V[j] = V[j - 1];
7       V[j - 1] = tmp;
8     }
9   return;
12 BEGIN {
13  nname = 0;
14  builtin["printf"] =    "int printf(const char *, ...)";
15  builtin["sprintf"] =   "int sprintf(char *, const char *, ...)";
16  builtin["malloc"] =    "void *malloc()";
17  builtin["calloc"] =    "void *calloc()";
18  builtin["memcpy"] =    "void *memcpy()";
19  builtin["memset"] =    "void *memset()";
20  builtin["memmove"] =   "void *memmove()";
21  builtin["strcpy"] =    "char *strcpy()";
22  builtin["strchr"] =    "char *strchr()";
23  builtin[""] =  "";
26 /^[0123456789abcdef]+ [ABCDGRSTUVW] / {
27   if ($3 != "symbols" && $3 != "symbols_nelts") {
28     name[nname] = $3;
29     nname++;
30   }
33 END {
34   sort(name, nname);
36   print "#include \"loader/symbols.h\"\n";
38   # Must deal with compiler builtins etc.
39   for (x = 0; x < nname; x++) {
40     if (builtin[name[x]] != "")
41       print builtin[name[x]] ";";
42     else
43       print "extern int " name[x]"();";
44   }
45   print "\n";
47   # nname++: An { 0, 0 } entry is added at the end of the vector.
48   print "const int symbols_nelts = " nname+1 ";";
49   print "const struct symbols symbols[" nname+1 "] = {";
50   for (x = 0; x < nname; x++)
51     print "{ \"" name[x] "\", (void *)&"name[x]" },";
52   print "{ (const char *)0, (void *)0} };";