X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=charfuncs.c;h=fab53a2c89eaa360c7e6d2f20d8dfe4f458d48af;hb=329f3bea220c9be3389fb47618c67cf26dd0c887;hp=fea0a99cf0081218b831794b55dc8db599e31176;hpb=f3143629476bae20f5310bbc0a59fe735b5d245d;p=onak.git diff --git a/charfuncs.c b/charfuncs.c index fea0a99..fab53a2 100644 --- a/charfuncs.c +++ b/charfuncs.c @@ -1,9 +1,20 @@ /* * charfuncs.c - Routines for dealing with character streams. * - * Jonathan McDowell + * Copyright 2002 Jonathan McDowell * - * Copyright 2002 Project Purple + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include @@ -25,11 +36,15 @@ int buffer_fetchchar(void *ctx, size_t count, void *c) struct buffer_ctx *buf = NULL; buf = (struct buffer_ctx *) ctx; + + if (buf->offset + count > buf->size) { + return 1; + } memcpy(c, &buf->buffer[buf->offset], count); buf->offset += count; - return (((buf->offset) == (buf->size)) ? 1 : 0); + return 0; } /**