summaryrefslogtreecommitdiff
path: root/ioreplay/src/meta
diff options
context:
space:
mode:
authorPaul Buetow <pbuetow@mimecast.com>2018-03-06 17:38:59 +0000
committerPaul Buetow <pbuetow@mimecast.com>2018-03-06 17:38:59 +0000
commit26b3b3e368a79ce29df732ea04e72a4c002ae2ce (patch)
treee3fc8d7461ab371279f7bf9c692096cd39cc92f6 /ioreplay/src/meta
parentae2221660f9b411fa78cdf8034f0803e9a870cde (diff)
rename into ioriot
Diffstat (limited to 'ioreplay/src/meta')
-rw-r--r--ioreplay/src/meta/meta.c111
-rw-r--r--ioreplay/src/meta/meta.h107
2 files changed, 0 insertions, 218 deletions
diff --git a/ioreplay/src/meta/meta.c b/ioreplay/src/meta/meta.c
deleted file mode 100644
index d56c17e..0000000
--- a/ioreplay/src/meta/meta.c
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2018 Mimecast Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "meta.h"
-
-#define _MAX_META_LEN 256
-
-meta_s* meta_new(FILE *replay_fd)
-{
- meta_s *m = Malloc(meta_s);
-
- m->replay_fd = replay_fd;
- m->offset = ftello(replay_fd);
- m->read_buf = NULL;
-
- return m;
-}
-
-void meta_destroy(meta_s *m)
-{
- if (!m)
- return;
-
- if (m->read_buf)
- free(m->read_buf);
-
- free(m);
-}
-
-void meta_reserve(meta_s *m)
-{
- // TODO: Use a hole in the .replay file to reserve space
- char buf[_MAX_META_LEN];
- Mset(&buf, '#', _MAX_META_LEN-1, char);
- fprintf(m->replay_fd, "%s\n", buf);
-}
-
-void meta_write_start(meta_s *m)
-{
- fseeko(m->replay_fd, m->offset, SEEK_SET);
- // Write required '#' so that the regular worker processes
- // will ignore that meta line.
- fprintf(m->replay_fd, "#");
-
- // Required for parsing in 'meta_read_s'
- fprintf(m->replay_fd, "|");
-}
-
-void meta_write_s(meta_s *m, char *key, char *val)
-{
- fprintf(m->replay_fd, "%s=%s|", key, val);
-}
-
-void meta_write_l(meta_s *m, char *key, long val)
-{
- char buf[1024];
- sprintf(buf, "%ld", val);
- fprintf(m->replay_fd, "%s=%ld|", key, val);
-}
-
-void meta_read_start(meta_s *m)
-{
- size_t len = 0;
- m->read_buf = Calloc(_MAX_META_LEN, char);
- getline(&m->read_buf, &len, m->replay_fd);
-}
-
-bool meta_read_s(meta_s *m, char *key, char **val)
-{
- char *saveptr = NULL;
- char *iterate_buf = Clone(m->read_buf);
- int keylen = strlen(key);
-
- char *tok = strtok_r(iterate_buf, "|", &saveptr);
-
- while (tok) {
- if (strncmp(tok, key, keylen) == 0 && tok[keylen] == '=') {
- asprintf(val, "%s", tok+keylen+1);
- free(iterate_buf);
- return true;
- }
- tok = strtok_r(NULL, "|", &saveptr);
- }
-
- free(iterate_buf);
- return false;
-}
-
-bool meta_read_l(meta_s *m, char *key, long *val)
-{
- char *buf = NULL;
-
- if (meta_read_s(m, key, &buf)) {
- *val = atol(buf);
- free(buf);
- return true;
- }
-
- return false;
-}
diff --git a/ioreplay/src/meta/meta.h b/ioreplay/src/meta/meta.h
deleted file mode 100644
index 10002cc..0000000
--- a/ioreplay/src/meta/meta.h
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 2018 Mimecast Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef META_H
-#define META_H
-
-#include "../defaults.h"
-
-/**
- * @brief The meta information definition
- *
- * This is used to write or read meta information to/from the header
- * of the .replay file. This information then is used by ioreplay
- * in other steps. E.g. reading the amount of used file descriptors
- * from the meta header in order to allocate data structures of the
- * correct sizes before running the test!
- */
-typedef struct meta_s_ {
- FILE* replay_fd; /**< The FS of the .replay file */
- off_t offset; /**< The meta offset (usually 0) */
- char* read_buf; /**< Pointer to a read buffer */
-} meta_s;
-
-/**
- * @brief Creates a new meta bject
- *
- * @return The new meta object
- */
-meta_s* meta_new();
-
-/**
- * @brief Destroys a meta object
- *
- * @param m The meta object
- */
-void meta_destroy(meta_s *m);
-
-/**
- * @brief Reserves space in the .replay file for the meta header
- *
- * @param m The meta object
- */
-void meta_reserve(meta_s *m);
-
-/**
- * @brief Indicates that we start writing the meta header to the .replay file
- *
- * @param m The meta object
- */
-void meta_write_start(meta_s *m);
-
-/**
- * @brief Writes a string to the meta header
- *
- * @param m The meta object
- * @param key The key
- * @param val The string value
- */
-void meta_write_s(meta_s *m, char *key, char *val);
-
-/**
- * @brief Writes a long to the meta header
- *
- * @param m The meta object
- * @param key The key
- * @param val The long value
- */
-void meta_write_l(meta_s *m, char *key, long val);
-
-/**
- * @brief indicates that we start reading from the meta header
- *
- * @param m The meta object
- */
-void meta_read_start(meta_s *m);
-
-/**
- * @brief Reads a string from the meta header
- *
- * @param m The meta object
- * @param key The key
- * @param val The string val read
- */
-bool meta_read_s(meta_s *m, char *key, char **val);
-
-/**
- * @brief Reads a long from the meta header
- *
- * @param m The meta object
- * @param key The key
- * @param val The long val read
- */
-bool meta_read_l(meta_s *m, char *key, long *val);
-
-#endif // META_H
-