akaros/tests/serialize_test.c
<<
>>
Prefs
   1/* Copyright (c) 2014 Google Inc., All Rights Reserved.
   2 * Kevin Klues <klueska@google.com>
   3 * See LICENSE for details. */
   4
   5#include <parlib/serialize.h>
   6#include <stdint.h>
   7#include <stdio.h>
   8
   9int main(int argc, char **argv, char **envp)
  10{
  11        struct serialized_data *sd = serialize_argv_envp(argv, envp);
  12        size_t *kargc = (size_t*)sd->buf;
  13        size_t *kenvc = (size_t*)(sd->buf + sizeof(size_t));
  14        char **kargv = (char**)(sd->buf + 2*sizeof(size_t));
  15        char **kenvp = (char**)(kargv + *kargc);
  16        uintptr_t bufbase = (uintptr_t)(kenvp + *kenvc);
  17
  18        printf("argc: %lu\n", *kargc);
  19        printf("envc: %lu\n", *kenvc);
  20        for (int i = 0; i < *kargc; i++)
  21                printf("argv[%d]: %s\n", i, kargv[i] + bufbase);
  22        for (int i = 0; i < *kenvc; i++)
  23                printf("envp[%d]: %s\n", i, kenvp[i] + bufbase);
  24        free_serialized_data(sd);
  25        return 0;
  26}
  27