Ejemplo n.º 1
0
void OSD_Printf(const char *fmt, ...)
{
	char tmpstr[1024], *chp;
	va_list va;
		
	if (!osdinited) OSD_Init();

	va_start(va, fmt);
	Bvsnprintf(tmpstr, 1024, fmt, va);
	va_end(va);

	if (osdlog) Bfputs(tmpstr, osdlog);

#if defined(_DEBUG) && defined(WIN32)
	OutputDebugStringA(tmpstr);
#endif

	for (chp = tmpstr; *chp; chp++) {
		if (*chp == '\r') osdpos=0;
		else if (*chp == '\n') {
			osdpos=0;
			linefeed();
		} else {
			osdtext[osdpos++] = *chp;
			if (osdpos == osdcols) {
				osdpos = 0;
				linefeed();
			}
		}
	}
}
Ejemplo n.º 2
0
    inline void async_encode_store(const std::string& command, const std::string& key, const std::string& value, std::size_t timeout, std::vector<char>& buffer) {
        auto timeout_str = boost::lexical_cast<std::string>(timeout);
        auto data_length = boost::lexical_cast<std::string>(value.length());

        fill_buffer(buffer, command, key, "0", timeout_str, data_length, noreply());
        fill_buffer(buffer, linefeed());
        fill_buffer(buffer, value);
        fill_buffer(buffer, linefeed());
    }
Ejemplo n.º 3
0
static void
carriage(void)

{

/*
 *
 * Handles carriage return character. If crislf is ON we'll generate a line feed
 * every time we get a carriage return character.
 *
 */

    if ( shadowprint == ON )		/* back to normal mode */
	changefont(fontname);

    advance = 1;
    shadowprint = OFF;

    hgoto(leftmargin);

    if ( crislf == ON )
	linefeed();

}   /* End of carriage */
Ejemplo n.º 4
0
static void
text(void)

{

    int		ch;			/* next input character */

/*
 *
 * Translates the next input file into PostScript. The redirect(-1) call forces
 * the initial output to go to /dev/null - so the stuff formfeed() does at the
 * end of each page doesn't go to stdout.
 *
 */

    redirect(-1);			/* get ready for the first page */
    formfeed();				/* force PAGE comment etc. */
    inittabs();

    while ( (ch = getc(fp_in)) != EOF )
	switch ( ch )  {
	    case '\010':		/* backspace */
		    backspace();
		    break;

	    case '\011':		/* horizontal tab */
		    htab();
		    break;

	    case '\012':		/* new line */
		    linefeed();
		    break;

	    case '\013':		/* vertical tab */
		    vtab();
		    break;

	    case '\014':		/* form feed */
		    formfeed();
		    break;

	    case '\015':		/* carriage return */
		    carriage();
		    break;

	    case '\016':		/* extended character set - SO */
		    break;

	    case '\017':		/* extended character set - SI */
		    break;

	    case '\031':		/* next char from supplementary set */
		    break;

	    case '\033':		/* 2 or 3 byte escape sequence */
		    escape();
		    break;

	    default:
		    oput(ch);
		    break;
	}   /* End switch */

    formfeed();				/* next file starts on a new page? */

}   /* End of text */
Ejemplo n.º 5
0
void print_text_xy(int mode,const  char *text,size_t n, bool auto_height_feed, int *x,int *y)//mode 0,dont display,just move the cursor;mode 1:display and move the cursor at the same time
{
	unsigned char c,d;
	unsigned char *cc=(unsigned  char*)text;
	unsigned int innercode,tempx=0;
	struct fonts curfont;
	unsigned int currentx=*x,currenty=*y,i;
	unsigned int xmax=getmaxx();
	FILE*fp=fopen("test.txt","wt");
	for(i=0;i<n;i++)
	{
		c=*cc;
		fwrite(&c,1,1,fp);
		cc++;
		/*if(16<currenty&&currenty<=32)
		getch();*/
		if(c>>7==1)
		{
			tempx=currentx+16-1;
			linefeed(&tempx,&currenty,16,16);
			if(tempx==0)
				currentx=tempx;
			d=*cc;
			cc++;
			innercode=c*256+d;
			if(mode)
				displayhz(1,innercode,2,currentx,currenty,1,15);
			currentx+=16;
			linefeed(&currentx,&currenty,16,16);
			i++;
			if(auto_height_feed)
			{
				cursor.cursor_x=currentx;
				cursor.cursor_y=currenty;
			}

		}
		else
		{
			if(c==10)
			{
				bar(currentx,currenty-16,xmax,currenty);
				currentx=0;
				currenty+=16;
				if(auto_height_feed)
				{
					cursor.cursor_x=currentx;
					cursor.cursor_y=currenty;
				}
				continue;
			}
			if(mode)
				displayen(1,c,0,currentx,currenty,1,15);
			currentx+=8;
			linefeed(&currentx,&currenty,8,16);
			if(auto_height_feed)
			{
				cursor.cursor_x=currentx;
				cursor.cursor_y=currenty;
			}
		}
	}
Ejemplo n.º 6
0
int dcldir_do_it(char *drive,char *dir,char *name,
                 time_t time_create,time_t time_access,time_t time_write,
                 unsigned long fsize,unsigned int fattrib,PARAM *dir_param)
{
    char    temp[MAX_TOKEN];
    char    vms[MAX_TOKEN];
    char    longname[MAX_TOKEN];
    char    shortname[MAX_TOKEN];
    char    xname[MAX_TOKEN];
    char    xattr[5];
    long    sz = 0;
#ifdef _WIN32
    DCL_FIND_DATA FindFileData;
    int     handle;
#endif

    if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
        (void) logical_get("INI$FTYPE",INI_VALUE);
        if (INI_VALUE[0] == 'V') {
            return(DCL_OK);
        }
    }
#ifdef _WIN32
    if (!*drive) {
        drive[0] = _getdrive() + 'A' - 1;
        drive[1] = ':';
        drive[2] = 0;
        }
    strcpy(vms,drive);
    strcat(vms,dir);
    _fullpath(temp,vms,MAX_TOKEN);
#else
    strcpy(temp,dir);
#endif
    cvfs_dos_to_vms(temp,vms);

    if (vms[strlen(vms)-1] == SLASH_CHR && strlen(vms) > 1)
        vms[strlen(vms)-1] = 0;

    dir_param->file_counter++;
    dir_param->gt_file_counter++;
    dir_param->col_counter++;

    if (dir_param->file_counter == 1 && dir_param->heading
        && (!dir_param->grand_total)) {
        dcl_printf(dir_param->output,"\nDirectory %s",vms);
        linefeed(dir_param);
        linefeed(dir_param);
    }
#ifdef _WIN32
    strcpy(longname,drive);
    strcat(longname,dir);
    strcat(longname,name);
    handle = Dcl_FindFirstFile(longname, &FindFileData);
    if (handle != (int)INVALID_HANDLE_VALUE &&
        *FindFileData.cAlternateFileName && *name != '.')
        strcpy(shortname, FindFileData.cAlternateFileName);
    else
#endif
        strcpy(shortname,name);

    if (dir_param->heading) {
        if (fattrib & _A_SUBDIR) {
            sprintf(xname,"[%s]",shortname);
            strcpy(shortname, xname);
            sprintf(xname,"[%s]",name);
            strcpy(name, xname);
        }
    }

    if (dir_param->brief) {
        if (!dir_param->total) {
            int len = strlen(name);
            int col_inc = len / 15;
            int col_width = (col_inc * 15) + 15;
            char wrk[256];
            snprintf(wrk, 256,"%-*.*s",col_width,col_width,name);
            dir_printfilename(dir_param->output,"%s",wrk);
            dir_param->col_counter += col_inc;
        }
        if (dir_param->col_counter >= dir_param->cols) {
            if (!dir_param->total)
                linefeed(dir_param);
            dir_param->col_counter = 0;
        }
    }

    if (dir_param->full) {
        strcpy(xattr,"W...");
        if (fattrib & _A_RDONLY) xattr[0] = 'R';
        if (fattrib & _A_SUBDIR) xattr[0] = 'D';
        if (fattrib & _A_HIDDEN) xattr[1] = 'H';
        if (fattrib & _A_SYSTEM) xattr[2] = 'S';
        if (fattrib & _A_ARCH)   xattr[3] = 'A';
        xattr[4] = 0;
        if (!dir_param->total){
            dir_printfilename(dir_param->output,"%s",name);
            linefeed(dir_param);
            if (fattrib & _A_SUBDIR)
                dcl_printf(dir_param->output,"Size         : <DIR>");
            else
                dcl_printf(dir_param->output,"Size         : %ld",fsize);
            linefeed(dir_param);
            tm_long_to_str(&time_create, temp);
            temp[20] = 0;
            dcl_printf(dir_param->output,"Date created : %s",temp);
            linefeed(dir_param);
            tm_long_to_str(&time_access, temp);
            temp[20] = 0;
            dcl_printf(dir_param->output,"Date accessed: %s",temp);
            linefeed(dir_param);
            tm_long_to_str(&time_write, temp);
            temp[20] = 0;
            dcl_printf(dir_param->output,"Date written : %s",temp);
            linefeed(dir_param);
            dcl_printf(dir_param->output,"Attribute    : %s",xattr);
            linefeed(dir_param);
            linefeed(dir_param);
            }
        dir_param->tot_size += fsize;
        dir_param->gt_tot_size += fsize;
        }


    if (dir_param->full == 0 && dir_param->brief == 0) {
        if (!dir_param->total)
//            if (dir_param->heading)
                dir_printfilename(dir_param->output,"%-15.15s",shortname);
//            else
//                dir_printfilename(dir_param->output,"%s\t",xname);
        if (dir_param->date) {
            tm_long_to_str(&time_write, temp);
            temp[20] = 0;
            if (!dir_param->total)
                dcl_printf(dir_param->output,"    %s",temp);
            }
        if (dir_param->size) {
            switch (dir_param->size) {
                case BYTES:
                    sz = fsize;
                    break;
                case BLOCKS:
                    sz = fsize / 512;
                    if (fsize % 512) sz++;
                    break;
                case KILOBYTES:
                    sz = fsize / 1024;
                    if (fsize % 1024) sz++;
                    break;
                case MEGABYTES:
                    sz = fsize / (1024 * 1000);
                    break;
                case GIGABYTES:
                    sz = fsize / (1024 * 1000000);
                    break;
                default:
                    ;
                }
            if (!dir_param->total) {
                if (fattrib & _A_SUBDIR)
                    dcl_printf(dir_param->output,"    <DIR>    ");
                else
                    dcl_printf(dir_param->output,"    %9ld",sz);
            }
            dir_param->tot_size += sz;
            dir_param->gt_tot_size += sz;
            }
        if (dir_param->attr) {
            strcpy(xattr,"W...");
            if (fattrib & _A_RDONLY) xattr[0] = 'R';
            if (fattrib & _A_SUBDIR)  xattr[0] = 'D';
            if (fattrib & _A_HIDDEN) xattr[1] = 'H';
            if (fattrib & _A_SYSTEM) xattr[2] = 'S';
            if (fattrib & _A_ARCH)   xattr[3] = 'A';
            xattr[4] = 0;
            if (!dir_param->total)
                dcl_printf(dir_param->output,"  %s",xattr);
            }
        if (!dir_param->total) {
            if (dir_param->heading)
                dir_printfilename(dir_param->output," %s",name);
            else
                dir_printfilename(dir_param->output," %s",longname);
        }
        if (!dir_param->total)
            linefeed(dir_param);
    }
#ifdef _WIN32
    Dcl_FindClose(handle);
#endif

    return(DCL_OK);
}
Ejemplo n.º 7
0
void dcldir_searchdir(char * name,int subdir,PARAM *dir_param)
{
    DCL_FIND_DATA ff;
    int     ok;
    int     handle;
    int     attrib = _A_SUBDIR;
    int     i = 0;
    int     n = 0;
    int     d = 0;
    char    temp[_MAX_PATH];
    char    path[_MAX_PATH];
    char    drive[_MAX_DRIVE];
    char    dir[_MAX_DIR];
    char    file[_MAX_FNAME];
    char    ext[_MAX_EXT];
    DCL_FIND_DATA *dd;
    size_t  s;

    n = 1024;
    do
        {
        dd = (DCL_FIND_DATA *) calloc(n,sizeof(ff));
        if (dd == NULL) n /= 2;
        }
    while (n >= 128 && dd == NULL);
    if (dd == NULL){
        dcl_printf(dcl[D].SYS_OUTPUT,"ERROR - DIR002\n");
        _SEVERITY = 4;
        _STATUS = 8;
        return;
        }

    strcpy(path,name);
    //for (i = 0; i < (int) strlen(path); i++)
    //    path[i] = toupper(path[i]);
    if (dir_param->all)
        attrib = attrib + _A_HIDDEN + _A_SYSTEM;
    _splitpath(path,drive,dir,file,ext);
    if (strlen(file) == 0)
        strcat(path,"*");
//    if (strlen(ext) == 0)
//        strcat(path,".*");
    handle = Dcl_FindFirstFile(path,&ff);
    ok = handle == (int)INVALID_HANDLE_VALUE ? 0 : 1;
    dir_param->dir_counter++;
    dir_param->file_counter = 0;
    dir_param->col_counter = 0;
    dir_param->tot_size = 0;

    if (CTRL_Y) {
        ok = 0;
    }
    while (ok) {
        _splitpath(path,drive,dir,file,ext);
        if (strlen(drive)==0 && strlen(dir)==0) {
           if (_getcwd(temp,_MAX_PATH) != NULL) {
               s = strlen(temp)-1;
           }
           else {
               s = 0;
           }
           if (temp[s] != SLASH_CHR) {
              strcat(temp,SLASH_STR);
              _splitpath(temp,drive,dir,file,ext);
              }
           }
        if ((unsigned long)ff.WriteTime >= (unsigned long)dir_param->since &&
            (unsigned long)ff.WriteTime <  (unsigned long)dir_param->before)
            {
            if (d < n){
               memcpy(&dd[d],&ff,sizeof(ff));
               d++;
               }
            }
        ok = Dcl_FindNextFile(handle, &ff);
        if (CTRL_Y) {
            ok = 0;
        }
    }
    Dcl_FindClose(handle);

    if (CTRL_Y) {
        free(dd);
        return;
    }

    --d;
    if (d) {
        switch (dir_param->order) {
            case O_NAME:
                //for(i = 0; i < d; printf("%s\n",dd[i++].cFileName));
                qsort((DCL_FIND_DATA*) dd,d+1,sizeof(DCL_FIND_DATA),dir_sort_n);
                //for(i = 0; i < d; printf("%s\n",dd[i++].cFileName));
                break;
            case O_EXTENSION:
                qsort((DCL_FIND_DATA*) dd,d+1,sizeof(DCL_FIND_DATA),dir_sort_e);
                break;
            case O_SIZE:
                qsort((DCL_FIND_DATA*) dd,d+1,sizeof(DCL_FIND_DATA),dir_sort_s);
                break;
            case O_DATE:
                qsort((DCL_FIND_DATA*) dd,d+1,sizeof(DCL_FIND_DATA),dir_sort_d);
                break;
            default:
                ;
        }
    }

    for(i = 0;i <= d;i++) {
        dcldir_do_it(drive,dir,dd[i].cFileName,dd[i].CreationTime,dd[i].AccessTime,dd[i].WriteTime,dd[i].nFileSize,
            dd[i].dwFileAttributes,dir_param);
    }
    if (CTRL_Y) {
        free(dd);
        return;
    }

    if (dir_param->brief && (!dir_param->total) && dir_param->file_counter) {
        if (dir_param->col_counter != 0)
            linefeed(dir_param);
/*        linefeed(dir_param);*/
    }
    if (dir_param->file_counter > 0 && dir_param->trailing
        && (!dir_param->grand_total)) {
        dcl_printf(dir_param->output,"Total of %d file",dir_param->file_counter);
        if (dir_param->file_counter > 1)
            dcl_printf(dir_param->output,"s");
        if (dir_param->size) {
            dcl_printf(dir_param->output,", %ld",dir_param->tot_size);
            switch (dir_param->size) {
                case BYTES:
                    dcl_printf(dir_param->output," bytes");
                    break;
                case BLOCKS:
                    dcl_printf(dir_param->output," blocks");
                    break;
                case KILOBYTES:
                    dcl_printf(dir_param->output," KBytes");
                    break;
                case MEGABYTES:
                    dcl_printf(dir_param->output," MBytes");
                    break;
                case GIGABYTES:
                    dcl_printf(dir_param->output," GBytes");
                    break;
                default:
                    dcl_printf(dir_param->output," ***");
            }
        }
        if (dir_param->full)
            dcl_printf(dir_param->output,",  %ld bytes",dir_param->tot_size);
        linefeed(dir_param);
    }

    free(dd);

    strcpy(temp,path);
    _splitpath(path,drive,dir,file,ext);
//    _makepath(path,drive,dir,"*",".*");
    _makepath(path,drive,dir,"*",NULL);

    if (subdir) {
        handle = Dcl_FindFirstFile(path,&ff);
        ok = handle == (int)INVALID_HANDLE_VALUE ? 0 : 1;
        if (CTRL_Y) {
            ok = 0;
        }
        while (ok){
            if (ff.dwFileAttributes & _A_SUBDIR) {
            	if (strcmp(ff.cFileName, ".") && strcmp(ff.cFileName, "..")) {
	                _splitpath(temp,drive,dir,file,ext);
	                strcat(dir,ff.cFileName);
	                strcat(dir,SLASH_STR);
	                _makepath(path,drive,dir,file,ext);
	                dcldir_searchdir(path,1,dir_param);
            	}
            }
            ok = Dcl_FindNextFile(handle, &ff);
            if (CTRL_Y) {
                ok = 0;
            }
        }
        Dcl_FindClose(handle);
        strcpy(path,temp);
    }
}