GitHub PullRequestReviewCommentEvent at 2014-03-11 18:55:01
Repository: lmctfy
Actor: vmarmol
Payload: {"comment":{"url":"https://api.github.com/repos/google/lmctfy/pulls/comments/10489697","id":10489697,"diff_hunk":"@@ -0,0 +1,297 @@\n+#ifndef LMCTFY_C_BINDING_LMCTFY_C_H_\n+#define LMCTFY_C_BINDING_LMCTFY_C_H_\n+\n+#include <unistd.h>\n+#include <stdint.h>\n+#include \"lmctfy.pb-c.h\"\n+#include \"util/task/codes.pb-c.h\"\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif // __cplusplus\n+\n+enum {\n+  CONTAINER_UPDATE_POLICY_DIFF,\n+  CONTAINER_UPDATE_POLICY_REPLACE\n+};\n+\n+enum {\n+  CONTAINER_LIST_POLICY_SELF,\n+  CONTAINER_LIST_POLICY_RECURSIVE\n+};\n+\n+enum {\n+  CONTAINER_STATS_TYPE_SUMMARY,\n+  CONTAINER_STATS_TYPE_FULL\n+};\n+\n+struct status {\n+  int error_code;\n+\n+  // Null-terminated string allocated on heap.\n+  // Needs to be free()'ed.\n+  char *message;\n+};\n+\n+\n+struct container;\n+struct container_api;\n+\n+// Callback used on an event notification.\n+//\n+// The container and status structure pointers are only valid within the\n+// callback.\n+//\n+// - container: The container that received the notification. It is an error\n+//    to delete it.\n+// - status: The status of the notification. If OK, then the event registered\n+//    occured. Otherwise, an error is reported in the status. Errors may\n+//    be caused by container deletion or unexpected registration errors.\n+//    it will be an error if the user call free(s->message);\n+// - user_data: \n+typedef void (*lmctfy_event_callback_f)(struct container *container,\n+                                        const struct status *status,\n+                                        void *user_data);\n+\n+typedef uint64_t notification_id_t;\n+\n+// Initializes the machine to start being able to create containers.\n+//\n+// Arguments:\n+//  - s: [output] s will be used as output.\n+//    If the original value of s->code is not\n+//    UTIL__ERROR__CODE__INVALID_ARGUMENT, then the function will return\n+//    immediately with value s->code. This will help users to propagete errors.\n+//    Otherwise, it contains the error code and message.\n+//  - spec: The specification.\n+//\n+// Returns:\n+//\n+//  Returns the error code. 0 on success. When there's an error, the return code\n+//  is same as s->error_code when s is not NULL.\n+int lmctfy_init_machine(struct status *s, const Containers__Lmctfy__InitSpec *spec);\n+\n+// Create a new container_api.\n+//\n+// Arguments:\n+//  - s: [output] s will be used as output.\n+//    If the original value of s->code is not\n+//    UTIL__ERROR__CODE__INVALID_ARGUMENT, then the function will return\n+//    immediately with value s->code. This will help users to propagete errors.\n+//    Otherwise, it contains the error code and message.\n+//  - api: [output] The address of a pointer to struct container_api. The\n+//    pointer of the container api will be stored in this address.\n+//\n+// Returns:\n+//\n+//  Returns the error code. 0 on success. When there's an error, the return code\n+//  is same as s->error_code when s is not NULL.\n+int lmctfy_new_container_api(struct status *s, struct container_api **api);\n+\n+// Release the container api. \n+//\n+// Arguments:\n+//\n+//  - api: The container api. This pointer will be invalid after the call to\n+//  this function\n+void lmctfy_delete_container_api(struct container_api *api);\n+\n+// Get a container\n+//\n+// Arguments:\n+//\n+//  - s: [output] s will be used as output.\n+//    If the original value of s->code is not\n+//    UTIL__ERROR__CODE__INVALID_ARGUMENT, then the function will return\n+//    immediately with value s->code. This will help users to propagete errors.\n+//    Otherwise, it contains the error code and message.\n+//  - container: [output] The address of a pointer to struct container. It will\n+//    be used to store the pointer to the container.\n+//  - api: A container api.\n+//  - container_name: the container name.\n+//\n+// Returns:\n+//\n+//  Returns the error code. 0 on success. When there's an error, the return code\n+//  is same as s->error_code when s is not NULL.\n+int lmctfy_container_api_get_container(\n+    struct status *s,\n+    struct container **container,\n+    const struct container_api *api,\n+    const char *container_name);\n+\n+// Create a container\n+//\n+// Arguments:\n+//\n+//  - s: [output] s will be used as output.\n+//    If the original value of s->code is not\n+//    UTIL__ERROR__CODE__INVALID_ARGUMENT, then the function will return\n+//    immediately with value s->code. This will help users to propagete errors.\n+//    Otherwise, it contains the error code and message.\n+//  - container: [output] The address of a pointer to struct container. It will\n+//    be used to store the newly created container.\n+//  - api: A container api.\n+//  - container_name: the container name.\n+//  - spec: container specification.\n+//\n+// Returns:\n+//\n+//  Returns the error code. 0 on success. When there's an error, the return code\n+//  is same as s->error_code when s is not NULL.\n+int lmctfy_container_api_create_container(\n+    struct status *s,\n+    struct container **container,\n+    struct container_api *api,\n+    const char *container_name,\n+    const Containers__Lmctfy__ContainerSpec *spec);\n+\n+// Destroy a container. The caller has to call lmctfy_delete_container after\n+// detroying a container. Otherwise, the memory of occupied by the container\n+// structure will not be released.\n+//\n+// Arguments:\n+//\n+//  - s: [output] s will be used as output.\n+//    If the original value of s->code is not\n+//    UTIL__ERROR__CODE__INVALID_ARGUMENT, then the function will return\n+//    immediately with value s->code. This will help users to propagete errors.\n+//    Otherwise, it contains the error code and message.\n+//  - api: A container api.\n+//  - container: The pointer to struct container. The pointer will become\n+//    invalid after a success destroy().\n+//\n+// Returns:\n+//\n+//  Returns the error code. 0 on success. When there's an error, the return code\n+//  is same as s->error_code when s is not NULL.\n+int lmctfy_container_api_destroy_container(struct status *s,\n+                                           struct container_api *api,\n+                                           struct container *container);\n+\n+// Detect what container the specified thread is in.\n+//\n+// Arguments:\n+//  - s: [output] Will be used to store the status. The function will first\n+//    check the error code stored in s->error_code and will only proceed if the\n+//    error code is not zero.\n+//  - container_name: [output] Will be used to store the container name.\n+//    It's the caller's responsibility to free() *container_name.\n+//  - api: The container api.\n+//  - pid: The thread ID to check. 0 refers to self.\n+int lmctfy_container_api_detect_container(struct status *s,\n+                                          char **container_name,\n+                                          struct container_api *api,\n+                                          pid_t pid);\n+\n+// XXX(monnand): Do we really need this macro?\n+#define lmctfy_container_api_detect_self(s, container_name, api) \\\n+    lmctfy_container_api_detect_container((s), (container_name), (api), 0)\n+\n+// Release the memory used by the container structure. The refered container\n+// will not be affected.\n+//\n+// Arguments:\n+//\n+//  - container: The container.  This pointer will be invalid after the call to\n+//    this function\n+void lmctfy_delete_container(struct container *container);\n+\n+int lmctfy_container_enter(struct status *s,\n+                           struct container *container,\n+                           const pid_t *tids,\n+                           const int n);\n+\n+// \n+// Arguments:\n+//\n+//  - s: [output]\n+//  - tid: [output] On success, tid stores the PID of the command.\n+//  - container\n+//  - argc: number of arguments (including the binary file path).\n+//  - argv: All arguments. The first element is the binary that will be executed\n+//    and must be an absolute path.\n+int lmctfy_container_run(struct status *s,\n+                         pid_t *tid,\n+                         struct container *container,\n+                         const int argc,\n+                         const char **argv,\n+                         const Containers__Lmctfy__RunSpec *spec);\n+\n+int lmctfy_container_exec(struct status *s,\n+                          struct container *container,\n+                          const int argc,\n+                          const char **argv);\n+\n+int lmctfy_container_update(struct status *s,\n+                            struct container *container,\n+                            int policy,\n+                            const Containers__Lmctfy__ContainerSpec *spec);\n+\n+int lmctfy_container_spec(struct status *s,\n+                          struct container *container,\n+                          Containers__Lmctfy__ContainerSpec **spec);\n+\n+// List all subcontainers.\n+//\n+// Arguments:\n+//\n+//  - s: [output]\n+//  - subcontainers: [output] The address of a pointer points to an array of\n+//    struct container pointers. The caller takes the onwership. On success, the\n+//    pointer will be assigned an address to an array of containers. The pointed \n+//    array should be released with free(). The containers inside the array\n+//    should be deleted/destroyed individually.\n+//  - nr_subcontainers: [output] The address of an integer used to store number\n+//    of subcontainers in the array.\n+//  - container: The container\n+//  - list_policy: CONTAINER_LIST_POLICY_SELF or CONTAINER_LIST_POLICY_RECURSIVE\n+int lmctfy_container_list_subcontainers(struct status *s,\n+                                        struct container **subcontainers[],\n+                                        int *nr_subcontainers,","path":"clmctfy/include/clmctfy.h","position":251,"original_position":251,"commit_id":"6910e09a7dbb776ed314210f27a09e0ff06fde7d","original_commit_id":"6910e09a7dbb776ed314210f27a09e0ff06fde7d","user":{"login":"vmarmol","id":985208,"avatar_url":"https://gravatar.com/avatar/db9e07d23f3bf996994276c0321c0b07?d=https%3A%2F%2Fidenticons.github.com%2Ffb4332f6d3cd70a2f8323c0cbe00f6fb.png&r=x","gravatar_id":"db9e07d23f3bf996994276c0321c0b07","url":"https://api.github.com/users/vmarmol","html_url":"https://github.com/vmarmol","followers_url":"https://api.github.com/users/vmarmol/followers","following_url":"https://api.github.com/users/vmarmol/following{/other_user}","gists_url":"https://api.github.com/users/vmarmol/gists{/gist_id}","starred_url":"https://api.github.com/users/vmarmol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmarmol/subscriptions","organizations_url":"https://api.github.com/users/vmarmol/orgs","repos_url":"https://api.github.com/users/vmarmol/repos","events_url":"https://api.github.com/users/vmarmol/events{/privacy}","received_events_url":"https://api.github.com/users/vmarmol/received_events","type":"User","site_admin":false},"body":"maybe we should standardize on <name> and <name>_size for arrays outparams?","created_at":"2014-03-11T18:55:01Z","updated_at":"2014-03-11T18:55:01Z","html_url":"https://github.com/google/lmctfy/pull/13#discussion_r10489697","pull_request_url":"https://api.github.com/repos/google/lmctfy/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/google/lmctfy/pulls/comments/10489697"},"html":{"href":"https://github.com/google/lmctfy/pull/13#discussion_r10489697"},"pull_request":{"href":"https://api.github.com/repos/google/lmctfy/pulls/13"}}}}