Skip to content

npp_add_host

Jurek Muszyński edited this page Jan 20, 2022 · 4 revisions

bool npp_add_host(const char *host, const char *res, const char *resmin, const char *snippets)

Description

Assigns res, resmin and snippets directories to a host. If requested host matches one of those set with npp_add_host, the engine will use these alternative resources instead of those from main res, resmin or snippets.

Host comparison is case-insensitive and port number is cuf off if present in request.

Directories specified in res, resmin and snippets need to be under NPP_DIR. For the security reasons it's not possible to set absolute path here. For example, setting res for example1.com to example1/res will cause engine to read static resources for that domain from $NPP_DIR/example1/res.

Returns

true if OK, false if NPP_MAX_HOSTS has been reached.

Example

// in npp_app_init()
// Host additional domains on example.com's server:
npp_add_host("example1.com", "example1/res", "example1/resmin", "example1/snippets");
npp_add_host("example2.com", "example2/res", "example2/resmin", "example2/snippets");

Notes

Requires NPP_MULTI_HOST compilation switch.

Clone this wiki locally