コード例 #1
0
ファイル: winmain.c プロジェクト: Sheetalm9/test
FILE *
fake_popen(const char * command, const char * type)
{
	FILE * f = NULL;
	char tmppath[MAX_PATH];
	char tmpfile[MAX_PATH];
	DWORD ret;

	if (type == NULL) return NULL;

	pipe_type = NUL;
	if (pipe_filename != NULL)
		free(pipe_filename);

	/* Random temp file name in %TEMP% */
	ret = GetTempPath(sizeof(tmppath), tmppath);
	if ((ret == 0) || (ret > sizeof(tmppath)))
		return NULL;
	ret = GetTempFileName(tmppath, "gpp", 0, tmpfile);
	if (ret == 0)
		return NULL;
	pipe_filename = strdup(tmpfile);

	if (*type == 'r') {
		char * cmd;
		int rc;
		pipe_type = *type;
		/* Execute command with redirection of stdout to temporary file. */
		cmd = (char *) malloc(strlen(command) + strlen(pipe_filename) + 5);
		sprintf(cmd, "%s > %s", command, pipe_filename);
		rc = system(cmd);
		free(cmd);
		/* Now open temporary file. */
		/* system() returns 1 if the command could not be executed. */
		if (rc != 1)
			f = fopen(pipe_filename, "r");
		else {
			remove(pipe_filename);
			free(pipe_filename);
			pipe_filename = NULL;
			errno = EINVAL;
		}
	} else if (*type == 'w') {
		pipe_type = *type;
		/* Write output to temporary file and handle the rest in fake_pclose. */
		if (type[1] == 'b')
			int_error(NO_CARET, "Could not execute pipe '%s'. Writing to binary pipes is not supported.", command);
		else
			f = fopen(pipe_filename, "w");
		pipe_command = strdup(command);
	}

	return f;
}
static void clear_access_permission_table_handler_callback()
{
	if(clear_access_permission_table_callback_handler)
	{
		clear_access_permission_table_callback_handler();
	}
	else  // NULL
	{
		int_error("clear_access_permission_table_callback_handler is NULL");
	}
}
コード例 #3
0
ファイル: symtab.c プロジェクト: ras52/bootstrap
member_type( struct_name, mem_name, off_ptr ) {
    auto *e = lookup_tab( structtab, 32, struct_name ); 
        /* sizeof(struct_entry) */

    if (!e) int_error("No such struct found '%s'", struct_name);
 
    e = lookup_tab( &e[5], 24, mem_name );    /* sizeof(sym_entry) */
    if (!e) error("No member %s in struct %s", mem_name, struct_name);
    if (off_ptr) *off_ptr = e[3];
    return e[5][2];
}
コード例 #4
0
static void add_authority_to_list_handler_callback(char *authority_name)
{
	if(add_authority_to_list_callback_handler)
	{
		add_authority_to_list_callback_handler(authority_name);
	}
	else  // NULL
	{
		int_error("add_authority_to_list_callback_handler is NULL");
	}
}
コード例 #5
0
static void clear_authority_table_handler_callback()
{
	if(clear_authority_table_callback_handler)
	{
		clear_authority_table_callback_handler();
	}
	else  // NULL
	{
		int_error("clear_authority_table_callback_handler is NULL");
	}
}
コード例 #6
0
static void add_authority_to_table_handler_callback(char *authority_name, char *ip_address, boolean authority_join_flag)
{
	if(add_authority_to_table_callback_handler)
	{
		add_authority_to_table_callback_handler(authority_name, ip_address, authority_join_flag);
	}
	else  // NULL
	{
		int_error("add_authority_to_table_callback_handler is NULL");
	}
}
コード例 #7
0
static void init_main()
{
	// Initial the signal transmissters
	if(sem_init(&wake_up_main_thread_mutex, 0, 0) != 0)
		int_error("Initial a mutex failed");

	if(sem_init(&confirm_err_msg_sending_to_frontend_mutex, 0, 0) != 0)
		int_error("Initial a mutex failed");
	
	if(sem_init(&send_signal_to_confirm_cancellation_thread_mutex, 0, 0) != 0)
		int_error("Initial a mutex failed");

	if(sem_init(&cancellation_thread_got_confirmation_mutex, 0, 0) != 0)
		int_error("Initial a mutex failed");

	strcpy(err_msg_to_frontend, "");
	emergency_phr_extraction_thread_terminated_flag = false;
	transaction_success_status_flag                 = false; 
	emergency_phr_extracting_cancellation_flag      = false;
}
コード例 #8
0
ファイル: server3.c プロジェクト: iloveloveyou/chirico
void init_dhparams(void)
{
    BIO *bio;

    bio = BIO_new_file("dh512.pem", "r");
    if (!bio)
        int_error("Error opening file dh512.pem");
    dh512 = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
    if (!dh512)
        int_error("Error reading DH parameters from dh512.pem");
    BIO_free(bio);

    bio = BIO_new_file("dh1024.pem", "r");
    if (!bio)
        int_error("Error opening file dh1024.pem");
    dh1024 = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
    if (!dh1024)
        int_error("Error reading DH parameters from dh1024.pem");
    BIO_free(bio);
}
コード例 #9
0
ファイル: internal.c プロジェクト: jurekogorek/gnuplot
void
f_push(union argument *x)
{
    struct udvt_entry *udv;

    udv = x->udv_arg;
    if (udv->udv_undef) {	/* undefined */
	int_error(NO_CARET, "undefined variable: %s", udv->udv_name);
    }
    push(&(udv->udv_value));
}
コード例 #10
0
// Implementaion
static void backend_alert_msg_handler_callback(char *alert_msg)
{
	if(backend_alert_msg_callback_handler)
	{
		backend_alert_msg_callback_handler(alert_msg);
	}
	else  // NULL
	{
		int_error("backend_alert_msg_callback_handler is NULL");
	}
}
コード例 #11
0
/*
 * Class:     MailServerConfigurationChanging
 * Method:    change_mail_server_configuration
 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL Java_MailServerConfigurationChanging_change_1mail_1server_1configuration(JNIEnv *env, jobject obj, 
	jstring j_mail_server_url, jstring j_authority_email_address, jstring j_authority_email_passwd)
{
	const char *mail_server_url;
	const char *authority_email_address;
	const char *authority_email_passwd;

	jclass     cls;
	boolean    changing_flag;

	// Get variables from Java
	mail_server_url         = (*env)->GetStringUTFChars(env, j_mail_server_url, 0);
	authority_email_address = (*env)->GetStringUTFChars(env, j_authority_email_address, 0);
	authority_email_passwd  = (*env)->GetStringUTFChars(env, j_authority_email_passwd, 0);

	Java_env    = env;
  	Java_object = obj;

	// Get the method ids for returning output to Java
	cls = (*env)->GetObjectClass(env, obj);

	Java_backend_alert_msg_callback_handler_id       = (*env)->GetMethodID(env, cls, "backend_alert_msg_callback_handler", "(Ljava/lang/String;)V");
	Java_backend_fatal_alert_msg_callback_handler_id = (*env)->GetMethodID(env, cls, "backend_fatal_alert_msg_callback_handler", "(Ljava/lang/String;)V");

	if(Java_backend_alert_msg_callback_handler_id == 0)
		int_error("Could not find method \"backend_alert_msg_callback_handler\"");

	if(Java_backend_fatal_alert_msg_callback_handler_id == 0)
		int_error("Could not find method \"backend_fatal_alert_msg_callback_handler\"");

	// Change emergency unit's mail server configuration at emergency staff authority
	changing_flag = change_emu_mail_server_configuration((char *)mail_server_url, (char *)authority_email_address, (char *)authority_email_passwd, 
		backend_alert_msg_callback_handler, backend_fatal_alert_msg_callback_handler);

	// Free up the Java string arguments
	(*env)->ReleaseStringUTFChars(env, j_mail_server_url, mail_server_url);
	(*env)->ReleaseStringUTFChars(env, j_authority_email_address, authority_email_address);
	(*env)->ReleaseStringUTFChars(env, j_authority_email_passwd, authority_email_passwd);

	return (jboolean)changing_flag;
}
コード例 #12
0
void
f_words(union argument *arg)
{
    struct value a, b, result;
    int nwords = 0;
    int ntarget;
    char *s;

    (void) arg;
    if (pop(&b)->type != INTGR)
	int_error(NO_CARET, "internal error : non-INTGR argument");
    ntarget = b.v.int_val;

    if (pop(&a)->type != STRING)
	int_error(NO_CARET, "internal error : non-STRING argument");
    s = a.v.string_val;

    Gstring(&result, "");
    while (*s) {
	while (isspace(*s)) s++;
	if (!*s)
	    break;
	nwords++;
	if (nwords == ntarget) { /* Found the one we wanted */
	    Gstring(&result,s);
	    s = result.v.string_val;
	}
	while (*s && !isspace(*s)) s++;
	if (nwords == ntarget) { /* Terminate this word cleanly */
	    *s = '\0';
	    break;
	}
    }

    if (ntarget < 0)
	/* words(s) = word(s,-1) = # of words in string */
	Ginteger(&result, nwords);

    push(&result);
    gpfree_string(&a);
}
コード例 #13
0
ファイル: symtab.c プロジェクト: ras52/bootstrap
/* Return the lvalue flag for the symbol NAME, or 1 if it is 
 * not defined (as we assume external symbols are lvalues).  
 * Also set *OFF_PTR to the symbol table offset of the symbol, or
 * 0 if it is not defined (as 0 is not a valid offset because 
 * 0(%ebp) is the calling frame's base pointer.) */
lookup_sym( name, off_ptr ) {
    auto e = lookup_tab( symtab, 24, name );    /* sizeof(sym_entry) */
    if (e) {
        if (e[2]) int_error("Object declaration is a typedef");
        if (off_ptr) *off_ptr = e[3];
        return is_lv_decl(e[5][2]);
    }

    /* Symbol not found -- default to rvalues e.g. functions */
    if (off_ptr) *off_ptr = 0;
    return 0;
}
コード例 #14
0
ファイル: parse.c プロジェクト: Reen/gnuplot
/* Used by plot2d/plot3d/fit:
 * Parse an expression that may return a string or may return a constant or may
 * be a dummy function using dummy variables x, y, ...
 * If any dummy variables are present, set (*atptr) to point to an action table
 * corresponding to the parsed expression, and return NULL.
 * Otherwise evaluate the expression and return a string if there is one.
 * The return value "str" and "*atptr" both point to locally-managed memory,
 * which must not be freed by the caller!
 */
char*
string_or_express(struct at_type **atptr)
{
    int i;
    TBOOLEAN has_dummies;

    static char* str = NULL;
    free(str);
    str = NULL;

    if (atptr)
	*atptr = NULL;

    if (END_OF_COMMAND)
	int_error(c_token, "expression expected");

    /* parsing for datablocks */
    if (equals(c_token,"$"))
	return parse_datablock_name();

    if (isstring(c_token)) {
	str = try_to_get_string();
	return str;
    }

    /* parse expression */
    temp_at();

    /* check if any dummy variables are used */
    has_dummies = FALSE;
    for (i = 0; i < at->a_count; i++) {
	enum operators op_index = at->actions[i].index;
	if ( op_index == PUSHD1 || op_index == PUSHD2 || op_index == PUSHD
                || op_index == SUM ) {
	    has_dummies = TRUE;
	    break;
	}
    }

    if (!has_dummies) {
	/* no dummy variables: evaluate expression */
	struct value val;

	evaluate_at(at, &val);
	if (!undefined && val.type == STRING)
	    str = val.v.string_val;
    }

    /* prepare return */
    if (atptr)
	*atptr  = at;
    return str;
}
コード例 #15
0
ファイル: scanner.c プロジェクト: gnuplot/gnuplot
static int
get_num(char str[])
{
    int count = 0;
    char *endptr;

    token[t_num].is_token = FALSE;
    token[t_num].l_val.type = INTGR;	/* assume unless . or E found */
    while (isdigit((unsigned char) str[count]))
	count++;
    if (str[count] == '.') {
	token[t_num].l_val.type = CMPLX;
	/* swallow up digits until non-digit */
	while (isdigit((unsigned char) str[++count]));
	/* now str[count] is other than a digit */
    }
    if (str[count] == 'e' || str[count] == 'E') {
	token[t_num].l_val.type = CMPLX;
	count++;
	if (str[count] == '-' || str[count] == '+')
	    count++;
	if (!isdigit((unsigned char) str[count])) {
	    token[t_num].start_index += count;
	    int_error(t_num, "expecting exponent");
	}
	while (isdigit((unsigned char) str[++count]));
    }
    if (token[t_num].l_val.type == INTGR) {
	long long lval;
	errno = 0;
	lval = strtoll(str, &endptr, 0);
	if (!errno) {
	    count = endptr - str;
	    /* Linux and Windows implementations of POSIX function strtoll() differ.*/
	    /* I don't know which is "correct" but returning 0 causes an infinite   */
	    /* loop on input "0x" as the scanner fails to progress.                 */
	    if (count == 0) count++;
	    if ((token[t_num].l_val.v.int_val = lval) == lval)
		return(count);
	    if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) {
		if ((long long unsigned int)lval == (long long unsigned int)token[t_num].l_val.v.int_val)
		    return(count);
	    }
	}
	int_warn(t_num, "integer overflow; changing to floating point");
	token[t_num].l_val.type = CMPLX;
	/* Fall through */
    }
    token[t_num].l_val.v.cmplx_val.imag = 0.0;
    token[t_num].l_val.v.cmplx_val.real = strtod(str, &endptr);
    count = endptr - str;
    return (count);
}
コード例 #16
0
ファイル: server.cpp プロジェクト: Mandragorian/netSSL
void init_dhparams()
{
	BIO *bio;

	bio = BIO_new_file("../../certificates/dh512.pem","r");
	if(!bio)
		int_error("Could not open dh512.pem file");
	dh512 = PEM_read_bio_DHparams(bio,nullptr,nullptr,nullptr);
	if(!dh512)
		int_error("Error reading DH params for dh512.pem");
	BIO_free(bio);

	bio = BIO_new_file("../../certificates/dh1024.pem", "r");
	if(!bio)
		int_error("Could not open dh512.pem file");
	dh1024 = PEM_read_bio_DHparams(bio,nullptr,nullptr,nullptr);
	if(!dh1024)
		int_error("Error reading DH params for dh1024.pem");
	BIO_free(bio);

}
コード例 #17
0
ファイル: util.c プロジェクト: lueckenhoff/gnuplot-current
void
graph_error(const char *fmt, va_dcl)
#endif
{
#ifdef VA_START
    va_list args;
#endif

    multiplot = FALSE;
    term_end_plot();

#ifdef VA_START
    VA_START(args, fmt);
#if 0
    /* HBB 20001120: this seems not to work at all. Probably because a
     * va_list argument, is, after all, something else than a varargs
     * list (i.e. a '...') */
    int_error(NO_CARET, fmt, args);
#else
    /* HBB 20001120: instead, copy the core code from int_error() to
     * here: */
    PRINT_SPACES_UNDER_PROMPT;
    PRINT_FILE_AND_LINE;

# if defined(HAVE_VFPRINTF) || _LIBC
    vfprintf(stderr, fmt, args);
# else
    _doprnt(fmt, args, stderr);
# endif
    va_end(args);
    fputs("\n\n", stderr);

    bail_to_command_line();
#endif /* 1/0 */
    va_end(args);
#else
    int_error(NO_CARET, fmt, a1, a2, a3, a4, a5, a6, a7, a8);
#endif

}
コード例 #18
0
/*
 * Class:     EmU_UserAndAdminManagement
 * Method:    edit_user_email_address_main
 * Signature: (ZLjava/lang/String;Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL Java_EmU_1UserAndAdminManagement_edit_1user_1email_1address_1main(
	JNIEnv *env, jobject obj, jboolean j_is_admin_flag, jstring j_username, jstring j_email_address)
{
	boolean    is_admin_flag;
	const char *username;
	const char *email_address;

	jclass     cls;
	boolean    editing_flag;

	// Get variables from Java
	is_admin_flag = (boolean)j_is_admin_flag;
	username      = (*env)->GetStringUTFChars(env, j_username, 0);
	email_address = (*env)->GetStringUTFChars(env, j_email_address, 0);

	Java_env     = env;
  	Java_object  = obj;

	// Get the method ids for returning output to Java
	cls = (*env)->GetObjectClass(env, obj);

	Java_backend_alert_msg_callback_handler_id       = (*env)->GetMethodID(env, cls, "backend_alert_msg_callback_handler", "(Ljava/lang/String;)V");
	Java_backend_fatal_alert_msg_callback_handler_id = (*env)->GetMethodID(env, cls, "backend_fatal_alert_msg_callback_handler", "(Ljava/lang/String;)V");

	if(Java_backend_alert_msg_callback_handler_id == 0)
		int_error("Could not find method \"backend_alert_msg_callback_handler\"");

	if(Java_backend_fatal_alert_msg_callback_handler_id == 0)
		int_error("Could not find method \"backend_fatal_alert_msg_callback_handler\"");

	// Edit the emergency unit's user/admin e-mail address
	editing_flag = edit_emu_user_email_address(is_admin_flag, (char *)username, (char *)email_address, 
		backend_alert_msg_callback_handler, backend_fatal_alert_msg_callback_handler);

	// Free up the Java string arguments
	(*env)->ReleaseStringUTFChars(env, j_username, username);
	(*env)->ReleaseStringUTFChars(env, j_email_address, email_address);

	return (jboolean)editing_flag;
}
コード例 #19
0
ファイル: misc.c プロジェクト: detiffel/benchmark
/* push onto load_file state stack
   essentially, we save information needed to undo the load_file changes
   called by load_file */
void
lf_push(FILE *fp, char *name, char *cmdline)
{
    LFS *lf;
    int argindex;

    lf = (LFS *) gp_alloc(sizeof(LFS), (char *) NULL);
    if (lf == (LFS *) NULL) {
	if (fp != (FILE *) NULL)
	    (void) fclose(fp);	/* it won't be otherwise */
	int_error(c_token, "not enough memory to load file");
    }
    lf->fp = fp;		/* save this file pointer */
    lf->name = name;
    lf->cmdline = cmdline;

    lf->interactive = interactive;	/* save current state */
    lf->inline_num = inline_num;	/* save current line number */
    lf->do_load_arg_substitution = do_load_arg_substitution;
    lf->call_argc = call_argc;
    for (argindex = 0; argindex < 10; argindex++) {
	lf->call_args[argindex] = call_args[argindex];
	call_args[argindex] = NULL;	/* initially no args */
    }
    lf->depth = lf_head ? lf_head->depth+1 : 0;	/* recursion depth */
    if (lf->depth > STACK_DEPTH)
	int_error(NO_CARET, "load/eval nested too deeply");
    lf->if_depth = if_depth;
    lf->if_open_for_else = if_open_for_else;
    lf->if_condition = if_condition;
    lf->c_token = c_token;
    lf->num_tokens = num_tokens;
    lf->tokens = gp_alloc((num_tokens+1) * sizeof(struct lexical_unit),
			  "lf tokens");
    memcpy(lf->tokens, token, (num_tokens+1) * sizeof(struct lexical_unit));
    lf->input_line = gp_strdup(gp_input_line);

    lf->prev = lf_head;		/* link to stack */
    lf_head = lf;
}
コード例 #20
0
void define()
{
    register int start_token;	/* the 1st token in the function definition */
    register struct udvt_entry *udv;
    register struct udft_entry *udf;

    if (equals(c_token + 1, "(")) {
	/* function ! */
	int dummy_num = 0;
	struct at_type *at_tmp;
	char save_dummy[MAX_NUM_VAR][MAX_ID_LEN + 1];
	memcpy(save_dummy, c_dummy_var, sizeof(save_dummy));
	start_token = c_token;
	do {
	    c_token += 2;	/* skip to the next dummy */
	    copy_str(c_dummy_var[dummy_num++], c_token, MAX_ID_LEN);
	} while (equals(c_token + 1, ",") && (dummy_num < MAX_NUM_VAR));
	if (equals(c_token + 1, ","))
	    int_error("function contains too many parameters", c_token + 2);
	c_token += 3;		/* skip (, dummy, ) and = */
	if (END_OF_COMMAND)
	    int_error("function definition expected", c_token);
	udf = dummy_func = add_udf(start_token);
	if ((at_tmp = perm_at()) == (struct at_type *) NULL)
	    int_error("not enough memory for function", start_token);
	if (udf->at)		/* already a dynamic a.t. there */
	    free((char *) udf->at);	/* so free it first */
	udf->at = at_tmp;	/* before re-assigning it. */
	memcpy(c_dummy_var, save_dummy, sizeof(save_dummy));
	m_capture(&(udf->definition), start_token, c_token - 1);
	dummy_func = NULL;	/* dont let anyone else use our workspace */
    } else {
	/* variable ! */
	start_token = c_token;
	c_token += 2;
	udv = add_udv(start_token);
	(void) const_express(&(udv->udv_value));
	udv->udv_undef = FALSE;
    }
}
コード例 #21
0
ファイル: client3.c プロジェクト: iloveloveyou/chirico
int main_ssl(int argc, char **argv)
{
	BIO *conn;
	SSL *ssl;
	SSL_CTX *ctx;
	long err;

	init_OpenSSL();
	seed_prng();

	ctx = setup_client_ctx();

	fprintf(stderr, "SERVER= %s:%s\n", SERVER, PORT);
	conn = BIO_new_connect(SERVER ":" PORT);
	if (!conn)
		int_error("Error creating connection BIO");

	if (BIO_do_connect(conn) <= 0)
		int_error("Error connecting to remote machine");

	ssl = SSL_new(ctx);
	SSL_set_bio(ssl, conn, conn);
	if (SSL_connect(ssl) <= 0)
		int_error("Error connecting SSL object");
	if ((err = post_connection_check(ssl, SERVER)) != X509_V_OK) {
		fprintf(stderr, "-Error: peer certificate: %s\n",
			X509_verify_cert_error_string(err));
		int_error("Error checking SSL object after connection");
	}
	fprintf(stderr, "SSL Connection opened\n");
	if (do_client_loop(ssl))
		SSL_shutdown(ssl);
	else
		SSL_clear(ssl);
	fprintf(stderr, "SSL Connection closed\n");

	SSL_free(ssl);
	SSL_CTX_free(ctx);
	return 0;
}
コード例 #22
0
ファイル: cclex.c プロジェクト: PDP-10/kcc
/* TOKPUSH(tok, sym) - Push a token
**	Note that the "constant" structure is not pushed or changed.
** It is OK for the current token to be a constant, if the token pushed
** (arg to tokpush) is not a constant.  In fact, no constants can be
** pushed.  The code for unary() in CCSTMT is the only place where this
** sort of thing has to be taken into account.
*/
void
tokpush(int t, SYMBOL *s)
{
    if(++tokstack >= MAXTSTACK)		/* Token stack depth exceeded? */
	--tokstack, int_error("tokpush: tokstack overflow");
    else
	{
	tstack[tokstack].ttoken = token;
	tstack[tokstack].tsym = csymbol;
	token = t;
	csymbol = s;
	}
}
static void add_access_permission_to_table_handler_callback(char *assigned_username, char *assigned_user_authority_name, 
	boolean upload_permission_flag, boolean download_permission_flag, boolean delete_permission_flag)
{
	if(add_access_permission_to_table_callback_handler)
	{
		add_access_permission_to_table_callback_handler(assigned_username, assigned_user_authority_name, 
			upload_permission_flag, download_permission_flag, delete_permission_flag);
	}
	else  // NULL
	{
		int_error("add_access_permission_to_table_callback_handler is NULL");
	}
}
コード例 #24
0
ファイル: client3.c プロジェクト: iloveloveyou/chirico
SSL_CTX *setup_client_ctx(void)
{
	SSL_CTX *ctx;

	ctx = SSL_CTX_new(SSLv23_method());
	if (SSL_CTX_load_verify_locations(ctx, CAFILE, CADIR) != 1)
		int_error("Error loading CA file and/or directory");
	if (SSL_CTX_set_default_verify_paths(ctx) != 1)
		int_error
		    ("Error loading default CA file and/or directory");
	if (SSL_CTX_use_certificate_chain_file(ctx, CERTFILE) != 1)
		int_error("Error loading certificate from file");
	if (SSL_CTX_use_PrivateKey_file(ctx, CERTFILE, SSL_FILETYPE_PEM) !=
	    1)
		int_error("Error loading private key from file");
	SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, verify_callback);
	SSL_CTX_set_verify_depth(ctx, 4);
	SSL_CTX_set_options(ctx, SSL_OP_ALL | SSL_OP_NO_SSLv2);
	if (SSL_CTX_set_cipher_list(ctx, CIPHER_LIST) != 1)
		int_error("Error setting cipher list (no valid ciphers)");
	return ctx;
}
コード例 #25
0
ファイル: server.c プロジェクト: zr139898/sample_app
int main(int argc, char * argv[]) {
    BIO * acc, * client;
    THREAD_TYPE tid;
    SSL * ssl;
    SSL_CTX * ctx;

    init_OpenSSL();
    seed_prng();

    ctx = setup_server_ctx();
    
    acc = BIO_new_accept(PORT);
    if (!acc)
        int_error("Error creating server socket");
    if (BIO_do_accept(acc) <= 0)
        int_error("Error binding server socket");
    // BIO_do_accept() will block and wait for a remote connection.
    while (1) {
        if (BIO_do_accept(acc) <= 0)
            int_error("Error accepting connection");
        // get the client BIO
        client = BIO_pop(acc);
        if (!(ssl = SSL_new(ctx)))
            int_error("Error creating SSL context");
        SSL_set_accept_state(ssl);
        SSL_set_bio(ssl, client, client);
        // create a new thread to handle the new connection,
        // The thread will call do_server_loop with the client BIO.
        // THREAD_CREATE(tid, entry, arg);
        // tid is the id of the new thread.
        // server_thread is the function defined above, which will call
        // do_server_loop() with the client BIO.
        THREAD_CREATE(tid, server_thread, ssl);
    }
    SSL_CTX_free(ctx);
    BIO_free(acc);
    return 0;
}
コード例 #26
0
/*
 * Class:     EmU_PHRAuthorityManagement
 * Method:    edit_phr_authority_ip_address_main
 * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL Java_EmU_1PHRAuthorityManagement_edit_1phr_1authority_1ip_1address_1main(
	JNIEnv *env, jobject obj, jstring j_phr_authority_name, jstring j_ip_address)
{
	const char *phr_authority_name;
	const char *ip_address;

	jclass     cls;
	boolean    editing_flag;

	// Get variables from Java
	phr_authority_name = (*env)->GetStringUTFChars(env, j_phr_authority_name, 0);
	ip_address         = (*env)->GetStringUTFChars(env, j_ip_address, 0);

	Java_env    = env;
  	Java_object = obj;

	// Get the method ids for returning output to Java
	cls = (*env)->GetObjectClass(env, obj);

	Java_backend_alert_msg_callback_handler_id       = (*env)->GetMethodID(env, cls, "backend_alert_msg_callback_handler", "(Ljava/lang/String;)V");
	Java_backend_fatal_alert_msg_callback_handler_id = (*env)->GetMethodID(env, cls, "backend_fatal_alert_msg_callback_handler", "(Ljava/lang/String;)V");

	if(Java_backend_alert_msg_callback_handler_id == 0)
		int_error("Could not find method \"backend_alert_msg_callback_handler\"");

	if(Java_backend_fatal_alert_msg_callback_handler_id == 0)
		int_error("Could not find method \"backend_fatal_alert_msg_callback_handler\"");

	// Edit PHR authority's IP address
	editing_flag = edit_phr_authority_ip_address((char *)phr_authority_name, (char *)ip_address, 
		backend_alert_msg_callback_handler, backend_fatal_alert_msg_callback_handler);

	// Free up the Java string arguments
	(*env)->ReleaseStringUTFChars(env, j_phr_authority_name, phr_authority_name);
	(*env)->ReleaseStringUTFChars(env, j_ip_address, ip_address);

	return (jboolean)editing_flag;
}
コード例 #27
0
/* Variable assignment operator */
void
f_assign(union argument *arg)
{
    struct value a, b;
    (void) arg;
    (void) pop(&b);	/* new value */
    (void) pop(&a);	/* name of variable */
    
    if (a.type == STRING) {
	struct udvt_entry *udv;
	if (!strncmp(a.v.string_val,"GPVAL_",6) || !strncmp(a.v.string_val,"MOUSE_",6))
	    int_error(NO_CARET,"Attempt to assign to a read-only variable");
	udv = add_udv_by_name(a.v.string_val);
	gpfree_string(&a);
	if (!udv->udv_undef)
	    gpfree_string(&(udv->udv_value));
	udv->udv_value = b;
	udv->udv_undef = FALSE;
	push(&b);
    } else {
	int_error(NO_CARET, "attempt to assign to something other than a named variable");
    }
}
コード例 #28
0
ファイル: listen.c プロジェクト: BackupTheBerlios/tuxap
__u16
listenSendMessage(Application_t *app, struct sk_buff *skb)
{
	_cmsg	*cmsg;

	cmsg = cmsg_alloc();
	if (!cmsg) {
		int_error();
		return (CAPI_MSGOSRESOURCEERR);
	}
	capi_message2cmsg(cmsg, skb->data);
	switch (CMSGCMD(cmsg)) {
		case CAPI_LISTEN_REQ:
			if (mISDN_FsmEvent(&app->listen_m, EV_LISTEN_REQ, cmsg))
				cmsg_free(cmsg);
			break;
		default:
			int_error();
			cmsg_free(cmsg);
	}
	dev_kfree_skb(skb);
	return(CAPI_NOERROR);
}
コード例 #29
0
ファイル: ESA_main.c プロジェクト: juniorkid/ProjectWeb
static void init_server()
{
	set_using_safety_threads_for_openssl(true);
	seed_prng();
    	init_openssl();

	assert_cache_directory_existence();
	get_necessary_info();
	load_pub_key();

	// Initial the e-mail sending lock mutex
	if(sem_init(&email_sending_lock_mutex, 0, 1) != 0)
		int_error("Initial a mutex failed");
}
コード例 #30
0
static void extend_cur_line()
{
  char *new_line;

  /* extent input line length */
  new_line=ralloc(cur_line, line_len+MAXBUF, NULL);
  if(!new_line) {
    reset_termio();
    int_error("Can't extend readline length", NO_CARET);
  }
  cur_line=new_line;
  line_len+=MAXBUF;

}