Displaying 20 results from an estimated 71 matches for "fgetc".
Did you mean:
fgets
2023 Feb 17
2
fseek/fgetc puzzle
...<stdio.h>
int main(void)
{
FILE *f = fopen("testfile", "w");
putc('A', f);
fclose(f);
f = fopen("testfile", "a+"); /* same behaviour for r+ */
fseek(f, -1L, SEEK_END);
printf("c=%d\n", fgetc(f));
/* fseek(f, 0, SEEK_END); -- with this it behaves as expected */
/* fflush(f); -- this too */
fputc('B', f);
}
$ gcc test.c && ./a.out; od -x -c testfile
c=65
0000000 4141 0042
A A B
0000003
I wrote two bytes and read one but som...
2020 Jul 25
0
[klibc:master] stdio: Define all the _unlocked functions and macros
...usr/klibc/fputc.c | 1 +
usr/klibc/fputs.c | 1 +
usr/klibc/fread2.c | 1 +
usr/klibc/fwrite2.c | 2 ++
usr/klibc/stdio/clearerr.c | 1 +
usr/klibc/stdio/feof.c | 1 +
usr/klibc/stdio/ferror.c | 1 +
usr/klibc/stdio/fflush.c | 2 +-
usr/klibc/stdio/fgetc.c | 1 +
usr/klibc/stdio/fileno.c | 1 +
12 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/usr/include/stdio.h b/usr/include/stdio.h
index 1d45fe1a..521213df 100644
--- a/usr/include/stdio.h
+++ b/usr/include/stdio.h
@@ -48,17 +48,24 @@ __extern int fseek(FILE *, off_t, int);...
2023 Feb 20
1
fseek/fgetc puzzle
On Mon, Feb 20, 2023 at 10:21:31PM +1100, Darren Tucker wrote:
> > My suggestion of course fails to explain why there's only one 'B'.
> > I would create the initial file separately from the test program.
>
> The "od" call in the middle of the above example proves there's only
> one byte after the first fclose.
Ah, so it does. What happens
if you
2023 Feb 20
1
fseek/fgetc puzzle
Darren Tucker wrote in
<CALDDTe39k4UFJWBvts5HWbbhHO+Vw9OAP0zBhu-Hje-2aR9+xA at mail.gmail.com>:
J?rg Schilling convinced me in 2017
Readd removed fflush()/fseek() in between read and write..
The behave:record_a_resend-2 test failed on Solaris 5.10 and 5.11,
messages in *record* where separated by four \n / U+000A instead
of two. It turns out that the effective sequence
2010 Nov 20
3
[PATCH 1/4] utils: cleanup unused includes
several errno.h for no good reasons.
cleanup losesetup which is not using getopt_long,
thus doesn't need getopt.h included.
Move stdarg.h include up in losesetup to more proper place.
Signed-off-by: maximilian attems <max at stro.at>
---
usr/utils/dmesg.c | 1 -
usr/utils/losetup.c | 4 +---
usr/utils/mkfifo.c | 1 -
usr/utils/nuke.c | 1 -
usr/utils/umount.c | 1
2001 Jun 06
0
snk authentication
...256];
+ int len;
+ unsigned char data[48];
+
+ fp = fopen (keyfile, "r");
+ if (fp == NULL) {
+ fprintf (stderr, "Error: Cannot open %s: %s\n", keyfile, strerror(errno));
+ exit(1);
+ }
+ len = 0;
+ memset(data, 0, sizeof(data));
+ while (len < sizeof(data)) {
+ int c1 = fgetc(fp);
+ int c2 = fgetc(fp);
+ if (c1 == '\n' || c1 == EOF || c2 == '\n' || c2 == EOF)
+ break;
+ data[len++] = (hexvalue(c1) << 4 ) + hexvalue(c2);
+ }
+ fclose(fp);
+ get_snk_pass("", secret, sizeof(secret), data);
+ if (! valid_secret_p(secret) ) {
+ get_passwo...
2005 Feb 25
15
FW: Getting PHP Config to work?
Hi,
I have been doing various testing with asterisk and its been going great.
However I am a bit feedup of using vi for editing configs, and would rather
do it from any machine on my LAN. I am running debian and * via xorcom rapid
on a test PC at the minute.
Hence phpconfig would be great, however I am having difficulty getting it to
work. I have searched the message boards and the wiki, and
2012 Nov 04
1
hexdump.c32 for Syslinux 5.00-pre9
...extended ASCII chars in dump\n"
+ " -?\n"
+ " -h\n"
+ " --help . . . . . . Display this help\n";
+
+ fprintf(stderr, usage, prog_name);
+ return EXIT_FAILURE;
+}
+
+static void eat_stdin(void)
+{
+ int i;
+
+ while (1) {
+ i = fgetc(stdin);
+ if (i == EOF || i == '\n')
+ return;
+ }
+}
+static int do_page(void)
+{
+ int i;
+
+ while (1) {
+ fprintf(stdout, "Continue? [Y|n]: ");
+ i = fgetc(stdin);
+ switch (i) {
+ case 'n':
+ case 'N':
+ eat_stdin();
+ return 1;
+...
2010 Apr 16
0
[PATCH] add minimal faccessat()
.....765052a 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -19,7 +19,7 @@ klib-y := vsnprintf.o snprintf.o vsprintf.o sprintf.o \
printf.o vprintf.o fprintf.o vfprintf.o perror.o \
statfs.o fstatfs.o umount.o \
creat.o open.o openat.o open_cloexec.o \
- fopen.o fread.o fread2.o fgetc.o fgets.o \
+ fopen.o fread.o fread2.o fgetc.o fgets.o faccessat.o \
fwrite.o fwrite2.o fputc.o fputs.o puts.o putchar.o \
sleep.o usleep.o strtotimespec.o strtotimeval.o \
raise.o abort.o assert.o alarm.o pause.o \
diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def
index ae...
2006 Aug 14
3
Making R script to run in a console
Hi,
is possible to make a R script to run under a console without open the R
environment?
Something like this example.R
#!/usr/bin/R
function(name="Put here your name") {
print(name)
}
In a console I make
./example.R name="Ronaldo Reis J?nior"
then program print my name.
It is possible?
Thanks
Ronaldo
--
A jury consists of twelve persons chosen to decide who has the
2009 Mar 06
4
rosh patch
...de = readdir(d);
- while (de != NULL) {
+ while ( de = readdir(d) ) {
#ifdef DO_DEBUG
filestr2[0] = 0;
file2pos = strlen(filestr);
@@ -401,7 +400,6 @@
#ifdef DO_DEBUG
// inchar = fgetc(stdin);
#endif /* DO_DEBUG */
- de = readdir(d);
}
closedir(d);
} else if (S_ISREG(fdstat.st_mode)) {
@@ -419,8 +417,7 @@
d = opendir(filestr);
if (d != NUL...
2006 Oct 09
1
Discussion starter for package level Connection API
...onnection con = getConnection(idx);
if (!con) return -1; /* just like fprintf(3)? */
if(!con->isopen) error(_("connection is not open"));
if(!con->canwrite) error(_("cannot write to this connection"));
return con->vfprintf(con,format,ap);
}
int R_FgetcConnection(int idx){
Rconnection con = getConnection(idx);
if (!con) return EOF; /* just like fgetc(3)? */
if(!con->isopen) error(_("connection is not open"));
if(!con->canread) error(_("cannot read from this connection"));
return con->fgetc(c...
2012 May 31
1
klibc 2.0 release
...[klibc] fflush: discard input data
[klibc] fseek: report error on fflush() failure
[klibc] f[d]open: don't bother setting input buffer
[klibc] Add rewind() function
[klibc] fgets: shave a few bytes off
[klibc] fgets: remove obsolete comment
[klibc] Optimize fgetc() to read the buffer directly
[klibc] Fix the zapping of unused input on output operation
[klibc] stdio: fix the handling of the eof and error flags on fseek
[klibc] isatty: allow errno to be set
[klibc] fgetc: shave off a few bytes
[klibc] f*open: support the glibc ...
2011 Feb 27
4
[PATCH] Add minimal mkstemp(3) implementation.
...vsnprintf.o snprintf.o vsprintf.o sprintf.o \
setpgrp.o getpgrp.o daemon.o \
printf.o vprintf.o fprintf.o vfprintf.o perror.o \
statfs.o fstatfs.o umount.o \
- creat.o open.o openat.o open_cloexec.o \
+ creat.o mkstemp.o open.o openat.o open_cloexec.o \
fopen.o fread.o fread2.o fgetc.o fgets.o \
fwrite.o fwrite2.o fputc.o fputs.o puts.o putchar.o \
sleep.o usleep.o strtotimespec.o strtotimeval.o \
diff --git a/usr/klibc/mkstemp.c b/usr/klibc/mkstemp.c
new file mode 100644
index 0000000..8430357
--- /dev/null
+++ b/usr/klibc/mkstemp.c
@@ -0,0 +1,93 @@
+/*-
+ * Compact mk...
2004 Jan 06
1
Keychain Patch Try II
...(readpassphrase(prompt, buf, sizeof buf, rppflags) == NULL) {
- if (flags & RP_ALLOW_EOF)
- return NULL;
- return xstrdup("");
- }
-#ifdef USE_KEYCHAIN
-
- fprintf(stderr, "Would you like to store this password in your
keychain (y/n)?\n");
- response = fgetc(stdin);
- if (response == 'y' || response == 'Y') {
- store_passphrase_on_keychain(prompt, buf);
- }
+ if (readpassphrase(prompt, buf, sizeof buf, rppflags) == NULL) {
+ if (flags & RP_ALLOW_EOF)
+ return NULL;
+ return xstrdup("");
}
-#endif /* USE_KEYC...
2020 Jul 25
0
[klibc:master] stdio: Add extern definition of clearerr()
...ions(+), 1 deletion(-)
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index ae5eb6dc..7929dee5 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -75,7 +75,7 @@ klib-y += vsnprintf.o snprintf.o vsprintf.o sprintf.o \
stdio/fread.o stdio/fwrite.o stdio/fflush.o \
stdio/ungetc.o stdio/fgetc.o \
stdio/fseek.o stdio/ftell.o stdio/rewind.o \
- stdio/fileno.o stdio/feof.o stdio/ferror.o
+ stdio/fileno.o stdio/feof.o stdio/ferror.o stdio/clearerr.o
klib-$(CONFIG_KLIBC_ERRLIST) += errlist.o
diff --git a/usr/klibc/stdio/clearerr.c b/usr/klibc/stdio/clearerr.c
new file mode 10064...
2010 Sep 06
0
encode and decode
...it) to ASCII, so we can simply play it in MATLAB:
system("mode com1: baud=38400 parity=n data=8 stop=1");//opening the rs232
FILE* mic=fopen("com1:", "w+" );
FILE *mic1 = fopen("mic.txt" , "wt");
while(1)
{
if (feof( mic ) == 0){
cbits[i]=fgetc(mic);
if(i==20)
{
speex_bits_read_from(&bits, cbits, nbBytes);
i=0;
speex_decode(state, &bits, output);
for (j=0;j<FRAME_SIZE;j++)
{
out[j]=output[j];
out_ascii[j*4]=hex2ascii((out[j] >> 12) & 0x000F);
out_ascii[j*4+1]=hex2ascii((out[j] >> 8) & 0x000F);
out...
2010 Sep 06
0
encoding on a ds'pic and decoding on a pc
...ose to it) to ASCII, so we can simply play it in MATLAB:
system("mode com1: baud=38400 parity=n data=8 stop=1");//opening the rs232
FILE* mic=fopen("com1:", "w+" );
FILE *mic1 = fopen("mic.txt" , "wt");
while(1)
{
if (feof( mic ) == 0){
cbits[i]=fgetc(mic);
if(i==20)
{
speex_bits_read_from(&bits, cbits, nbBytes);
i=0;
speex_decode(state, &bits, output);
for (j=0;j<FRAME_SIZE;j++)
{
out[j]=output[j];
out_ascii[j*4]=hex2ascii((out[j] >> 12) & 0x000F);
out_ascii[j*4+1]=hex2ascii((out[j] >> 8) & 0x000F);
out_ascii[j*4+...
2006 Nov 02
0
ssh strlen fixes
...*lineno);
+ if (buf[0] != '\0')
+ debug("%s: %s line %lu exceeds size limit",
+ __func__, filename, *lineno);
+ else
+ debug("%s: %s line %lu contains a NUL character",
+ __func__, filename, *lineno);
/* discard remainder of line */
while (fgetc(f) != '\n' && !feof(f))
; /* nothing */
Index: sftp.c
===================================================================
RCS file: /home/ray/openbsd/src/usr.bin/ssh/sftp.c,v
retrieving revision 1.93
diff -u -p -r1.93 sftp.c
--- sftp.c 30 Sep 2006 17:48:22 -0000 1.93
+++ sftp.c...
2005 Feb 28
2
phpconfig
Hello,
I recently downloaded phpconfig from
http://asterisk.espia-net.net/horde/chora/cvs.php/phpconfig?login=2
but on installing it, my interface does not look like the one at
http://rd.it.utah.edu/phpconfig/.
The main differences are:
1)On opening a file for editing, on the left menu mine has ony two
links i.e Header and the filename.conf as opposed to the deffrent
sections on the demo site.