Skip to content
Snippets Groups Projects
Commit 6f0a3f8a authored by Adrien Béraud's avatar Adrien Béraud
Browse files

cleanup unused code, headers

Change-Id: I29512e29c2dea7d681e6d9e78ad24523e0414a13
parent e8717577
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (C) 2004-2020 Savoir-faire Linux Inc.
* Copyright (C) 2010 Michael Kerrisk
* Copyright (C) 2007-2009 Rémi Denis-Courmont
*
* Author: Rafaël Carré <rafael.carre@savoirfairelinux.com>
*
......@@ -131,73 +129,6 @@ check_dir(const char* path, mode_t UNUSED dirmode, mode_t parentmode)
return true;
}
#ifndef _WIN32
/* Lock a file region */
static int
lockReg(int fd, int cmd, int type, int whence, int start, off_t len)
{
struct flock fl;
fl.l_type = type;
fl.l_whence = whence;
fl.l_start = start;
fl.l_len = len;
return fcntl(fd, cmd, &fl);
}
static int /* Lock a file region using nonblocking F_SETLK */
lockRegion(int fd, int type, int whence, int start, int len)
{
return lockReg(fd, F_SETLK, type, whence, start, len);
}
FileHandle
create_pidfile()
{
const std::string name(get_home_dir() + DIR_SEPARATOR_STR PIDFILE);
FileHandle f(name);
char buf[100];
f.fd = open(f.name.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (f.fd == -1) {
JAMI_ERR("Could not open PID file %s", f.name.c_str());
return f;
}
if (lockRegion(f.fd, F_WRLCK, SEEK_SET, 0, 0) == -1) {
if (errno == EAGAIN or errno == EACCES)
JAMI_ERR("PID file '%s' is locked; probably "
"'%s' is already running",
f.name.c_str(),
PACKAGE_NAME);
else
JAMI_ERR("Unable to lock PID file '%s'", f.name.c_str());
close(f.fd);
f.fd = -1;
return f;
}
if (ftruncate(f.fd, 0) == -1) {
JAMI_ERR("Could not truncate PID file '%s'", f.name.c_str());
close(f.fd);
f.fd = -1;
return f;
}
snprintf(buf, sizeof(buf), "%ld\n", (long) getpid());
const int buf_strlen = strlen(buf);
if (write(f.fd, buf, buf_strlen) != buf_strlen) {
JAMI_ERR("Problem writing to PID file '%s'", f.name.c_str());
close(f.fd);
f.fd = -1;
return f;
}
return f;
}
#endif // !_WIN32
std::string
expand_path(const std::string& path)
{
......@@ -572,21 +503,6 @@ writeArchive(const std::string& archive_str, const std::string& path, const std:
}
}
FileHandle::FileHandle(const std::string& n)
: fd(-1)
, name(n)
{}
FileHandle::~FileHandle()
{
// we will only delete the file if it was created by this process
if (fd != -1) {
close(fd);
if (unlink(name.c_str()) == -1)
JAMI_ERR("%s", strerror(errno));
}
}
#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
#else
static char* program_dir = NULL;
......
......@@ -117,15 +117,6 @@ void writeArchive(const std::string& data,
std::mutex& getFileLock(const std::string& path);
struct FileHandle
{
int fd;
const std::string name;
FileHandle(const std::string& name);
~FileHandle();
};
FileHandle create_pidfile();
/**
* Remove a file with optional erasing of content.
* Return the same value as std::remove().
......
......@@ -4,9 +4,6 @@
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
* Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
*
* Portions Copyright (c) 2000 Billy Biggs <bbiggs@div8.net>
* Portions Copyright (c) 2004 Wirlab <kphone@wirlab.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
......@@ -38,10 +35,8 @@ DTMF::startTone(char code)
newTone_ = code;
}
using std::vector;
bool
DTMF::generateDTMF(vector<AudioSample>& buffer)
DTMF::generateDTMF(std::vector<AudioSample>& buffer)
{
try {
if (currentTone_ != 0) {
......
......@@ -4,9 +4,6 @@
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
* Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
*
* Portions Copyright (c) 2000 Billy Biggs <bbiggs@div8.net>
* Portions Copyright (c) 2004 Wirlab <kphone@wirlab.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
......@@ -22,8 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __DTMF_H_
#define __DTMF_H_
#pragma once
#include "dtmfgenerator.h"
......@@ -31,7 +27,6 @@
* @file dtmf.h
* @brief DMTF library to generate a dtmf sample
*/
namespace jami {
class DTMF
......@@ -63,5 +58,3 @@ private:
};
} // namespace jami
#endif // __KEY_DTMF_H_
......@@ -4,8 +4,6 @@
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
* Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
*
* Portions (c) 2003 iptel.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
......
/*
* Copyright (C) 2004-2020 Savoir-faire Linux Inc.
* Copyright (c) 2002 Fabrice Bellard
* Copyright (c) 2007 The FFmpeg Project
*
* Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
* Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment