xref: /DragonReach/src/main.rs (revision b58bd5a17ff5d5ea5385adc176e215cd2b9a485c)
1 #![no_std]
2 #![no_main]
3 use cfg_if::cfg_if;
4 
5 cfg_if!{
6     if #[cfg(target_os = "dragonos")]{
7         extern crate drstd;
8         use drstd as std;
9         use std::print;
10         use std::println;
11         use std::rc::Rc;
12         use unit::service::ServiceUnit;
13     }
14 }
15 
16 extern crate hashbrown;
17 
18 mod contants;
19 mod error;
20 mod parse;
21 mod task;
22 mod unit;
23 
24 use crate::unit::service;
25 
26 use self::unit::Unit;
27 
28 pub struct FileDescriptor(usize);
29 
30 #[cfg(target_os = "dragonos")]
31 #[no_mangle]
32 fn main() {
33     use unit::service::ServiceUnit;
34 
35     let service = match ServiceUnit::from_path("/bin/test.service"){
36         Ok(service) => service,
37         Err(e) => {
38             println!("Error:{}",e.error_format());
39             return;
40         }
41     };
42     let service = service.as_ref();
43     println!("parse_result:");
44     println!("Description:{:?}", service.unit_base().unit_part().description());
45     println!("Documentation:{:?}",service.unit_base().unit_part().documentation());
46     println!("ServiceType:{:?}",service.service_part().service_type());
47     println!("ExecStrat:{:?}",service.service_part().exec_start());
48     println!("WorkingDirectory:{:?}",service.service_part().working_directory());
49     println!("Environment:{:?}",service.service_part().environment());
50     println!("Restart:{:?}",service.service_part().restart());
51     println!("RestartSec:{:?}",service.service_part().restart_sec());
52     println!("User:{:?}",service.service_part().user());
53     println!("Group:{:?}",service.service_part().group());
54     println!("TimeoutStartSec:{:?}",service.service_part().timeout_start_sec());
55     println!("TimeoutStopSec:{:?}",service.service_part().timeout_stop_sec());
56 }
57 
58 #[cfg(not(target_os = "dragonos"))]
59 fn main() {
60     use unit::service::ServiceUnit;
61 
62     let service = match ServiceUnit::from_path("/home/heyicong/DragonReach/parse_test/test.service"){
63         Ok(service) => service,
64         Err(e) => {
65             println!("Error:{}",e.error_format());
66             return;
67         }
68     };
69 
70 
71     let service = service.as_ref();
72     println!("parse_result:");
73     println!("Description:{:?}", service.unit_base().unit_part().description());
74     println!("Documentation:{:?}",service.unit_base().unit_part().documentation());
75     println!("ServiceType:{:?}",service.service_part().service_type());
76     println!("ExecStrat:{:?}",service.service_part().exec_start());
77     println!("WorkingDirectory:{:?}",service.service_part().working_directory());
78     println!("Environment:{:?}",service.service_part().environment());
79     println!("Restart:{:?}",service.service_part().restart());
80     println!("RestartSec:{:?}",service.service_part().restart_sec());
81     println!("User:{:?}",service.service_part().user());
82     println!("Group:{:?}",service.service_part().group());
83     println!("TimeoutStartSec:{:?}",service.service_part().timeout_start_sec());
84     println!("TimeoutStopSec:{:?}",service.service_part().timeout_stop_sec());
85 }
86