---
name: "Ns_UrlSpecific"
section: "3"
platform: "linux"
package: "aolserver4"
version: "4.0.10-7"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/Ns_UrlSpecific"
---

# Ns\_UrlSpecific(3)

Store and retrieve URL-specific data

```

```

## NAME

Ns\_UrlSpecificAlloc, Ns\_UrlSpecificDestroy, Ns\_UrlSpecificGet, Ns\_UrlSpecificGetExact, Ns\_UrlSpecificGetFast, Ns\_UrlSpecificSet - Store and retrieve URL-specific data

## SYNOPSIS

```
#include "ns.h"

int
Ns_UrlSpecificAlloc(void)

void *
Ns_UrlSpecificDestroy(char *server, char *method, char *url,
    int id, int flags)

void *
Ns_UrlSpecificGet(char *server, char *method, char *url,
    int id)

void *
Ns_UrlSpecificGetExact(char *server, char *method, char *url,
    int id, int flags)

void *
Ns_UrlSpecificGetFast(char *server, char *method, char *url,
    int id)

void
Ns_UrlSpecificSet(char *server, char *method, char *url,
    int id, void *data, int flags, void (*deletefunc) (void *))
```

## DESCRIPTION

These functions allow you to store URL-specific data in memory for later retrieval. They are used when registering procedures for example.

- **Ns\_UrlSpecificAlloc**()

  Return a unique ID used to identify a unique virtual URL-space that is then used with the Ns\_UrlSpecific storage functions. You should only call this function at server startup, and not after. Here is an example:

  ```
  static int myId;
  void
  Init(void)
  {
      /* Allocate the id once at startup. */
      myId = Ns_UrlSpecificAlloc();
  }
  void
  Store(char *server, char *method, char *url, char *data)
  {
      Ns_UrlSpecificSet(server, method, url, myId,
      data, 0, NULL);
  }
  char *
  Fetch(char *server, char *method, char *url)
  {
      char *data;
      data = Ns_UrlSpecificGet(server, method, url, myId);
      return (char *) data;
  }
  ```

- **Ns\_UrlSpecificDestroy**(*server, method, url, id, flags*)

  The Ns\_UrlSpecificDestroy function deletes URL-specific data previously stored with Ns\_UrlSpecificSet with the same method/URL combination and the same inheritance setting.

  An id of -1 matches all ids. For example, Ns\_UrlSpecificDestroy("myserver", "GET", "/", -1, NS\_OP\_RECURSE) removes all data for the method GET for server "myserver".

  The flags argument can be:

-

  NS\_OP\_NODELETE - If set, the deletefunc specified in Ns\_UrlSpeciciSet is run.

-

  NS\_OP\_RECURSE - If set, then data for all URLs more specific than the passed-in URL are also destroyed.

-

  NS\_OP\_NOINHERIT - If set, data that was stored with this flag in Ns\_UrlSpecificSet will be deleted.  If not set, the data stored without this flag will be deleted.

- **Ns\_UrlSpecificGet**(*server, method, url, id*)

  The Ns\_UrlSpecificGet function retrieves the best match that it can find for in the URL subspace identified by id that the passed-in URL matches. For instance, suppose you had previously registered a handle/method/url/id combination of {myserver, GET, /, 1} and {myserver, GET, /inventory, 1}. The following call would match the data registered at {myserver, GET, /inventory, 1}:

  ```
  Ns_UrlSpecificGet("myserver", "GET", "/inventory/RJ45", 1)
  ```

- **Ns\_UrlSpecificGetExact**(*server, method, url, id, flags*)

  Retrieves stored data for the exact method/URL/id combination specified that was stored with the same inheritance setting.

  If the flags argument is set to NS\_OP\_NOINHERIT,  the data stored with NS\_OP\_NOINHERIT will be retrieved.  If the flags argument is set to 0, the data stored without NS\_OP\_NOINHERIT will be retrieved.

- **Ns\_UrlSpecificGetFast**(*server, method, url, id*)

  Same as Ns\_UrlSpecificGet but does not support wildcards, making it much faster.

- **Ns\_UrlSpecificSet**(*server, method, url, id, data, flags, deletefunc*)

  The Ns\_UrlSpecificSet function stores data in memory, allowing subsequent retrieval using handle, method, url, id, and inheritance flag.

  The flags argument can be NS\_OP\_NOINHERIT or NS\_OP\_NODELETE. You can store two sets of data based on the same handle, method, url, and id combination-- one set with inheritance on and one set with inheritance off. If the NS\_OP\_NOINHERIT flag is set, the data is stored based on the exact URL. If NS\_OP\_NOINHERIT is omitted, the data is stored based on the specified URL and any URL below it. In this case, Ns\_UrlSpecificGetExact will match to the closest URL when retrieving the data.

  The deletefunc argument is called with data as an argument when this handle/url/method/id combination is re-registered or deleted, or when this server shuts down. unless NS\_OP\_NODELETE is set.

  Normally, calling Ns\_UrlSpecificSet on a handle/url/method/id combination which already has an operation registered for it causes the previous operation's delete procedure to be called. You can override this behavior by adding the NS\_OP\_NODELETE flag.

## SEE ALSO

nsd(1), [info(n)](/info/n.md)

## KEYWORDS
