USERS *adduser(unsigned int fdclient, char *host, acetables *g_ape) { USERS *nuser = NULL; /* Calling module */ FIRE_EVENT(adduser, nuser, fdclient, host, g_ape); nuser = init_user(g_ape); nuser->type = (fdclient ? HUMAN : BOT); g_ape->uHead = nuser; nuser->pipe = init_pipe(nuser, USER_PIPE, g_ape); hashtbl_append(g_ape->hSessid, nuser->sessid, (void *)nuser); g_ape->nConnected++; addsubuser(fdclient, host, nuser, g_ape); return nuser; }
USERS *adduser(ape_socket *client, const char *host, const char *ip, USERS *allocated, acetables *g_ape) { USERS *nuser = NULL; /* Calling module */ if (allocated == NULL) { FIRE_EVENT(allocateuser, nuser, client, host, ip, g_ape); nuser = init_user(g_ape); strncpy(nuser->ip, ip, 16); nuser->pipe = init_pipe(nuser, USER_PIPE, g_ape); nuser->type = (client != NULL ? HUMAN : BOT); nuser->istmp = 1; hashtbl_append(g_ape->hSessid, nuser->sessid, (void *)nuser); addsubuser(client, host, nuser, g_ape); } else { FIRE_EVENT(adduser, nuser, allocated, g_ape); nuser = allocated; nuser->istmp = 0; g_ape->nConnected++; //ape_log(APE_INFO, __FILE__, __LINE__, g_ape, // "New user - (ip : %s)", nuser->ip); } return nuser; }
/* * 2.输入获取 * 3.处理输入 */ void login() { int Login_status; init_clock(); init_user(); while (1) { /* 显示界面 */ show_login_window(); /* 获取用户名 */ get_user_name(); /* 获取密码 */ get_pass_word(); Login_status = check_login(); /* * 验证用户名密码 */ if ( Login_status == LOGIN_INFO_SUCCESS ) { /* 进入系统 */ sys_main(); } /* 错误提示 */ print_err(Login_status); } }
void test(int argc, char *argv[]) { const char *hostname; const char *service = "HTTP"; gss_buffer_desc input_token; gss_buffer_desc output_token; gss_buffer_desc name; char *ccname = NULL; gss_ctx_id_t ctx = GSS_C_NO_CONTEXT; gss_ctx_id_t ctx_init = GSS_C_NO_CONTEXT; memset(&input_token, 0, sizeof(input_token)); memset(&output_token, 0, sizeof(output_token)); memset(&name, 0, sizeof(name)); if (argc != 2) return; hostname = argv[1]; init_user(&ctx_init, service, hostname, NULL, &output_token); /* fwrite(output_token.value, output_token.length, 1, stdout); */ if (accept_user(&ctx, &output_token, &input_token, &name, &ccname) == OK) { fprintf(stderr, "User authenticated\r\n"); } }
int main(void) { int str,agi,dex,luc,hp; init_user(&str,&agi,&dex,&luc,&hp); printf("str = %d\nagi = %d\ndex = %d\nluc = %d\nhp = %d\n",str,agi,dex,luc,hp); return 0; }
int Condor_Auth_Kerberos :: authenticate(const char * /* remoteHost */, CondorError* /* errstack */, bool /*non_blocking*/) { int status = 0; if ( mySock_->isClient() ) { // we are the client. // initialize everything if needed. if (init_kerberos_context() && init_server_info()) { if (isDaemon() || get_mySubSystem()->isDaemon() ) { status = init_daemon(); } else { status = init_user(); } } else { status = FALSE; } int message = (status == TRUE? KERBEROS_PROCEED : KERBEROS_ABORT); mySock_->encode(); if (!mySock_->code(message) || !mySock_->end_of_message()) { status = FALSE; } else { if (message == KERBEROS_PROCEED) { // We are ready to go status = authenticate_client_kerberos(); } else { status = FALSE; } } } else { // we are the server. int ready; mySock_->decode(); if (!mySock_->code(ready) || !mySock_->end_of_message()) { status = FALSE; } else { if (ready == KERBEROS_PROCEED) { dprintf(D_SECURITY,"About to authenticate client using Kerberos\n" ); // initialize everything if needed. if (init_kerberos_context() && init_server_info()) { status = authenticate_server_kerberos(); } else { status = FALSE; } } } } return( status ); }
void main (void) { Uint32 fs=DSK6713_AIC23_FREQ_16KHZ; // Sampling frequency SEQUENCE seq = {input_bits, ninput_bits, 0}; USER usr; init_arrays(); init_user(&usr); // Init state variables comm_intr(fs); // DSK Init while(1) { wait_buffer(); read_bits(&seq, usr.nbits, usr.bits); cod_rz(&usr, oblock, (usr.lSymb)/2); //cod_polar (&usr, oblock); //cod_bipolar (&usr, oblock); } }
int main(int argc, char **argv) { int listenfd, connfd; socklen_t clientlen = sizeof(struct sockaddr_in); struct sockaddr_in clientaddr; user* u; /* Init node and set port accoriding to configue file */ init_node(argc, argv); /* Init the linked list of channel and the table of user */ init_channel(); init_user(); /* Init server socket and set it as unblocked */ listenfd = init_unblocking_server_socket(curr_node_config_entry->irc_port); /* connect to local daemon */ local_client_fd = socket_connect(curr_node_config_entry->ipaddr,curr_node_config_entry->local_port); /* Init struct pool */ init_pool(); add_listen_fd(listenfd); while (1) { /* Wait for listening/connected descriptor(s) to become ready */ p.ready_set = p.read_set; p.nready = Select(p.maxfd+1, &p.ready_set, NULL, NULL, NULL); /* If listening descriptor ready, add new client to pool */ if (FD_ISSET(listenfd, &p.ready_set)) { connfd = Accept(listenfd, (SA *)&clientaddr, &clientlen); /* create a user struct for the connect fd */ u = (user*) Calloc(1,sizeof(user)); user_table[connfd] = u; /*set server_name and host_name for user */ u->host_name = strdup(Gethostbyaddr((const char*)&clientaddr.sin_addr,sizeof(clientaddr.sin_addr),AF_INET)->h_name); u->server_name = strdup(Gethostbyname("localhost")->h_name); add_client(connfd); } /* Echo a text line from each ready connected descriptor */ check_clients(); } }
void check_login(sLoginInfo *send, int newfd) { char *file[3]; char read_buf[BUF_SIZE] = {0}; char all_buf[BUF_SIZE]; int i = 0; int fd, nwrite, enter_write; int user_login_flag = 0; off_t off_len = 0; if((fd = open(FILENAME, O_RDONLY,0644)) == ERR) pri_err("open file"); while(1) { lseek(fd, off_len, SEEK_SET); if(read(fd, read_buf,BUF_SIZE) == 0) break; off_len += strlen(read_buf) + 2; i = 0; file[i++] = strtok(read_buf,":"); while(file[i++] = strtok(NULL, ":")) ; if(strcmp(file[0], send->login_name) == OK) { if(strcmp(file[1], send->login_passwd) == OK) { if(init_user(file)) send->type = USER_LOGIN_FAILED_ONLINE;//user online else { send->type = USER_LOGIN_SUCCESS; } break; }else{ send->type = USER_LOGIN_PASSWD_ERROR;//passwd error break; } }else{ send->type = USER_LOGIN_FAILED;//no user name } memset(read_buf, 0,sizeof(read_buf)); } write(newfd, send, sizeof(sLoginInfo)); get_online_user(send,newfd ); close(fd); }
int main (int argc, char *argv[]) { GtkBuilder *login; GtkBuilder *builder; GtkWidget *loginwindow; GtkWidget *window; GtkButton *loginbtn; gtk_init( &argc, &argv ); /* Create builder */ builder = gtk_builder_new(); gtk_builder_add_from_file( builder, "ui.glade", NULL ); window = GTK_WIDGET( gtk_builder_get_object( builder, "window1" ) ); login = gtk_builder_new(); gtk_builder_add_from_file(login, "login.glade", NULL); loginwindow = GTK_WIDGET(gtk_builder_get_object(login, "loginwindow")); loginbtn = GTK_BUTTON(gtk_builder_get_object(login, "loginbtn")); g_signal_connect(loginbtn, "clicked", G_CALLBACK(cb_login_button), NULL); init_db(); init_login(login, loginwindow, window); init_user(builder); init_material(builder); init_auth(builder); init_inout(builder); gtk_builder_connect_signals( login, NULL); g_object_unref( G_OBJECT( login) ); gtk_builder_connect_signals( builder, NULL); g_object_unref( G_OBJECT( builder ) ); gtk_widget_show(loginwindow); gtk_main(); return( 0 ); }
/* * interface, not static */ void init_filter_tree(int argc) { char * exp; int exp_num = 0; init_op_stack(argc); filter_list_size = argc; filter_list_len = 0; filter_list = (Filter **)(malloc(sizeof(Filter) * argc)); while((exp = get_exp()) != NULL) { exp_num++; char * optarg; //all the exps if (IS_EQUAL(exp, "-name")) { optarg = _get_arg("-name"); init_fnmatch(optarg, true); } else if (IS_EQUAL(exp, "-iname")) { optarg = _get_arg("-iname"); init_fnmatch(optarg, false); } else if (IS_EQUAL(exp, "-user")) { optarg = _get_arg("-user"); init_user(optarg); } else if (IS_EQUAL(exp, "-group")) { optarg = _get_arg("-group"); init_group(optarg); } else if (IS_EQUAL(exp, "-perm")) { optarg = _get_arg("-perm"); init_perm(optarg); } else if (IS_EQUAL(exp, "-regex")) { optarg = _get_arg("-regex"); init_reg(optarg); } else if (IS_EQUAL(exp, "-amin")) { optarg = _get_arg("-amin"); init_time(AMIN, optarg); } else if (IS_EQUAL(exp, "-atime")) { optarg = _get_arg("-atime"); init_time(ATIME, optarg); } else if (IS_EQUAL(exp, "-anewer")) { optarg = _get_arg("-anewer"); init_time(ANEWER, optarg); } else if (IS_EQUAL(exp, "-cnewer")) { optarg = _get_arg("-cnewer"); init_time(CNEWER, optarg); } else if (IS_EQUAL(exp, "-cmin")) { optarg = _get_arg("-cmin"); init_time(CMIN, optarg); } else if (IS_EQUAL(exp, "-ctime")) { optarg = _get_arg("-ctime"); init_time(CTIME, optarg); } else if (IS_EQUAL(exp, "-mtime")) { optarg = _get_arg("-mtime"); init_time(MMIN, optarg); } else if (IS_EQUAL(exp, "-mnewer")) { optarg = _get_arg("-mnewer"); init_time(MNEWER, optarg); } else if (IS_EQUAL(exp, "-type")) { optarg = _get_arg("-type"); init_filetype(optarg); } else if (IS_EQUAL(exp, "-size")) { optarg = _get_arg("-size"); init_filesize(optarg); } else if (IS_EQUAL(exp, "-not")) { #ifdef DEBUG fprintf(stderr, "filter not adapter\n"); #endif filter_not(); } else if (IS_EQUAL(exp, "-and")) { #ifdef DEBUG fprintf(stderr, "filter and\n"); #endif filter_and(); } else if (IS_EQUAL(exp, "-or")) { #ifdef DEBUG fprintf(stderr, "filter or\n"); #endif filter_or(); } else { //TODO } } if (exp_num == 0) { init_true(); } filter_tree.passed = op_stack[0]; free_op_stack(); }
int main(int argc, char *argv[]) { #define init(a) do { \ } while(0) example_user_t * user; user = init_user(3); /* bloom filter must fail */ if (!is_fatal) { printf("fatal not called after bloom failure\n"); } user = init_user(2); /* bucket creation must fail */ if (!is_fatal) { printf("fatal not called after bucket creation failure\n"); } user = init_user(1); /* table creation must fail */ if (!is_fatal) { printf("fatal not called after table creation failure\n"); } user = init_user(4); /* hash must create OK */ if (is_fatal) { printf("fatal error when creating hash normally\n"); /* bad idea to continue running */ return 1; } /* let's add users until expansion fails */ users = 0; malloc_cnt = 4; while (1) { user = (example_user_t*)malloc(sizeof(example_user_t)); user->id = user_id; if (user_id++ == 1000) { printf("there is no way 1000 iterations didn't require realloc\n"); break; } if (!setjmp(j_buf)) { HASH_ADD_INT(users, id, user); } malloc_cnt = 0; if (malloc_failed) { if (!is_fatal) { printf("fatal not called after bucket not extended\n"); } if (user_id < 10) { printf("there is no way your bucket size is 10\n"); } /* we can't really do anything, the hash is not in consistent * state, so assume this is a success. */ break; } } printf("End\n"); return 0; }
void init() { sigset_t sigmask; sigemptyset(&sigmask); sigaddset(&sigmask, SIGALRM); sigaddset(&sigmask, SIGUSR1); sigprocmask(SIG_BLOCK, &sigmask, NULL); console_print("Emergence Client " VERSION "\n"); SDL_Init(SDL_INIT_AUDIO); init_user(); init_network(); init_timer(); init_openssl(); init_key(); init_download(); init_servers(); create_cvars(); init_console_cvars(); init_render_cvars(); init_map_cvars(); create_control_cvars(); // create_input_cvars(); init_tick_cvars(); init_console(); create_colour_cvars(); struct string_t *string = new_string_string(emergence_home_dir); string_cat_text(string, "/client.config"); if(!exec_config_file(string->text)) { exec_config_file(find_resource("default-controls.config")); } else { char *ver = get_cvar_string("version"); if(*ver == '\0') { struct string_t *command = new_string_text("rm "); string_cat_string(command, emergence_home_dir); string_cat_text(command, "/skins/default.skin*"); console_print("%s\n", command->text); system(command->text); vid_mode = -1; // find a nice mode exec_config_file(find_resource("default-controls.config")); } free(ver); } free_string(string); set_cvar_string("version", VERSION); init_skin(); init_input(); init_control(); init_render(); init_rcon(); init_ping(); create_cvar_command("quit", client_shutdown_char); init_sound(); init_game(); init_alarm(); render_frame(); string = new_string_text("%s%s", emergence_home_dir->text, "/client.autoexec"); if(!exec_config_file(string->text)) exec_config_file(find_resource("default-client.autoexec")); free_string(string); start_server_discovery(); }
CK_RV init(const char *module, const unsigned char *pin, bee *b) { return init_user(module, CKU_USER, pin, b); }
int main(int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "usage: %s [ip]\n", argv[0]); exit(1); } init_user(); init_connection(argv[1]); signup_signin(); init_curses(); init_windows_attr(); init_windows(); // catch response from server pthread_t response_thd; if(pthread_create(&response_thd, NULL, response_handler, (void *)0)) ERR_EXIT("Create response thread failed"); get_online(); while (1) { int c = wgetch(target->win); switch(c) { case '\t': target->text[target->len] = '\0'; strcat(target->text, " "); target->len += 4; target->y += 4; break; case KEY_BACKSPACE: if (target->y != 0) { target->len--; if (target->offset == 0) mvwaddch(target->win, target->x,--target->y,' '); else { int i; for (i = target->len + target->offset; i < target->len; i++) { target->text[i] = target->text[i + 1]; mvwaddch(target->win, target->x, i, target->text[i]); } mvwaddch(target->win, target->x, i,' '); target->y--; } wrefresh(target->win); } break; case 27: //esc close_client(); case KEY_MOUSE: // waddstr(target->win, "clicked"); if(getmouse(&event) == OK) serve_mouse_event(event.y, event.x); break; case 13: //enter target->text[target->len] = '\0'; if (strcmp(target->type, COMMENT) == 0) { send_cmt(); } else { upload_file(); } reset_input(); break; case KEY_DOWN: break; case KEY_UP: break; case KEY_LEFT: if (target->len != 0) { target->y--; target->offset--; } break; case KEY_RIGHT: if (target->offset != 0) { target->y++; target->offset++; } break; default: mvwaddch(target->win, target->x, target->y, c); if (target->offset == 0) { target->text[target->len++] = c; } else { int i; for (i = target->len; i > target->len + target->offset; i--) target->text[i] = target->text[i - 1]; target->text[i] = c; target->len++; while (i++ < target->len - 1) mvwaddch(target->win, target->x, i, target->text[i]); } wrefresh(target->win); // wprintw(target->win, "%d", c); target->y++; break; } wmove(target->win, target->x, target->y); wrefresh(target->win); } close_client(); }
static int init_sec_context(char *buf, int index, ei_x_buff *presult) { ei_x_buff result = *presult; /* {init_sec_context, {Idx, Service, Host, Input}} -> {ok, {Idx, Data}} | {error, Error} */ int arity; gss_buffer_desc in; gss_buffer_desc out; int res; char *service = NULL; char *hostname = NULL; long idx; OM_uint32 min_stat; memset(&in, 0, sizeof(in)); memset(&out, 0, sizeof(out)); EI(ei_decode_tuple_header(buf, &index, &arity)); EI(arity != 4); EI(ei_decode_long(buf, &index, &idx)); DECODE_STRING(&service); DECODE_STRING(&hostname); EI(decode_gssapi_binary(buf, &index, &in)); if (idx < 0) { idx = session_find_free(); if (idx < 0) ENCODE_ERROR("no_mem"); g_sessions[idx] = GSS_C_NO_CONTEXT; } else { if (idx < 0 || idx >= MAX_SESSIONS || !g_sessions[idx]) ENCODE_ERROR("bad_instance"); } res = init_user(&g_sessions[idx], service, hostname, &in, &out); if (!GSS_ERROR(res)) { const char *status = (res & GSS_S_CONTINUE_NEEDED)?"needsmore":"ok"; EI(ei_x_encode_atom(&result, status) || ei_x_encode_tuple_header(&result, 2) || ei_x_encode_long(&result, idx) || ei_x_encode_binary(&result, out.value, out.length) ); } else { EI(ei_x_encode_atom(&result, "error") || ei_x_encode_long(&result, res)); } error: if (service) free(service); if (hostname) free(hostname); if (in.value) gss_release_buffer(&min_stat, &in); if (out.value) gss_release_buffer(&min_stat, &out); *presult = result; return 0; }
int main (int argc, char *argv[]) { /* Check to see if the user is running * us as root, which is a nono */ if (geteuid () == 0) { fprintf (stderr, "Don't run ircd as root!!!\n"); return (-1); } /* save server boot time right away, so getrusage works correctly */ set_time (); /* Setup corefile size immediately after boot -kre */ setup_corefile (); /* set initialVMTop before we allocate any memory */ initialVMTop = get_vm_top (); ServerRunning = 0; /* It ain't random, but it ought to be a little harder to guess */ srand (SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid () << 20))); memset (&me, 0, sizeof (me)); memset (&meLocalUser, 0, sizeof (meLocalUser)); me.localClient = &meLocalUser; dlinkAdd (&me, &me.node, &global_client_list); /* Pointer to beginning of Client list */ memset (&ServerInfo, 0, sizeof (ServerInfo)); /* Initialise the channel capability usage counts... */ init_chcap_usage_counts (); ConfigFileEntry.dpath = DPATH; ConfigFileEntry.configfile = CPATH; /* Server configuration file */ ConfigFileEntry.klinefile = KPATH; /* Server kline file */ ConfigFileEntry.xlinefile = XPATH; /* Server xline file */ ConfigFileEntry.dlinefile = DLPATH; /* dline file */ ConfigFileEntry.cresvfile = CRESVPATH; /* channel resv file */ ConfigFileEntry.nresvfile = NRESVPATH; /* nick resv file */ myargv = argv; umask (077); /* better safe than sorry --SRB */ parseargs (&argc, &argv, myopts); build_version (); if (printVersion) { printf ("ircd: version %s\n", ircd_version); exit (EXIT_SUCCESS); } if (chdir (ConfigFileEntry.dpath)) { perror ("chdir"); exit (EXIT_FAILURE); } if (!server_state.foreground) make_daemon (); else print_startup (getpid ()); #ifdef HAVE_LIBCRYPTO dh_init(); fprintf(stderr, "SSL: Initialize\n"); SSL_load_error_strings(); SSLeay_add_ssl_algorithms(); ServerInfo.ctx = SSL_CTX_new(SSLv23_server_method()); if (!ServerInfo.ctx) { ERR_print_errors_fp(stderr); return 0; } fprintf(stderr, "SSL: Client based SSL connections are enabled.\n"); #endif setup_signals (); /* We need this to initialise the fd array before anything else */ fdlist_init (); if (!server_state.foreground) close_all_connections (); /* this needs to be before init_netio()! */ else check_can_use_v6 (); /* Done in close_all_connections normally */ init_log (logFileName); init_netio (); /* This needs to be setup early ! -- adrian */ /* Check if there is pidfile and daemon already running */ check_pidfile (pidFileName); /* Init the event subsystem */ eventInit (); init_sys (); #ifndef NOBALLOC initBlockHeap (); #endif init_dlink_nodes (); init_slink_nodes (); initialize_message_files (); dbuf_init (); init_hash (); init_ip_hash_table (); /* client host ip hash table */ init_host_hash (); /* Host-hashtable. */ clear_hash_parse (); init_client (); init_user (); init_channels (); init_class (); init_whowas (); init_stats (); init_hooks (); read_conf_files (1); /* cold start init conf files */ initServerMask (); init_uid (); init_auth (); /* Initialise the auth code */ init_resolver (); /* Needs to be setup before the io loop */ init_reject (); /* Set up the reject code. */ init_umodes (); /* Set up the usermode system. */ initialize_foundation_signals(); /* register things that modules need */ #ifdef HAVE_LIBCRYPTO bio_spare_fd = save_spare_fd ("SSL private key validation"); #endif /* HAVE_LIBCRYPTO */ initialize_server_capabs (); /* Set up default_server_capabs */ initialize_global_set_options (); if (ServerInfo.name == NULL) { fprintf (stderr, "ERROR: No server name specified in serverinfo block.\n"); ilog (L_CRIT, "No server name specified in serverinfo block."); exit (EXIT_FAILURE); } strlcpy (me.name, ServerInfo.name, sizeof (me.name)); /* serverinfo{} description must exist. If not, error out. */ if (ServerInfo.description == NULL) { fprintf (stderr, "ERROR: No server description specified in serverinfo block.\n"); ilog (L_CRIT, "ERROR: No server description specified in serverinfo block."); exit (EXIT_FAILURE); } strlcpy (me.info, ServerInfo.description, sizeof (me.info)); me.from = &me; me.servptr = &me; SetMe (&me); make_server (&me); strlcpy (me.serv->up, me.name, sizeof (me.serv->up)); me.lasttime = me.since = me.firsttime = CurrentTime; hash_add_client (&me); /* add ourselves to global_serv_list */ dlinkAdd (&me, make_dlink_node (), &global_serv_list); check_class (); #ifndef STATIC_MODULES if (chdir (MODPATH)) { ilog (L_CRIT, "Could not load core modules. Terminating!"); exit (EXIT_FAILURE); } mod_set_base (); load_all_modules (1); load_core_modules (1); /* Go back to DPATH after checking to see if we can chdir to MODPATH */ chdir (ConfigFileEntry.dpath); #else load_all_modules (1); #endif write_pidfile (pidFileName); ilog (L_NOTICE, "Server Ready"); eventAddIsh ("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME); /* We want try_connections to be called as soon as possible now! -- adrian */ /* No, 'cause after a restart it would cause all sorts of nick collides */ eventAddIsh ("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME); eventAddIsh ("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME); /* Setup the timeout check. I'll shift it later :) -- adrian */ eventAddIsh ("comm_checktimeouts", comm_checktimeouts, NULL, 1); if (splitmode) eventAddIsh ("check_splitmode", check_splitmode, NULL, 60); ServerRunning = 1; io_loop (); return (0); }