summaryrefslogtreecommitdiff
path: root/fitz/stm_open.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-04 23:35:45 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-04 23:35:45 +0200
commit7cf6ccee8c6b59d8aac17ab6e4673bcb69f5e8d2 (patch)
treeb329db03bae14fca178add9909b78b050345c140 /fitz/stm_open.c
parentefc46353676c27b24f2933dce78305796951a01e (diff)
downloadmupdf-7cf6ccee8c6b59d8aac17ab6e4673bcb69f5e8d2.tar.xz
Le Roi est mort, vive le Roi!
The run-together words are dead! Long live the underscores! The postscript inspired naming convention of using all run-together words has served us well, but it is now time for more readable code. In this commit I have also added the sed script, rename.sed, that I used to convert the source. Use it on your patches and application code.
Diffstat (limited to 'fitz/stm_open.c')
-rw-r--r--fitz/stm_open.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/fitz/stm_open.c b/fitz/stm_open.c
index c7cf8409..74346f73 100644
--- a/fitz/stm_open.c
+++ b/fitz/stm_open.c
@@ -1,7 +1,7 @@
#include "fitz.h"
fz_stream *
-fz_newstream(void *state,
+fz_new_stream(void *state,
int(*read)(fz_stream *stm, unsigned char *buf, int len),
void(*close)(fz_stream *stm))
{
@@ -25,13 +25,13 @@ fz_newstream(void *state,
stm->state = state;
stm->read = read;
stm->close = close;
- stm->seek = nil;
+ stm->seek = NULL;
return stm;
}
fz_stream *
-fz_keepstream(fz_stream *stm)
+fz_keep_stream(fz_stream *stm)
{
stm->refs ++;
return stm;
@@ -51,7 +51,7 @@ fz_close(fz_stream *stm)
/* File stream */
-static int readfile(fz_stream *stm, unsigned char *buf, int len)
+static int read_file(fz_stream *stm, unsigned char *buf, int len)
{
int n = read(*(int*)stm->state, buf, len);
if (n < 0)
@@ -59,7 +59,7 @@ static int readfile(fz_stream *stm, unsigned char *buf, int len)
return n;
}
-static void seekfile(fz_stream *stm, int offset, int whence)
+static void seek_file(fz_stream *stm, int offset, int whence)
{
int n = lseek(*(int*)stm->state, offset, whence);
if (n < 0)
@@ -69,7 +69,7 @@ static void seekfile(fz_stream *stm, int offset, int whence)
stm->wp = stm->bp;
}
-static void closefile(fz_stream *stm)
+static void close_file(fz_stream *stm)
{
int n = close(*(int*)stm->state);
if (n < 0)
@@ -78,7 +78,7 @@ static void closefile(fz_stream *stm)
}
fz_stream *
-fz_openfd(int fd)
+fz_open_fd(int fd)
{
fz_stream *stm;
int *state;
@@ -86,40 +86,40 @@ fz_openfd(int fd)
state = fz_malloc(sizeof(int));
*state = fd;
- stm = fz_newstream(state, readfile, closefile);
- stm->seek = seekfile;
+ stm = fz_new_stream(state, read_file, close_file);
+ stm->seek = seek_file;
return stm;
}
fz_stream *
-fz_openfile(const char *name)
+fz_open_file(const char *name)
{
int fd = open(name, O_BINARY | O_RDONLY, 0);
if (fd == -1)
- return nil;
- return fz_openfd(fd);
+ return NULL;
+ return fz_open_fd(fd);
}
#ifdef _WIN32
fz_stream *
-fz_openfilew(const wchar_t *name)
+fz_open_file_w(const wchar_t *name)
{
int fd = _wopen(name, O_BINARY | O_RDONLY, 0);
if (fd == -1)
- return nil;
- return fz_openfd(fd);
+ return NULL;
+ return fz_open_fd(fd);
}
#endif
/* Memory stream */
-static int readbuffer(fz_stream *stm, unsigned char *buf, int len)
+static int read_buffer(fz_stream *stm, unsigned char *buf, int len)
{
return 0;
}
-static void seekbuffer(fz_stream *stm, int offset, int whence)
+static void seek_buffer(fz_stream *stm, int offset, int whence)
{
if (whence == 0)
stm->rp = stm->bp + offset;
@@ -131,19 +131,19 @@ static void seekbuffer(fz_stream *stm, int offset, int whence)
stm->wp = stm->ep;
}
-static void closebuffer(fz_stream *stm)
+static void close_buffer(fz_stream *stm)
{
if (stm->state)
- fz_dropbuffer(stm->state);
+ fz_drop_buffer(stm->state);
}
fz_stream *
-fz_openbuffer(fz_buffer *buf)
+fz_open_buffer(fz_buffer *buf)
{
fz_stream *stm;
- stm = fz_newstream(fz_keepbuffer(buf), readbuffer, closebuffer);
- stm->seek = seekbuffer;
+ stm = fz_new_stream(fz_keep_buffer(buf), read_buffer, close_buffer);
+ stm->seek = seek_buffer;
stm->bp = buf->data;
stm->rp = buf->data;
@@ -156,12 +156,12 @@ fz_openbuffer(fz_buffer *buf)
}
fz_stream *
-fz_openmemory(unsigned char *data, int len)
+fz_open_memory(unsigned char *data, int len)
{
fz_stream *stm;
- stm = fz_newstream(nil, readbuffer, closebuffer);
- stm->seek = seekbuffer;
+ stm = fz_new_stream(NULL, read_buffer, close_buffer);
+ stm->seek = seek_buffer;
stm->bp = data;
stm->rp = data;