Skip to content

Commit

Permalink
Create Wraps.h
Browse files Browse the repository at this point in the history
  • Loading branch information
parvathika authored Sep 2, 2024
1 parent 05bc855 commit 356d032
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions mocks/Wraps.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#pragma once

#include <stdio.h>
#include <mntent.h>
#include "secure_wrappermock.h"

class WrapsImpl {
public:
virtual ~WrapsImpl() = default;

virtual int system(const char* command) = 0;
virtual FILE* popen(const char* command, const char* type) = 0;
virtual int pclose(FILE *pipe) = 0;
virtual void syslog(int pri, const char* fmt, va_list args) = 0;
virtual FILE* setmntent(const char* command, const char* type) = 0;
virtual struct mntent* getmntent(FILE *pipe) = 0;
virtual FILE *v_secure_popen(const char *direction, const char *command, va_list args) = 0;
virtual int v_secure_pclose(FILE *) = 0;
virtual int v_secure_system(const char *command, va_list args) =0;
virtual ssize_t readlink(const char *pathname, char *buf, size_t bufsiz) = 0;
};

class Wraps {
protected:
static WrapsImpl* impl;

public:
Wraps();
Wraps(const Wraps &obj) = delete;
static void setImpl(WrapsImpl* newImpl);
static Wraps& getInstance();

static int system(const char* command);

static FILE* popen(const char* command, const char* type);

static int pclose(FILE* pipe);

static void syslog(int pri, const char* fmt, va_list args);

static FILE* setmntent(const char* command, const char* type);

static struct mntent* getmntent(FILE* pipe);

static FILE *v_secure_popen(const char *direction, const char *command, va_list args);

static int v_secure_pclose(FILE *file);

static int v_secure_system(const char *command, va_list args);

ssize_t readlink(const char *pathname, char *buf, size_t bufsiz);
};

0 comments on commit 356d032

Please sign in to comment.