builtin.c

来自「举世闻名的joe记事本源程序」· C语言 代码 · 共 64 行

C
64
字号
/* *	Built-in config files *	Copyright *		(C) 2006 Joseph H. Allen * *	This file is part of JOE (Joe's Own Editor) */#include "types.h"JFILE *jfopen(unsigned char *name, char *mode){	if (name[0] == '*') {		int x;		for (x = 0; builtins[x]; x += 2) {			if (!zcmp(builtins[x], name + 1)) {				JFILE *j = (JFILE *)joe_malloc(sizeof(JFILE));				j->f = 0;				j->p = builtins[x + 1];				return j;			}		}		return 0;	} else {		FILE *f = fopen((char *)name, (char *)mode);		if (f) {			JFILE *j = (JFILE *)joe_malloc(sizeof(JFILE));			j->f = f;			j->p = 0;			return j;		} else {			return 0;		}	}}int jfclose(JFILE *f){	int rtn = 0;	if (f->f)		rtn = fclose(f->f);	joe_free(f);	return rtn;}unsigned char *jfgets(unsigned char *buf,int len,JFILE *f){	if (f->f)		return (unsigned char *)fgets((char *)buf, len, f->f);	else {		if (f->p[0]) {			int x;			for (x = 0; f->p[x] && f->p[x] != '\n'; ++x)				buf[x] = f->p[x];			if (f->p[x] == '\n') {				buf[x++] = '\n';			}			buf[x] = 0;			f->p += x;			return buf;		} else			return 0;	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?