summaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-11-06 15:19:49 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-11-06 17:54:09 +0100
commit39857a9745cec89da08a2d1101495a32b3535e38 (patch)
treef76c5ba079f265fbb5f34ae1f1009f3a37a30370 /server.c
parent003b3a589a0db5eb1db9376d707f3ca68220dba0 (diff)
Provide default implementations for server functions
By providing default implementations, servers can provide partial implementations of protocols without having to stub out functions. * server.c (WriteDefaultRoutine): New function. (WriteRoutine): Call WriteDefaultRoutine.
Diffstat (limited to 'server.c')
-rw-r--r--server.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/server.c b/server.c
index ae5977f..bcdeb0b 100644
--- a/server.c
+++ b/server.c
@@ -1279,6 +1279,28 @@ WriteFieldDecl(FILE *file, const argument_t *arg)
}
static void
+WriteDefaultRoutine(FILE *file, const routine_t *rt)
+{
+ fprintf(file, "\n/* Default implementation of %s */\n",
+ rt->rtServerName);
+
+ fprintf(file, "#ifdef\tMIG_EOPNOTSUPP\n");
+
+ fprintf(file, "%s __attribute__ ((weak))\n%s\n",
+ ReturnTypeStr(rt), rt->rtServerName);
+ fprintf(file, "(\n");
+ WriteList(file, rt->rtArgs, WriteServerVarDecl,
+ akbServerArg, ",\n", "\n");
+
+ if (rt->rtReturn == argNULL)
+ fprintf(file, ") {}\n");
+ else
+ fprintf(file, ") { return MIG_EOPNOTSUPP; }\n");
+
+ fprintf(file, "#endif\t/* MIG_EOPNOTSUPP */\n");
+}
+
+static void
WriteRoutine(FILE *file, const routine_t *rt)
{
fprintf(file, "\n");
@@ -1346,6 +1368,8 @@ WriteRoutine(FILE *file, const routine_t *rt)
}
fprintf(file, "}\n");
+
+ WriteDefaultRoutine(file, rt);
}
void