533112afe2a2005e80cdb1f82904ea65032d4302 braney Sat Oct 2 11:37:34 2021 -0700 split hg/lib into two separate libaries, one only used by the cgis diff --git src/hg/cgilib/api.c src/hg/cgilib/api.c new file mode 100644 index 0000000..e63ae0e --- /dev/null +++ src/hg/cgilib/api.c @@ -0,0 +1,24 @@ +/* Utility functions for web API programs */ + +/* Copyright (C) 2014 The Regents of the University of California + * See README in this or parent directory for licensing information. */ + +#include "common.h" +#include "api.h" + +void apiOut(char *text, char *jsonp) +/* Output content header and text to stdout */ +{ +// It's debatable whether the type should be text/plain, text/javascript or application/javascript; +// text/javascript works with all our supported browsers, so we are using that one. +puts("Content-Type:text/javascript\n"); + +if (jsonp) + { + printf("%s(%s)", jsonp, text); + } +else + { + puts(text); + } +}