Changeset 604

Show
Ignore:
Timestamp:
05/15/07 23:31:21 (2 years ago)
Author:
chtekk
Message:

Let's try this: get also converts.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/vcd/methods/vxdb/vxdb_vx_limit_get.c

    r596 r604  
    1616// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
    1717 
     18#include <unistd.h> 
     19#include <inttypes.h> 
     20 
    1821#include "auth.h" 
    1922#include "methods.h" 
     
    2225 
    2326#include <lucid/log.h> 
     27#include <lucid/scanf.h> 
     28#include <lucid/str.h> 
     29 
     30static 
     31uint64_t bytestopages(uint64_t bytes) { 
     32        uint64_t pages; 
     33        pages = (bytes * 1024) / (uint64_t) getpagesize(); 
     34        return pages; 
     35} 
     36 
     37static 
     38struct limtype_data { 
     39        char *type; 
     40} LIMTYPE[] = { 
     41        { "ANON"    }, 
     42        { "AS"      }, 
     43        { "MAPPED"  }, 
     44        { "MEMLOCK" }, 
     45        { "RSS"     }, 
     46        { "SHMEM"   }, 
     47        { NULL      } 
     48}; 
    2449 
    2550/* vxdb.vx.limit.get(string name[, string type]) */ 
     
    6994 
    7095        vxdb_foreach_step(rc, dbr) 
     96                char *typedb  = vxdb_column_text(dbr, 0); 
     97                uint64_t soft = vxdb_column_uint64(dbr, 1); 
     98                uint64_t max  = vxdb_column_uint64(dbr, 2); 
     99 
     100                for(i = 0; LIMTYPE[i].type; i++) { 
     101                        if (str_equal(typedb, LIMTYPE[i].type)) { 
     102                                soft = bytestopages(soft); 
     103                                max  = bytestopages(max); 
     104                        } 
     105                } 
     106 
     107                char *softs, maxs; 
     108                asprintf(&softs, "%" PRIu64, soft); 
     109                asprintf(&maxs,  "%" PRIu64, max); 
     110 
    71111                xmlrpc_array_append_item(env, response, xmlrpc_build_value(env, 
    72112                                "{s:s,s:s,s:s}", 
    73                                 "type", vxdb_column_text(dbr, 0)
    74                                 "soft", vxdb_column_text(dbr, 1)
    75                                 "max",  vxdb_column_text(dbr, 2))); 
     113                                "type", typedb
     114                                "soft", softs
     115                                "max",  maxs)); 
    76116 
    77117        if (rc != VXDB_DONE)