Changeset 167 for trunk/src/slib.c
- Timestamp:
- Mar 15, 2008, 12:38:20 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/slib.c
r162 r167 56 56 #include "sh_static.h" 57 57 #include "sh_pthread.h" 58 #include "sh_string.h" 58 59 59 60 #undef FIL__ … … 1504 1505 int fd; /* The file descriptor. */ 1505 1506 char * path; /* The file path. */ 1507 sh_string * content; /* The file content */ 1506 1508 } SL_OFILE; 1507 1509 … … 1624 1626 1625 1627 sl_strlcpy (ofiles[fd]->path, filename, len); 1626 ofiles[fd]->ticket = ticket; 1627 ofiles[fd]->fd = fd; 1628 ofiles[fd]->ticket = ticket; 1629 ofiles[fd]->fd = fd; 1630 ofiles[fd]->content = NULL; 1628 1631 1629 1632 SL_IRETURN(ticket, _("sl_make_ticket")); … … 1862 1865 1863 1866 sl_strlcpy (ofiles[fd]->path, filename, len); 1864 ofiles[fd]->ticket = ticket; 1865 ofiles[fd]->fd = fd; 1867 ofiles[fd]->ticket = ticket; 1868 ofiles[fd]->fd = fd; 1869 ofiles[fd]->content = NULL; 1866 1870 1867 1871 SL_IRETURN(ticket, _("sl_open_file")); … … 1981 1985 } 1982 1986 1987 int sl_init_content (SL_TICKET ticket, size_t size) 1988 { 1989 int fd; 1990 1991 if (SL_ISERROR(fd = sl_read_ticket(ticket))) 1992 return (fd); 1993 1994 if (ofiles[fd] == NULL || fd != ofiles[fd]->fd || fd < 0) 1995 return (SL_EINTERNAL); 1996 1997 if (ofiles[fd]->content) 1998 sh_string_destroy(&(ofiles[fd]->content)); 1999 ofiles[fd]->content = sh_string_new(size); 2000 2001 return SL_ENONE; 2002 } 2003 2004 sh_string * sl_get_content (SL_TICKET ticket) 2005 { 2006 int fd; 2007 2008 if (SL_ISERROR(fd = sl_read_ticket(ticket))) 2009 return (NULL); 2010 2011 if (ofiles[fd] == NULL || fd != ofiles[fd]->fd || fd < 0) 2012 return (NULL); 2013 2014 return (ofiles[fd]->content); 2015 } 2016 1983 2017 int sl_close (SL_TICKET ticket) 1984 2018 { … … 2001 2035 if (ofiles[fd] != NULL) 2002 2036 { 2037 if (ofiles[fd]->content) 2038 sh_string_destroy(&(ofiles[fd]->content)); 2003 2039 (void) free(ofiles[fd]->path); 2004 2040 (void) free(ofiles[fd]); … … 2015 2051 if (ofiles[fd] != NULL && fd != except) 2016 2052 { 2053 if (ofiles[fd]->content) 2054 sh_string_destroy(&(ofiles[fd]->content)); 2017 2055 if (ofiles[fd]->path != NULL) 2018 2056 (void) free(ofiles[fd]->path);
Note:
See TracChangeset
for help on using the changeset viewer.