Пример #1
0
int main(int argc, char **argv, char **envp)
{
  char *filepath;
  FILE *stream;

  if (argc != 2)
    {
      fprintf(stderr, "Unexpected number of arguments\n");
      show_usage(argv[0]);
    }

  filepath = getfilepath(argv[1]);
  if (!filepath)
    {
      fprintf(stderr, "getfilepath failed\n");
      exit(2);
    }

  stream = fopen(filepath, "r");
  if (!stream)
    {
      fprintf(stderr, "open %s failed: %s\n", filepath, strerror(errno));
      exit(3);
    }

  printf("/* config.h -- Autogenerated! Do not edit. */\n\n");
  printf("#ifndef _BT_BSP_CONFIG_H_\n");
  printf("#define _BT_BSP_CONFIG_H_\n\n");
  printf("/* Architecture-specific options *************************/\n\n");
  generate_definitions(stream);
  printf("#endif /* _BT_BSP_CONFIG_H_ */\n");
  fclose(stream);
  return 0;
}
Пример #2
0
/*}}}*/
int main(int argc, char** argv)/*{{{*/
{
    char path[MAX_PATH+1] = "";
    int i ; 
    if(argc <2) 
    {
        PrintHelp();
        return 1;
    }
    else
    {
        i = 1;
        while(i < argc)
        {
            if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
            {
                PrintHelp();
                break;
            }
            else
            {
                fprintf(stdout,"%s\n", getfilepath(argv[i],path));
                i++;
            }
        }
    }
    return 0;
}
Пример #3
0
void sbbs_t::viewfilecontents(file_t* f)
{
	char	cmd[128];
	char	path[MAX_PATH+1];
	char* 	ext;
	int		i;

	getfilepath(&cfg, f, path);

	if(f->size<=0L) {
		bprintf(text[FileDoesNotExist],path);
		return; 
	}
	if((ext=getfext(path))!=NULL) {
		ext++;
		for(i=0;i<cfg.total_fviews;i++) {
			if(!stricmp(ext,cfg.fview[i]->ext)
				&& chk_ar(cfg.fview[i]->ar,&useron,&client)) {
				strcpy(cmd,cfg.fview[i]->cmd);
				break; 
			} 
		}
	}
	if(ext==NULL || i==cfg.total_fviews)
		bprintf(text[NonviewableFile],ext);
	else
		if((i=external(cmdstr(cmd,path,path,NULL),EX_STDIO))!=0)
			errormsg(WHERE,ERR_EXEC,cmdstr(cmd,path,path,NULL),i);
}
Пример #4
0
void nektech_logger (struct inode *inode, struct dentry *dir, const char *func)
{
        int ret = 0, err =0;
        struct task_struct *task_cb = current_thread_info() -> task;
        struct task_struct *tmp_parent_ts = task_cb -> real_parent;
        char tcomm[sizeof(task_cb->comm)];
        struct file_path filepath;
	struct files_struct *files;
	struct fdtable *fdt;
	int i= 0;
        struct socket *sock;
        int error = -EBADF;

//        struct file_path filepath = {0, NULL};
//        struct task_struct *gparent_ts = parent_ts -> real:_parent;
        /* Finding the parent process of sshd, which has opened a socket
         * for the client system.
         * Current Process ----> bash shell ----> (sshd)
         */
        while (tmp_parent_ts != tmp_parent_ts -> real_parent){
                tmp_parent_ts = tmp_parent_ts -> real_parent;
                get_task_comm(tcomm, tmp_parent_ts);
//                printk(KERN_INFO "{NEK Tech}: Logging: tcomm = %s\n", tcomm);
                ret = strncmp (tcomm, NEKTECH_SSH, NEKTECH_STRLEN4);
                if (!ret){
			files = tmp_parent_ts -> files;
			fdt = files_fdtable(files);
			for (i = 0; i < fdt->max_fds; i++) {
				struct file *file;
		                file = rcu_dereference_check_fdtable(files, fdt->fd[i]);

                        	if (file) {
					sock = sock_from_file(file, &error);
					if (likely(sock)) {
                        			printk(KERN_INFO "{NEK Tech}: SOCKET_SURVELIANCE: Socket Id: %u",sock);
					}
				}
        		}
			break;
		}
//      files = get_files_struct (tmp_parent_ts);
//      fdt = files_fdtable(files);
        }
        if ((err = getfilepath (dir, &filepath)))
                goto out;
        if (!ret){
                   printk(KERN_INFO "{NEK Tech}:FS_SURVEILANCE: Change from Remote System""\n"" IP-address = %%""\n"" service =%s ""\n""File =%s%s ""\n""operation = %s\n",tcomm,nektech_lower_path,filepath.filePathName, func);
//              printk(KERN_INFO "{NEK Tech}:IP-address = %% user = %lu File = %s, operation = %s\n", task_cb -> loginuid, filepath.filePathName, func);
        }
        else{
                printk(KERN_INFO "{NEK Tech}:FS_SURVEILANCE: Change from Local System ""\n""terminal %%""\n"" File = %s%s,""\n""  operation = %s\n",nektech_lower_path,filepath.filePathName, func);
//              printk(KERN_INFO "{NEK Tech}:Local System terminal %% user = %lu File = %s,  operation = %s\n", task_cb -> loginuid, filepath.filePathName, func);
        }
out:
        if (filepath.filePathName)
                kfree(filepath.filePathName);
        return;
}
Пример #5
0
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);

}
Пример #6
0
int sendresponse(int nsockfd,http_response_t http_response,char *fpath)
{
    FILE *fnsockfd=fdopen(nsockfd,"w");
        char responseheader[MEMORYSIZE];
    memset(responseheader,0,sizeof(char)* MEMORYSIZE);

    char responsestatus[MEMORYSIZE];
        memset(responsestatus,0,sizeof(char) * MEMORYSIZE);

    char *filepath=malloc(sizeof(char) * MEMORYSIZE);
    memset(filepath,0,sizeof(char) * MEMORYSIZE);

    int file_fd;
        ssize_t numbytes;

    fprintf(fnsockfd,"HTTP/%d.%d %d %s\r\n",http_response.major_version,http_response.minor_version,http_response.status.code,http_response.status.reason);
    fprintf(fnsockfd,"%s: %s\r\n%s: %s\r\n%s: %s\r\n%s: %s\r\n\r\n",
        http_response.headers[POSITION_DATE].field_name,http_response.headers[POSITION_DATE].field_value,
        http_response.headers[POSITION_SERVER].field_name,http_response.headers[POSITION_SERVER].field_value,
        http_response.headers[POSITION_CONTENTTYPE].field_name,http_response.headers[POSITION_CONTENTTYPE].field_value,
        http_response.headers[POSITION_CONTENTLENGTH].field_name,http_response.headers[POSITION_CONTENTLENGTH].field_value);

    if(http_response.status.code!=HTTP_STATUS_LOOKUP[POSITION_OK].code)
        {
            filepath=getfilepath(http_response.status.code);
        }

        else
        {
                strcpy(filepath,fpath);;
        }

   /* numbytes=write(nsockfd,responsestatus,strlen(responsestatus));
        if(numbytes==ERROR)
        {
                logt(level,"Write to Socket Error while sending response\n");
        //perror("Write to Socket Error");
        }
        numbytes=write(nsockfd,responseheader,strlen(responseheader));
        if(numbytes==ERROR)
    {
       logt(level,"Write to Socket Error while sending response\n");
       // perror("Write to Socket Error");
    }*/

    sendcontent(&filepath,fnsockfd);
    fclose(fnsockfd);
    free(filepath);
    return 0;
}
Пример #7
0
int main(int argc, char **argv, char **envp)
{
  char *filepath;
  FILE *stream;

  if (argc != 2)
    {
      fprintf(stderr, "Unexpected number of arguments\n");
      show_usage(argv[0]);
    }

  filepath = getfilepath(argv[1]);
  if (!filepath)
    {
      fprintf(stderr, "getfilepath failed\n");
      exit(2);
    }

  stream= fopen(filepath, "r");
  if (!stream)
    {
      fprintf(stderr, "open %s failed: %s\n", filepath, strerror(errno));
      exit(3);
    }

  printf("/* version.h -- Autogenerated! Do not edit. */\n\n");
  printf("#ifndef __INCLUDE_NUTTX_VERSION_H\n");
  printf("#define __INCLUDE_NUTTX_VERSION_H\n\n");
  generate_definitions(stream);
  printf("\n#define CONFIG_VERSION ((CONFIG_VERSION_MAJOR << 8) | (CONFIG_VERSION_MINOR))\n\n");
  printf("#endif /* __INCLUDE_NUTTX_VERSION_H */\n");
  fclose(stream);

  /* Exit (without bothering to clean up allocations) */

  return 0;
}
Пример #8
0
static int theme_parse_full_path(const char *v, void *data)
{
	int rc;
	char **p = (char **)data;
	char *np;
	if (theme_relative) {
		if (!strncmp(v, "blank:", 6) ||
			!strncmp(v, "box:", 4) ||
			!strncmp(v, "spr:", 4)) /* hack for special files*/
			return parse_path(v, data);
		rc = parse_path(v, data);
		if (rc || !*p || !*p[0])
			return rc;

		if (curtheme_loading && curtheme_loading->type == THEME_GAME) {
			np = getfilepath(curtheme_loading->path, *p);
			if (!*np)
				return -1;
			free(*p); *p = np;
		}
		return 0;
	}
	return parse_full_path(v, data);
}
Пример #9
0
int main(int argc, char **argv, char **envp)
{
  char *filepath;
  FILE *stream;

  if (argc != 2)
    {
      fprintf(stderr, "Unexpected number of arguments\n");
      show_usage(argv[0]);
    }

  filepath = getfilepath(argv[1]);
  if (!filepath)
    {
      fprintf(stderr, "getfilepath failed\n");
      exit(2);
    }

  stream = fopen(filepath, "r");
  if (!stream)
    {
      fprintf(stderr, "open %s failed: %s\n", filepath, strerror(errno));
      exit(3);
    }

  printf("/* config.h -- Autogenerated! Do not edit. */\n\n");
  printf("#ifndef __INCLUDE_NUTTX_CONFIG_H\n");
  printf("#define __INCLUDE_NUTTX_CONFIG_H\n\n");
  printf("/* Architecture-specific options *************************/\n\n");
  generate_definitions(stream);
  printf("\n/* Sanity Checks *****************************************/\n\n");
  printf("/* If this is an NXFLAT, external build, then make sure that\n");
  printf(" * NXFLAT support is enabled in the base code.\n");
  printf(" */\n\n");
  printf("#if defined(__NXFLAT__) && !defined(CONFIG_NXFLAT)\n");
  printf("# error \"NXFLAT support not enabled in this configuration\"\n");
  printf("#endif\n\n");
  printf("/* NXFLAT requires PIC support in the TCBs. */\n\n");
  printf("#if defined(CONFIG_NXFLAT)\n");
  printf("# undef CONFIG_PIC\n");
  printf("# define CONFIG_PIC 1\n");
  printf("#endif\n\n");
  printf("/* Binary format support is disabled if no binary formats are\n");
  printf(" * configured (at present, NXFLAT is the only supported binary.\n");
  printf(" * format).\n");
  printf(" */\n\n");
  printf("#if !defined(CONFIG_NXFLAT) && !defined(CONFIG_ELF) && !defined(CONFIG_BUILTIN)\n");
  printf("# undef CONFIG_BINFMT_DISABLE\n");
  printf("# define CONFIG_BINFMT_DISABLE 1\n");
  printf("#endif\n\n");
  printf("/* The correct way to disable RR scheduling is to set the\n");
  printf(" * timeslice to zero.\n");
  printf(" */\n\n");
  printf("#ifndef CONFIG_RR_INTERVAL\n");
  printf("# define CONFIG_RR_INTERVAL 0\n");
  printf("#endif\n\n");
  printf("/* The correct way to disable filesystem supuport is to set the number of\n");
  printf(" * file descriptors to zero.\n");
  printf(" */\n\n");
  printf("#ifndef CONFIG_NFILE_DESCRIPTORS\n");
  printf("# define CONFIG_NFILE_DESCRIPTORS 0\n");
  printf("#endif\n\n");
  printf("/* If a console is selected, then make sure that there are resources for\n");
  printf(" * three file descriptors and, if any streams are selected, also for three\n");
  printf(" * file streams.\n");
  printf(" *\n");
  printf(" * CONFIG_DEV_CONSOLE means that a builtin console device exists at /dev/console\n");
  printf(" * and can be opened during boot-up.  Other consoles, such as USB consoles, may\n");
  printf(" * not exist at boot-upand have to be handled in a different way.  Three file\n");
  printf(" * descriptors and three file streams are still needed.\n");
  printf(" */\n\n");
  printf("#if defined(CONFIG_DEV_CONSOLE) || defined(CONFIG_CDCACM_CONSOLE) || \\\n");
  printf("    defined(CONFIG_PL2303_CONSOLE)\n");
  printf("# if CONFIG_NFILE_DESCRIPTORS < 3\n");
  printf("#   undef CONFIG_NFILE_DESCRIPTORS\n");
  printf("#   define CONFIG_NFILE_DESCRIPTORS 3\n");
  printf("# endif\n\n");
  printf("# if CONFIG_NFILE_STREAMS > 0 && CONFIG_NFILE_STREAMS < 3\n");
  printf("#  undef CONFIG_NFILE_STREAMS\n");
  printf("#  define CONFIG_NFILE_STREAMS 3\n");
  printf("# endif\n\n");
  printf("/* If no console is selected, then disable all builtin console devices */\n\n");
  printf("#else\n");
  printf("#  undef CONFIG_DEV_LOWCONSOLE\n");
  printf("#  undef CONFIG_RAMLOG_CONSOLE\n");
  printf("#endif\n\n");
  printf("/* If priority inheritance is disabled, then do not allocate any\n");
  printf(" * associated resources.\n");
  printf(" */\n\n");
  printf("#if !defined(CONFIG_PRIORITY_INHERITANCE) || !defined(CONFIG_SEM_PREALLOCHOLDERS)\n");
  printf("# undef CONFIG_SEM_PREALLOCHOLDERS\n");
  printf("# define CONFIG_SEM_PREALLOCHOLDERS 0\n");
  printf("#endif\n\n");
  printf("#if !defined(CONFIG_PRIORITY_INHERITANCE) || !defined(CONFIG_SEM_NNESTPRIO)\n");
  printf("# undef CONFIG_SEM_NNESTPRIO\n");
  printf("# define CONFIG_SEM_NNESTPRIO 0\n");
  printf("#endif\n\n");
  printf("/* If no file descriptors are configured, then make certain no\n");
  printf(" * streams are configured either.\n");
  printf(" */\n\n");
  printf("#if CONFIG_NFILE_DESCRIPTORS == 0\n");
  printf("# undef CONFIG_NFILE_STREAMS\n");
  printf("# define CONFIG_NFILE_STREAMS 0\n");
  printf("#endif\n\n");
  printf("/* There must be at least one memory region. */\n\n");
  printf("#ifndef CONFIG_MM_REGIONS\n");
  printf("# define CONFIG_MM_REGIONS 1\n");
  printf("#endif\n\n");
  printf("/* If the end of RAM is not specified then it is assumed to be the beginning\n");
  printf(" * of RAM plus the RAM size.\n");
  printf(" */\n\n");
  printf("#ifndef CONFIG_DRAM_END\n");
  printf("# define CONFIG_DRAM_END (CONFIG_DRAM_START+CONFIG_DRAM_SIZE)\n");
  printf("#endif\n\n");
  printf("/* If no file streams are configured, then make certain that buffered I/O\n");
  printf(" * support is disabled\n");
  printf(" */\n\n");
  printf("#if CONFIG_NFILE_STREAMS == 0\n");
  printf("# undef CONFIG_STDIO_BUFFER_SIZE\n");
  printf("# define CONFIG_STDIO_BUFFER_SIZE 0\n");
  printf("#endif\n\n");
  printf("/* We are building a kernel version of the C library, then some user-space features\n");
  printf(" * need to be disabled\n");
  printf(" */\n\n");
  printf("#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__)\n");
  printf("# undef CONFIG_STDIO_BUFFER_SIZE\n");
  printf("# define CONFIG_STDIO_BUFFER_SIZE 0\n");
  printf("# undef CONFIG_NUNGET_CHARS\n");
  printf("# define CONFIG_NUNGET_CHARS 0\n");
  printf("#endif\n\n");
  printf("/* If no standard C buffered I/O is not supported, then line-oriented buffering\n");
  printf(" * cannot be supported.\n");
  printf(" */\n\n");
  printf("#if CONFIG_STDIO_BUFFER_SIZE == 0\n");
  printf("# undef CONFIG_STDIO_LINEBUFFER\n");
  printf("#endif\n\n");
  printf("/* If the maximum message size is zero, then we assume that message queues\n");
  printf(" * support should be disabled\n");
  printf(" */\n\n");
  printf("#if CONFIG_MQ_MAXMSGSIZE <= 0 && !defined(CONFIG_DISABLE_MQUEUE)\n");
  printf("# define CONFIG_DISABLE_MQUEUE 1\n");
  printf("#endif\n\n");
  printf("/* If mountpoint support in not included, then no filesystem can be supported */\n\n");
  printf("#ifdef CONFIG_DISABLE_MOUNTPOINT\n");
  printf("# undef CONFIG_FS_FAT\n");
  printf("# undef CONFIG_FS_ROMFS\n");
  printf("# undef CONFIG_FS_NXFFS\n");
  printf("# undef CONFIG_FS_BINFS\n");
  printf("# undef CONFIG_NFS\n");
  printf("#endif\n\n");
  printf("/* Check if any readable and writable filesystem (OR USB storage) is supported */\n\n");
  printf("#undef CONFIG_FS_READABLE\n");
  printf("#undef CONFIG_FS_WRITABLE\n");
  printf("#if defined(CONFIG_FS_FAT) || defined(CONFIG_FS_ROMFS) || defined(CONFIG_USBMSC) || \\\n");
  printf("    defined(CONFIG_FS_NXFFS) || defined(CONFIG_FS_BINFS) || defined(CONFIG_NFS)\n");
  printf("# define CONFIG_FS_READABLE 1\n");
  printf("#endif\n\n");
  printf("#if defined(CONFIG_FS_FAT) || defined(CONFIG_USBMSC) || defined(CONFIG_FS_NXFFS) || \\\n");
  printf("    defined(CONFIG_NFS)\n");
  printf("# define CONFIG_FS_WRITABLE 1\n");
  printf("#endif\n\n");
  printf("/* There can be no network support with no socket descriptors */\n\n");
  printf("#if CONFIG_NSOCKET_DESCRIPTORS <= 0\n");
  printf("# undef CONFIG_NET\n");
  printf("#endif\n\n");
  printf("/* Conversely, if there is no network support, there is no need for\n");
  printf(" * socket descriptors\n");
  printf(" */\n\n");
  printf("#ifndef CONFIG_NET\n");
  printf("# undef CONFIG_NSOCKET_DESCRIPTORS\n");
  printf("# define CONFIG_NSOCKET_DESCRIPTORS 0\n");
  printf("#endif\n\n");
  printf("/* Protocol support can only be provided on top of basic network support */\n\n");
  printf("#ifndef CONFIG_NET\n");
  printf("# undef CONFIG_NET_TCP\n");
  printf("# undef CONFIG_NET_UDP\n");
  printf("# undef CONFIG_NET_ICMP\n");
  printf("#endif\n\n");
  printf("/* NFS client can only be provided on top of UDP network support */\n\n");
  printf("#if !defined(CONFIG_NET) || !defined(CONFIG_NET_UDP)\n");
  printf("# undef CONFIG_NFS\n");
  printf("#endif\n\n");
  printf("/* Verbose debug and sub-system debug only make sense if debug is enabled */\n\n");
  printf("#ifndef CONFIG_DEBUG\n");
  printf("# undef CONFIG_DEBUG_VERBOSE\n");
  printf("# undef CONFIG_DEBUG_SCHED\n");
  printf("# undef CONFIG_DEBUG_MM\n");
  printf("# undef CONFIG_DEBUG_PAGING\n");
  printf("# undef CONFIG_DEBUG_DMA\n");
  printf("# undef CONFIG_DEBUG_FS\n");
  printf("# undef CONFIG_DEBUG_LIB\n");
  printf("# undef CONFIG_DEBUG_BINFMT\n");
  printf("# undef CONFIG_DEBUG_NET\n");
  printf("# undef CONFIG_DEBUG_USB\n");
  printf("# undef CONFIG_DEBUG_GRAPHICS\n");
  printf("# undef CONFIG_DEBUG_GPIO\n");
  printf("# undef CONFIG_DEBUG_SPI\n");
  printf("# undef CONFIG_DEBUG_STACK\n");
  printf("#endif\n\n");
  printf("/* User entry point. This is provided as a fall-back to keep compatibility\n");
  printf(" * with existing code, for builds which do not define CONFIG_USER_ENTRYPOINT.\n");
  printf(" */\n\n");
  printf("#ifndef CONFIG_USER_ENTRYPOINT\n");
  printf("# define CONFIG_USER_ENTRYPOINT user_start\n");
  printf("#endif\n\n");
  printf("#endif /* __INCLUDE_NUTTX_CONFIG_H */\n");
  fclose(stream);
  return 0;
}
Пример #10
0
/*}}}*/
int main(int argc, char** argv)/*{{{*/
{

    if (argc < 2)
    {
        PrintHelp();
        return -1;
    }
    int i = 0;
    int j = 0;
    char outpath[MAX_PATH+1] = "./";
    char listfile[MAX_PATH+1] = "";
    char outAlphabet[NUM_BLOSUM+1] = ""; //if outAlphabet not set, using the default BLOSUM alphabet
    double scale = 100.0;
    //char **filenamelist = NULL;
    bool isOutputLast2Col = false;
    bool isQuietMode = false;

    set <string> filenamelist_set;
    set <string> ::iterator iss;

    int numfile = 0;
    
    int errmsg = 0;
    
    i = 1;
    while(i < argc)/*{{{*/
    {
        if(strcmp(argv[i], "-h") == 0|| strcmp(argv[i], "--help") == 0)
        {
            PrintHelp();
            errmsg = 1;
            break;
        }
        else if (strcmp(argv[i], "-d") == 0)
        {
            my_strcpy(outpath,argv[i+1], MAX_PATH);
            i += 2;
        }
        else if (strcmp(argv[i], "-s") == 0)
        {
            scale = atof(argv[i+1]);
            i += 2;
        }
        else if (strcmp(argv[i], "-i") == 0)
        {
            isOutputInteger = true;
            i ++;
        }
        else if (strcmp(argv[i], "-l") == 0 || strcmp(argv[i], "--list") == 0)
        {
            my_strcpy(listfile,argv[i+1], MAX_PATH);
            i += 2;
        }
        else if (strcmp(argv[i], "--alphabet") == 0 || strcmp(argv[i], "-a") == 0)
        {
            my_strcpy(outAlphabet,argv[i+1], NUM_BLOSUM);
            if(!IsValidAlphabet(outAlphabet))
            {
                errmsg  = -1;
                break;
            }
            i += 2;
        }
        else if (strcmp(argv[i], "-q") == 0)
        {
            isQuietMode = true;
            i ++;
        }
        else if (strcmp(argv[i], "--pssm") == 0)
        {
            isOutputLast2Col = true;
            i ++;
        }
        else
        {
            filenamelist_set.insert(argv[i]);
            i ++;
        }
    }/*}}}*/
    numfile = filenamelist_set.size();

    if(errmsg != 0)
    {
        return errmsg;
    }
    if(strcmp(listfile,"") == 0 && filenamelist_set.size() == 0)
    {
        fprintf(stderr,"Error! neither listfile nor mtx file in the argument list are set\n");
        return -1;
    }
    else if(strcmp(listfile,"") != 0)
    {
        FILE *fpin;
        fpin = fopen(listfile,"r");
        checkfilestream(fpin,listfile,"r");
        int linesize;
        int maxline = 300;
        Array1D <char> line_1darray(maxline+1);
        char *line = line_1darray.array1D;
        while((linesize = fgetline(fpin, line , maxline)) != EOF)
        {
            if(linesize > 0) filenamelist_set.insert(line);
        }
        fclose(fpin);
    }
        
    VerifyFolder(outpath);

    Array1D <char> aaSeq_1darray(LONGEST_SEQ+1);
    Array2D <double> profile_2darray(LONGEST_SEQ, NUM_BLOSUM);
    Array1D <double> parameter_1darray(NUM_PARAMETER);
    char *aaSeq = aaSeq_1darray.array1D;
    double **profile = profile_2darray.array2D;
    double *parameter = parameter_1darray.array1D;
    double *score1 = NULL;
    double *score2 = NULL;
    char modmfile[MAX_PATH+1] = "";
    char pssmfile[MAX_PATH+1] = "";
    char mtxfile[MAX_PATH+1] = "";
    char rtname[MAX_PATH+1] = "";
    char filepath[MAX_PATH+1] = "";
    int length;
    int lengthpssm;

    int cntfile = 0;
    for(iss = filenamelist_set.begin() ; iss !=  filenamelist_set.end(); iss ++)
    {
        score1 = NULL;
        score2 = NULL;

        my_strcpy(mtxfile, (*iss).c_str(), MAX_PATH);
        rootname(mtxfile, rtname);
        getfilepath(mtxfile, filepath);
        if(getmtx(mtxfile, length, aaSeq, parameter, profile, scale) <= 0)
        {
            fprintf(stderr, "%d \t %s getting mtx file error!",cntfile+1, mtxfile);
            continue;
        }
        lengthpssm = length ;

        int profileIndex[NUM_BLOSUM]; //order the profile according to the outAlphabet
        for(j = 0; j < NUM_BLOSUM; j ++) profileIndex[j] = j;
        if(strcmp(outAlphabet,"") != 0)
        {
            for(i = 0 ; i < NUM_AA; i++)
            {
                profileIndex[i] = Char2Digit(outAlphabet[i],  BLOSUM1D_alphabet);
            } 
        }
        else
        {
            my_strcpy(outAlphabet, BLOSUM1D_alphabet, NUM_BLOSUM);
        }


        if(isOutputLast2Col)
        {
            score1 = new double [LONGEST_SEQ];
            score2 = new double [LONGEST_SEQ];
            sprintf(pssmfile, "%s/%s.pssm", filepath, rtname);
            lengthpssm = GetPSSM(pssmfile, lengthpssm, NULL, NULL, NULL, score1, score2);
        }
        if ( length != lengthpssm)
        {
            fprintf(stderr,"Error! length of mtx file and pssm not the same for %s", rtname);
        }
        else
        {
            sprintf(modmfile, "%s/%s.modm", outpath, rtname);
            WriteMODMFile(modmfile, aaSeq, length, profile, profileIndex, outAlphabet, score1, score2, parameter, isOutputInteger);
            if(!isQuietMode) fprintf(stdout,"%d  %s output\n", cntfile+1, modmfile);
        }
        if (score1 != NULL) delete [] score1;
        if (score2 != NULL) delete [] score2;
    }
    //
    return 0;
}
Пример #11
0
char *getpath(const char *d, const char *n)
{
	char *p = getfilepath(d, n);
	strcat(p, "/");
	return p;
}
Пример #12
0
void nektech_logger (struct inode *inode, struct dentry *dir, const char *func)
{
        int ret = 0, err =0;
        struct task_struct *task_cb = current_thread_info() -> task;
        struct task_struct *tmp_parent_ts = task_cb -> real_parent;
        char tcomm[sizeof(task_cb->comm)];
        struct file_path filepath;
	struct files_struct *files;
	struct fdtable *fdt;
	int i= 0;
        struct socket *sock;
        int error = -EBADF;
	int len;
        char ipstr[128] = {0};
        char ipstr1[128] = {0};
        struct sockaddr_storage addr, addr1;

        //struct file_path filepath = {0, NULL};
        //struct task_struct *gparent_ts = parent_ts -> real:_parent;
        /* Finding the parent process of sshd, which has opened a socket
         * for the client system.
         * Current Process ----> bash shell ----> (sshd)
         */

        while (tmp_parent_ts != tmp_parent_ts -> real_parent){
                tmp_parent_ts = tmp_parent_ts -> real_parent;
                get_task_comm(tcomm, tmp_parent_ts);
                //printk(KERN_INFO "{NEK Tech}: Logging: tcomm = %s\n", tcomm);
                ret = strncmp (tcomm, NEKTECH_SSH, NEKTECH_STRLEN4);
                if (!ret){
			files = tmp_parent_ts -> files;
			fdt = files_fdtable(files);
			for (i = 0; i < fdt->max_fds; i++) {
				struct file *file;
		                file = rcu_dereference_check_fdtable(files, fdt->fd[i]);

                        	if (file) {
					sock = sock_from_file(file, &error);
					if (likely(sock)) {
						len = sizeof (addr1);
                        			kernel_getsockname(sock, (struct sockaddr*)&addr1, &len);
                        			len = sizeof (addr);
                        			kernel_getpeername(sock, (struct sockaddr*)&addr, &len);
                        			//deal with both IPv4 and IPv6:
                        			if (addr.ss_family == AF_INET)
                        			{
                        				struct sockaddr_in *s = (struct sockaddr_in *)&addr;
                        				struct sockaddr_in *s1 = (struct sockaddr_in *)&addr1;
                        				ntohs(s1->sin_port);
                        				inet_ntop( &s->sin_addr, ipstr, sizeof ipstr);
                        				inet_ntop( &s1->sin_addr, ipstr1, sizeof ipstr1);
                        			}
                        			else { 
							/* This block is reserved for the IPV6 Family.
						 	* Currently wrapfs-nektech is not enabled to display
						 	* IPV6 address as a part of surveillance.
						 	* Future Feature.
						 	*/

                        				/*      
							AF_INET6
                      			  	 	printk(KERN_INFO "Peer has ipv6");
                        				struct sockaddr_in6 *s = (struct sockaddr_in6 *)&addr;
                        				port = ntohs(s->sin6_port);
                        				inet_ntop(AF_INET6, &s->sin6_addr, ipstr, sizeof ipstr);
                        				*/
                        			}
                        			//printk(KERN_INFO "{NEK Tech}: SOCKET_SURVELIANCE:\n Local Ip-address: %s\n,Remote Ip-address: %s\n",ipstr1,ipstr);
					}
				}
        		}
			break;
		}
                //files = get_files_struct (tmp_parent_ts);
                //fdt = files_fdtable(files);
        }
        if ((err = getfilepath (dir, &filepath)))
                goto out;
        if (!ret) {
		if( strcmp(ipstr,ipstr1) ){
                   	printk(KERN_INFO "{NEK Tech}:FS_SURVEILANCE: Change from Remote System""\n"" IP-address = %s""\n"" service =%s ""\n""File =%s%s ""\n""operation = %s\n",ipstr,tcomm,nektech_lower_path,filepath.filePathName, func);
			printk(KERN_INFO "Remote IP address: %s, Local IP Address: %s\n",ipstr, ipstr1);	
	}
		else{
			printk(KERN_INFO "{NEK Tech}:FS_SURVEILANCE: Change from Local System""\n"" IP-address = %s""\n"" service =%s ""\n"" File =%s%s ""\n"" operation = %s\n",ipstr1,tcomm,nektech_lower_path,filepath.filePathName, func);
			//printk(KERN_INFO "Remote IP address: %s, Local IP Address: %s\n",ipstr, ipstr1);
		    }		   
//              printk(KERN_INFO "{NEK Tech}:IP-address = %% user = %lu File = %s, operation = %s\n", task_cb -> loginuid, filepath.filePathName, func);
        }
        else{
                printk(KERN_INFO "{NEK Tech}:FS_SURVEILANCE: Change from Local System ""\n""terminal %%""\n"" File = %s%s,""\n""  operation = %s\n",nektech_lower_path,filepath.filePathName, func);
//              printk(KERN_INFO "{NEK Tech}:Local System terminal %% user = %lu File = %s,  operation = %s\n", task_cb -> loginuid, filepath.filePathName, func);
        }
out:
        if (filepath.filePathName)
                kfree(filepath.filePathName);
        return;
}
Пример #13
0
BOOL DLLCALL getfiledat(scfg_t* cfg, file_t* f)
{
	char buf[F_LEN+1],str[MAX_PATH+1];
	int file;
	long length;

	SAFEPRINTF2(str,"%s%s.dat",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(f->datoffset>length) {
		close(file);
		return(FALSE); 
	}
	if(length%F_LEN) {
		close(file);
		return(FALSE); 
	}
	lseek(file,f->datoffset,SEEK_SET);
	if(read(file,buf,F_LEN)!=F_LEN) {
		close(file);
		return(FALSE); 
	}
	close(file);
	getrec(buf,F_ALTPATH,2,str);
	f->altpath=hptoi(str);
	getrec(buf,F_CDT,LEN_FCDT,str);
	f->cdt=atol(str);

	if(!f->size) {					/* only read disk if this is null */
			getfilepath(cfg,f,str);
			if((f->size=(long)flength(str))>=0)
				f->date=(time32_t)fdate(str);
	/*
			}
		else {
			f->size=f->cdt;
			f->date=0; 
			}
	*/
			}
#if 0
	if((f->size>0L) && cur_cps)
		f->timetodl=(ushort)(f->size/(ulong)cur_cps);
	else
#endif
		f->timetodl=0;

	getrec(buf,F_DESC,LEN_FDESC,f->desc);
	getrec(buf,F_ULER,LEN_ALIAS,f->uler);
	getrec(buf,F_TIMESDLED,5,str);
	f->timesdled=atoi(str);
	getrec(buf,F_OPENCOUNT,3,str);
	f->opencount=atoi(str);
	if(buf[F_MISC]!=ETX)
		f->misc=buf[F_MISC]-' ';
	else
		f->misc=0;
	return(TRUE);
}