Browse Source

Initial commit

tags/v0.1.0
NGnius (Graham) 3 years ago
commit
9ad3b1bbc0
6 changed files with 70 additions and 0 deletions
  1. +3
    -0
      .gitignore
  2. +15
    -0
      Cargo.toml
  3. +21
    -0
      LICENSE
  4. +3
    -0
      README.md
  5. +19
    -0
      src/lib.rs
  6. +9
    -0
      src/version.rs

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
/target
Cargo.lock
/.idea

+ 15
- 0
Cargo.toml View File

@@ -0,0 +1,15 @@
[package]
name = "filmscript"
version = "0.1.0"
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libc = "0.2"
clap = "2"

[lib]
name = "filmscript"
crate-type = ["rlib", "cdylib"]

+ 21
- 0
LICENSE View File

@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 NGnius

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 3
- 0
README.md View File

@@ -0,0 +1,3 @@
# FilmScript

The best Canadian camera technology since IMAX.

+ 19
- 0
src/lib.rs View File

@@ -0,0 +1,19 @@
use std::ffi::CString;
use std::os::raw::c_char;

mod version;

pub unsafe fn allocate_cstring(input: &str) -> *mut c_char {
let input_c = CString::new(input).expect("Rust &str -> CString conversion failed");
let space = libc::malloc(libc::strlen(input_c.as_ptr()) + 1) as *mut c_char;
libc::strcpy(space, input_c.as_ptr());
return space;
}

#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}

+ 9
- 0
src/version.rs View File

@@ -0,0 +1,9 @@
//use libc;
use std::os::raw::c_char;
use crate::allocate_cstring;

#[no_mangle]
pub unsafe extern "C" fn filmscript_version() -> *const c_char {
let crate_v = clap::crate_version!();
allocate_cstring(crate_v)
}

Loading…
Cancel
Save