static void fetion_keep_alive(PurpleConnection * gc) { struct fetion_account_data *sip = gc->proto_data; time_t curtime = time(NULL); /* register again if first registration expires */ if (sip->reregister < curtime) { do_register(sip); } return; }
static int retr_proxy( SNET *sn, char *login, SNET *pushersn ) { char cookiebuf[ 128 ], lpath[ MAXPATHLEN ]; char cbuf[ MAXCOOKIELEN ], spath[ MAXPATHLEN ]; struct proxies *proxy; int rc; /* S: 241-[cookiename] [hostname to use cookie with] * S: 241- ... * S: 241 Cookies registered and sent. */ if (( al->al_flag & AL_PROXY ) == 0 ) { syslog( LOG_ERR, "%s cannot retrieve cookies", al->al_hostname ); snet_writef( sn, "%d RETR: %s cannot retrieve cookies.\r\n", 443, al->al_hostname ); return( 1 ); } for ( proxy = al->al_proxies; proxy != NULL; proxy = proxy->pr_next ) { if ( mkcookie( sizeof( cookiebuf ), cookiebuf ) != 0 ) { syslog( LOG_ERR, "retr_proxy: mkcookie error" ); return( -1 ); } if ( snprintf( cbuf, sizeof( cbuf ), "%s=%s", proxy->pr_cookie, cookiebuf ) >= sizeof( cbuf )) { syslog( LOG_ERR, "retr_proxy: full cookie too long" ); return( -1 ); } if ( mkcookiepath( NULL, hashlen, cbuf, spath, sizeof( spath )) < 0 ) { syslog( LOG_ERR, "retr_proxy: mkcookiepath error" ); return( 1 ); } if ( mkcookiepath( NULL, hashlen, login, lpath, sizeof( lpath )) < 0 ) { syslog( LOG_ERR, "retr_proxy: mkcookiepath error" ); return( 1 ); } if (( rc = do_register( login, lpath, spath )) < 0 ) { continue; } if (( pushersn != NULL ) && ( !replicated )) { snet_writef( pushersn, "REGISTER %s - %s\r\n", login, cbuf ); } snet_writef( sn, "%d-%s %s\r\n", 241, cbuf, proxy->pr_hostname ); } snet_writef( sn, "%d Cookies registered and sent\r\n", 241 ); return( 0 ); }
ph_result_t ph_hook_register_cstr(const char *name, ph_hook_func func, void *closure, int8_t pri, ph_hook_unreg_func unreg) { ph_hook_point_t *hp = ph_hook_point_get_cstr(name, true); if (!hp) { return PH_ERR; } return do_register(hp, func, closure, pri, unreg); }
//分析message函数, on_read之后调用 void talk_to_client::do_analyze(const std::string &msg) { if (msg.find(requests.request_register) == 0)do_register(msg); else if (msg.find(requests.request_login) == 0)do_login(msg); else if (msg.find(requests.request_ping) == 0)do_ping(); else if (msg.find(requests.request_ask) == 0)do_anw_clients(); else if (msg.find(requests.request_send_to) == 0)do_sendto(msg); else if (msg.find(requests.request_exit) == 0)do_exit(); else std::cout << msg << std::endl; return; }
gboolean actions_register(const gchar *name, ObActionsDataSetupFunc setup, ObActionsDataFreeFunc free, ObActionsRunFunc run) { ObActionsDefinition *def = do_register(name, free, run); if (def) { def->canbeinteractive = FALSE; def->setup.n = setup; } return def != NULL; }
static void check_fd (int fd) { #if 0 /* This would be a better way if the accept()'ed socket * had the /dev/v4v_* inode but for now it doesn't */ struct stat st; if (v4v_dgram_inode.st_ino == (ino_t) (-1L) || v4v_stream_inode.st_ino == (ino_t) (-1L)) { if (stat (V4V_DGRAM_DEV, &st)) return; v4v_dgram_inode.st_dev = st.st_dev; v4v_dgram_inode.st_ino = st.st_ino; if (stat (V4V_STREAM_DEV, &st)) return; v4v_stream_inode.st_dev = st.st_dev; v4v_stream_inode.st_ino = st.st_ino; } if (fstat (fd, &st)) return; do_register (&v4v_checked, fd); if (((st.st_dev == v4v_stream_inode.st_dev) && (st.st_ino == v4v_stream_inode.st_ino)) || ((st.st_dev == v4v_dgram_inode.st_dev) && (st.st_ino == v4v_dgram_inode.st_ino))) do_register (&v4v_fds, fd); #else struct v4v_ring_id id; int ret; do_register (&v4v_checked, fd); if (!ioctl (fd, V4VIOCGETSOCKNAME, &id)) { do_register (&v4v_fds, fd); } #endif }
int auth_init() { printf("|Student Gradebook|\n" "1) Login\n" "2) Create New Account\n" "3) Exit\n"); char c; printf("Enter a command: "); while (! ((c = getchar()) >= '1' && c <= '3')); while (getchar() != '\n'); if (c == '3') exit(EXIT_SUCCESS); printf("\n"); if (c == '1') return do_login(); else if (c == '2') return do_register(); return 1; }
static void job_proc(void) { struct ipc_struct ipc; struct pack *p; struct ProcChild *sender; char *t, *s; int cmd; size_t size; p = pack_new(256); while (1) { if (1 == proc_listen(&sender, &cmd, &size, 1)) break; } proc_get(sender, &ipc, p, size); bk_channel = ipc.source; switch (cmd) { case CMD_REGISTER: pack_get(p, &t, NULL); pack_get(p, &s, NULL); do_register(ipc.node, t, s); break; case CMD_REMOVE: pack_get(p, &t, NULL); do_remove(t); break; case CMD_CALL: do_call(ipc.node, p); break; case CMD_CALL_PACKAGE: pack_get(p, &t, NULL); do_call_package(ipc.node, t, p); break; case CMD_GETLIST: do_getlist(ipc.node); break; case CMD_DUMP_PROFILE: do_dump_profile(); break; case CMD_EVENT: pack_get(p, &t, NULL); pack_get(p, &s, NULL); do_event(t, ipc.node, s, p); break; } }
int do_client(int sockfd,sqlite3 *pdb) { MSG msg; char *p_username,*p_password; while(1) { recv(sockfd,&msg,sizeof(msg),0); switch(msg.type) { case REGISTER: p_password = strdup(msg.password); p_username = strdup(msg.username); do_register(sockfd,pdb,p_username,p_password); free(p_username); free(p_password); break; case LOGIN: p_password = strdup(msg.password); p_username = strdup(msg.username); do_login(sockfd,pdb,p_username,p_password); free(p_username); free(p_password); break; case WORD: do_word(sockfd,pdb,msg.mtext); break; defalut: exit(EXIT_SUCCESS); } } return 0; }
static void job_proc(void) { struct ProcChild *sender; char *t, *s; int cmd; size_t size; while (1) { if (1 == proc_listen(&sender, &cmd, &size, 1)) break; } ipc_recv(sender, size); chan = ipc_get_data(); chan_id = ipc_get_id(); switch (cmd) { case CMD_REGISTER: ipc_get_arg(&t, NULL); ipc_get_arg(&s, NULL); do_register(ipc_get_node(), t, s); break; case CMD_REMOVE: ipc_get_arg(&t, NULL); do_remove(t); break; case CMD_CALL: do_call(ipc_get_node()); break; case CMD_CALL_PACKAGE: ipc_get_arg(&t, NULL); do_call_package(ipc_get_node(), t); break; case CMD_GETLIST: do_getlist(ipc_get_node()); break; case CMD_DUMP_PROFILE: do_dump_profile(); break; } }
int dpkg_psys_register(psys_pkg_t pkg, psys_err_t *err) { int ret; jmp_buf buf; pkg = psys_pkg_copy(pkg); if (!pkg) { psys_err_set_nomem(err); return -1; } psys_pkg_assert_valid(pkg); init_error_handler(err, buf, out); modstatdb_init(ADMINDIR, msdbrw_needsuperuser); ret = do_register(pkg, err, &buf); out: modstatdb_shutdown(); cleanup(); psys_pkg_free(pkg); return ret; }
int dispatch(char * input) { // parse out the command character char * start = input; char * command = strsep(&start, DELIMITER); if(strlen(command) < 1) return 1; switch(command[0]) { case 'R': do_register(start); break; case 'D': do_deregister(start); break; case 'Y': default: printk(KERN_ERR "mp2: Unrecognized command.\n"); return 1; } return 0; }
int dpkg_psys_register_update(psys_pkg_t pkg, psys_err_t *err) { int ret; jmp_buf buf; char *dpkgname; struct pkginfo *dpkg; pkg = psys_pkg_copy(pkg); if (!pkg) { psys_err_set_nomem(err); return -1; } psys_pkg_assert_valid(pkg); init_error_handler(err, buf, out); modstatdb_init(ADMINDIR, msdbrw_needsuperuser); dpkgname = dpkg_name(psys_pkg_vendor(pkg), psys_pkg_name(pkg)); dpkg = findpackage(dpkgname); if (ensure_installed(dpkg, err)) { ret = -1; goto out; } if (ensure_version_newer(pkg, dpkg, err)) { ret = -1; goto out; } dpkg->status = stat_notinstalled; ret = do_register(pkg, err, &buf); out: modstatdb_shutdown(); cleanup(); psys_pkg_free(pkg); return ret; }
int main(int argc, char **argv) { apeconfig *srv; int random, im_r00t = 0, pidfd = 0, serverfd; unsigned int getrandom = 0, ct_id; const char *pidfile = NULL; char *confs_path = NULL; struct _fdevent fdev; char cfgfile[513] = APE_CONFIG_FILE; acetables *g_ape; if (argc > 1 && strcmp(argv[1], "--version") == 0) { printf("\n AJAX Push Engine Server %s - (C) Anthony Catel <*****@*****.**>\n http://www.ape-project.org/\n\n", _VERSION); return 0; } if (argc > 1 && strcmp(argv[1], "--help") == 0) { printf("\n AJAX Push Engine Server %s - (C) Anthony Catel <*****@*****.**>\n http://www.ape-project.org/\n", _VERSION); printf("\n usage: aped [options]\n\n"); printf(" Options:\n --help : Display this help\n --version : Show version number\n --cfg <config path>: Load a specific config file (default is %s)\n\n", cfgfile); return 0; } else if (argc > 2 && strcmp(argv[1], "--cfg") == 0) { memset(cfgfile, 0, 513); strncpy(cfgfile, argv[2], 512); confs_path = get_path(cfgfile); } else if (argc > 1) { printf("\n AJAX Push Engine Server %s - (C) Anthony Catel <*****@*****.**>\n http://www.ape-project.org/\n\n", _VERSION); printf(" Unknown parameters - check \"aped --help\"\n\n"); return 0; } if (NULL == (srv = ape_config_load(cfgfile))) { printf("\nExited...\n\n"); exit(1); } if (getuid() == 0) { im_r00t = 1; } signal(SIGINT, &signal_handler); signal(SIGTERM, &signal_handler); if (VTICKS_RATE < 1) { printf("[ERR] TICKS_RATE cant be less than 1\n"); return 0; } random = open("/dev/urandom", O_RDONLY); if (!random) { printf("Cannot open /dev/urandom... exiting\n"); return 0; } read(random, &getrandom, 3); srand(getrandom); close(random); g_ape = xmalloc(sizeof(*g_ape)); g_ape->basemem = 1; // set 1 for testing if growup works g_ape->srv = srv; g_ape->confs_path = confs_path; g_ape->is_daemon = 0; ape_log_init(g_ape); fdev.handler = EVENT_UNKNOWN; #ifdef USE_EPOLL_HANDLER fdev.handler = EVENT_EPOLL; #endif #ifdef USE_KQUEUE_HANDLER fdev.handler = EVENT_KQUEUE; #endif g_ape->co = xmalloc(sizeof(*g_ape->co) * g_ape->basemem); memset(g_ape->co, 0, sizeof(*g_ape->co) * g_ape->basemem); g_ape->bad_cmd_callbacks = NULL; g_ape->bufout = xmalloc(sizeof(struct _socks_bufout) * g_ape->basemem); g_ape->timers.timers = NULL; g_ape->timers.ntimers = 0; g_ape->events = &fdev; if (events_init(g_ape, &g_ape->basemem) == -1) { printf("Fatal error: APE compiled without an event handler... exiting\n"); return 0; }; serverfd = servers_init(g_ape); ape_log(APE_INFO, __FILE__, __LINE__, g_ape, "APE starting up - pid : %i", getpid()); if (strcmp(CONFIG_VAL(Server, daemon, srv), "yes") == 0 && (pidfile = CONFIG_VAL(Server, pid_file, srv)) != NULL) { if ((pidfd = open(pidfile, O_TRUNC | O_WRONLY | O_CREAT, 0655)) == -1) { ape_log(APE_WARN, __FILE__, __LINE__, g_ape, "Cant open pid file : %s", CONFIG_VAL(Server, pid_file, srv)); } } if (im_r00t) { struct group *grp = NULL; struct passwd *pwd = NULL; if (inc_rlimit(atoi(CONFIG_VAL(Server, rlimit_nofile, srv))) == -1) { ape_log(APE_WARN, __FILE__, __LINE__, g_ape, "Cannot set the max filedescriptos limit (setrlimit) %s", strerror(errno)); } /* Set uid when uid section exists */ if (ape_config_get_section(srv, "uid")) { /* Get the user information (uid section) */ if ((pwd = getpwnam(CONFIG_VAL(uid, user, srv))) == NULL) { ape_log(APE_ERR, __FILE__, __LINE__, g_ape, "Can\'t find username %s", CONFIG_VAL(uid, user, srv)); return -1; } if (pwd->pw_uid == 0) { ape_log(APE_ERR, __FILE__, __LINE__, g_ape, "%s uid can\'t be 0", CONFIG_VAL(uid, user, srv)); return -1; } /* Get the group information (uid section) */ if ((grp = getgrnam(CONFIG_VAL(uid, group, srv))) == NULL) { printf("[ERR] Can\'t find group %s\n", CONFIG_VAL(uid, group, srv)); ape_log(APE_ERR, __FILE__, __LINE__, g_ape, "Can\'t find group %s", CONFIG_VAL(uid, group, srv)); return -1; } if (grp->gr_gid == 0) { ape_log(APE_ERR, __FILE__, __LINE__, g_ape, "%s gid can\'t be 0", CONFIG_VAL(uid, group, srv)); return -1; } setgid(grp->gr_gid); setgroups(0, NULL); initgroups(CONFIG_VAL(uid, user, srv), grp->gr_gid); setuid(pwd->pw_uid); } } else { printf("[WARN] You have to run \'aped\' as root to increase r_limit\n"); ape_log(APE_WARN, __FILE__, __LINE__, g_ape, "You have to run \'aped\' as root to increase r_limit"); } if (strcmp(CONFIG_VAL(Server, daemon, srv), "yes") == 0) { ape_log(APE_INFO, __FILE__, __LINE__, g_ape, "Starting daemon"); ape_daemon(pidfd, g_ape); events_reload(g_ape->events); events_add(g_ape->events, serverfd, EVENT_READ); } if (!g_ape->is_daemon) { printf(" _ ___ ___ \n"); printf(" /_\\ | _ \\ __|\n"); printf(" / _ \\| _/ _| \n"); printf("/_/ \\_\\_| |___|\nAJAX Push Engine\n\n"); printf("Bind on port %i\n\n", atoi(CONFIG_VAL(Server, port, srv))); printf("Version : %s\n", _VERSION); printf("Build : %s %s\n", __DATE__, __TIME__); printf("Author : Weelya ([email protected])\n\n"); } signal(SIGPIPE, SIG_IGN); ape_dns_init(g_ape); g_ape->cmd_hook.head = NULL; g_ape->cmd_hook.foot = NULL; g_ape->hSessid = hashtbl_init(); g_ape->hChannel = hashtbl_init(); g_ape->hPubid = hashtbl_init(); g_ape->proxy.list = NULL; g_ape->proxy.hosts = NULL; g_ape->hCallback = hashtbl_init(); g_ape->uHead = NULL; g_ape->cHead = NULL; g_ape->nConnected = 0; g_ape->plugins = NULL; g_ape->properties = NULL; ct_id = add_ticked(check_timeout, g_ape)->identifier; do_register(g_ape); transport_start(g_ape); findandloadplugin(g_ape); server_is_running = 1; server_is_shutdowning = 0; /* Starting Up */ sockroutine(g_ape); /* loop */ /* Shutdown */ if (pidfile != NULL) { unlink(pidfile); } free(confs_path); ape_dns_free(g_ape); del_timer_identifier(ct_id, g_ape); events_free(g_ape); transport_free(g_ape); hashtbl_free(g_ape->hSessid, 0); hashtbl_free(g_ape->hChannel, 0); hashtbl_free(g_ape->hPubid, 0); do_unregister(g_ape); hashtbl_free(g_ape->hCallback, 1); ape_config_free(srv); int i; for (i = 0; i < g_ape->basemem; i++) { if (g_ape->co[i] != NULL) { close_socket(i, g_ape); free(g_ape->co[i]); } } free(g_ape->co); free(g_ape->bufout); free_all_hook_cmd(g_ape); free_all_plugins(g_ape); free(g_ape); return 0; }
struct proc_dir_entry * svc_proc_register(struct svc_stat *statp, const struct file_operations *fops) { return do_register(statp->program->pg_name, statp, fops); }
struct proc_dir_entry * rpc_proc_register(struct rpc_stat *statp) { return do_register(statp->program->name, statp, &rpc_proc_fops); }
void func(void) { do_register(&xyz); }
int f_register( SNET *sn, int ac, char *av[], SNET *pushersn ) { struct cinfo ci; struct timeval tv; int rc; char lpath[ MAXPATHLEN ], spath[ MAXPATHLEN ]; /* REGISTER login_cookie ip service_cookie */ if ( al->al_key != CGI ) { syslog( LOG_ERR, "f_register: %s not allowed", al->al_hostname ); snet_writef( sn, "%d REGISTER: %s not allowed to register.\r\n", 420, al->al_hostname ); return( 1 ); } if ( ac != 4 ) { syslog( LOG_ERR, "f_register: %s wrong number of args.", al->al_hostname ); snet_writef( sn, "%d REGISTER: Wrong number of args.\r\n", 520 ); return( 1 ); } if ( mkcookiepath( NULL, hashlen, av[ 1 ], lpath, sizeof( lpath )) < 0 ) { syslog( LOG_ERR, "f_register: mkcookiepath login cookie error" ); snet_writef( sn, "%d REGISTER: Invalid cookie path.\r\n", 521 ); return( 1 ); } if ( mkcookiepath( NULL, hashlen, av[ 3 ], spath, sizeof( spath )) < 0 ) { syslog( LOG_ERR, "f_register: mkcookiepath service cookie error" ); snet_writef( sn, "%d REGISTER: Invalid cookie path.\r\n", 522 ); return( 1 ); } if ( read_cookie( lpath, &ci ) != 0 ) { snet_writef( sn, "%d REGISTER error: Sorry\r\n", 523 ); return( 1 ); } if ( ci.ci_state == 0 ) { syslog( LOG_ERR, "f_register: %s logged out, can't register", ci.ci_user ); snet_writef( sn, "%d REGISTER: Already logged out\r\n", 421 ); return( 1 ); } /* check for idle timeout, and if so, log'em out */ if ( gettimeofday( &tv, NULL ) != 0 ){ syslog( LOG_ERR, "f_register: gettimeofday: %m" ); return( -1 ); } if ( tv.tv_sec - ci.ci_itime >= idle_out_time ) { if ( tv.tv_sec - ci.ci_itime < ( idle_out_time + grey_time )) { syslog( LOG_NOTICE, "f_register: idle grey window" ); snet_writef( sn, "%d REGISTER: Idle Grey Window\r\n", 521 ); return( 1 ); } snet_writef( sn, "%d REGISTER: Idle logged out\r\n", 422 ); if ( do_logout( lpath ) < 0 ) { syslog( LOG_ERR, "f_register: %s: %m", lpath ); return( -1 ); } return( 1 ); } if (( rc = do_register( av[ 1 ], lpath, spath )) < 0 ) { return( -1 ); } /* double action policy?? */ if ( rc > 0 ) { snet_writef( sn, "%d REGISTER error: Cookie already exists\r\n", 226 ); return( rc ); } snet_writef( sn, "%d REGISTER successful: Cookie Stored.\r\n", 220 ); if (( pushersn != NULL ) && ( !replicated )) { snet_writef( pushersn, "REGISTER %s %s %s\r\n", av[ 1 ], av[ 2 ], av [ 3 ] ); } if ( !replicated ) { /* just log service name, no need for full cookie */ (void)strtok( av[ 3 ], "=" ); syslog( LOG_INFO, "REGISTER %s %s %s %s", ci.ci_user, ci.ci_realm, ci.ci_ipaddr, av[ 3 ] ); } return( 0 ); }
struct proc_dir_entry * svc_proc_register(struct svc_stat *statp) { return do_register(statp->program->pg_name, statp, 1); }
static void do_control_request(int direction) { switch (USB_ControlRequest.bRequest) { case REQUEST_REGISTER: do_register(direction, USB_ControlRequest.wValue); break; case REQUEST_FREQUENCY: do_frequency(direction, USB_ControlRequest.wValue); break; case REQUEST_RXTX_MODE: do_rxtx_mode(direction, USB_ControlRequest.wValue); break; case REQUEST_MODINDEX: do_modindex(direction, USB_ControlRequest.wValue); break; case REQUEST_CSMA_RSSI: do_csma_rssi(direction, USB_ControlRequest.wValue); break; case REQUEST_POWER: do_power(direction, USB_ControlRequest.wValue); break; case REQUEST_AFC: do_acf(direction, USB_ControlRequest.wValue); break; case REQUEST_IFBW: do_ifbw(direction, USB_ControlRequest.wValue); break; case REQUEST_TRAINING: do_training(direction, USB_ControlRequest.wValue); break; case REQUEST_SYNCWORD: do_syncword(direction, USB_ControlRequest.wValue); break; case REQUEST_BITRATE: do_bitrate(direction, USB_ControlRequest.wValue); break; case REQUEST_TX: do_tx(direction, USB_ControlRequest.wValue); break; case REQUEST_RX: do_rx(direction, USB_ControlRequest.wValue); break; case REQUEST_TX_FREQUENCY: do_tx_frequency(direction, USB_ControlRequest.wValue); break; case REQUEST_RX_FREQUENCY: do_rx_frequency(direction, USB_ControlRequest.wValue); break; case REQUEST_SERIALNUMBER: do_serialnumber(direction, USB_ControlRequest.wValue); break; case REQUEST_FWREVISION: do_fw_revision(direction, USB_ControlRequest.wValue); break; case REQUEST_RESET: reboot(); break; case REQUEST_DFU: jump_to_bootloader(); break; } }
static void inline register_af (int fd) { do_register (&v4v_afs, fd); }
static void inline register_fd (int fd) { do_register (&v4v_fds, fd); }
int main() { create_amigonet(); char line[ MAX_LEN ]; char *result, *cmd, *arg1, *arg2; char *name1, *name2, *birthdate1, *birthdate2; printf("> "); fflush(stdout); while ( ( result = fgets( line, MAX_LEN, stdin ) ) ) { if ( line[ 0 ] == '#' ) { printf( "%s", line ); } else { #ifdef DEBUG printf("%s", line); #endif cmd = strtok( line, " \n" ); if( cmd == NULL) { // do nothing } else if ( strcmp( cmd, REGISTER ) == 0 ) { arg1 = strtok( NULL, " \n" ); arg2 = strtok( NULL, " \n" ); birthdate1 = strtok( NULL, " \n" ); if( arg1 && arg2 && birthdate1 && (birthdate1[2] == '/') && (birthdate1[5] == '/')) { name1 = alloc_and_cat( arg1, arg2 ); do_register( name1, birthdate1 ); free(name1); } else { fprintf(stderr, "Error, invalid arguments for addUser\n"); } } else if ( strcmp( cmd, PRINTFRIENDS) == 0 ) { } else if ( strcmp( cmd, PRINTNUMUSERS) == 0 ) { do_printNumUsers(); } else if ( strcmp( cmd, EXIT) == 0 ) { break; } else if ( strcmp( cmd, FRIEND ) == 0 ) { } else if ( strcmp( cmd, UNFRIEND ) == 0 ) { } else { fprintf( stderr, "Error, illegal command \"%s\"\n", line ); } } printf("> "); fflush(stdout); } destroy_amigonet(); }