Annotation of OpenXM/src/kan96xx/plugin/file2.hh, Revision 1.5
1.5 ! takayama 1: /* $OpenXM: OpenXM/src/kan96xx/plugin/file2.hh,v 1.4 2001/08/12 03:13:36 takayama Exp $ */
1.1 maekawa 2: else if (strcmp(key,"fp2fdopen") == 0) {
3: if (size != 2) errorKan1("%s\n","[(fp2fdopen) obj] extension obj-fp2.");
1.3 takayama 4: if (SecureMode) errorKan1("%s\n","Security violation for fp2fdopen.");
1.1 maekawa 5: obj1 = getoa(obj,1);
6: if (obj1.tag != Sinteger) {
7: errorKan1("%s\n","[(fp2fdopen) file-descriptor-integer] extension obj-fp2.");
8: }
9: rob.tag = Sfile;
10: rob.lc.str = MAGIC2 ;
11: rob.rc.voidp = (void *) fp2open(KopInteger(obj1));
12:
13: }
14: else if (strcmp(key,"fp2fflush") == 0) {
15: if (size != 2) errorKan1("%s\n","[(fp2fflush) obj-fp2] extension 0.");
16: obj1= getoa(obj,1);
17: if (obj1.tag != Sfile) {
18: errorKan1("%s\n","[(fp2fflush) obj-fp2] extension 0.");
19: }
20: if (strcmp(obj1.lc.str,MAGIC2) != 0) {
21: errorKan1("%s\n","[(fp2fflush) obj-fp2] extension 0. obj-fp2 is not Sfile (FILE2).");
22: }
23: fp2fflush((FILE2 *) obj1.rc.voidp);
24: rob = KpoInteger(0);
25: }
26: else if (strcmp(key,"fp2fclose") == 0) {
27: if (size != 2) errorKan1("%s\n","[(fp2fclose) obj-fp2] extension r.");
28: obj1= getoa(obj,1);
29: if (obj1.tag != Sfile) {
30: errorKan1("%s\n","[(fp2fclose) obj-fp2] extension r.");
31: }
32: if (strcmp(obj1.lc.str,MAGIC2) != 0) {
33: errorKan1("%s\n","[(fp2fclose) obj-fp2] extension r. obj-fp2 is not Sfile (FILE2).");
34: }
35: rob = KpoInteger(fp2fclose((FILE2 *) obj1.rc.voidp));
36: }
37: else if (strcmp(key,"fp2fgetc") == 0) {
38: if (size != 2) errorKan1("%s\n","[(fp2fgetc) obj-fp2] extension c.");
39: obj1= getoa(obj,1);
40: if (obj1.tag != Sfile) {
41: errorKan1("%s\n","[(fp2fgetc) obj-fp2] extension c.");
42: }
43: if (strcmp(obj1.lc.str,MAGIC2) != 0) {
44: errorKan1("%s\n","[(fp2fgetc) obj-fp2] extension c. obj-fp2 is not Sfile (FILE2).");
45: }
46: rob = KpoInteger(fp2fgetc((FILE2 *) obj1.rc.voidp));
47: }
48: else if (strcmp(key,"fp2fputc") == 0) {
49: if (size != 3) errorKan1("%s\n","[(fp2fgetc) c obj-fp2] extension c.");
50: obj1 = getoa(obj,1);
51: if (obj1.tag != Sinteger) {
52: errorKan1("%s\n","[(fp2fputc) c-integer obj-fp2] extension c.");
53: }
54: obj2= getoa(obj,2);
55: if (obj2.tag != Sfile) {
56: errorKan1("%s\n","[(fp2fputc) c obj-file-fp2] extension c.");
57: }
58: if (strcmp(obj2.lc.str,MAGIC2) != 0) {
59: errorKan1("%s\n","[(fp2fputc) c obj-fp2] extension c. obj-fp2 is not Sfile (FILE2).");
60: }
61: rob = KpoInteger(fp2fputc(obj1.lc.ival,(FILE2 *) obj2.rc.voidp));
62: }
63: else if (strcmp(key,"fp2dumpBuffer") == 0) {
64: if (size != 2) errorKan1("%s\n","[(fp2dumpBuffer) obj-fp2] extension c.");
65: obj1= getoa(obj,1);
66: if (obj1.tag != Sfile) {
67: errorKan1("%s\n","[(fp2dumpBuffer) obj-fp2] extension c.");
68: }
69: if (strcmp(obj1.lc.str,MAGIC2) != 0) {
70: errorKan1("%s\n","[(fp2dumpBuffer) obj-fp2] extension c. obj-fp2 is not Sfile (FILE2).");
71: }
72: rob = KpoInteger(fp2dumpBuffer((FILE2 *) obj1.rc.voidp));
73: }
74: else if (strcmp(key,"fp2openForRead") == 0) {
75: if (size != 2) errorKan1("%s\n","[(fp2openForRead) name] extension c.");
1.3 takayama 76: if (SecureMode) errorKan1("%s\n","Security violation for fp2openForRead.");
1.1 maekawa 77: obj1= getoa(obj,1);
78: if (obj1.tag != Sdollar) {
79: errorKan1("%s\n","[(fp2openForRead) name-string] extension c.");
80: }
81: rob = KpoInteger(open(obj1.lc.str,O_RDONLY));
82: }
83: else if (strcmp(key,"fp2openForWrite") == 0) {
84: if (size != 2) errorKan1("%s\n","[(fp2openForWrite) name] extension c.");
1.3 takayama 85: if (SecureMode) errorKan1("%s\n","Security violation for fp2openForWrite.");
1.1 maekawa 86: obj1= getoa(obj,1);
87: if (obj1.tag != Sdollar) {
88: errorKan1("%s\n","[(fp2openForWrite) name-string] extension c.");
89: }
90: rob = KpoInteger(creat(obj1.lc.str, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH));
91: }
92: else if (strcmp(key,"fp2close") == 0) {
93: if (size != 2) errorKan1("%s\n","[(fp2close) fd] extension c.");
94: obj1= getoa(obj,1);
95: if (obj1.tag != Sinteger) {
96: errorKan1("%s\n","[(fp2close) fd-integer] extension c.");
97: }
98: rob = KpoInteger(close(obj1.lc.ival));
99: }
100: else if (strcmp(key,"fp2clearReadBuf") == 0) {
101: if (size != 2) errorKan1("%s\n","[(fp2ClearReadBuf) obj-fp2] extension c.");
102: obj1= getoa(obj,1);
103: if (obj1.tag != Sfile) {
104: errorKan1("%s\n","[(fp2clearReadBuf) obj-fp2] extension c.");
105: }
106: if (strcmp(obj1.lc.str,MAGIC2) != 0) {
107: errorKan1("%s\n","[(fp2clearReadBuf) obj-fp2] extension c. obj-fp2 is not Sfile (FILE2).");
108: }
109: rob = KpoInteger(fp2dumpBuffer((FILE2 *) obj1.rc.voidp));
110: rob = KpoInteger(fp2clearReadBuf((FILE2 *)obj1.rc.voidp));
1.5 ! takayama 111: }
! 112: else if (strcmp(key,"fp2fcloseInString") == 0) {
! 113: if (size != 2) errorKan1("%s\n","[(fp2closeInString) obj-fp2] extension s.");
! 114: obj1= getoa(obj,1);
! 115: if (obj1.tag != Sfile) {
! 116: errorKan1("%s\n","[(fp2fcloseInString) obj-fp2] extension s.");
! 117: }
! 118: if (strcmp(obj1.lc.str,MAGIC2) != 0) {
! 119: errorKan1("%s\n","[(fp2fcloseInString) obj-fp2] extension s. obj-fp2 is not Sfile (FILE2).");
! 120: }
! 121: {
! 122: int mysize;
! 123: rob = KpoString(fp2fcloseInString((FILE2 *) obj1.rc.voidp,&mysize));
! 124: }
1.4 takayama 125: }
126: else if (strcmp(key,"fp2pushfile") == 0) {
127: if (size != 2) errorKan1("%s\n","[(fp2pushfile) name] extension array-of-int.");
128: if (SecureMode) errorKan1("%s\n","Security violation for fp2pushfile.");
129: obj1= getoa(obj,1);
130: if (obj1.tag != Sdollar) {
131: errorKan1("%s\n","[(fp2pushfile) name] extension array-of-int.");
132: }
133: {
134: FILE *fp;
135: int n,i,c;
136: fp = fopen(obj1.lc.str,"r");
137: if (fp == NULL) errorKan1("%s\n","fp2pushfile : file not found.");
138: n = 0;
139: while ((c = fgetc(fp)) != EOF) n++;
140: fclose(fp);
141: fp = fopen(obj1.lc.str,"r");
142: rob = newObjectArray(n);
143: i = 0;
144: while ((c = fgetc(fp)) != EOF) {
145: putoa(rob,i,KpoInteger(c));
146: i++;
147: }
148: fclose(fp);
149: }
1.1 maekawa 150: }
151:
152:
153:
154:
155:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>