1*f206f17aSGnoCiYeH #![no_std] 2*f206f17aSGnoCiYeH #![no_main] 3*f206f17aSGnoCiYeH use cfg_if::cfg_if; 421fc724cSGnoCiYeH 5*f206f17aSGnoCiYeH cfg_if!{ 6*f206f17aSGnoCiYeH if #[cfg(target_os = "dragonos")]{ 7*f206f17aSGnoCiYeH extern crate drstd; 8*f206f17aSGnoCiYeH use drstd as std; 94e851715SGnoCiYeH use std::print; 104e851715SGnoCiYeH use std::println; 114e851715SGnoCiYeH use std::rc::Rc; 124e851715SGnoCiYeH use unit::service::ServiceUnit; 13*f206f17aSGnoCiYeH } 14*f206f17aSGnoCiYeH } 15*f206f17aSGnoCiYeH 16*f206f17aSGnoCiYeH extern crate hashbrown; 174e851715SGnoCiYeH 1821fc724cSGnoCiYeH mod contants; 194e851715SGnoCiYeH mod error; 204e851715SGnoCiYeH mod parse; 214e851715SGnoCiYeH mod task; 2221fc724cSGnoCiYeH mod unit; 2321fc724cSGnoCiYeH 244e851715SGnoCiYeH use crate::unit::service; 2521fc724cSGnoCiYeH 264e851715SGnoCiYeH use self::unit::Unit; 274e851715SGnoCiYeH 284e851715SGnoCiYeH pub struct FileDescriptor(usize); 294e851715SGnoCiYeH 30*f206f17aSGnoCiYeH #[cfg(target_os = "dragonos")] 31*f206f17aSGnoCiYeH #[no_mangle] 324e851715SGnoCiYeH fn main() { 33*f206f17aSGnoCiYeH use unit::service::ServiceUnit; 34*f206f17aSGnoCiYeH 35*f206f17aSGnoCiYeH let service = match ServiceUnit::from_path("/bin/test.service"){ 36*f206f17aSGnoCiYeH Ok(service) => service, 37*f206f17aSGnoCiYeH Err(e) => { 38*f206f17aSGnoCiYeH println!("Error:{}",e.error_format()); 39*f206f17aSGnoCiYeH return; 404e851715SGnoCiYeH } 41*f206f17aSGnoCiYeH }; 42*f206f17aSGnoCiYeH let service = service.as_ref(); 43*f206f17aSGnoCiYeH println!("parse_result:"); 44*f206f17aSGnoCiYeH println!("Description:{:?}", service.unit_base().unit_part().description()); 45*f206f17aSGnoCiYeH println!("Documentation:{:?}",service.unit_base().unit_part().documentation()); 46*f206f17aSGnoCiYeH println!("ServiceType:{:?}",service.service_part().service_type()); 47*f206f17aSGnoCiYeH println!("ExecStrat:{:?}",service.service_part().exec_start()); 48*f206f17aSGnoCiYeH println!("WorkingDirectory:{:?}",service.service_part().working_directory()); 49*f206f17aSGnoCiYeH println!("Environment:{:?}",service.service_part().environment()); 50*f206f17aSGnoCiYeH println!("Restart:{:?}",service.service_part().restart()); 51*f206f17aSGnoCiYeH println!("RestartSec:{:?}",service.service_part().restart_sec()); 52*f206f17aSGnoCiYeH println!("User:{:?}",service.service_part().user()); 53*f206f17aSGnoCiYeH println!("Group:{:?}",service.service_part().group()); 54*f206f17aSGnoCiYeH println!("TimeoutStartSec:{:?}",service.service_part().timeout_start_sec()); 55*f206f17aSGnoCiYeH println!("TimeoutStopSec:{:?}",service.service_part().timeout_stop_sec()); 56*f206f17aSGnoCiYeH } 57*f206f17aSGnoCiYeH 58*f206f17aSGnoCiYeH #[cfg(not(target_os = "dragonos"))] 59*f206f17aSGnoCiYeH fn main() { 60*f206f17aSGnoCiYeH use unit::service::ServiceUnit; 61*f206f17aSGnoCiYeH 62*f206f17aSGnoCiYeH let service = match ServiceUnit::from_path("/home/heyicong/DragonReach/parse_test/test.service"){ 63*f206f17aSGnoCiYeH Ok(service) => service, 64*f206f17aSGnoCiYeH Err(e) => { 65*f206f17aSGnoCiYeH println!("Error:{}",e.error_format()); 66*f206f17aSGnoCiYeH return; 67*f206f17aSGnoCiYeH } 68*f206f17aSGnoCiYeH }; 69*f206f17aSGnoCiYeH 70*f206f17aSGnoCiYeH 71*f206f17aSGnoCiYeH let service = service.as_ref(); 72*f206f17aSGnoCiYeH println!("parse_result:"); 73*f206f17aSGnoCiYeH println!("Description:{:?}", service.unit_base().unit_part().description()); 74*f206f17aSGnoCiYeH println!("Documentation:{:?}",service.unit_base().unit_part().documentation()); 75*f206f17aSGnoCiYeH println!("ServiceType:{:?}",service.service_part().service_type()); 76*f206f17aSGnoCiYeH println!("ExecStrat:{:?}",service.service_part().exec_start()); 77*f206f17aSGnoCiYeH println!("WorkingDirectory:{:?}",service.service_part().working_directory()); 78*f206f17aSGnoCiYeH println!("Environment:{:?}",service.service_part().environment()); 79*f206f17aSGnoCiYeH println!("Restart:{:?}",service.service_part().restart()); 80*f206f17aSGnoCiYeH println!("RestartSec:{:?}",service.service_part().restart_sec()); 81*f206f17aSGnoCiYeH println!("User:{:?}",service.service_part().user()); 82*f206f17aSGnoCiYeH println!("Group:{:?}",service.service_part().group()); 83*f206f17aSGnoCiYeH println!("TimeoutStartSec:{:?}",service.service_part().timeout_start_sec()); 84*f206f17aSGnoCiYeH println!("TimeoutStopSec:{:?}",service.service_part().timeout_stop_sec()); 8521fc724cSGnoCiYeH } 86