예제 #1
0
int
main(int argc, char *argv[])
{
	time_t rawtime;
	struct tm *timeinfo;
	char ftime[64];

	time(&rawtime);
	timeinfo = localtime(&rawtime);
	ascftime(ftime, "%m/%d/%Y %H/%M/%S", timeinfo);
	printf(ftime);
	printf("\n");
	return (0);
}
예제 #2
0
static int sftp_list_file(ssh_session session,char *remote_dir,char *remote_file)
{
	sftp_attributes file;
	char datex[22];
	char mtemp[1024];
	time_t mtime=0;
#ifdef WIN32
	struct tm *mytime=NULL;
	int x=0;
#endif
	sftp_session sftp=sftp_new(session);

	if(!sftp)
	{
		prterr("sftp error initialising channel: %s\n",ssh_get_error(session));
		return(1);
	}
	if(sftp_init(sftp))
	{
        	prterr("error initializing sftp: %s\n",ssh_get_error(session));
		return(1);
	}
	
	memset(datex,0,22);
	memset(mtemp,0,1024);
	if(isEMPTY(remote_dir) || !RDAstrcmp(remote_dir,"\"\""))
	{
		sprintf(mtemp,"%s",remote_file);
	} else {
		sprintf(mtemp,"%s/%s",remote_dir,remote_file);
	}
	file=sftp_stat(sftp,mtemp);
	if(file==NULL)
	{
		/* when file=NULL, an error has occured OR the directory listing is end of file */
		prterr("Error getting file info for [%s]",mtemp);
		sftp_free(sftp);
		return(1);
	}else{
	

#ifndef WIN32
#ifdef _POSIX_SOURCE
		mtime=file->mtime;
		//strftime(datex,22,"%b %d %Y %l:%M %p",localtime(&file->mtime));
		strftime(datex,22,"%b %d %Y %l:%M %p",localtime(&mtime));
#else
		TRACE;
		ascftime(datex,"%b %d %Y %l:%M %p",localtime(&file->mtime));
#endif /* _POSIX_SOURCE */
#else /* WIN32 */
		TRACE;
		mytime=localctime(&file->mtime);
		x=mytime->tm_year;
		while(x>=200) x-=100;
		sprintf(datex,"%02d/%02d/%04d  ",mytime->tm_mon+1,mytime->tm_mday,1900+my_time->tm_year);
#endif
		fprintf(stdout,"%s\t\t%llu\t\t%s\r\n",remote_file,(long long unsigned int) file->size,datex);

		if(diagapps)
		{
		prterr("\"%30s\"(%.8o) : %s(%.5d) %s(%.5d) : %.10llu bytes  %.10llu\n",
			file->name,
			file->permissions,
			file->owner,
			file->uid,
			file->group,
			file->gid,
			(long long unsigned int) file->size,
			(long long unsigned int) file->mtime);
		}
		sftp_attributes_free(file);
	}
	sftp_free(sftp);
	return(0);
}
예제 #3
0
static void do_sftp(ssh_session session)
{
	sftp_session sftp=sftp_new(session);
	sftp_dir dir;
	sftp_attributes file;
	char datex[11];
	time_t atime=0;
#ifdef WIN32
	struct tm *mytime=NULL;
	int x=0;
#endif

	if(!sftp)
	{
		prterr("sftp error initialising channel: %s\n",ssh_get_error(session));
		return;
	}
	if(sftp_init(sftp))
	{
        	prterr("error initializing sftp: %s\n",ssh_get_error(session));
		return;
	}
	dir=sftp_opendir(sftp,docfolder);
	if(!dir) 
	{
		prterr("Directory not opened(%s)\n", ssh_get_error(session));
		return;
	}
/* reading the whole directory, file by file */
	while((file=sftp_readdir(sftp,dir)))
	{
		if(strncmp(file->name,".",1))
		{
			if(details==FALSE)
			{
				fprintf(stdout,"%s\r\n",file->name);
			} else {
#ifndef WIN32
#ifdef _POSIX_SOURCE
				atime=file->atime;
				strftime(datex,11,"%m/%d/%Y",localtime(&atime));
#else
				ascftime(datex,"%m/%d/%Y",localtime(&file->atime));
#endif /* _POSIX_SOURCE */
#else /* WIN32 */
				mytime=localctime(&file->atime);
				x=mytime->tm_year;
				while(x>=200) x-=100;
				sprintf(datex,"%02d/%02d/%04d",mytime->tm_mon+1,mytime->tm_mday,1900+my_time->tm_year);
#endif
				fprintf(stdout,"%s\t%llu\t%s\r\n",file->name,(long long unsigned int) file->size,datex);
			}
		}
		if(diagapps)
		{
		prterr("%30s(%.8o) : %s(%.5d) %s(%.5d) : %.10llu bytes\n",
			file->name,
			file->permissions,
			file->owner,
			file->uid,
			file->group,
			file->gid,
			(long long unsigned int) file->size);
		}
		sftp_attributes_free(file);
	}
/* when file=NULL, an error has occured OR the directory listing is end of file */
	if(!sftp_dir_eof(dir))
	{
		prterr("Error: %s\n", ssh_get_error(session));
		return;
	}
	if(sftp_closedir(dir))
	{
		prterr("Error: %s\n", ssh_get_error(session));
		return;
	}
	sftp_free(sftp);
}
예제 #4
0
파일: occcgl.cpp 프로젝트: DTidd/OpenRDAAPI
int main(int argc,char **argv)
#endif
{
	time_t ltime;
	RDArsrc *mainrsrc=NULL;
	int fromnum=1,tonum=3000;
	char zfill=TRUE;
        int x,nofields=0;
        char *name=NULL;
        NRDfield *fldx=NULL,*fields=NULL;
        short edit_rsrc=TRUE;
	int z=0,curyear=0;
	char *curyearstr=NULL;
/*
	char *lic_format=NULL;
	int no_lic=0;
*/

	if(InitializeSubsystems(argc,argv,module,
		"CREATE OCCTAX GROUP LICENSE NUMBERS")) 
	{
		RDAAPPMAINLOOP();
		return;
	}
	if((occglic=APPOPNNRD(module,"OCCGLIC",TRUE,TRUE))==(-1)) return;
	if((occyear=APPOPNNRD(module,"OCCYEAR",TRUE,FALSE))==(-1)) return;
	if((occgrp=APPOPNNRD(module,"OCCGRP",TRUE,FALSE))==(-1)) return;
	LOCNRDFILE(occglic);	
	LOCNRDFILE(occgrp);	
	mainrsrc=RDArsrcNEW(module,"CREATE OCCTAX GROUP LICENSE NUMBERS");
	nofields=NUMFLDS(occglic);
	fields=FLDPOINTER(occglic);
	if(fields!=NULL)
	{
		for(x=0,fldx=fields;x<nofields;++x,++fldx)
		{
			if(!RDAstrcmp(fldx->name,"CHARGE YEAR"))
			{
				edit_rsrc=TRUE;
				if(FIELDscrn(occglic,fldx->name,&edit_rsrc))
				{
					year_len=fldx->len;
					yearsavl=makeyears(yearsavl,fldx->len);
					curyearstr=Rmalloc(5);
					time(&ltime);
#ifndef WIN32
#ifdef _POSIX_SOURCE
					strftime(curyearstr,5,"%Y",localtime(&ltime));
#else
					ascftime(curyearstr,"%Y",localtime(&ltime));
#endif
#endif
#ifdef WIN32
					strftime(curyearstr,5,"%Y",localtime(&ltime));
#endif
					curyear=FINDAPPLIBELEMENT(yearsavl,curyearstr);
					if(curyear==(-1))
					{
						curyear=0;
					}
					addlstrsrc(mainrsrc,"CHARGE YEARS",
						&curyear,
						TRUE,changeyears,yearsavl->numlibs,
						&yearsavl->libs,NULL);
				}
			} else if(!RDAstrcmp(fldx->name,"GROUP NUMBER"))
			{
				edit_rsrc=TRUE;
				if(FIELDscrn(occglic,fldx->name,&edit_rsrc))
				{
					if(grpsavl!=NULL)
					{
						freeapplib(grpsavl);
					}
					group_len=fldx->len;
					grpsavl=APPlibNEW();
					addAPPlib(grpsavl,"No Year Groups");
					addlstrsrc(mainrsrc,"GROUP NUMBERS",
						&z,TRUE,changegrps,grpsavl->numlibs,
						&grpsavl->libs,NULL);
				}
			} else {
/*
				nonlstmakefld(mainrsrc,paymstr,fldx,TRUE);
*/
			}
		}
	}
	if(name!=NULL) Rfree(name);
	grpsavl=makegrps(mainrsrc,grpsavl,group_len);
	FINDRSCLISTAPPlib(mainrsrc,"GROUP NUMBERS",0,grpsavl);
	if(curyearstr!=NULL) Rfree(curyearstr);

	addstdrsrc(mainrsrc,"PREFIX",VARIABLETEXT,15,NULL,TRUE);
	addstdrsrc(mainrsrc,"SUFFIX",VARIABLETEXT,15,NULL,TRUE);
	addstdrsrc(mainrsrc,"FROM NUMBER",LONGV,15,&fromnum,TRUE);
	addstdrsrc(mainrsrc,"TO NUMBER",LONGV,15,&tonum,TRUE);
	addstdrsrc(mainrsrc,"ZERO FILL",BOOLNS,1,&zfill,TRUE);
	addbtnrsrc(mainrsrc,"DEFAULTS",TRUE,SaveDefaults,NULL);
	addbtnrsrc(mainrsrc,"SELECT",TRUE,selectocccgl,NULL);
	addrfexrsrc(mainrsrc,"QUIT",TRUE,quitocccgl,NULL);
	addbtnrsrc(mainrsrc,"HELP",TRUE,screenhelp,NULL);
	addbtnrsrc(mainrsrc,"PRINT RESOURCES",TRUE,printrsrcs,NULL);
	DefaultScreens(mainrsrc);

	APPmakescrn(mainrsrc,FALSE,quitocccgl,NULL,TRUE);

	changeyears(mainrsrc);
/*
	FINDFLDGETINT(occgrp,"NEXT LICENSE NUMBER",&fromnum);
	FINDFLDGETINT(occgrp,"NUMBER OF LICENSES",&no_lic);
	FINDFLDGETSTRING(occgrp,"LICENSE NUMBER FORMAT",&lic_format);
	tonum=fromnum+no_lic;
	FINDRSCSETSTRING(mainrsrc,"PREFIX",lic_format);
	FINDRSCSETINT(mainrsrc,"FROM NUMBER",fromnum);
	FINDRSCSETINT(mainrsrc,"TO NUMBER",tonum);
	if(lic_format!=NULL) Rfree(lic_format);
	updateallrsrc(mainrsrc);
*/

	RDAAPPMAINLOOP();
}