您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xstrncpy函数代码示例

51自学网 2021-06-03 11:52:56
  C++
这篇教程C++ xstrncpy函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中xstrncpy函数的典型用法代码示例。如果您正苦于以下问题:C++ xstrncpy函数的具体用法?C++ xstrncpy怎么用?C++ xstrncpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了xstrncpy函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: log_lastlog

static void log_lastlog(struct login_context *cxt){	struct sigaction sa, oldsa_xfsz;	struct lastlog ll;	time_t t;	int fd;	if (!cxt->pwd)		return;	/* lastlog is huge on systems with large UIDs, ignore SIGXFSZ */	memset(&sa, 0, sizeof(sa));	sa.sa_handler = SIG_IGN;	sigaction(SIGXFSZ, &sa, &oldsa_xfsz);	fd = open(_PATH_LASTLOG, O_RDWR, 0);	if (fd < 0)		goto done;	if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1)		goto done;	/*	 * Print last log message.	 */	if (!cxt->quiet) {		if (read(fd, (char *)&ll, sizeof(ll)) == sizeof(ll) &&							ll.ll_time != 0) {			time_t ll_time = (time_t) ll.ll_time;			printf(_("Last login: %.*s "), 24 - 5, ctime(&ll_time));			if (*ll.ll_host != '/0')				printf(_("from %.*s/n"),				       (int)sizeof(ll.ll_host), ll.ll_host);			else				printf(_("on %.*s/n"),				       (int)sizeof(ll.ll_line), ll.ll_line);		}		if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1)			goto done;	}	memset((char *)&ll, 0, sizeof(ll));	time(&t);	ll.ll_time = t;		/* ll_time is always 32bit */	if (cxt->tty_name)		xstrncpy(ll.ll_line, cxt->tty_name, sizeof(ll.ll_line));	if (cxt->hostname)		xstrncpy(ll.ll_host, cxt->hostname, sizeof(ll.ll_host));	if (write_all(fd, (char *)&ll, sizeof(ll)))		warn(_("write lastlog failed"));done:	if (fd >= 0)		close(fd);	sigaction(SIGXFSZ, &oldsa_xfsz, NULL);		/* restore original setting */}
开发者ID:abrodkin,项目名称:util-linux,代码行数:60,


示例2: log_btmp

/* * Logs failed login attempts in _PATH_BTMP, if it exists. * Must be called only with username the name of an actual user. * The most common login failure is to give password instead of username. */static void log_btmp(struct login_context *cxt){	struct utmpx ut;	struct timeval tv;	memset(&ut, 0, sizeof(ut));	strncpy(ut.ut_user,		cxt->username ? cxt->username : "(unknown)",		sizeof(ut.ut_user));	if (cxt->tty_number)		strncpy(ut.ut_id, cxt->tty_number, sizeof(ut.ut_id));	if (cxt->tty_name)		xstrncpy(ut.ut_line, cxt->tty_name, sizeof(ut.ut_line));	gettimeofday(&tv, NULL);	ut.ut_tv.tv_sec = tv.tv_sec;	ut.ut_tv.tv_usec = tv.tv_usec;	ut.ut_type = LOGIN_PROCESS;	/* XXX doesn't matter */	ut.ut_pid = cxt->pid;	if (cxt->hostname) {		xstrncpy(ut.ut_host, cxt->hostname, sizeof(ut.ut_host));		if (*cxt->hostaddress)			memcpy(&ut.ut_addr_v6, cxt->hostaddress,			       sizeof(ut.ut_addr_v6));	}	updwtmpx(_PATH_BTMP, &ut);}
开发者ID:sebras,项目名称:util-linux,代码行数:37,


示例3: dolastlog

voiddolastlog(int quiet) {    struct lastlog ll;    int fd;        if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) {	lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), SEEK_SET);	if (!quiet) {	    if (read(fd, (char *)&ll, sizeof(ll)) == sizeof(ll) &&		ll.ll_time != 0) {		    time_t ll_time = (time_t) ll.ll_time;		    printf("Last login: %.*s ",			   24-5, ctime(&ll_time));				    if (*ll.ll_host != '/0')			    printf("from %.*s/n",				   (int)sizeof(ll.ll_host), ll.ll_host);		    else			    printf("on %.*s/n",				   (int)sizeof(ll.ll_line), ll.ll_line);	    }	    lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), SEEK_SET);	}	memset((char *)&ll, 0, sizeof(ll));	time(&ll.ll_time);	xstrncpy(ll.ll_line, tty_name, sizeof(ll.ll_line));	if (hostname)	    xstrncpy(ll.ll_host, hostname, sizeof(ll.ll_host));	write(fd, (char *)&ll, sizeof(ll));	close(fd);    }}
开发者ID:lisa-project,项目名称:lisa-user,代码行数:34,


示例4: get_hostname_hostip

int get_hostname_hostip(){	static int configured = 0;	if (!configured)	{		struct hostent *hbuf;		struct in_addr in;		if(gethostname(myhostname, sizeof(myhostname)) == -1)			return -1;		if ((hbuf = gethostbyname(myhostname)) != NULL)		{#if 0			xstrncpy(myhostname, hbuf->h_name, sizeof(myhostname));			xstrncpy(myhostip, hbuf->h_addr, sizeof(myhostip));#endif			if(find_fqdn(myhostname, hbuf) == NULL)	/* by asuka */				return -2;			memcpy(&in.s_addr, *(hbuf->h_addr_list), sizeof(in.s_addr));			xstrncpy(myhostip, inet_ntoa(in), sizeof(myhostip));		}		configured = 1;	}	return 0;}
开发者ID:PichuChen,项目名称:formosa,代码行数:26,


示例5: log_btmp

/* * Log failed login attempts in _PATH_BTMP if that exists. */static void log_btmp(struct passwd const* pw) {    struct utmp ut;    struct timeval tv;    const char* tty_name, *tty_num;    memset(&ut, 0, sizeof(ut));    strncpy(ut.ut_user,            pw && pw->pw_name ? pw->pw_name : "(unknown)",            sizeof(ut.ut_user));    get_terminal_name(STDERR_FILENO, NULL, &tty_name, &tty_num);    if (tty_num) {        xstrncpy(ut.ut_id, tty_num, sizeof(ut.ut_id));    }    if (tty_name) {        xstrncpy(ut.ut_line, tty_name, sizeof(ut.ut_line));    }#if defined(_HAVE_UT_TV)    /* in <utmpbits.h> included by <utmp.h> */    gettimeofday(&tv, NULL);    ut.ut_tv.tv_sec = tv.tv_sec;    ut.ut_tv.tv_usec = tv.tv_usec;#else    {        time_t t;        time(&t);        ut.ut_time = t; /* ut_time is not always a time_t */    }#endif    ut.ut_type = LOGIN_PROCESS; /* XXX doesn't matter */    ut.ut_pid = getpid();    updwtmp(_PATH_BTMP, &ut);}
开发者ID:TheNeikos,项目名称:bughack,代码行数:38,


示例6: logbtmp

static voidlogbtmp(const char *line, const char *username, const char *hostname) {	struct utmp ut;	memset(&ut, 0, sizeof(ut));	strncpy(ut.ut_user, username ? username : "(unknown)",		sizeof(ut.ut_user));	strncpy(ut.ut_id, line + 3, sizeof(ut.ut_id));	xstrncpy(ut.ut_line, line, sizeof(ut.ut_line));#if defined(_HAVE_UT_TV)	    /* in <utmpbits.h> included by <utmp.h> */	gettimeofday(&ut.ut_tv, NULL);#else	{		time_t t;		time(&t);		ut.ut_time = t;	    /* ut_time is not always a time_t */	}#endif	ut.ut_type = LOGIN_PROCESS; /* XXX doesn't matter */	ut.ut_pid = pid;	if (hostname) {		xstrncpy(ut.ut_host, hostname, sizeof(ut.ut_host));		if (hostaddress[0])			memcpy(&ut.ut_addr, hostaddress, sizeof(ut.ut_addr));	}#if HAVE_UPDWTMP		/* bad luck for ancient systems */	updwtmp(_PATH_BTMP, &ut);#endif}
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:33,


示例7: xstrlen

char		*update_txtbox(char *str, SDL_KeyboardEvent *event){  int		len;  char		*tmp;  // enter 13 + numpad 271  // bksp = 8  // esc = 27  len = xstrlen(str);  if (event->keysym.sym >= ' '      && event->keysym.sym <= '~')    {      tmp = (char*)xmalloc(len + 2);      xstrncpy(tmp, str, len);      tmp[len] = event->keysym.sym;      tmp[len + 1] = 0;      free(str);      str = tmp;    }  else if (event->keysym.sym == 266)    {      tmp = (char*)xmalloc(len + 2);      xstrncpy(tmp, str, len);      tmp[len] = '.';      tmp[len + 1] = 0;      free(str);      str = tmp;    }  else if (event->keysym.sym >= 256	   && event->keysym.sym <= 265)    {      tmp = (char*)xmalloc(len + 2);      xstrncpy(tmp, str, len);      tmp[len] = (event->keysym.sym - 256 + '0');      tmp[len + 1] = 0;      free(str);      str = tmp;    }  else if (event->keysym.sym == 27)    gfx->win->focus = -1;  else if (event->keysym.sym == 8)    {      if (len > 1)	{	  tmp = xstrndup(str, len - 1);	  free(str);	  str = tmp;	}      else if (len == 1)	{	  free(str);	  str = 0;	}      else if (!str)	printf("%c", 7);    }  return (str);}
开发者ID:BackupTheBerlios,项目名称:freewar-svn,代码行数:58,


示例8: redirectStart

voidredirectStart(clientHttpRequest * http, RH * handler, void *data){    ConnStateData *conn = http->conn;    redirectStateData *r = NULL;    const char *fqdn;    char *urlgroup = conn->port->urlgroup;    char buf[8192];    char claddr[20];    char myaddr[20];    assert(http);    assert(handler);    debug(61, 5) ("redirectStart: '%s'/n", http->uri);    if (Config.onoff.redirector_bypass && redirectors->stats.queue_size) {	/* Skip redirector if there is one request queued */	n_bypassed++;	handler(data, NULL);	return;    }    r = cbdataAlloc(redirectStateData);    r->orig_url = xstrdup(http->uri);    r->client_addr = conn->log_addr;    r->client_ident = NULL;    if (http->request->auth_user_request)	r->client_ident = authenticateUserRequestUsername(http->request->auth_user_request);    else if (http->request->extacl_user) {	r->client_ident = http->request->extacl_user;    }    if (!r->client_ident && conn->rfc931[0])	r->client_ident = conn->rfc931;#if USE_SSL    if (!r->client_ident)	r->client_ident = sslGetUserEmail(fd_table[conn->fd].ssl);#endif    if (!r->client_ident)	r->client_ident = dash_str;    r->method_s = http->request->method->string;    r->handler = handler;    r->data = data;    cbdataLock(r->data);    if ((fqdn = fqdncache_gethostbyaddr(r->client_addr, 0)) == NULL)	fqdn = dash_str;    xstrncpy(claddr, inet_ntoa(r->client_addr), 20);    xstrncpy(myaddr, inet_ntoa(http->request->my_addr), 20);    snprintf(buf, 8191, "%s %s/%s %s %s %s myip=%s myport=%d",	r->orig_url,	claddr,	fqdn,	r->client_ident[0] ? rfc1738_escape(r->client_ident) : dash_str,	r->method_s,	urlgroup ? urlgroup : "-",	myaddr,	http->request->my_port);    debug(61, 6) ("redirectStart: sending '%s' to the helper/n", buf);    strcat(buf, "/n");    helperSubmit(redirectors, buf, redirectHandleReply, r);}
开发者ID:cristdai,项目名称:squid2,代码行数:57,


示例9: voice_init_section

void voice_init_section(void){	xstrncpy(setup.voice.standardmsg		, setup.spool					, VOICE_MAX_MESSAGE );	xstrncat(setup.voice.standardmsg		, "/messages/standard.msg"	, VOICE_MAX_MESSAGE );	xstrncpy(setup.voice.beepmsg			, setup.spool					, VOICE_MAX_MESSAGE );	xstrncat(setup.voice.beepmsg			, "/messages/beep.msg"		, VOICE_MAX_MESSAGE );	xstrncpy(setup.voice.timeoutmsg		, setup.spool					, VOICE_MAX_MESSAGE );	xstrncat(setup.voice.timeoutmsg		, "/messages/timeout.msg"	, VOICE_MAX_MESSAGE );	xstrncpy(setup.voice.tclscriptname	, setup.spool					, VOICE_MAX_SCRIPT  );	xstrncat(setup.voice.tclscriptname	, "/standard.tcl"				, VOICE_MAX_SCRIPT  );	xstrncpy(setup.voice.checknewpath	, setup.spool					, VOICE_MAX_CHECKNEW);	xstrncat(setup.voice.checknewpath	, "/incoming"					, VOICE_MAX_CHECKNEW);	xstrncpy(setup.voice.callerid			, "*** Unknown ***"			, VOICE_MAX_CALLERID);	xstrncpy(setup.voice.phone				, "*** Unknown ***"			, VOICE_MAX_PHONE	  );	xstrncpy(setup.voice.name				, "*** Unknown ***"			, VOICE_MAX_NAME	  );	xstrncpy(setup.voice.section			, "STANDARD"					, VOICE_MAX_SECTION );	setup.voice.rings			= -1;	setup.voice.ringsonnew	= -1;	setup.voice.doanswer		= TRUE;	setup.voice.dorecord		= TRUE;	setup.voice.dobeep		= TRUE;	setup.voice.domessage	= TRUE;	setup.voice.dotimeout	= TRUE;	setup.voice.recordtime	= TRUE;}
开发者ID:marschap,项目名称:isdn4k-utils,代码行数:26,


示例10: authenticateBasicStart

/* send the initial data to a basic authenticator module */static voidauthenticateBasicStart(auth_user_request_t * auth_user_request, RH * handler, void *data){    authenticateStateData *r = NULL;    char buf[8192];    char user[1024], pass[1024];    basic_data *basic_auth;    assert(auth_user_request);    assert(handler);    assert(auth_user_request->auth_user->auth_type == AUTH_BASIC);    assert(auth_user_request->auth_user->scheme_data != NULL);    basic_auth = auth_user_request->auth_user->scheme_data;    debug(29, 9) ("authenticateStart: '%s:%s'/n", basic_auth->username,	basic_auth->passwd);    if (basicConfig->authenticate == NULL) {	handler(data, NULL);	return;    }    /* check to see if the auth_user already has a request outstanding */    if (basic_auth->flags.credentials_ok == 2) {	/* there is a request with the same credentials already being verified */	auth_basic_queue_node *node;	node = xmalloc(sizeof(auth_basic_queue_node));	assert(node);	/* save the details */	node->next = basic_auth->auth_queue;	basic_auth->auth_queue = node;	node->handler = handler;	node->data = data;	cbdataLock(data);	return;    } else {	r = cbdataAlloc(authenticateStateData);	r->handler = handler;	cbdataLock(data);	r->data = data;	r->auth_user_request = auth_user_request;	authenticateAuthUserRequestLock(r->auth_user_request);	/* mark the user as haveing verification in progress */	basic_auth->flags.credentials_ok = 2;	if (basicConfig->utf8) {	    latin1_to_utf8(user, sizeof(user), basic_auth->username);	    latin1_to_utf8(pass, sizeof(pass), basic_auth->passwd);	    xstrncpy(user, rfc1738_escape(user), sizeof(user));	    xstrncpy(pass, rfc1738_escape(pass), sizeof(pass));	} else {	    xstrncpy(user, rfc1738_escape(basic_auth->username), sizeof(user));	    xstrncpy(pass, rfc1738_escape(basic_auth->passwd), sizeof(pass));	}	snprintf(buf, sizeof(buf), "%s %s/n", user, pass);	helperSubmit(basicauthenticators, buf, authenticateBasicHandleReply, r);    }}
开发者ID:CoolerVoid,项目名称:squid,代码行数:54,


示例11: vboxgettyrc_parse

static int vboxgettyrc_parse(unsigned char *tty){	unsigned char tempsectname[VBOX_MAX_RCLINE_SIZE + 1];	xstrncpy(temppathname, SYSCONFDIR		 , PATH_MAX);	xstrncat(temppathname, "/vboxgetty.conf", PATH_MAX);		/* First time, the global ttyI settings will be	*/		/* parsed.													*/	xstrncpy(tempsectname, "vboxgetty-tty", VBOX_MAX_RCLINE_SIZE);	if (rc_read(rc_getty_c, temppathname, tempsectname) == -1) return(-1);		/* Second, the settings for the used ttyI will be	*/		/* parsed.														*/	xstrncpy(tempsectname, "vboxgetty-", VBOX_MAX_RCLINE_SIZE);	xstrncat(tempsectname, tty			  , VBOX_MAX_RCLINE_SIZE);	if (rc_read(rc_getty_c, temppathname, tempsectname) == -1) return(-1);		/* After this, all unset variables will be filled with	*/		/* the defaults.														*/	log_line(LOG_D, "Filling unset configuration variables with defaults.../n");	if (!rc_set_empty(rc_getty_c, "init"				, "ATZ&B512"		 )) return(-1);	if (!rc_set_empty(rc_getty_c, "badinitsexit"		, "10"				 )) return(-1);	if (!rc_set_empty(rc_getty_c, "initpause"			, "2500"				 )) return(-1);	if (!rc_set_empty(rc_getty_c, "commandtimeout"	, "4"					 )) return(-1);	if (!rc_set_empty(rc_getty_c, "echotimeout"		, "4"					 )) return(-1);	if (!rc_set_empty(rc_getty_c, "ringtimeout"		, "6"					 )) return(-1);	if (!rc_set_empty(rc_getty_c, "alivetimeout"		, "1800"				 )) return(-1);	if (!rc_set_empty(rc_getty_c, "toggledtrtime"	, "400"				 )) return(-1);	if (!rc_set_empty(rc_getty_c, "spooldir"			, "/var/spool/vbox")) return(-1);	modemsetup.echotimeout		= xstrtol(rc_get_entry(rc_getty_c, "echotimeout"	), 4		);	modemsetup.commandtimeout	= xstrtol(rc_get_entry(rc_getty_c, "commandtimeout"), 4		);	modemsetup.ringtimeout		= xstrtol(rc_get_entry(rc_getty_c, "ringtimeout"	), 6		);	modemsetup.alivetimeout		= xstrtol(rc_get_entry(rc_getty_c, "alivetimeout"	), 1800	);	modemsetup.toggle_dtr_time	= xstrtol(rc_get_entry(rc_getty_c, "toggledtrtime"	), 400	);	if (!rc_get_entry(rc_getty_c, "initnumber"))	{		log_line(LOG_E, "Variable /"initnumber/" *must* be set!/n");				return(-1);	}	return(0);}
开发者ID:marschap,项目名称:isdn4k-utils,代码行数:52,


示例12: voice_set_header

static void voice_set_header(vaheader_t *header){	memset(header, 0, sizeof(vaheader_t));	xstrncpy(header->magic	 , VAH_MAGIC				, VAH_MAX_MAGIC	);	xstrncpy(header->name	 , setup.voice.name		, VAH_MAX_NAME		);	xstrncpy(header->callerid, setup.voice.callerid	, VAH_MAX_CALLERID);	xstrncpy(header->phone	 , setup.voice.phone		, VAH_MAX_PHONE	);	xstrncpy(header->location, "*** Unknown ***"		, VAH_MAX_LOCATION);	header->time			= htonl(time(NULL));	header->compression	= htonl(setup.modem.compression);}
开发者ID:marschap,项目名称:isdn4k-utils,代码行数:13,


示例13: log_lastlog

static void log_lastlog(struct login_context *cxt){	struct lastlog ll;	time_t t;	int fd;	if (!cxt->pwd)		return;	fd = open(_PATH_LASTLOG, O_RDWR, 0);	if (fd < 0)		return;	if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1)		goto done;	/*	 * Print last log message	 */	if (!cxt->quiet) {		if (read(fd, (char *)&ll, sizeof(ll)) == sizeof(ll) &&							ll.ll_time != 0) {			time_t ll_time = (time_t) ll.ll_time;			printf(_("Last login: %.*s "), 24 - 5, ctime(&ll_time));			if (*ll.ll_host != '/0')				printf(_("from %.*s/n"),				       (int)sizeof(ll.ll_host), ll.ll_host);			else				printf(_("on %.*s/n"),				       (int)sizeof(ll.ll_line), ll.ll_line);		}		if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1)			goto done;	}	memset((char *)&ll, 0, sizeof(ll));	time(&t);	ll.ll_time = t;		/* ll_time is always 32bit */	if (cxt->tty_name)		xstrncpy(ll.ll_line, cxt->tty_name, sizeof(ll.ll_line));	if (cxt->hostname)		xstrncpy(ll.ll_host, cxt->hostname, sizeof(ll.ll_host));	if (write_all(fd, (char *)&ll, sizeof(ll)))		warn(_("write lastlog failed"));done:	close(fd);}
开发者ID:Yowiee,项目名称:util-linux,代码行数:51,


示例14: main

int main(int argc, char *argv[]){	setlocale(LC_ALL, "");	bindtextdomain(PACKAGE, LOCALEDIR);	textdomain(PACKAGE);	atexit(close_stdout);	if (!strcmp(program_invocation_short_name, "vigr")) {		program = VIGR;		xstrncpy(orig_file, GROUP_FILE, sizeof(orig_file));	} else {		program = VIPW;		xstrncpy(orig_file, PASSWD_FILE, sizeof(orig_file));	}	if (1 < argc) {		if (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) {			printf(UTIL_LINUX_VERSION);			exit(EXIT_SUCCESS);		}		if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))			usage(stdout);		usage(stderr);	}	edit_file(0);	if (program == VIGR) {		strncpy(orig_file, SGROUP_FILE, FILENAMELEN - 1);	} else {		strncpy(orig_file, SHADOW_FILE, FILENAMELEN - 1);	}	if (access(orig_file, F_OK) == 0) {		char response[80];		printf((program == VIGR)		       ? _("You are using shadow groups on this system./n")		       : _("You are using shadow passwords on this system./n"));		/* TRANSLATORS: this program uses for y and n rpmatch(3),		 * which means they can be translated. */		printf(_("Would you like to edit %s now [y/n]? "), orig_file);		if (fgets(response, sizeof(response), stdin)) {			if (rpmatch(response) == RPMATCH_YES)				edit_file(1);		}	}	exit(EXIT_SUCCESS);}
开发者ID:hallyn,项目名称:util-linux,代码行数:50,


示例15: verify_browser

/* Given a user agent, determine the browser used. * * ###NOTE: The size of the list is proportional to the run time, * which makes this pretty slow * * On error, NULL is returned. * On success, a malloc'd  string containing the browser is returned. */char *verify_browser (char *str, char *type){  char *a, *b, *ptr, *slash;  size_t i;  if (str == NULL || *str == '/0')    return NULL;  for (i = 0; i < ARRAY_SIZE (browsers); i++) {    if ((a = strstr (str, browsers[i][0])) == NULL)      continue;    /* check if there is a space char in the token string, that way strpbrk     * does not stop at the first space within the token string */    if ((strchr (browsers[i][0], ' ')) != NULL && (b = strchr (a, ' ')) != NULL)      b++;    else      b = a;    xstrncpy (type, browsers[i][1], BROWSER_TYPE_LEN);    /* Internet Explorer 11 */    if (strstr (a, "rv:11") && strstr (a, "Trident/7.0")) {      return alloc_string ("MSIE/11.0");    }    /* Opera +15 uses OPR/# */    if (strstr (a, "OPR") != NULL && (slash = strrchr (a, '/'))) {      return parse_opera (slash);    }    /* Opera has the version number at the end */    if (strstr (a, "Opera") && (slash = strrchr (a, '/')) && a < slash) {      memmove (a + 5, slash, strlen (slash) + 1);    }    /* IE Old */    if (strstr (a, "MSIE") != NULL) {      if ((ptr = strpbrk (a, ";)-")) != NULL)        *ptr = '/0';      a = char_replace (a, ' ', '/');    }    /* all others */    else if ((ptr = strpbrk (b, ";) ")) != NULL) {      *ptr = '/0';    }    return alloc_string (a);  }  xstrncpy (type, "Unknown", BROWSER_TYPE_LEN);  return alloc_string ("Unknown");}
开发者ID:maniacs-ops,项目名称:goaccess,代码行数:57,


示例16: parse_date3

static struct tm *parse_date3(const char *str){    /* Wed Jun  9 01:29:59 1993 GMT */    static struct tm tm;    char *s;    static char buf[128];    while (*str && *str == ' ')	str++;    xstrncpy(buf, str, 128);    if (NULL == (s = strtok(buf, w_space)))	return NULL;    if (NULL == (s = strtok(NULL, w_space)))	return NULL;    tm.tm_mon = make_month(s);    if (NULL == (s = strtok(NULL, w_space)))	return NULL;    tm.tm_mday = atoi(s);    if (NULL == (s = strtok(NULL, ":")))	return NULL;    tm.tm_hour = atoi(s);    if (NULL == (s = strtok(NULL, ":")))	return NULL;    tm.tm_min = atoi(s);    if (NULL == (s = strtok(NULL, w_space)))	return NULL;    tm.tm_sec = atoi(s);    if (NULL == (s = strtok(NULL, w_space)))	return NULL;    /* Y2K fix, [email
C++ xstrndup函数代码示例
C++ xstrlen函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。