コード例 #1
0
ファイル: ls_render.c プロジェクト: simfeng/tview
/*
 * This function is used to split ls output
 * into filename type and size.
 * */
void 
GenerateFileInfo(char *line)
{
	char *buf = line;
	char *outptr = NULL;
	char *res[1];
	char *name = NULL;
	int  i = 0;
	
	//res = malloc(sizeof(char) * 128);
	/*first step is to get the finename*/
	while((res[0] = strtok_r(buf," ",&outptr)) != NULL)
	{
		buf = NULL;
		if(i == 4){
			strcpy(lsview->fileinfo[lsview->fileno].size,res[0]);
			lsview->fileinfo[lsview->fileno].size[strlen(res[0])]='K';
			lsview->fileinfo[lsview->fileno].size[strlen(res[0])+1] = '\0';
		}

		if(i == 8){
			right_trim(res[0]);
			strcpy(lsview->fileinfo[lsview->fileno].name,res[0]);
			lsview->fileinfo[lsview->fileno].name[strlen(res[0])] = '\0';
		}
		i++;
	}

	name = lsview->fileinfo[lsview->fileno].name;
	/*second get the filetype */
	GatherFileType(name,lsview->fileinfo[lsview->fileno].type);
}
コード例 #2
0
ファイル: eAudit_string.c プロジェクト: fU9ANg/eAudit
/**********************************
*func name:
*function:
*parameters:
*call:
*called:
*return:
*/
void trim(char *src)
{
    char *s = src;
    
    left_trim(s);
    right_trim(s);
}
コード例 #3
0
ファイル: exif.c プロジェクト: velvet-jones/imgfiler
// get the tag
void get_tag(ExifData* d, ExifIfd ifd, ExifTag tag, char* buf, int len)
{
  ExifEntry *entry = exif_content_get_entry(d->ifd[ifd],tag);
  if (entry) {
    exif_entry_get_value(entry, buf, len);
    right_trim(buf,' ');
  }
}
コード例 #4
0
ファイル: main.c プロジェクト: JesseEisen/tview
static void 
load_command(FILE *fp)
{
	int i = 0;
	size_t bufsize = 20;
	ssize_t nbytes;
	char *buffer = NULL;

	while((nbytes = getline(&buffer,&bufsize,fp)) != -1)
	{
		command[i] = (char *)malloc(sizeof(char) * 20);
		right_trim(buffer);
		strcpy(command[i], buffer);	
		i++;
	}


}
コード例 #5
0
ファイル: eAudit_string.c プロジェクト: fU9ANg/eAudit
/**********************************
*func name:
*function:
*parameters:
*call:
*called:
*return:
*/
char *quick_trim(char *src)
{
    register char *s = src;
    char *addr = NULL;
    
    while(*s != '\0')
    {
        if (0 == isspace(*s))
        	  break;       	  

        s++;
    }
    
    addr = s;
    right_trim(addr);

    return addr;
}
コード例 #6
0
ファイル: find_render.c プロジェクト: JesseEisen/tview
void 
GenerateFileInfo_find(char *line)
{
	//assert(line == NULL);
	char *buf;
	int linelen, pathlen;

	linelen = strlen(line);
	
	buf = strrchr(line,'/');
	strcpy(fdview->findinfo[fdview->lineidx].name,buf+1);

	pathlen = linelen - strlen(buf);
	strncpy(fdview->findinfo[fdview->lineidx].path,line,pathlen);

	right_trim(line);
	GatherFileType(line,fdview->findinfo[fdview->lineidx].type);

}
コード例 #7
0
ファイル: Input.cpp プロジェクト: PCMSolver/pcmsolver
std::string trim(std::string s) {
  left_trim(s);
  right_trim(s);
  return s;
}
コード例 #8
0
ファイル: Input.cpp プロジェクト: PCMSolver/pcmsolver
std::string right_trim(const char * src) {
  std::string tmp(src);
  return right_trim(tmp);
}
コード例 #9
0
ファイル: find_render.c プロジェクト: JesseEisen/tview
void 
Draw_Find_OutPut(void)
{
	int totallines = fdview->lineidx;
	int i,highlight, j = 0;
	int start =0,end = 0;
	enum line_type  type;
	
	start = 0;
	highlight = g_current + g_change;
	if(highlight < 0){
		mvwaddstr(status_win,0,0,"At the top");
		highlight = 0;
	}else if(highlight < LINES -2){
		if(highlight == totallines) {
			mvwaddstr(status_win,0,0,"At the end");
			highlight = totallines - 1;
		}
	}else{
		start = highlight - LINES + 2;
		if(highlight == totallines){
			mvwaddstr(status_win,0,0,"Hit the bottom");
			highlight = totallines - 1;
			start = highlight - LINES + 1;
		}
	}

	if(totallines < LINES - 1)
		end = totallines;
	else if(totallines >= LINES)
		end = start + LINES;

	werase(stdscr);
	for(i = start; i < end; i++){
		if(i == highlight){
			snprintf(vim_cmd,sizeof(vim_cmd),VIM_CMD_FIND,fdview->findinfo[i].path,fdview->findinfo[i].name);
			type = LINE_CURSOR;
			g_current = i;
			wattrset(stdscr,get_line_attr(type));
			wchgat(stdscr,-1,0,type,NULL);
		}else{
			type = LINE_FILE_LINCON;
			wchgat(stdscr,-1,0,type,NULL);
			wattrset(stdscr,get_line_attr(LINE_FILE_NAME));
		}
		
		if(type != LINE_CURSOR){
			wattrset(stdscr,get_line_attr(LINE_FILE_NAME));
			mvwaddstr(stdscr,j,0,fdview->findinfo[i].path);
		}else{
			mvwaddstr(stdscr,j,0,fdview->findinfo[i].path);
		}

		if(type != LINE_CURSOR){
			wattrset(stdscr,get_line_attr(LINE_FILE_LINUM));
		}
		right_trim(fdview->findinfo[i].name);
		mvwaddstr(stdscr,j,35,fdview->findinfo[i].name);

		if(type != LINE_CURSOR){
			wattrset(stdscr,get_line_attr(LINE_DELIMITER));
		}
		mvwaddstr(stdscr,j,60,fdview->findinfo[i].type);
		mvwaddch(stdscr,j,COLS-1,'\n');
		j++;
	}
	g_change = 0;
}