forked from KolibriOS/kolibrios
Mistakes in functions of work with files and with system calls KolibriOS are corrected.
New functions for work with system calls KolibriOS are added. Functions for format output are added: printf (), fprintf (), sprintf (), snprintf (), vsnprintf (). For material numbers it is meanwhile supported only format output the (%f), and exponential output a (%e) is not realized yet. Functions for format output correctly work only in GCC because TinyC incorrectly works with the functions containing variable number of arguments. git-svn-id: svn://kolibrios.org@647 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
9
programs/develop/ktcc/trunk/libc/stdio/fclose.c
Normal file
9
programs/develop/ktcc/trunk/libc/stdio/fclose.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void fclose(FILE* file)
|
||||
{
|
||||
free(file->buffer);
|
||||
free(file);
|
||||
}
|
5
programs/develop/ktcc/trunk/libc/stdio/feof.c
Normal file
5
programs/develop/ktcc/trunk/libc/stdio/feof.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <stdio.h>
|
||||
int feof(FILE* file)
|
||||
{
|
||||
return file->filepos>=file->filesize;
|
||||
}
|
7
programs/develop/ktcc/trunk/libc/stdio/fflush.c
Normal file
7
programs/develop/ktcc/trunk/libc/stdio/fflush.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
int fflush(FILE* file)
|
||||
{
|
||||
if ((file->mode & 3)==FILE_OPEN_READ)
|
||||
return 0;
|
||||
return(EOF);
|
||||
}
|
22
programs/develop/ktcc/trunk/libc/stdio/fgetc.c
Normal file
22
programs/develop/ktcc/trunk/libc/stdio/fgetc.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
int fgetc(FILE* file)
|
||||
{
|
||||
dword res;
|
||||
|
||||
if ((file->mode & 3!=FILE_OPEN_READ) && (file->mode & FILE_OPEN_PLUS==0)) return EOF;
|
||||
|
||||
if (file->filepos>=file->filesize)
|
||||
{
|
||||
return EOF;
|
||||
}
|
||||
else
|
||||
{
|
||||
res=_ksys_readfile(file->filename,file->filepos,1,file->buffer);
|
||||
if (res==0)
|
||||
{
|
||||
file->filepos++;
|
||||
return (int)file->buffer[0];
|
||||
}
|
||||
else return(res);
|
||||
}
|
||||
}
|
6
programs/develop/ktcc/trunk/libc/stdio/fgetpos.c
Normal file
6
programs/develop/ktcc/trunk/libc/stdio/fgetpos.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
int fgetpos(FILE* file,fpos_t* pos)
|
||||
{
|
||||
*pos=file->filepos;
|
||||
return 0;
|
||||
}
|
138
programs/develop/ktcc/trunk/libc/stdio/fopen.c
Normal file
138
programs/develop/ktcc/trunk/libc/stdio/fopen.c
Normal file
@@ -0,0 +1,138 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern char __argv;
|
||||
extern char __path;
|
||||
|
||||
const char* getfullpath(const char *path){
|
||||
|
||||
int i,j,relpath_pos,localpath_size;
|
||||
int filename_size;
|
||||
char local_path;
|
||||
char *programpath;
|
||||
char *newpath;
|
||||
|
||||
i=0;
|
||||
local_path=1; //enable local path
|
||||
while((*(path+i)!='\0') || (*(path+i)!=0))
|
||||
{
|
||||
if (*(path+i)=='.')
|
||||
{
|
||||
if (*(path+i+1)=='/')
|
||||
{ //detected relative path
|
||||
relpath_pos=i+2;
|
||||
local_path=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (*(path+i)=='/')
|
||||
{ //disabple local path
|
||||
local_path=0;
|
||||
return(path);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
filename_size=i;
|
||||
|
||||
programpath=&__path;
|
||||
|
||||
if (local_path==1)
|
||||
{
|
||||
i=0x400;
|
||||
//find local path of program
|
||||
while(*(programpath+i)!='/')
|
||||
{
|
||||
i--;
|
||||
}
|
||||
localpath_size=i;
|
||||
newpath=malloc(0x400);
|
||||
//copy local path to the new path
|
||||
for(i=0;i<=localpath_size;i++)
|
||||
{
|
||||
*(newpath+i)=*(programpath+i);
|
||||
}
|
||||
//copy filename to the new path
|
||||
for(i=0;i<filename_size;i++)
|
||||
{
|
||||
*(newpath+localpath_size+1+i)=*(path+i);
|
||||
}
|
||||
return(newpath);
|
||||
}
|
||||
|
||||
//if we here than path is a relative
|
||||
i=0x400;
|
||||
//find local path of program
|
||||
while(*(programpath+i)!='/')
|
||||
{
|
||||
i--;
|
||||
}
|
||||
localpath_size=i;
|
||||
i=0;
|
||||
//find file name size
|
||||
while((*(path+relpath_pos+i)!='\0') || (*(path+relpath_pos+i)!=0))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
filename_size=i;
|
||||
newpath=malloc(0x400);
|
||||
//copy local path to the new path
|
||||
for(i=0;i<=localpath_size;i++)
|
||||
{
|
||||
*(newpath+i)=*(programpath+i);
|
||||
}
|
||||
//copy filename to the new path
|
||||
for(i=0;i<filename_size;i++)
|
||||
{
|
||||
*(newpath+localpath_size+1+i)=*(path+relpath_pos+i);
|
||||
}
|
||||
return(newpath);
|
||||
}
|
||||
|
||||
|
||||
FILE* fopen(const char* filename, const char *mode)
|
||||
{
|
||||
FILE* res;
|
||||
int imode;
|
||||
imode=0;
|
||||
if (*mode=='r')
|
||||
{
|
||||
imode=FILE_OPEN_READ;
|
||||
mode++;
|
||||
}else if (*mode=='w')
|
||||
{
|
||||
imode=FILE_OPEN_WRITE;
|
||||
mode++;
|
||||
}else if (*mode=='a')
|
||||
{
|
||||
imode=FILE_OPEN_APPEND;
|
||||
mode++;
|
||||
}else
|
||||
return 0;
|
||||
if (*mode=='t')
|
||||
{
|
||||
imode|=FILE_OPEN_TEXT;
|
||||
mode++;
|
||||
}else if (*mode=='b')
|
||||
mode++;
|
||||
if (*mode=='+')
|
||||
{
|
||||
imode|=FILE_OPEN_PLUS;
|
||||
mode++;
|
||||
}
|
||||
if (*mode!=0)
|
||||
return 0;
|
||||
res=malloc(sizeof(FILE));
|
||||
res->buffer=malloc(256);
|
||||
res->buffersize=256;
|
||||
res->filesize=0;
|
||||
res->filepos=0;
|
||||
res->mode=imode;
|
||||
res->filename=getfullpath(filename);
|
||||
|
||||
if ((imode==FILE_OPEN_READ) || (imode==FILE_OPEN_APPEND))
|
||||
{
|
||||
res->filesize=_ksys_get_filesize(res->filename);
|
||||
}
|
||||
return res;
|
||||
}
|
729
programs/develop/ktcc/trunk/libc/stdio/format_print.c
Normal file
729
programs/develop/ktcc/trunk/libc/stdio/format_print.c
Normal file
@@ -0,0 +1,729 @@
|
||||
/*
|
||||
function for format output to the string
|
||||
*/
|
||||
|
||||
#include <kolibrisys.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
//#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
int formatted_double_to_string(long double number,int format1,int format2,char *s)
|
||||
{
|
||||
double n;
|
||||
double nbefor;
|
||||
double nafter;
|
||||
double v,v2;
|
||||
long intdigit;
|
||||
long beforpointdigit;
|
||||
long div;
|
||||
int i;
|
||||
int pos;
|
||||
int size;
|
||||
int fmt1;
|
||||
int fmt2;
|
||||
long mul;
|
||||
char buf[200];
|
||||
|
||||
size=(int)s;
|
||||
n=(double)number;
|
||||
if (n<0) {*s='-';s++;n=-n;}
|
||||
|
||||
fmt1=format1;
|
||||
fmt2=format2;
|
||||
if (fmt2>18) {fmt2=18;} //maximum of size long long type
|
||||
|
||||
//clear array befor output
|
||||
for(i=0;i<=200;i++) {buf[i]=0;}
|
||||
|
||||
if ((fmt1>=0) && (n<1))
|
||||
{ //formatted output if 0<=n<1
|
||||
mul=1;
|
||||
for(i=0;i<fmt2;i++)
|
||||
{n=n*10;mul=mul*10;}
|
||||
|
||||
n=n*10;
|
||||
n=ceil(n);
|
||||
intdigit=floor(n);
|
||||
//intdigit=n;
|
||||
intdigit=(intdigit/10);
|
||||
|
||||
pos=0;
|
||||
mul=mul/10;
|
||||
for(i=0;i<fmt2-1;i++)
|
||||
{
|
||||
div=intdigit/mul;
|
||||
buf[pos]=(char)div;
|
||||
pos++;
|
||||
intdigit=intdigit-div*mul;
|
||||
mul=mul/10;
|
||||
if (mul==1) break;
|
||||
}
|
||||
buf[pos]=(char)intdigit;
|
||||
*s='0';s++;
|
||||
*s='.';s++;
|
||||
for(i=0;i<format2;i++)
|
||||
{
|
||||
if ((buf[i]>=0) && (buf[i]<=9)) {*s='0'+buf[i];}
|
||||
else {*s='0';}
|
||||
s++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //if n>=1
|
||||
//v=floorf(n+0.00000000000001);
|
||||
beforpointdigit=floor(n+0.00000000000001);
|
||||
//beforpointdigit=n;
|
||||
nbefor=beforpointdigit;
|
||||
nafter=n-nbefor;
|
||||
|
||||
//print part of number befor point
|
||||
mul=1;
|
||||
for(i=0;i<200-2;i++)
|
||||
{
|
||||
mul=mul*10;
|
||||
if ((beforpointdigit/mul)==0) {fmt1=i+1;break;}
|
||||
}
|
||||
|
||||
pos=0;
|
||||
mul=mul/10;
|
||||
for(i=0;i<fmt1-1;i++)
|
||||
{
|
||||
div=beforpointdigit/mul;
|
||||
buf[pos]=(char)div;
|
||||
pos++;
|
||||
beforpointdigit=beforpointdigit-div*mul;
|
||||
mul=mul/10;
|
||||
if (mul==1) break;
|
||||
}
|
||||
buf[pos]=(char)beforpointdigit;
|
||||
|
||||
for(i=0;i<fmt1;i++)
|
||||
{
|
||||
if ((buf[i]>=0) && (buf[i]<=9)) {*s='0'+buf[i];}
|
||||
s++;
|
||||
}
|
||||
|
||||
//print part of number after point
|
||||
mul=1;
|
||||
for(i=0;i<fmt2;i++)
|
||||
{nafter=nafter*10;mul=mul*10;}
|
||||
|
||||
nafter=nafter*10;
|
||||
nafter=ceil(nafter);
|
||||
intdigit=floor(nafter);
|
||||
//intdigit=nafter;
|
||||
intdigit=intdigit/10;
|
||||
|
||||
pos=0;
|
||||
mul=mul/10;
|
||||
for(i=0;i<fmt2-1;i++)
|
||||
{
|
||||
div=intdigit/mul;
|
||||
buf[pos]=(char)div;
|
||||
pos++;
|
||||
intdigit=intdigit-div*mul;
|
||||
mul=mul/10;
|
||||
if (mul==1) break;
|
||||
}
|
||||
buf[pos]=(char)intdigit;
|
||||
*s='.';s++;
|
||||
for(i=0;i<format2;i++)
|
||||
{
|
||||
if ((buf[i]>=0) && (buf[i]<=9)) {*s='0'+buf[i];}
|
||||
else {*s='0';}
|
||||
s++;
|
||||
}
|
||||
|
||||
}
|
||||
size=(int)s-size;
|
||||
return(size);
|
||||
}
|
||||
|
||||
int formatted_long_to_string(long long number,int fmt1,char *s)
|
||||
{
|
||||
int i;
|
||||
int pos;
|
||||
int fmt;
|
||||
int size;
|
||||
int difference_pos;
|
||||
long digit;
|
||||
long mul;
|
||||
long div;
|
||||
char buf[200];
|
||||
|
||||
//clear array befor output
|
||||
for(i=0;i<200;i++) {buf[i]=0;}
|
||||
digit=number;
|
||||
|
||||
size=(int)s;
|
||||
if (digit<0) {*s='-';s++;digit=-digit;}
|
||||
if (digit==0) {*s='0';s++;goto end;}
|
||||
|
||||
mul=1;
|
||||
for(i=0;i<200-2;i++)
|
||||
{
|
||||
mul=mul*10;
|
||||
if ((digit/mul)==0) {fmt=i+1;break;}
|
||||
}
|
||||
|
||||
difference_pos=i+1;
|
||||
|
||||
pos=0;
|
||||
mul=mul/10;
|
||||
for(i=0;i<fmt-1;i++)
|
||||
{
|
||||
div=digit/mul;
|
||||
buf[pos]=(char)div;
|
||||
pos++;
|
||||
digit=digit-div*mul;
|
||||
mul=mul/10;
|
||||
if (mul==1) break;
|
||||
}
|
||||
buf[pos]=(char)digit;
|
||||
|
||||
if (fmt1>=difference_pos) fmt=fmt1;
|
||||
else
|
||||
fmt=difference_pos;
|
||||
|
||||
for(i=0;i<fmt;i++)
|
||||
{
|
||||
if (i<difference_pos)
|
||||
{
|
||||
if ((buf[i]>=0) && (buf[i]<=9)) {*s='0'+buf[i];}
|
||||
}
|
||||
else
|
||||
{
|
||||
*s=' ';
|
||||
}
|
||||
s++;
|
||||
}
|
||||
end:
|
||||
size=(int)s-size;
|
||||
return(size);
|
||||
}
|
||||
|
||||
int formatted_hex_to_string(long long number,int fmt1,char flag_register,char *s)
|
||||
{
|
||||
long n;
|
||||
int i,pos;
|
||||
int fmt;
|
||||
long size;
|
||||
int difference_pos;
|
||||
char xdigs_lower[16]="0123456789abcdef";
|
||||
char xdigs_upper[16]="0123456789ABCDEF";
|
||||
char buf[200];
|
||||
|
||||
n=(long)number;
|
||||
size=(int)s;
|
||||
if (n<0) {*s='-';s++;n=-n;}
|
||||
|
||||
if (n==0) {*s='0';s++;goto end;}
|
||||
for(i=0;i<200;i++) {buf[i]=0;}
|
||||
|
||||
i=0;
|
||||
if (flag_register==0)
|
||||
{
|
||||
while (n>0)
|
||||
{
|
||||
buf[i]=xdigs_lower[n & 15];
|
||||
n=n>>4;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (n>0)
|
||||
{
|
||||
buf[i]=xdigs_upper[n & 15];
|
||||
n=n>>4;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
pos=i;
|
||||
difference_pos=i;
|
||||
|
||||
for(i=pos-1;i>=0;i--)
|
||||
{
|
||||
*s=buf[i];
|
||||
s++;
|
||||
}
|
||||
|
||||
if (fmt1-difference_pos>0)
|
||||
{
|
||||
for(i=difference_pos+1;i<=fmt1;i++)
|
||||
{
|
||||
*s=' ';
|
||||
s++;
|
||||
}
|
||||
}
|
||||
end:size=(int)s-size;
|
||||
return(size);
|
||||
}
|
||||
|
||||
int formatted_octa_to_string(long long number,int fmt1,char flag_register,char *s)
|
||||
{
|
||||
long n;
|
||||
int i,pos;
|
||||
int fmt;
|
||||
long size;
|
||||
int difference_pos;
|
||||
char xdigs_lower[16]="012345678";
|
||||
char buf[200];
|
||||
|
||||
n=number;
|
||||
size=(int)s;
|
||||
if (n<0) {*s='-';s++;n=-n;}
|
||||
|
||||
if (n==0) {*s='0';s++;goto end;}
|
||||
for(i=0;i<200;i++) {buf[i]=0;}
|
||||
|
||||
i=0;
|
||||
if (flag_register==0)
|
||||
{
|
||||
while (n>0)
|
||||
{
|
||||
buf[i]=xdigs_lower[n & 7];
|
||||
n=n>>3;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
pos=i;
|
||||
difference_pos=i;
|
||||
|
||||
for(i=pos-1;i>=0;i--)
|
||||
{
|
||||
*s=buf[i];
|
||||
s++;
|
||||
}
|
||||
|
||||
if (fmt1-difference_pos>0)
|
||||
{
|
||||
for(i=difference_pos+1;i<=fmt1;i++)
|
||||
{
|
||||
*s=' ';
|
||||
s++;
|
||||
}
|
||||
}
|
||||
end:size=(int)s-size;
|
||||
return(size);
|
||||
}
|
||||
|
||||
int format_print(char *dest, size_t maxlen,const char *fmt0, va_list argp)
|
||||
{
|
||||
int i,j,k;
|
||||
int length;
|
||||
int fmt1,fmt2,stepen;
|
||||
size_t pos,posc;
|
||||
long long intdigit;
|
||||
long double doubledigit;
|
||||
float floatdigit;
|
||||
const char *fmt,*fmtc;
|
||||
char *s;
|
||||
char *str;
|
||||
char buffmt1[30];
|
||||
char buffmt2[30];
|
||||
char buf[1024];
|
||||
char format_flag;
|
||||
char flag_point;
|
||||
char flag_noformat;
|
||||
char flag_long;
|
||||
char flag_unsigned;
|
||||
char flag_register;
|
||||
char flag_plus;
|
||||
|
||||
fmt=fmt0;
|
||||
s=dest;
|
||||
pos=0;
|
||||
while(pos<maxlen)
|
||||
{
|
||||
if (*fmt=='%')
|
||||
{
|
||||
|
||||
if (*(fmt+1)=='%')
|
||||
{
|
||||
*s='%';
|
||||
s++;
|
||||
fmt=fmt+2;
|
||||
pos++;
|
||||
goto exit_check;
|
||||
}
|
||||
//checking to containg format in the string
|
||||
fmtc=fmt;
|
||||
posc=pos;
|
||||
format_flag=0;
|
||||
flag_long=0;
|
||||
flag_unsigned=0;
|
||||
flag_register=0;
|
||||
flag_plus=0;
|
||||
while((*fmtc!='\0') || (*fmtc!=0))
|
||||
{
|
||||
fmtc++;
|
||||
posc++;
|
||||
switch(*fmtc)
|
||||
{
|
||||
case 'c':
|
||||
case 'C':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
case 'i':
|
||||
case 'I':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'e':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'E':
|
||||
format_flag=1;
|
||||
flag_long=1;
|
||||
break;
|
||||
case 'f':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'F':
|
||||
format_flag=1;
|
||||
flag_long=1;
|
||||
break;
|
||||
case 'g':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'G':
|
||||
format_flag=1;
|
||||
flag_long=1;
|
||||
break;
|
||||
case 'l':
|
||||
flag_long=1;
|
||||
break;
|
||||
case 'L':
|
||||
flag_long=2;
|
||||
break;
|
||||
case 'o':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'u':
|
||||
case 'U':
|
||||
format_flag=1;
|
||||
flag_unsigned=1;
|
||||
break;
|
||||
case 'x':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'X':
|
||||
flag_register=1;
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
format_flag=1;
|
||||
flag_unsigned=1;
|
||||
break;
|
||||
case '+':
|
||||
flag_plus=1;
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
if ((*fmtc=='%') || (*fmtc==' ')) break;
|
||||
if (format_flag==1) break;
|
||||
}
|
||||
|
||||
if (format_flag==0)
|
||||
{
|
||||
*s=*fmt;
|
||||
fmt++;
|
||||
s++;
|
||||
pos++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((posc-pos)==1)
|
||||
{//simbols % and format simbol near tothere(for example %c )
|
||||
fmt=fmtc+1;
|
||||
switch(*fmtc)
|
||||
{
|
||||
case 'c':
|
||||
case 'C':
|
||||
if ((pos+1)<maxlen)
|
||||
{
|
||||
//*s=(int)va_arg(argp,char*);
|
||||
*s=*((char *)argp);
|
||||
argp=argp+4;
|
||||
*s++;pos++;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
str=va_arg(argp,char*);
|
||||
length=strlen(str);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,str,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
case 'i':
|
||||
case 'I':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
//intdigit=*((long*)argp);
|
||||
//argp=argp+4;
|
||||
if ((intdigit>0) && (flag_plus==1) && (pos+1<maxlen))
|
||||
{
|
||||
*s='+';
|
||||
s++;
|
||||
pos++;
|
||||
}
|
||||
length=formatted_long_to_string(intdigit,0,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
//intdigit=*((long int *)argp);
|
||||
//argp=argp+4;
|
||||
|
||||
length=formatted_octa_to_string(intdigit,0,flag_register,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
case 'U':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long int);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
|
||||
if (flag_unsigned==1) {
|
||||
if (intdigit<0) {intdigit=-intdigit;}
|
||||
}
|
||||
|
||||
length=formatted_long_to_string(intdigit,0,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'x':
|
||||
case 'X':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
//intdigit=*((long int *)argp);
|
||||
//argp=argp+4;
|
||||
|
||||
length=formatted_hex_to_string(intdigit,0,flag_register,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
intdigit=va_arg(argp,size_t);
|
||||
|
||||
if (flag_unsigned==1) {
|
||||
if (intdigit<0) {intdigit=-intdigit;}
|
||||
}
|
||||
|
||||
length=formatted_long_to_string(intdigit,0,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt++;
|
||||
flag_point=0;
|
||||
flag_noformat=0;
|
||||
fmt1=0;
|
||||
fmt2=0;
|
||||
j=0;
|
||||
k=0;
|
||||
for(i=pos+1;i<posc;i++)
|
||||
{
|
||||
switch(*fmt)
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (flag_point==0)
|
||||
{
|
||||
buffmt1[j]=*fmt-'0';
|
||||
j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffmt2[k]=*fmt-'0';
|
||||
k++;
|
||||
}
|
||||
break;
|
||||
case '.':
|
||||
flag_point=1;
|
||||
break;
|
||||
case 'l':
|
||||
case 'L':
|
||||
break;
|
||||
case '+':
|
||||
break;
|
||||
default:flag_noformat=1;
|
||||
}
|
||||
if (flag_noformat==1) break;
|
||||
fmt++;
|
||||
}
|
||||
if (flag_noformat==0)
|
||||
{
|
||||
stepen=1;
|
||||
for(i=j-1;i>=0;i--)
|
||||
{
|
||||
fmt1=fmt1+buffmt1[i]*stepen;
|
||||
stepen=stepen*10;
|
||||
}
|
||||
stepen=1;
|
||||
for(i=k-1;i>=0;i--)
|
||||
{
|
||||
fmt2=fmt2+buffmt2[i]*stepen;
|
||||
stepen=stepen*10;
|
||||
}
|
||||
switch(*fmtc)
|
||||
{
|
||||
case 'f':
|
||||
case 'F':
|
||||
if (flag_long==0) {doubledigit=va_arg(argp,double);}
|
||||
if (flag_long>=1) {doubledigit=va_arg(argp,long double);}
|
||||
//doubledigit=*((double *)argp);
|
||||
//sargp=argp+8;
|
||||
length=formatted_double_to_string(doubledigit,fmt1,fmt2,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
case 'i':
|
||||
case 'I':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
|
||||
if ((intdigit>0) && (flag_plus==1) && (pos+1<maxlen))
|
||||
{
|
||||
*s='+';
|
||||
s++;
|
||||
pos++;
|
||||
}
|
||||
length=formatted_long_to_string(intdigit,fmt1,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
length=formatted_octa_to_string(intdigit,fmt1,flag_register,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
case 'U':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long int);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
|
||||
if (flag_unsigned==1) {
|
||||
if (intdigit<0) {intdigit=-intdigit;}
|
||||
}
|
||||
|
||||
length=formatted_long_to_string(intdigit,fmt1,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'x':
|
||||
case 'X':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long int);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
length=formatted_hex_to_string(intdigit,fmt1,flag_register,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
intdigit=va_arg(argp,size_t);
|
||||
|
||||
if (flag_unsigned==1) {
|
||||
if (intdigit<0) {intdigit=-intdigit;}
|
||||
}
|
||||
|
||||
length=formatted_long_to_string(intdigit,fmt1,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
fmt=fmtc+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*fmt=='\0') {break;}
|
||||
*s=*fmt;
|
||||
fmt++;
|
||||
s++;
|
||||
pos++;
|
||||
}
|
||||
exit_check:;
|
||||
}
|
||||
return(pos);
|
||||
}
|
21
programs/develop/ktcc/trunk/libc/stdio/fprintf.c
Normal file
21
programs/develop/ktcc/trunk/libc/stdio/fprintf.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int format_print(char *dest, size_t maxlen, const char *fmt,va_list argp);
|
||||
|
||||
int fprintf(FILE* file, const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
char *buf;
|
||||
int printed;
|
||||
//int data[4];
|
||||
|
||||
va_start (arg, format);
|
||||
buf=malloc(4096*2); //8kb max
|
||||
//data[0]=(int)&arg-(int)&format;
|
||||
|
||||
printed=format_print(buf,8191, format,arg);
|
||||
fwrite(buf,printed,1,file);
|
||||
free(buf);
|
||||
|
||||
return(printed);
|
||||
}
|
35
programs/develop/ktcc/trunk/libc/stdio/fputc.c
Normal file
35
programs/develop/ktcc/trunk/libc/stdio/fputc.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
int fputc(int c,FILE* file)
|
||||
{
|
||||
dword res;
|
||||
|
||||
if ((file->mode & 3)==FILE_OPEN_READ) return EOF;
|
||||
|
||||
file->buffer[0]=c;
|
||||
if ((file->mode & 3)==FILE_OPEN_APPEND)
|
||||
{
|
||||
file->filepos=file->filesize;
|
||||
file->filesize++;
|
||||
res=_ksys_appendtofile(file->filename,file->filepos,1,file->buffer);
|
||||
if (res!=0) return(res);
|
||||
file->filepos++;
|
||||
return(0);
|
||||
}
|
||||
if ((file->mode & 3)==FILE_OPEN_WRITE)
|
||||
{
|
||||
if (file->filepos==0)
|
||||
{ //file not craeted
|
||||
res=_ksys_rewritefile(file->filename,1,file->buffer);
|
||||
if (res!=0) return(res);
|
||||
file->filepos++;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{ //file craeted and need append one byte
|
||||
res=_ksys_appendtofile(file->filename,file->filepos,1,file->buffer);
|
||||
if (res!=0) return(res);
|
||||
file->filepos++;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
26
programs/develop/ktcc/trunk/libc/stdio/fread.c
Normal file
26
programs/develop/ktcc/trunk/libc/stdio/fread.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <kolibrisys.h>
|
||||
|
||||
int fread(void *buffer,int size,int count,FILE* file)
|
||||
{
|
||||
dword res;
|
||||
dword fullsize;
|
||||
|
||||
if ((file->mode!=FILE_OPEN_READ) || (file->mode==FILE_OPEN_PLUS)) return 0;
|
||||
|
||||
fullsize=count*size;
|
||||
if ((fullsize+file->filepos)>(file->filesize))
|
||||
{
|
||||
fullsize=file->filesize-file->filepos;
|
||||
if (fullsize<=0) return(0);
|
||||
}
|
||||
|
||||
res=_ksys_readfile(file->filename,file->filepos,fullsize,buffer);
|
||||
if (res==0)
|
||||
{
|
||||
file->filepos=file->filepos+fullsize;
|
||||
fullsize=fullsize/size;
|
||||
return(fullsize);
|
||||
}
|
||||
else return 0;
|
||||
}
|
188
programs/develop/ktcc/trunk/libc/stdio/fscanf.c
Normal file
188
programs/develop/ktcc/trunk/libc/stdio/fscanf.c
Normal file
@@ -0,0 +1,188 @@
|
||||
#include <stdio.h>
|
||||
void skipspaces(FILE* file)
|
||||
{
|
||||
int c;
|
||||
while(1)
|
||||
{
|
||||
c=getc(file);
|
||||
if (c!=' ' && c!='\r' && c!='\n')
|
||||
{
|
||||
ungetc(c,file);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
int fscanf(FILE* file,const char* format, ...)
|
||||
{
|
||||
int res;
|
||||
void* arg;
|
||||
int i;
|
||||
int c;
|
||||
int contflag;
|
||||
int longflag;
|
||||
int sign;
|
||||
long long number;
|
||||
long double rnumber;
|
||||
char* str;
|
||||
res=0;
|
||||
arg=&format;
|
||||
arg+=sizeof(const char*);
|
||||
while (*format!='\0')
|
||||
{
|
||||
if (*format!='%')
|
||||
{
|
||||
c=fgetc(file);
|
||||
if (c!=*format)
|
||||
{
|
||||
fungetc(c,file);
|
||||
return -1;
|
||||
}
|
||||
format++;
|
||||
continue;
|
||||
}
|
||||
contflag=1;
|
||||
longflag=0;
|
||||
while (*format && contflag)
|
||||
{
|
||||
switch(*format)
|
||||
{
|
||||
case '.':
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
format++;
|
||||
continue;
|
||||
break;
|
||||
case 'l':
|
||||
if (longflag==0)
|
||||
longflag=1;
|
||||
else
|
||||
longflag=2;
|
||||
format++;
|
||||
break;
|
||||
case 'L':
|
||||
longflag=2;
|
||||
format++;
|
||||
break;
|
||||
case 'f':
|
||||
case 'd':
|
||||
case 'c':
|
||||
case 's':
|
||||
case '%':
|
||||
contflag=0;
|
||||
break;
|
||||
default:
|
||||
contflag=0;
|
||||
}
|
||||
}
|
||||
if (contflag)
|
||||
break;
|
||||
switch(*format)
|
||||
{
|
||||
case '%':
|
||||
c=fgetc(file);
|
||||
if (c!='%')
|
||||
{
|
||||
ungetc(c,file);
|
||||
return -1;
|
||||
}
|
||||
res--;
|
||||
break;
|
||||
case 'd':
|
||||
number=0;
|
||||
sign=1;
|
||||
skipspaces(file);
|
||||
c=fgetc(file);
|
||||
if (c=='-')
|
||||
{
|
||||
sign=-1;
|
||||
}else if (c!='+')
|
||||
ungetc(c,file);
|
||||
contflag=0;
|
||||
while(1)
|
||||
{
|
||||
c=fgetc(file);
|
||||
if (c>='0' && c<='9')
|
||||
{
|
||||
contflag++;
|
||||
number=number*10+(c-'0');
|
||||
}else
|
||||
break;
|
||||
}
|
||||
ungetc(c,file);
|
||||
if (!contflag)
|
||||
return res;
|
||||
if (longflag<=1)
|
||||
{
|
||||
*((int*)arg)=number;
|
||||
arg+=sizeof(int);
|
||||
}else
|
||||
{
|
||||
*((long long*)arg)=number;
|
||||
arg+=sizeof(long long);
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
c=fgetc(file);
|
||||
if (c==EOF)
|
||||
return res;
|
||||
*((char*)arg)=c;
|
||||
arg+=sizeof(char);
|
||||
break;
|
||||
case 's':
|
||||
skipspaces(file);
|
||||
contflag=0;
|
||||
str=*((char**)arg);
|
||||
arg+=sizeof(char*);
|
||||
while(1)
|
||||
{
|
||||
c=fgetc(file);
|
||||
if (c==EOF || c==' ' || c=='\n' || c=='\r')
|
||||
{
|
||||
ungetc(c,file);
|
||||
break;
|
||||
}
|
||||
*str=c;
|
||||
str++;
|
||||
contflag++;
|
||||
}
|
||||
if (!contflag)
|
||||
return res;
|
||||
break;
|
||||
case 'f':
|
||||
skipspaces(file);
|
||||
// TODO: read real numbers
|
||||
rnumber=0;
|
||||
switch (longflag)
|
||||
{
|
||||
case 0:
|
||||
*((float*)arg)=rnumber;
|
||||
arg+=sizeof(float);
|
||||
break;
|
||||
case 1:
|
||||
*((double*)arg)=rnumber;
|
||||
arg+=sizeof(double);
|
||||
break;
|
||||
case 2:
|
||||
*((long double*)arg)=rnumber;
|
||||
arg+=sizeof(long double);
|
||||
break;
|
||||
default:
|
||||
return res;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
format++;
|
||||
res++;
|
||||
}
|
||||
return res;
|
||||
}
|
11
programs/develop/ktcc/trunk/libc/stdio/fseek.c
Normal file
11
programs/develop/ktcc/trunk/libc/stdio/fseek.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
int fseek(FILE* file,long offset,int origin)
|
||||
{
|
||||
if (origin==SEEK_CUR)
|
||||
offset+=file->filepos;
|
||||
else if (origin==SEEK_END)
|
||||
offset+=file->filesize;
|
||||
else if (origin!=SEEK_SET)
|
||||
return EOF;
|
||||
return fsetpos(file,offset);
|
||||
}
|
11
programs/develop/ktcc/trunk/libc/stdio/fsetpos.c
Normal file
11
programs/develop/ktcc/trunk/libc/stdio/fsetpos.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
int fsetpos(FILE* file,const fpos_t * pos)
|
||||
{
|
||||
if (*pos>=0)
|
||||
{
|
||||
file->filepos=*pos;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return EOF;
|
||||
}
|
5
programs/develop/ktcc/trunk/libc/stdio/ftell.c
Normal file
5
programs/develop/ktcc/trunk/libc/stdio/ftell.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <stdio.h>
|
||||
long ftell(FILE* file)
|
||||
{
|
||||
return file->filepos;
|
||||
}
|
58
programs/develop/ktcc/trunk/libc/stdio/fwrite.c
Normal file
58
programs/develop/ktcc/trunk/libc/stdio/fwrite.c
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <stdio.h>
|
||||
#include <kolibrisys.h>
|
||||
|
||||
int fwrite(void *buffer,int size,int count,FILE* file)
|
||||
{
|
||||
dword res;
|
||||
dword fullsize;
|
||||
|
||||
if (file->mode==FILE_OPEN_READ) return 0;
|
||||
|
||||
if (file->mode==FILE_OPEN_APPEND)
|
||||
file->filepos=file->filesize;
|
||||
fullsize=count*size;
|
||||
|
||||
if ((file->filesize)<(file->filepos+fullsize)) file->filesize=file->filepos+fullsize;
|
||||
|
||||
/*
|
||||
if (file->mode==FILE_OPEN_APPEND)
|
||||
{
|
||||
file->filepos==file->filesize;
|
||||
res=_ksys_appendtofile(file->filename,file->filepos,fullsize,buffer);
|
||||
if (res==0)
|
||||
{
|
||||
file->filepos+=fullsize;
|
||||
fullsize=fullsize/size;
|
||||
return(fullsize);
|
||||
}
|
||||
else return(0);
|
||||
|
||||
}
|
||||
*/
|
||||
if ((file->mode==FILE_OPEN_WRITE) || (file->mode==FILE_OPEN_APPEND))
|
||||
{
|
||||
if (file->filepos==0)
|
||||
{ //file mot craeted yet
|
||||
res=_ksys_rewritefile(file->filename,fullsize,buffer);
|
||||
if (res==0)
|
||||
{
|
||||
file->filepos+=fullsize;
|
||||
fullsize=fullsize/count;
|
||||
return(fullsize);
|
||||
}
|
||||
else return(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
res=_ksys_appendtofile(file->filename,file->filepos,fullsize,buffer);
|
||||
if (res==0)
|
||||
{
|
||||
file->filepos+=fullsize;
|
||||
fullsize=fullsize/count;
|
||||
return(fullsize);
|
||||
}
|
||||
else return(0);
|
||||
}
|
||||
}
|
||||
else return(0);
|
||||
}
|
75
programs/develop/ktcc/trunk/libc/stdio/printf.c
Normal file
75
programs/develop/ktcc/trunk/libc/stdio/printf.c
Normal file
@@ -0,0 +1,75 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <kolibrisys.h>
|
||||
|
||||
char* dllname="/sys/lib/console.obj";
|
||||
int console_init_status;
|
||||
|
||||
char* imports[] = {"START","version","con_init","con_write_asciiz","con_printf","con_exit",NULL};
|
||||
char* caption = "Console test - colors";
|
||||
|
||||
dword* dll_ver;
|
||||
void stdcall (* con_init)(dword wnd_width, dword wnd_height, dword scr_width, dword scr_height, const char* title);
|
||||
void stdcall (* con_write_asciiz)(const char* string);
|
||||
void cdecl (* con_printf)(const char* format,...);
|
||||
void stdcall (* con_exit)(dword bCloseWindow);
|
||||
|
||||
struct import{
|
||||
char *name;
|
||||
void *data;
|
||||
};
|
||||
|
||||
void printf_link(struct import *exp, char** imports){
|
||||
|
||||
dll_ver = (dword*)
|
||||
_ksys_cofflib_getproc(exp, imports[1]);
|
||||
con_init = (void stdcall (*)(dword , dword, dword, dword, const char*))
|
||||
_ksys_cofflib_getproc(exp, imports[2]);
|
||||
con_printf = (void cdecl (*)(const char*,...))
|
||||
_ksys_cofflib_getproc(exp, imports[4]);
|
||||
con_exit = (void stdcall (*)(dword))
|
||||
_ksys_cofflib_getproc(exp, imports[5]);
|
||||
}
|
||||
|
||||
int init_console(void)
|
||||
{
|
||||
struct import * hDll;
|
||||
|
||||
if((hDll = (struct import *)_ksys_cofflib_load(dllname)) == 0){
|
||||
debug_out_str("can't load lib\n");
|
||||
return 1;
|
||||
}
|
||||
printf_link(hDll, imports);
|
||||
debug_out_str("dll loaded\n");
|
||||
|
||||
con_init(-1, -1, -1, -1, caption);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int printf(const char *format,...)
|
||||
{
|
||||
int i;
|
||||
int printed_simbols;
|
||||
va_list arg;
|
||||
char simbol[]={"%s"};
|
||||
char *s;
|
||||
|
||||
va_start(arg,format);
|
||||
|
||||
if (console_init_status==0)
|
||||
{
|
||||
i=init_console();
|
||||
console_init_status=1;
|
||||
}
|
||||
|
||||
if (i==0)
|
||||
{
|
||||
s=malloc(4096);
|
||||
printed_simbols=format_print(s,4096,format,arg);
|
||||
con_printf(simbol,s);
|
||||
free(s);
|
||||
}
|
||||
return(printed_simbols);
|
||||
}
|
||||
|
5
programs/develop/ktcc/trunk/libc/stdio/rewind.c
Normal file
5
programs/develop/ktcc/trunk/libc/stdio/rewind.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <stdio.h>
|
||||
void rewind(FILE* file)
|
||||
{
|
||||
file->filepos=0;
|
||||
}
|
15
programs/develop/ktcc/trunk/libc/stdio/snprintf.c
Normal file
15
programs/develop/ktcc/trunk/libc/stdio/snprintf.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <kolibrisys.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int format_print(char *dest, size_t maxlen, const char *fmt,va_list argp);
|
||||
|
||||
|
||||
int snprintf(char *dest, size_t size,const char *format,...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start (arg, format);
|
||||
return format_print(dest,size, format, arg);
|
||||
}
|
||||
|
||||
|
15
programs/develop/ktcc/trunk/libc/stdio/sprintf.c
Normal file
15
programs/develop/ktcc/trunk/libc/stdio/sprintf.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <kolibrisys.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int format_print(char *dest, size_t maxlen, const char *fmt,va_list argp);
|
||||
|
||||
|
||||
int sprintf(char *dest,const char *format,...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start (arg, format);
|
||||
return format_print(dest,4096, format, arg);
|
||||
}
|
||||
|
||||
|
15
programs/develop/ktcc/trunk/libc/stdio/vsnprintf.c
Normal file
15
programs/develop/ktcc/trunk/libc/stdio/vsnprintf.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <kolibrisys.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int format_print(char *dest, size_t maxlen, const char *fmt,
|
||||
va_list argp);
|
||||
|
||||
|
||||
int vsnprintf(char *dest, size_t size,const char *format,va_list ap)
|
||||
{
|
||||
|
||||
return format_print(dest,size, format, ap);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user