From: Steve McDaniel <steven@synapsenetwork.org>
To: linux-c-programming@vger.kernel.org
Subject: Re: customer getline function
Date: Mon, 30 Oct 2006 00:47:12 -0500 [thread overview]
Message-ID: <ei43ld$lob$1@sea.gmane.org> (raw)
In-Reply-To: <ei4343$ks4$1@sea.gmane.org>
LoL, I guess I should really read over things before sending out
emails...it is actually supposed to be custom.....and
the function declaration is supposed to be bufferGetLine
Steve McDaniel wrote:
> I wrote a getBufferLine function that will read a line at a time from a
> buffer. Just returns everything til it hits '\n', then will move to the
> next.It works on small buffers, but seems to segfault on anything large.
> Trying to figure out how pointers work in C, any pointers would help.
>
> here is an example to use this function....
> while ((c = getBufferLine(&ptr,buf,BufLen)) != NULL)
> printf("%s", c);
>
> unsigned char* buffer_line_get(unsigned char** lineptr, unsigned char*
> buffer, int size)
> {
> static int index;
> unsigned char* c;
>
> if((size - index) == 0)
> return NULL;
>
> if (lineptr == NULL)
> *lineptr = c = buffer;
> else
> *lineptr = ((c = buffer) + index + 1);
>
> index = 0;
> while ((lineptr[index++] != '\n') && (index < size));
>
> lineptr+=index;
> *(buffer + index) = 0;
> return c;
> }
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
prev parent reply other threads:[~2006-10-30 5:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-30 5:37 customer getline function Steve McDaniel
2006-10-30 5:47 ` Steve McDaniel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='ei43ld$lob$1@sea.gmane.org' \
--to=steven@synapsenetwork.org \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).