All patches
[idzebra-moved-to-github.git] / util / res.c
index 0d29a9f..57ed120 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the Zebra server.
-   Copyright (C) 1995-2008 Index Data
+   Copyright (C) 1994-2009 Index Data
 
 Zebra is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
@@ -332,6 +332,22 @@ int res_get_match(Res r, const char *name, const char *value, const char *s)
     return 0;
 }
 
+const char *res_get_named(Res r, const char *resName, const char *name)
+{
+    //This part relies on dynamic stack allocation cus I'm lazy
+    //resName.name = strlen(resName) + 1 + strlen(name) + (space for \0)
+    unsigned int resLen = strlen(resName) + strlen(name) + 2;
+    char wholeName[resLen];
+    memset(wholeName, NULL, resLen);
+
+    strcat(wholeName, resName);
+    strcat(wholeName, ".");
+    strcat(wholeName, name);
+
+    const char *nr = res_get(r, wholeName);
+    return nr;
+}
+
 void res_set(Res r, const char *name, const char *value)
 {
     struct res_entry *re;
@@ -541,6 +557,7 @@ int res_check(Res r_i, Res r_v)
 /*
  * Local variables:
  * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
  * indent-tabs-mode: nil
  * End:
  * vim: shiftwidth=4 tabstop=8 expandtab