ON 20050805@8:24:09 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm#38569.8501041667 [xiaofan-sg-] Code: in a new file at: http://www.piclist.com/techref/member/xiaofan-sg-/getline.html
<pre>
1st Try: to put getlin.h and getline.c

/* GNU Mailutils -- a suite of utilities for electronic mail
   Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library 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
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA  */

#ifndef _GETLINE_H_
# define _GETLINE_H_ 1

# include <stdio.h>

# ifndef PARAMS
#  if defined (__GNUC__) || __STDC__
#   define PARAMS(args) args
#  else
#   define PARAMS(args) ()
#  endif
# endif

extern int getline PARAMS ((char **_lineptr, size_t *_n, FILE *_stream));

extern int getdelim PARAMS ((char **_lineptr, size_t *_n, int _delimiter, FILE *_stream));

#endif /* ! _GETLINE_H_ */



/* getline.c -- Replacement for GNU C library function getline

Copyright (C) 1993 Free Software Foundation, Inc.

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; either version 2 of the
License, or (at your option) any later version.

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.  */

/* Written by Jan Brittenson, bson@gnu.ai.mit.edu.  */

/*
 * Modified for WinCvs/MacCVS : Alexandre Parenteau <aubonbeurre@hotmail.com> --- April 1998
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <sys/types.h>

#include <stdio.h>
#include <assert.h>
#include <errno.h>

#if STDC_HEADERS || defined(WIN32) || defined(TARGET_OS_MAC)
#include <stdlib.h>
#else
char *malloc (), *realloc ();
#endif

#include "getline.h"

/* Always add at least this many bytes when extending the buffer.  */
#define MIN_CHUNK 64

/* Read up to (and including) a TERMINATOR from STREAM into *LINEPTR
   + OFFSET (and null-terminate it). *LINEPTR is a pointer returned from
   malloc (or NULL), pointing to *N characters of space.  It is realloc'd
   as necessary.  Return the number of characters read (not including the
   null terminator), or -1 on error or EOF.  On a -1 return, the caller
   should check feof(), if not then errno has been set to indicate
   the error.  */

int
getstr (char **lineptr, size_t *n, FILE *stream, char terminator, int offset)
{
  int nchars_avail;		/* Allocated but unused chars in *LINEPTR.  */
  char *read_pos;		/* Where we're reading into *LINEPTR. */
  int ret;

  if (!lineptr || !n || !stream)
    {
      errno = EINVAL;
      return -1;
    }

  if (!*lineptr)
    {
      *n = MIN_CHUNK;
      *lineptr = (char *)malloc (*n);
      if (!*lineptr)
	{
	  errno = ENOMEM;
	  return -1;
	}
    }

  nchars_avail = *n - offset;
  read_pos = *lineptr + offset;

  for (;;)
    {
      int save_errno;
      register int c = getc (stream);

      save_errno = errno;

      /* We always want at least one char left in the buffer, since we
	 always (unless we get an error while reading the first char)
	 NUL-terminate the line buffer.  */

      assert((*lineptr + *n) == (read_pos + nchars_avail));
      if (nchars_avail < 2)
	{
	  if (*n > MIN_CHUNK)
	    *n *= 2;
	  else
	    *n += MIN_CHUNK;

	  nchars_avail = *n + *lineptr - read_pos;
	  *lineptr = (char *)realloc (*lineptr, *n);
	  if (!*lineptr)
	    {
	      errno = ENOMEM;
	      return -1;
	    }
	  read_pos = *n - nchars_avail + *lineptr;
	  assert((*lineptr + *n) == (read_pos + nchars_avail));
	}

      if (ferror (stream))
	{
	  /* Might like to return partial line, but there is no
	     place for us to store errno.  And we don't want to just
	     lose errno.  */
	  errno = save_errno;
	  return -1;
	}

      if (c == EOF)
	{
	  /* Return partial line, if any.  */
	  if (read_pos == *lineptr)
	    return -1;
	  else
	    break;
	}

#ifdef TARGET_OS_MAC
      if (terminator == '\n' && c == '\r')
	c = '\n';
#endif

      *read_pos++ = c;
      nchars_avail--;

      if (c == terminator)
	/* Return the line.  */
	break;
   }

  /* Done - NUL terminate and return the number of chars read.  */
  *read_pos = '\0';

  ret = read_pos - (*lineptr + offset);
  return ret;
}

/* __ssize_t getline (char **lineptr, size_t *n, FILE *stream) */

__size_t getline (char **lineptr, size_t *n, FILE *stream)
{
  return getstr (lineptr, n, stream, '\n', 0);
}



</pre>
ON 20050805@8:27:56 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm#38569.8527199074 [xiaofan-sg-] Code:
Modified Make file for fsusb win32 port
Note: put usb.h and libusb.a into the MingW
include and lib directory respectively.


# This file is part of fsusb_picdem
#
# fsusb_picdem 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; either version 2 of the License, or
# (at your option) any later version.
#
# fsusb_picdem 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 fsusb_picdem; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA



OPTS=-Wall -D_GNU_SOURCE
OBJS=fsusb.o rjlhex.o memimg.o getline.o

CFLAGS=$(OPTS) -I$(LIBUSB)/include
LDFLAGS=-L$(LIBUSB)/lib -lusb

# Needed for static linking under OS X:
# LDFLAGS=-lusb -lIOKit -framework CoreFoundation



all: fsusb

fsusb: main.o $(OBJS)
	$(CC) $(CFLAGS) -o $@ main.o $(OBJS) $(LDFLAGS)

clean:
	-rm fsusb *.o
ON 20050805@8:48:35 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm#38569.8670717593 [xiaofan-sg-] Code: in a new file at: http://www.piclist.com/techref/member/xiaofan-sg-/fsusb.c




ON 20050805@8:52:19 PM at page:
http://www.piclist.com/techref/member/xiaofan-sg-/fsusb.c#
  [xiaofan-sg-] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\fsusb.c&version=0



ON 20050805@8:55:40 PM at page:
http://www.piclist.com/techref/member/xiaofan-sg-/index.htm#
  [xiaofan-sg-] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=9



ON 20050805@8:56:57 PM at page:
http://www.piclist.com/techref/member/xiaofan-sg-/index.htm#38569.8728819444
  [xiaofan-sg-] See also:
/techref/member/xiaofan-sg-/fsusb.c




ON 20050805@9:00:21 PM at page:
http://www.piclist.com/techref/member/xiaofan-sg-/index.htm#
  [xiaofan-sg-] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=14



ON 20050805@9:00:55 PM at page:
http://www.piclist.com/techref/member/xiaofan-sg-/index.htm#
  [xiaofan-sg-] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=15



ON 20050805@9:01:07 PM at page:
http://www.piclist.com/techref/member/xiaofan-sg-/index.htm#
  [xiaofan-sg-] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=16



ON 20050805@9:02:51 PM at page:
http://www.piclist.com/techref/member/xiaofan-sg-/index.htm#38569.8769791667
  [xiaofan-sg-] Code:
in a new file at:
http://www.piclist.com/techref/member/xiaofan-sg-/Makefile.txt
<PRE>Modified Make file for fsusb win32 port
Note: put usb.h and libusb.a into the MingW
include and lib directory respectively.


# This file is part of fsusb_picdem
#
# fsusb_picdem 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; either version 2 of the License, or
# (at your option) any later version.
#
# fsusb_picdem 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 fsusb_picdem; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA



OPTS=-Wall -D_GNU_SOURCE
OBJS=fsusb.o rjlhex.o memimg.o getline.o

CFLAGS=$(OPTS) -I$(LIBUSB)/include
LDFLAGS=-L$(LIBUSB)/lib -lusb

# Needed for static linking under OS X:
# LDFLAGS=-lusb -lIOKit -framework CoreFoundation



all: fsusb

fsusb: main.o $(OBJS)
	$(CC) $(CFLAGS) -o $@ main.o $(OBJS) $(LDFLAGS)

clean:
	-rm fsusb *.o
</PRE>

ON 20050805@9:03:54 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/Makefile.txt# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\Makefile.txt&version=0 ON 20050805@9:05:17 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/Makefile.txt# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\Makefile.txt&version=1 ON 20050805@9:06:54 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/Makefile.txt# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\Makefile.txt&version=2 ON 20050805@9:07:52 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm#38569.8804513889 [xiaofan-sg-] See also: /techref/member/xiaofan-sg-/Makefile.txt fsusb Makefile ON 20050805@9:10:38 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=25 ON 20050805@9:11:28 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm#38569.882962963 [xiaofan-sg-] See also: in a new file at: http://www.piclist.com/techref/member/xiaofan-sg-/getline.txt ON 20050805@9:14:09 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/getline.txt# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\getline.txt&version=0 ON 20050805@9:20:23 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=28 ON 20050805@9:29:24 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=29 ON 20050805@9:32:25 PM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=30 ON 20050806@6:00:29 AM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=31 ON 20050806@6:04:16 AM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=32 ON 20050806@6:05:36 AM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=33 ON 20050806@6:07:23 AM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=34 ON 20050809@3:46:47 AM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=35 ON 20050809@3:50:07 AM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=36 ON 20050809@3:52:03 AM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\member\xiaofan-sg-\index.htm&version=37 ON 20050809@3:53:24 AM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: @96|HTMLAppend '

' @96 ON 20050809@3:54:36 AM at page: http://www.piclist.com/techref/member/xiaofan-sg-/index.htm# [xiaofan-sg-] edited the page. Difference: |NoChange