mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
refactor: remove now unused build.rs and extern declarations
This commit is contained in:
448
Cargo.lock
generated
448
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -5,10 +5,6 @@ authors = ["dignifiedquire <dignifiedquire@gmail.com>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MPL"
|
license = "MPL"
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
cc = "1.0.35"
|
|
||||||
pkg-config = "0.3"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
deltachat_derive = { path = "./deltachat_derive" }
|
deltachat_derive = { path = "./deltachat_derive" }
|
||||||
libc = "0.2.51"
|
libc = "0.2.51"
|
||||||
|
|||||||
38
build.rs
38
build.rs
@@ -1,38 +0,0 @@
|
|||||||
extern crate cc;
|
|
||||||
|
|
||||||
fn link_static(lib: &str) {
|
|
||||||
println!("cargo:rustc-link-lib=static={}", lib);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn link_framework(fw: &str) {
|
|
||||||
println!("cargo:rustc-link-lib=framework={}", fw);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn add_search_path(p: &str) {
|
|
||||||
println!("cargo:rustc-link-search={}", p);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn build_tools() {
|
|
||||||
let mut config = cc::Build::new();
|
|
||||||
config.file("misc.c").compile("libtools.a");
|
|
||||||
|
|
||||||
println!("rerun-if-changed=build.rs");
|
|
||||||
println!("rerun-if-changed=misc.h");
|
|
||||||
println!("rerun-if-changed=misc.c");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
build_tools();
|
|
||||||
|
|
||||||
add_search_path("/usr/local/lib");
|
|
||||||
|
|
||||||
let target = std::env::var("TARGET").unwrap();
|
|
||||||
if target.contains("-apple") || target.contains("-darwin") {
|
|
||||||
link_framework("CoreFoundation");
|
|
||||||
link_framework("CoreServices");
|
|
||||||
link_framework("Security");
|
|
||||||
}
|
|
||||||
|
|
||||||
// local tools
|
|
||||||
link_static("tools");
|
|
||||||
}
|
|
||||||
52
misc.c
52
misc.c
@@ -1,52 +0,0 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
|
|
||||||
static char* internal_dc_strdup(const char* s) /* strdup(NULL) is undefined, save_strdup(NULL) returns an empty string in this case */
|
|
||||||
{
|
|
||||||
char* ret = NULL;
|
|
||||||
if (s) {
|
|
||||||
if ((ret=strdup(s))==NULL) {
|
|
||||||
exit(16); /* cannot allocate (little) memory, unrecoverable error */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ((ret=(char*)calloc(1, 1))==NULL) {
|
|
||||||
exit(17); /* cannot allocate little memory, unrecoverable error */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* dc_mprintf(const char* format, ...)
|
|
||||||
{
|
|
||||||
char testbuf[1];
|
|
||||||
char* buf = NULL;
|
|
||||||
int char_cnt_without_zero = 0;
|
|
||||||
|
|
||||||
va_list argp;
|
|
||||||
va_list argp_copy;
|
|
||||||
va_start(argp, format);
|
|
||||||
va_copy(argp_copy, argp);
|
|
||||||
|
|
||||||
char_cnt_without_zero = vsnprintf(testbuf, 0, format, argp);
|
|
||||||
va_end(argp);
|
|
||||||
if (char_cnt_without_zero < 0) {
|
|
||||||
va_end(argp_copy);
|
|
||||||
return internal_dc_strdup("ErrFmt");
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = malloc(char_cnt_without_zero+2 /* +1 would be enough, however, protect against off-by-one-errors */);
|
|
||||||
if (buf==NULL) {
|
|
||||||
va_end(argp_copy);
|
|
||||||
return internal_dc_strdup("ErrMem");
|
|
||||||
}
|
|
||||||
|
|
||||||
vsnprintf(buf, char_cnt_without_zero+1, format, argp_copy);
|
|
||||||
va_end(argp_copy);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
1
misc.h
1
misc.h
@@ -1 +0,0 @@
|
|||||||
char* dc_mprintf (const char* format, ...); /* The result must be free()'d. */
|
|
||||||
7
src/x.rs
7
src/x.rs
@@ -33,13 +33,6 @@ pub fn strndup(s: *const libc::c_char, n: libc::c_ulong) -> *mut libc::c_char {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
pub fn clock() -> libc::clock_t;
|
|
||||||
|
|
||||||
// -- DC Methods
|
|
||||||
pub fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) unsafe fn strcasecmp(s1: *const libc::c_char, s2: *const libc::c_char) -> libc::c_int {
|
pub(crate) unsafe fn strcasecmp(s1: *const libc::c_char, s2: *const libc::c_char) -> libc::c_int {
|
||||||
let s1 = std::ffi::CStr::from_ptr(s1)
|
let s1 = std::ffi::CStr::from_ptr(s1)
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
|
|||||||
Reference in New Issue
Block a user