static int module_open(boot_module_t *bm, int mode, const char *kdev, bool doload) { int fd; const char *path; /* check the expanded path first */ path = module_path(bm, kdev); fd = open(path, mode); if (fd != -1) { if ((howto & AB_SILENT) == 0 && doload) printf("Loading %s ", path); } else { /* now attempt the raw path provided */ fd = open(bm->bm_path, mode); if (fd != -1 && (howto & AB_SILENT) == 0 && doload) printf("Loading %s ", bm->bm_path); } if (!doload && fd == -1) { printf("WARNING: couldn't open %s", bm->bm_path); if (strcmp(bm->bm_path, path) != 0) printf(" (%s)", path); printf("\n"); } return fd; }
void setSearchPath(lua_State *L) { std::string rule_path(IB_XSTRINGIFY(RULE_BASE_PATH)); std::string module_path(IB_XSTRINGIFY(MODULE_BASE_PATH)); rule_path.append("/?.lua"); module_path.append("/?.lua"); ib_lua_add_require_path(ib_engine, L, rule_path.c_str()); ib_lua_add_require_path(ib_engine, L, module_path.c_str()); }
int module_init (void) { if (lt_dlinit()) { const char *error = lt_dlerror(); #ifdef HAVE_EBCDIC strcpy( ebuf, error ); __etoa( ebuf ); error = ebuf; #endif Debug(LDAP_DEBUG_ANY, "lt_dlinit failed: %s\n", error, 0, 0); return -1; } return module_path( LDAP_MODULEDIR ); }
int rtapi_get_tags(const char *mod_name) { char modpath[PATH_MAX]; int result = 0, n = 0; char *cp1 = ""; flavor_ptr flavor = default_flavor(); if (kernel_threads(flavor)) { if (module_path(modpath, mod_name) < 0) { perror("module_path"); return -1; } } else { if (get_rtapi_config(modpath,"RTLIB_DIR",PATH_MAX) != 0) { perror("cant get RTLIB_DIR ?\n"); return -1; } strcat(modpath,"/"); strcat(modpath, flavor->name); strcat(modpath,"/"); strcat(modpath,mod_name); strcat(modpath, flavor->mod_ext); } const char **caps = get_caps(modpath); char **p = (char **)caps; while (p && *p && strlen(*p)) { cp1 = *p++; if (strncmp(cp1,"HAL=", 4) == 0) { n = strtol(&cp1[4], NULL, 10); result |= n ; } } free(caps); return result; }
int slappasswd( int argc, char *argv[] ) { int rc = EXIT_SUCCESS; #ifdef LUTIL_SHA1_BYTES char *default_scheme = "{SSHA}"; #else char *default_scheme = "{SMD5}"; #endif char *scheme = default_scheme; char *newpw = NULL; char *pwfile = NULL; const char *text; const char *progname = "slappasswd"; int i; char *newline = "\n"; struct berval passwd = BER_BVNULL; struct berval hash; #ifdef LDAP_DEBUG /* tools default to "none", so that at least LDAP_DEBUG_ANY * messages show up; use -d 0 to reset */ slap_debug = LDAP_DEBUG_NONE; #endif ldap_syslog = 0; while( (i = getopt( argc, argv, "c:d:gh:no:s:T:vu" )) != EOF ) { switch (i) { case 'c': /* crypt salt format */ scheme = "{CRYPT}"; lutil_salt_format( optarg ); break; case 'g': /* new password (generate) */ if ( pwfile != NULL ) { fprintf( stderr, "Option -g incompatible with -T\n" ); return EXIT_FAILURE; } else if ( newpw != NULL ) { fprintf( stderr, "New password already provided\n" ); return EXIT_FAILURE; } else if ( lutil_passwd_generate( &passwd, 8 )) { fprintf( stderr, "Password generation failed\n" ); return EXIT_FAILURE; } break; case 'h': /* scheme */ if ( scheme != default_scheme ) { fprintf( stderr, "Scheme already provided\n" ); return EXIT_FAILURE; } else { scheme = ch_strdup( optarg ); } break; case 'n': newline = ""; break; case 'o': if ( parse_slappasswdopt() ) { usage ( progname ); } break; case 's': /* new password (secret) */ if ( pwfile != NULL ) { fprintf( stderr, "Option -s incompatible with -T\n" ); return EXIT_FAILURE; } else if ( newpw != NULL ) { fprintf( stderr, "New password already provided\n" ); return EXIT_FAILURE; } else { char* p; newpw = ch_strdup( optarg ); for( p = optarg; *p != '\0'; p++ ) { *p = '\0'; } } break; case 'T': /* password file */ if ( pwfile != NULL ) { fprintf( stderr, "Password file already provided\n" ); return EXIT_FAILURE; } else if ( newpw != NULL ) { fprintf( stderr, "Option -T incompatible with -s/-g\n" ); return EXIT_FAILURE; } pwfile = optarg; break; case 'u': /* RFC2307 userPassword */ break; case 'v': /* verbose */ verbose++; break; default: usage ( progname ); } } if( argc - optind != 0 ) { usage( progname ); } #ifdef SLAPD_MODULES if ( module_init() != 0 ) { fprintf( stderr, "%s: module_init failed\n", progname ); return EXIT_FAILURE; } if ( modulepath && module_path(modulepath) ) { rc = EXIT_FAILURE; goto destroy; } if ( moduleload && module_load(moduleload, 0, NULL) ) { rc = EXIT_FAILURE; goto destroy; } #endif if( pwfile != NULL ) { if( lutil_get_filed_password( pwfile, &passwd )) { rc = EXIT_FAILURE; goto destroy; } } else if ( BER_BVISEMPTY( &passwd )) { if( newpw == NULL ) { /* prompt for new password */ char *cknewpw; newpw = ch_strdup(getpassphrase("New password: "******"Re-enter new password: "******"Password values do not match\n" ); rc = EXIT_FAILURE; goto destroy; } } passwd.bv_val = newpw; passwd.bv_len = strlen(passwd.bv_val); } else { hash = passwd; goto print_pw; } lutil_passwd_hash( &passwd, scheme, &hash, &text ); if( hash.bv_val == NULL ) { fprintf( stderr, "Password generation failed for scheme %s: %s\n", scheme, text ? text : "" ); rc = EXIT_FAILURE; goto destroy; } if( lutil_passwd( &hash, &passwd, NULL, &text ) ) { fprintf( stderr, "Password verification failed. %s\n", text ? text : "" ); rc = EXIT_FAILURE; goto destroy; } print_pw:; printf( "%s%s" , hash.bv_val, newline ); destroy:; #ifdef SLAPD_MODULES module_kill(); #endif return rc; }
int g95_parse_arg(int argc, char *argv[]) { const char *option; int i; option = argv[0]; if (strcmp(option, "-v") == 0) { g95_option.verbose = 1; return 1; } if (strcmp(option, "-Wline-truncation") == 0) { g95_option.line_truncation = 1; return 1; } if (strcmp(option, "-Wunused-label") == 0) { g95_option.unused_label = 1; return -1; } if (strncmp(option, "-Wno=", 5) == 0) { set_nowarn(option+5); return 1; } if (strcmp(option, "-fimplicit-none") == 0 || strcmp(option, "-Wimplicit") == 0) { g95_option.implicit_none = 1; return -1; } if (strcmp(option, "-ffixed-line-length-80") == 0) { g95_option.fixed_line_length = 80; return -1; } if (strcmp(option, "-ffixed-line-length-132") == 0) { g95_option.fixed_line_length = 132; return -1; } if (strcmp(option, "-ffree-form") == 0) { g95_option.form = FORM_FREE; return -1; } if (strcmp(option, "-ffixed-form") == 0) { g95_option.form = FORM_FIXED; return -1; } if (strcmp(option, "-fmodule-private") == 0) { g95_option.module_access_private = 1; return -1; } if (strcmp(option, "-fdollar-ok") == 0) { g95_option.dollar = 1; return 1; } if (strcmp(option, "-fno-backslash") == 0) { g95_option.no_backslash = 1; return 1; } if (strcmp(option, "-fno-underscoring") == 0) { g95_option.no_underscoring = 1; return 1; } if (strcmp(option, "-fno-second-underscore") == 0) { g95_option.no_second_underscore = 1; return 1; } if (strncmp(option, "-fqkind=", 8) == 0) { i = atoi(option+8); if (g95_validate_kind(BT_REAL, i) < 0) g95_fatal_error("Argument to -fqkind isn't a valid real kind"); g95_option.q_kind = i; return -1; } if (strcmp(option, "-fquiet") == 0 || strcmp(option, "-quiet") == 0) { g95_option.quiet = 1; return 1; } if (strcmp(option, "-i8") == 0) { g95_option.default_integer = 8; return -1; } if (strcmp(option, "-r8") == 0) { g95_option.r_value = 8; return -1; } if (strcmp(option, "-d8") == 0) { g95_option.r_value = 8; g95_option.default_integer = 8; return -1; } if (strcmp(option, "-l1") == 0) { g95_option.l1 = 1; return -1; } if (option[0] == '-' && option[1] == 'I') { if (option[2] != '\0') { add_path(&option[2]); return 1; } if (argc <= 2 || argv[1][0] == '-') { g95_status("g95: Directory required after -I\n"); exit(3); } add_path(argv[1]); return 2; } if (strncmp(option, "-fmod=", 6) == 0) { module_path(option); add_path(option + 6); return 1; } if (option[0] == '-') { g95_status("g95: Unrecognized option '%s'\n", option); exit(3); } if (g95_source_file != NULL) { g95_status("g95: Second source file '%s' found\n", option); exit(3); } g95_source_file = (char *) option; return 1; }
int g95_handle_arg(size_t scode, const char *arg, int value) { enum opt_code code; int r; r = 1; code = (enum opt_code) scode; if (code == N_OPTS) return 1; switch(code) { case OPT_arch: break; case OPT_cpp: g95_option.cpp = value; break; case OPT_D: g95_define_cpp_macro((char *) arg, 1); break; case OPT_d8: g95_option.default_integer = 8; g95_option.r_value = 8; break; case OPT_E: g95_option.preprocess_only = value; break; case OPT_fbackslash: g95_option.no_backslash = !value; break; case OPT_fbounds_check: g95_option.bounds_check = value; break; case OPT_fc_binding: g95_option.c_binding = value; break; case OPT_fcase_upper: g95_option.case_upper = value; break; case OPT_fdollar_ok: g95_option.dollar = value; break; case OPT_fd_comment: g95_option.d_comment = value; break; case OPT_fendian_: if (strcasecmp(arg, "big") == 0) g95_option.endian = 1; else if (strcasecmp(arg, "little") == 0) g95_option.endian = 2; else g95_fatal_error("Bad value for -fendian"); break; case OPT_ffixed_form: g95_option.form = FORM_FIXED; break; case OPT_ffixed_line_length_80: g95_option.fixed_line_length = 80; break; case OPT_ffixed_line_length_132: g95_option.fixed_line_length = 132; break; case OPT_ffree_form: g95_option.form = FORM_FREE; break; case OPT_ffree_line_length_huge: g95_option.huge_line = 1; break; case OPT_fimplicit_none: g95_option.implicit_none = value; break; case OPT_fintrinsic_extensions: g95_option.intrinsic_extensions = value; break; case OPT_fintrinsic_extensions_: g95_option.intrinsic_extensions = 1; g95_option.intrinsics = (char *) arg; break; case OPT_fleading_underscore: g95_option.leading_underscore = value; flag_leading_underscore = !value; break; case OPT_max_frame_size_: g95_option.max_frame_size = value; break; case OPT_fmod_: module_path(arg); add_path(arg); break; case OPT_fmodule_private: g95_option.module_access_private = value; break; case OPT_fmultiple_save: g95_option.multiple_save = value; break; case OPT_fone_error: g95_option.one_error = value; break; case OPT_fonetrip: g95_option.onetrip = value; break; case OPT_freal_loops: g95_option.real_loops = value; break; case OPT_fpack_derived: g95_option.pack_derived = value; break; case OPT_fqkind_: g95_option.q_kind = atoi(arg); if (g95_validate_kind(BT_REAL, g95_option.q_kind) < 0) g95_fatal_error("Argument to -fqkind isn't a valid real kind"); break; case OPT_fsecond_underscore: g95_option.no_second_underscore = !value; break; case OPT_fshort_circuit: g95_option.short_circuit = value; break; case OPT_fsloppy_char: g95_option.sloppy_char = value; break; case OPT_fstatic: g95_option.static_var = value; break; case OPT_fsyntax: g95_option.verbose = value; break; case OPT_ftrace_: if (strcasecmp(arg, "none") == 0) g95_option.trace = TRACE_NONE; else if (strcasecmp(arg, "frame") == 0) g95_option.trace = TRACE_FRAME; else if (strcasecmp(arg, "full") == 0) g95_option.trace = TRACE_FULL; else g95_fatal_error("Bad value for -ftrace"); break; case OPT_ftr15581: g95_option.tr15581 = value; break; case OPT_finteger_: g95_option.integer_init = 1; g95_option.integer_value = atoi(arg); break; case OPT_flogical_: if (strcasecmp(arg, "none") == 0) g95_option.logical_init = LOGICAL_INIT_NONE; else if (strcasecmp(arg, "true") == 0) g95_option.logical_init = LOGICAL_INIT_TRUE; else if (strcasecmp(arg, "false") == 0) g95_option.logical_init = LOGICAL_INIT_FALSE; else g95_fatal_error("Bad value for -flogical"); break; case OPT_freal_: if (strcasecmp(arg, "none") == 0) g95_option.real_init = REAL_INIT_NONE; else if (strcasecmp(arg, "zero") == 0) g95_option.real_init = REAL_INIT_ZERO; else if (strcasecmp(arg, "nan") == 0) g95_option.real_init = REAL_INIT_NAN; else if (strcasecmp(arg, "inf") == 0) g95_option.real_init = REAL_INIT_PLUS_INF; else if (strcasecmp(arg, "+inf") == 0) g95_option.real_init = REAL_INIT_PLUS_INF; else if (strcasecmp(arg, "-inf") == 0) g95_option.real_init = REAL_INIT_MINUS_INF; else g95_fatal_error("Bad value for -freal"); break; case OPT_fpointer_: if (strcasecmp(arg, "none") == 0) g95_option.pointer_init = POINTER_INIT_NONE; else if (strcasecmp(arg, "null") == 0) g95_option.pointer_init = POINTER_INIT_NULL; else if (strcasecmp(arg, "invalid") == 0) g95_option.pointer_init = POINTER_INIT_INVALID; else g95_fatal_error("Bad value for -fpointer"); break; case OPT_fround_: if (strcasecmp(arg, "nearest") == 0) g95_option.round = ROUND_NEAREST; else if (strcasecmp(arg, "plus") == 0) g95_option.round = ROUND_PLUS; else if (strcasecmp(arg, "minus") == 0) g95_option.round = ROUND_MINUS; else if (strcasecmp(arg, "zero") == 0) g95_option.round = ROUND_ZERO; else g95_fatal_error("Bad value for -fround"); break; case OPT_fzero: g95_option.zero_init = value; break; case OPT_funderscoring: g95_option.no_underscoring = !value; break; case OPT_I: add_path(arg); break; case OPT_i4: g95_option.default_integer = 4; break; case OPT_i8: g95_option.default_integer = 8; break; case OPT_include: break; case OPT_M: g95_option.deps = 1; break; case OPT_r4: g95_option.r_value = 4; break; case OPT_r8: g95_option.r_value = 8; break; case OPT_r10: #if !defined(FPU_387) && !defined(FPU_SSE) g95_fatal_error("r10 option not supported on this platform"); #endif g95_option.r_value = 10; break; case OPT_r16: g95_option.r_value = 16; break; case OPT_no_cpp: g95_option.cpp = !value; break; case OPT_std_F: g95_option.fmode = 96; g95_option.symbol_len = 31; break; case OPT_std_f2003: g95_option.fmode = 2003; g95_option.symbol_len = 63; break; case OPT_std_f95: g95_option.fmode = 95; g95_option.symbol_len = 31; break; case OPT_traditional: g95_option.traditional = 1; break; case OPT_nontraditional: g95_option.traditional = 0; break; case OPT_U: g95_define_cpp_macro((char *) arg, 0); break; case OPT_Wall: set_Wall(); break; case OPT_Werror: g95_option.werror = value; break; case OPT_Werror_: set_error_list(arg); break; case OPT_Wglobals: g95_option.globals = value; break; case OPT_Wimplicit_interface: g95_option.implicit_interface = value; break; case OPT_Wimplicit_none: g95_option.implicit_none = value; break; case OPT_Wline_truncation: g95_option.line_truncation = value; break; case OPT_Wmissing_intent: g95_option.missing_intent = value; break; case OPT_Wno_: set_nowarn(arg); break; case OPT_Wobsolescent: g95_option.obsolescent = value; break; case OPT_Wprecision_loss: g95_option.prec_loss = value; break; case OPT_Wuninitialized: g95_option.uninit = value; g95_option.uninit = 0; /* Disabled for now. */ warn_uninitialized = 2; break; case OPT_Wunused_label: g95_option.unused_label = value; break; case OPT_Wunused_internal_procs: g95_option.unused_internal_procs = value; break; case OPT_Wunused_module_vars: g95_option.unused_module_vars = value; break; case OPT_Wunused_module_procs: g95_option.unused_module_procs = value; break; case OPT_Wunused_parameter: g95_option.unused_parameter = value; break; case OPT_Wunused_target: g95_option.unused_target = value; break; case OPT_Wunused_types: g95_option.unused_types = value; break; case OPT_Wunused_vars: g95_option.unused_vars = value; break; case OPT_Wunset_vars: g95_option.unset_vars = value; break; default: r = 0; break; } return r; }