当前位置: 首页>>代码示例>>C++>>正文


C++ SAFECOPY函数代码示例

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


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

示例1: findstr_in_string

BOOL DLLCALL findstr_in_string(const char* insearchof, char* string)
{
	char*	p;
	char	str[256];
	char	search[81];
	int		c;
	int		i;
	BOOL	found=FALSE;

	if(string==NULL || insearchof==NULL)
		return(FALSE);

	SAFECOPY(search,insearchof);
	strupr(search);
	SAFECOPY(str,string);

	p=str;	
	SKIP_WHITESPACE(p);

	if(*p==';')		/* comment */
		return(FALSE);

	if(*p=='!')	{	/* !match */
		found=TRUE;
		p++;
	}

	truncsp(p);
	c=strlen(p);
	if(c) {
		c--;
		strupr(p);
		if(p[c]=='~') {
			p[c]=0;
			if(strstr(search,p))
				found=!found; 
		}

		else if(p[c]=='^' || p[c]=='*') {
			p[c]=0;
			if(!strncmp(p,search,c))
				found=!found; 
		}

		else if(p[0]=='*') {
			i=strlen(search);
			if(i<c)
				return(found);
			if(!strncmp(p+1,search+(i-c),c))
				found=!found; 
		}

		else if(!strcmp(p,search))
			found=!found; 
	} 
	return(found);
}
开发者ID:kindy,项目名称:synchronet-bbs-1,代码行数:57,代码来源:str_util.c

示例2: md

BOOL md(char *inpath)
{
	DIR*	dir;
	char	path[MAX_PATH+1];

	if(inpath[0]==0)
		return(FALSE);

	SAFECOPY(path,inpath);

	/* Remove trailing '.' if present */
	if(path[strlen(path)-1]=='.')
		path[strlen(path)-1]=0;

	/* Remove trailing slash if present */
	if(path[strlen(path)-1]=='\\' || path[strlen(path)-1]=='/')
		path[strlen(path)-1]=0;

	dir=opendir(path);
	if(dir==NULL) {
		/* lprintf("Creating directory: %s",path); */
		if(MKDIR(path)) {
			lprintf(LOG_WARNING,"!ERROR %d creating directory: %s",errno,path);
			return(FALSE); 
		} 
	}
	else
		closedir(dir);
	
	return(TRUE);
}
开发者ID:K6BSD,项目名称:SBBSUnstable,代码行数:31,代码来源:load_cfg.c

示例3: js_PrepareToExecute

void DLLCALL js_PrepareToExecute(JSContext *cx, JSObject *obj, const char *filename, const char* startup_dir)
{
	JSString*	str;
	jsval		val;

	if(JS_GetProperty(cx, obj, "js", &val) && JSVAL_IS_OBJECT(val)) {
		JSObject* js = JSVAL_TO_OBJECT(val);
		char	dir[MAX_PATH+1];

		if(filename!=NULL) {
			char* p;

			if((str=JS_NewStringCopyZ(cx, filename)) != NULL)
				JS_DefineProperty(cx, js, "exec_path", STRING_TO_JSVAL(str)
					,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY);
			if((str=JS_NewStringCopyZ(cx, getfname(filename))) != NULL)
				JS_DefineProperty(cx, js, "exec_file", STRING_TO_JSVAL(str)
					,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY);
			SAFECOPY(dir,filename);
			p=getfname(dir);
			*p=0;
			if((str=JS_NewStringCopyZ(cx, dir)) != NULL)
				JS_DefineProperty(cx, js, "exec_dir", STRING_TO_JSVAL(str)
					,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY);
		}
		if(startup_dir==NULL)
			startup_dir="";
		if((str=JS_NewStringCopyZ(cx, startup_dir)) != NULL)
			JS_DefineProperty(cx, js, "startup_dir", STRING_TO_JSVAL(str)
				,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY);
	}
#if defined(_MSC_VER)
	_set_invalid_parameter_handler(msvc_invalid_parameter_handler);
#endif
}
开发者ID:mattzorzin,项目名称:synchronet,代码行数:35,代码来源:js_internal.c

示例4: getdirsize

long DLLCALL getdirsize(const char* path, BOOL include_subdirs, BOOL subdir_only)
{
	char		match[MAX_PATH+1];
	glob_t		g;
	unsigned	gi;
	long		count=0;

	if(!isdir(path))
		return -1;

	SAFECOPY(match,path);
	backslash(match);
	strcat(match,ALLFILES);
	glob(match,GLOB_MARK,NULL,&g);
	if(include_subdirs && !subdir_only)
		count=g.gl_pathc;
	else
		for(gi=0;gi<g.gl_pathc;gi++) {
			if(*lastchar(g.gl_pathv[gi])=='/') {
				if(!include_subdirs)
					continue;
			} else
				if(subdir_only)
					continue;
			count++;
		}
	globfree(&g);
	return(count);
}
开发者ID:donfanning,项目名称:syncterm,代码行数:29,代码来源:dirwrap.c

示例5: isdir

BOOL DLLCALL isdir(const char *filename)
{
	char	path[MAX_PATH+1];
	char*	p;
	struct stat st;

	SAFECOPY(path,filename);

	p=lastchar(path);
	if(p!=path && IS_PATH_DELIM(*p)) {	/* chop off trailing slash */
#if !defined(__unix__)
		if(*(p-1)!=':')		/* Don't change C:\ to C: */
#endif
			*p=0;
	}

#if defined(__BORLANDC__) && !defined(__unix__)	/* stat() doesn't work right */
	if(stat(path, &st)!=0 || strchr(path,'*')!=NULL || strchr(path,'?')!=NULL)
#else
	if(stat(path, &st)!=0)
#endif
		return(FALSE);

	return(S_ISDIR(st.st_mode) ? TRUE : FALSE);
}
开发者ID:donfanning,项目名称:syncterm,代码行数:25,代码来源:dirwrap.c

示例6: WinMain

//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR cmd, int)
{
    memset(SpyForms,0,sizeof(SpyForms));
    try
    {
        Application->Initialize();
        Application->Title = "Synchronet Control Panel";
		Application->CreateForm(__classid(TMainForm), &MainForm);
         Application->CreateForm(__classid(TTelnetForm), &TelnetForm);
         Application->CreateForm(__classid(TFtpForm), &FtpForm);
         Application->CreateForm(__classid(TWebForm), &WebForm);
         Application->CreateForm(__classid(TMailForm), &MailForm);
         Application->CreateForm(__classid(TNodeForm), &NodeForm);
         Application->CreateForm(__classid(TStatsForm), &StatsForm);
         Application->CreateForm(__classid(TClientForm), &ClientForm);
         Application->CreateForm(__classid(TUserListForm), &UserListForm);
         Application->CreateForm(__classid(TEventsForm), &EventsForm);
         Application->CreateForm(__classid(TServicesForm), &ServicesForm);
         Application->CreateForm(__classid(TLoginAttemptsForm), &LoginAttemptsForm);
         if(cmd[0] && isdir(cmd))
            SAFECOPY(MainForm->global.ctrl_dir,cmd);
         sbbs_get_ini_fname(MainForm->ini_file, MainForm->global.ctrl_dir, NULL /* auto-hostname */);
		Application->Run();
    }
    catch (Exception &exception)
    {
             Application->ShowException(&exception);
    }
    return 0;
}
开发者ID:kindy,项目名称:synchronet-bbs-1,代码行数:31,代码来源:sbbsctrl.cpp

示例7: removefiledat

BOOL DLLCALL removefiledat(scfg_t* cfg, file_t* f)
{
	char	c,str[MAX_PATH+1],ixbname[12],*ixbbuf,fname[13];
    int		i,file;
	long	l,length;

	SAFECOPY(fname,f->name);
	for(i=8;i<12;i++)   /* Turn FILENAME.EXT into FILENAMEEXT */
		fname[i]=fname[i+1];
	SAFEPRINTF2(str,"%s%s.ixb",cfg->dir[f->dir]->data_dir,cfg->dir[f->dir]->code);
	if((file=sopen(str,O_RDONLY|O_BINARY,SH_DENYWR))==-1) {
		return(FALSE); 
	}
	length=(long)filelength(file);
	if(!length) {
		close(file);
		return(FALSE); 
	}
	if((ixbbuf=(char *)malloc(length))==0) {
		close(file);
		return(FALSE); 
	}
	if(lread(file,ixbbuf,length)!=length) {
		close(file);
		free((char *)ixbbuf);
		return(FALSE); 
	}
	close(file);
	if((file=sopen(str,O_WRONLY|O_TRUNC|O_BINARY,SH_DENYRW))==-1) {
		return(FALSE); 
	}
	for(l=0;l<length;l+=F_IXBSIZE) {
		for(i=0;i<11;i++)
			ixbname[i]=ixbbuf[l+i];
		ixbname[i]=0;
		if(stricmp(ixbname,fname))
			if(lwrite(file,&ixbbuf[l],F_IXBSIZE)!=F_IXBSIZE) {
				close(file);
				free((char *)ixbbuf);
				return(FALSE); 
		} 
	}
	free((char *)ixbbuf);
	close(file);
	SAFEPRINTF2(str,"%s%s.dat",cfg->dir[f->dir]->data_dir,cfg->dir[f->dir]->code);
	if((file=sopen(str,O_WRONLY|O_BINARY,SH_DENYRW))==-1) {
		return(FALSE); 
	}
	lseek(file,f->datoffset,SEEK_SET);
	c=ETX;          /* If first char of record is ETX, record is unused */
	if(write(file,&c,1)!=1) { /* So write a D_T on the first byte of the record */
		close(file);
		return(FALSE); 
	}
	close(file);
	if(f->dir==cfg->user_dir)  /* remove file from index */
		rmuserxfers(cfg,0,0,f->name);
	return(TRUE);
}
开发者ID:K6BSD,项目名称:SBBSUnstable,代码行数:59,代码来源:filedat.c

示例8: x_settitle

void x_settitle(const char *title)
{
	struct x11_local_event ev;

	ev.type=X11_LOCAL_SETTITLE;
	SAFECOPY(ev.data.title, title);
	while(write(local_pipe[1], &ev, sizeof(ev))==-1);
}
开发者ID:K6BSD,项目名称:SBBSUnstable,代码行数:8,代码来源:x_cio.c

示例9: x_setname

void x_setname(const char *name)
{
	struct x11_local_event ev;

	ev.type=X11_LOCAL_SETNAME;
	SAFECOPY(ev.data.name, name);
	while(write(local_pipe[1], &ev, sizeof(ev))==-1);
}
开发者ID:K6BSD,项目名称:SBBSUnstable,代码行数:8,代码来源:x_cio.c

示例10: glob

int	DLLCALL	glob(const char *pattern, int flags, void* unused, glob_t* glob)
{
    struct	_finddata_t ff;
	long	ff_handle;
	size_t	found=0;
	char	path[MAX_PATH+1];
	char*	p;
	char**	new_pathv;

	if(!(flags&GLOB_APPEND)) {
		glob->gl_pathc=0;
		glob->gl_pathv=NULL;
	}

	ff_handle=_findfirst((char*)pattern,&ff);
	while(ff_handle!=-1) {
		if((flags&GLOB_PERIOD || (ff.name[0]!='.' && !(ff.attrib&_A_HIDDEN))) &&
			(!(flags&GLOB_ONLYDIR) || ff.attrib&_A_SUBDIR)) {
			if((new_pathv=(char**)realloc(glob->gl_pathv
				,(glob->gl_pathc+1)*sizeof(char*)))==NULL) {
				globfree(glob);
				return(GLOB_NOSPACE);
			}
			glob->gl_pathv=new_pathv;

			/* build the full pathname */
			SAFECOPY(path,pattern);
			p=getfname(path);
			*p=0;
			strcat(path,ff.name);

			if((glob->gl_pathv[glob->gl_pathc]=(char*)malloc(strlen(path)+2))==NULL) {
				globfree(glob);
				return(GLOB_NOSPACE);
			}
			strcpy(glob->gl_pathv[glob->gl_pathc],path);
			if(flags&GLOB_MARK && ff.attrib&_A_SUBDIR)
				strcat(glob->gl_pathv[glob->gl_pathc],"/");

			glob->gl_pathc++;
			found++;
		}
		if(_findnext(ff_handle, &ff)!=0) {
			_findclose(ff_handle);
			ff_handle=-1;
		}
	}

	if(found==0)
		return(GLOB_NOMATCH);

	if(!(flags&GLOB_NOSORT)) {
		qsort(glob->gl_pathv,found,sizeof(char*),glob_compare);
	}

	return(0);	/* success */
}
开发者ID:donfanning,项目名称:syncterm,代码行数:57,代码来源:dirwrap.c

示例11: getfilepath

void sbbs_t::fileinfo(file_t* f)
{
	char	ext[513];
	char 	tmp[512];
	char	path[MAX_PATH+1];
	char	fpath[MAX_PATH+1];
	uint	i,j;

	for(i=0;i<usrlibs;i++)
		if(usrlib[i]==cfg.dir[f->dir]->lib)
			break;
	for(j=0;j<usrdirs[i];j++)
		if(usrdir[i][j]==f->dir)
			break;

	getfilepath(&cfg,f,path);
	bprintf(text[FiLib],i+1,cfg.lib[cfg.dir[f->dir]->lib]->lname);
	bprintf(text[FiDir],j+1,cfg.dir[f->dir]->lname);
	bprintf(text[FiFilename],getfname(path));
	SAFECOPY(fpath,path);
	fexistcase(fpath);
	if(strcmp(path,fpath) && strcmp(f->desc,getfname(fpath)))	/* Different "actual" filename */
		bprintf(text[FiFilename],getfname(fpath));

	if(f->size!=-1L)
		bprintf(text[FiFileSize],ultoac(f->size,tmp));
	bprintf(text[FiCredits]
		,(cfg.dir[f->dir]->misc&DIR_FREE || !f->cdt) ? "FREE" : ultoac(f->cdt,tmp));
	bprintf(text[FiDescription],f->desc);
	bprintf(text[FiUploadedBy],f->misc&FM_ANON ? text[UNKNOWN_USER] : f->uler);
	if(f->date)
		bprintf(text[FiFileDate],timestr(&f->date));
	bprintf(text[FiDateUled],timestr(&f->dateuled));
	bprintf(text[FiDateDled],f->datedled ? timestr(&f->datedled) : "Never");
	bprintf(text[FiTimesDled],f->timesdled);
	if(f->size!=-1L)
		bprintf(text[FiTransferTime],sectostr(f->timetodl,tmp));
	if(f->altpath) {
		if(f->altpath<=cfg.altpaths) {
			if(SYSOP)
				bprintf(text[FiAlternatePath],cfg.altpath[f->altpath-1]); 
		}
		else
			bprintf(text[InvalidAlternatePathN],f->altpath); 
	}
	CRLF;
	if(f->misc&FM_EXTDESC) {
		getextdesc(&cfg,f->dir,f->datoffset,ext);
		CRLF;
		putmsg(ext,P_NOATCODES);
		CRLF; }
	if(f->size==-1L)
		bprintf(text[FileIsNotOnline],f->name);
	if(f->opencount)
		bprintf(text[FileIsOpen],f->opencount,f->opencount>1 ? "s" : nulstr);

}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:57,代码来源:file.cpp

示例12: return

int sbbs_t::bulkmailhdr(smb_t* smb, smbmsg_t* msg, uint usernum)
{
    char		str[256];
    int			i,j;
	ushort		nettype=NET_UNKNOWN;
    node_t		node;
	user_t		user;
	smbmsg_t	newmsg;

	user.number=usernum;
	if(getuserdat(&cfg, &user)!=0)
		return(0);

	if((i=smb_copymsgmem(NULL,&newmsg,msg))!=SMB_SUCCESS)
		return(i);

	SAFECOPY(str,user.alias);
	smb_hfield_str(&newmsg,RECIPIENT,str);

	if(cfg.sys_misc&SM_FWDTONET && user.misc&NETMAIL && user.netmail[0]) {
		bprintf(text[UserNetMail],user.netmail);
		smb_hfield_netaddr(&newmsg,RECIPIENTNETADDR,user.netmail,&nettype);
		smb_hfield_bin(&newmsg,RECIPIENTNETTYPE,nettype);
	} else {
		sprintf(str,"%u",usernum);
		smb_hfield_str(&newmsg,RECIPIENTEXT,str);
	}

	j=smb_addmsghdr(smb,&newmsg,SMB_SELFPACK);
	smb_freemsgmem(&newmsg);
	if(j!=SMB_SUCCESS)
		return(j);

	lncntr=0;
	bprintf(text[Emailing],user.alias,usernum);
	sprintf(str,"%s bulk-mailed %s #%d"
		,useron.alias,user.alias,usernum);
	logline("E+",str);
	useron.emails++;
	logon_emails++;
	useron.etoday++;
	for(i=1;i<=cfg.sys_nodes;i++) { /* Tell user, if online */
		getnodedat(i,&node,0);
		if(node.useron==usernum && !(node.misc&NODE_POFF)
			&& (node.status==NODE_INUSE || node.status==NODE_QUIET)) {
			sprintf(str,text[EmailNodeMsg],cfg.node_num,useron.alias);
			putnmsg(&cfg,i,str);
			break; 
		} 
	}
	if(i>cfg.sys_nodes) {   /* User wasn't online, so leave short msg */
		sprintf(str,text[UserSentYouMail],useron.alias);
		putsmsg(&cfg,usernum,str); 
	}
	return(0);
}
开发者ID:kindy,项目名称:synchronet-bbs-1,代码行数:56,代码来源:bulkmail.cpp

示例13: SAFECOPY

void sbbs_t::center(char *instr)
{
	char str[256];
	int i,j;

	SAFECOPY(str,instr);
	truncsp(str);
	j=bstrlen(str);
	for(i=0;i<(cols-j)/2;i++)
		outchar(' ');
	bputs(str);
	CRLF;
}
开发者ID:kindy,项目名称:synchronet-bbs-1,代码行数:13,代码来源:con_out.cpp

示例14: parse_ini

void parse_ini(char* program)
{
	char section[MAX_PATH+1];

	if(ini==NULL)	/* no initialization file */
		return;

	/* Read the root section of the sbbsexec.ini file */
	log_level=iniGetLogLevel(ini,program,"LogLevel",log_level);
	if(iniGetBool(ini,program,"Debug",FALSE))
		log_level=LOG_DEBUG;
	yield_interval=iniGetFloat(ini,program,"YieldInterval",yield_interval);
	hangup_supported=iniGetBool(ini,program,"CanDisconnect",hangup_supported);

	lprintf(LOG_INFO,"Parsed %s section of %s"
		,program==ROOT_SECTION ? "root" : program
		,ini_fname);

	/* [UART] section */
	if(program==ROOT_SECTION)
		SAFECOPY(section,"UART");
	else
		SAFEPRINTF(section,"%s.UART",program);

	virtualize_uart=iniGetBool(ini,section,"Virtualize",virtualize_uart);
	switch(iniGetInteger(ini,section,"ComPort",0)) {
		case 1:	/* COM1 */
			uart_irq		=UART_COM1_IRQ;
			uart_io_base	=UART_COM1_IO_BASE;
			break;
		case 2:	/* COM2 */
			uart_irq		=UART_COM2_IRQ;
			uart_io_base	=UART_COM2_IO_BASE;
			break;
		case 3:	/* COM3 */
			uart_irq		=UART_COM3_IRQ;
			uart_io_base	=UART_COM3_IO_BASE;
			break;
		case 4:	/* COM4 */
			uart_irq		=UART_COM4_IRQ;
			uart_io_base	=UART_COM4_IO_BASE;
			break;
	}
	uart_irq=(BYTE)iniGetShortInt(ini,section,"IRQ",uart_irq);
	uart_io_base=iniGetShortInt(ini,section,"Address",uart_io_base);

	lprintf(LOG_INFO,"Parsed %s section of %s"
		,section
		,ini_fname);
}
开发者ID:kindy,项目名称:synchronet-bbs-1,代码行数:50,代码来源:sbbsexec.c

示例15: putfileixb

BOOL DLLCALL putfileixb(scfg_t* cfg, file_t* f)
{
	char	str[MAX_PATH+1],fname[13];
	uchar*	ixbbuf;
	int		file;
	long	l,length;

	SAFEPRINTF2(str,"%s%s.ixb",cfg->dir[f->dir]->data_dir,cfg->dir[f->dir]->code);
	if((file=sopen(str,O_RDWR|O_BINARY,SH_DENYRW))==-1) {
		return(FALSE); 
	}
	length=(long)filelength(file);
	if(length%F_IXBSIZE) {
		close(file);
		return(FALSE); 
	}
	if((ixbbuf=(uchar *)malloc(length))==NULL) {
		close(file);
		return(FALSE); 
	}
	if(lread(file,ixbbuf,length)!=length) {
		close(file);
		free(ixbbuf);
		return(FALSE); 
	}
	SAFECOPY(fname,f->name);
	for(l=8;l<12;l++)	/* Turn FILENAME.EXT into FILENAMEEXT */
		fname[l]=fname[l+1];
	for(l=0;l<length;l+=F_IXBSIZE) {
		SAFEPRINTF(str,"%11.11s",ixbbuf+l);
		if(!stricmp(str,fname))
			break; 
	}
	free(ixbbuf);

	if(l>=length) {
		close(file);
		return(FALSE); 
	}
	
	lseek(file,l+11+3,SEEK_SET);

	write(file,&f->dateuled,4);
	write(file,&f->datedled,4);

	close(file);

	return(TRUE);
}
开发者ID:K6BSD,项目名称:SBBSUnstable,代码行数:49,代码来源:filedat.c


注:本文中的SAFECOPY函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。