Annotation of OpenXM/src/kan96xx/plugin/file2.hh, Revision 1.6
1.6 ! takayama 1: /* $OpenXM: OpenXM/src/kan96xx/plugin/file2.hh,v 1.5 2003/11/23 13:16:30 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: }
1.6 ! takayama 63: else if (strcmp(key,"fp2fputs") == 0) {
! 64: if (size != 3) errorKan1("%s\n","[(fp2fgets) str obj-fp2] extension c.");
! 65: obj1 = getoa(obj,1);
! 66: if (obj1.tag != Sdollar) {
! 67: errorKan1("%s\n","[(fp2fputs) str obj-fp2] extension c.");
! 68: }
! 69: obj2= getoa(obj,2);
! 70: if (obj2.tag != Sfile) {
! 71: errorKan1("%s\n","[(fp2fputs) str obj-file-fp2] extension c.");
! 72: }
! 73: if (strcmp(obj2.lc.str,MAGIC2) != 0) {
! 74: errorKan1("%s\n","[(fp2fputs) str obj-fp2] extension c. obj-fp2 is not Sfile (FILE2).");
! 75: }
! 76: rob = KpoInteger(fp2fputs(KopString(obj1),(FILE2 *) obj2.rc.voidp));
! 77: }
1.1 maekawa 78: else if (strcmp(key,"fp2dumpBuffer") == 0) {
79: if (size != 2) errorKan1("%s\n","[(fp2dumpBuffer) obj-fp2] extension c.");
80: obj1= getoa(obj,1);
81: if (obj1.tag != Sfile) {
82: errorKan1("%s\n","[(fp2dumpBuffer) obj-fp2] extension c.");
83: }
84: if (strcmp(obj1.lc.str,MAGIC2) != 0) {
85: errorKan1("%s\n","[(fp2dumpBuffer) obj-fp2] extension c. obj-fp2 is not Sfile (FILE2).");
86: }
87: rob = KpoInteger(fp2dumpBuffer((FILE2 *) obj1.rc.voidp));
88: }
89: else if (strcmp(key,"fp2openForRead") == 0) {
90: if (size != 2) errorKan1("%s\n","[(fp2openForRead) name] extension c.");
1.3 takayama 91: if (SecureMode) errorKan1("%s\n","Security violation for fp2openForRead.");
1.1 maekawa 92: obj1= getoa(obj,1);
93: if (obj1.tag != Sdollar) {
94: errorKan1("%s\n","[(fp2openForRead) name-string] extension c.");
95: }
96: rob = KpoInteger(open(obj1.lc.str,O_RDONLY));
97: }
98: else if (strcmp(key,"fp2openForWrite") == 0) {
99: if (size != 2) errorKan1("%s\n","[(fp2openForWrite) name] extension c.");
1.3 takayama 100: if (SecureMode) errorKan1("%s\n","Security violation for fp2openForWrite.");
1.1 maekawa 101: obj1= getoa(obj,1);
102: if (obj1.tag != Sdollar) {
103: errorKan1("%s\n","[(fp2openForWrite) name-string] extension c.");
104: }
105: rob = KpoInteger(creat(obj1.lc.str, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH));
106: }
107: else if (strcmp(key,"fp2close") == 0) {
108: if (size != 2) errorKan1("%s\n","[(fp2close) fd] extension c.");
109: obj1= getoa(obj,1);
110: if (obj1.tag != Sinteger) {
111: errorKan1("%s\n","[(fp2close) fd-integer] extension c.");
112: }
113: rob = KpoInteger(close(obj1.lc.ival));
114: }
115: else if (strcmp(key,"fp2clearReadBuf") == 0) {
116: if (size != 2) errorKan1("%s\n","[(fp2ClearReadBuf) obj-fp2] extension c.");
117: obj1= getoa(obj,1);
118: if (obj1.tag != Sfile) {
119: errorKan1("%s\n","[(fp2clearReadBuf) obj-fp2] extension c.");
120: }
121: if (strcmp(obj1.lc.str,MAGIC2) != 0) {
122: errorKan1("%s\n","[(fp2clearReadBuf) obj-fp2] extension c. obj-fp2 is not Sfile (FILE2).");
123: }
124: rob = KpoInteger(fp2dumpBuffer((FILE2 *) obj1.rc.voidp));
125: rob = KpoInteger(fp2clearReadBuf((FILE2 *)obj1.rc.voidp));
1.5 takayama 126: }
127: else if (strcmp(key,"fp2fcloseInString") == 0) {
128: if (size != 2) errorKan1("%s\n","[(fp2closeInString) obj-fp2] extension s.");
129: obj1= getoa(obj,1);
130: if (obj1.tag != Sfile) {
131: errorKan1("%s\n","[(fp2fcloseInString) obj-fp2] extension s.");
132: }
133: if (strcmp(obj1.lc.str,MAGIC2) != 0) {
134: errorKan1("%s\n","[(fp2fcloseInString) obj-fp2] extension s. obj-fp2 is not Sfile (FILE2).");
135: }
136: {
137: int mysize;
138: rob = KpoString(fp2fcloseInString((FILE2 *) obj1.rc.voidp,&mysize));
139: }
1.4 takayama 140: }
141: else if (strcmp(key,"fp2pushfile") == 0) {
142: if (size != 2) errorKan1("%s\n","[(fp2pushfile) name] extension array-of-int.");
143: if (SecureMode) errorKan1("%s\n","Security violation for fp2pushfile.");
144: obj1= getoa(obj,1);
145: if (obj1.tag != Sdollar) {
146: errorKan1("%s\n","[(fp2pushfile) name] extension array-of-int.");
147: }
148: {
149: FILE *fp;
150: int n,i,c;
151: fp = fopen(obj1.lc.str,"r");
152: if (fp == NULL) errorKan1("%s\n","fp2pushfile : file not found.");
153: n = 0;
154: while ((c = fgetc(fp)) != EOF) n++;
155: fclose(fp);
156: fp = fopen(obj1.lc.str,"r");
157: rob = newObjectArray(n);
158: i = 0;
159: while ((c = fgetc(fp)) != EOF) {
160: putoa(rob,i,KpoInteger(c));
161: i++;
162: }
163: fclose(fp);
164: }
1.1 maekawa 165: }
1.6 ! takayama 166: else if (strcmp(key,"fp2select") == 0) {
! 167: if (size != 3) errorKan1("%s\n","[(fp2select) obj-fp2 t] extension status.");
! 168: obj1 = getoa(obj,2);
! 169: obj1 = Kto_int32(obj1);
! 170: if (obj1.tag != Sinteger) {
! 171: errorKan1("%s\n","[(fp2select) obj-fp2 t] extension status.");
! 172: }
! 173: obj2= getoa(obj,1);
! 174: if (obj2.tag != Sfile) {
! 175: errorKan1("%s\n","[(fp2select) obj-fp2 t] extension status.");
! 176: }
! 177: if (strcmp(obj2.lc.str,MAGIC2) != 0) {
! 178: errorKan1("%s\n","[(fp2select) obj-fp2 t] extension status. obj-fp2 is not Sfile (FILE2).");
! 179: }
! 180: rob = KpoInteger(fp2select((FILE2 *) obj2.rc.voidp,obj1.lc.ival));
! 181: }
! 182: else if (strcmp(key,"fp2fopen") == 0) {
! 183: if (size != 3) errorKan1("%s\n","[(fp2fopen) name mode] extension obj-fp2.");
! 184: if (SecureMode) errorKan1("%s\n","Security violation for fp2fopen.");
! 185: obj1= getoa(obj,1);
! 186: if (obj1.tag != Sdollar) {
! 187: errorKan1("%s\n","[(fp2fopen) name-string mode] extension obj-fp2.");
! 188: }
! 189: obj2= getoa(obj,2);
! 190: if (obj2.tag != Sdollar) {
! 191: errorKan1("%s\n","[(fp2fopen) name-string mode] extension obj-fp2.");
! 192: }
! 193: {
! 194: FILE *fff;
! 195: fff = fopen(KopString(obj1),KopString(obj2));
! 196: if (fff == NULL) {
! 197: rob = NullObject;
! 198: }else{
! 199: rob.tag = Sfile;
! 200: rob.lc.str = MAGIC2 ;
! 201: rob.rc.voidp = (void *) fp2open(fileno(fff));
! 202: fp2setfp((FILE2 *) rob.rc.voidp, fff, 0);
! 203: }
! 204: }
! 205: }
! 206: else if (strcmp(key,"fp2mkfifo") == 0) {
! 207: if (size != 2) errorKan1("%s\n","[(fp2mkfifo) name] extension obj-fp2.");
! 208: if (SecureMode) errorKan1("%s\n","Security violation for fp2mkfifo.");
! 209: obj1= getoa(obj,1);
! 210: if (obj1.tag != Sdollar) {
! 211: errorKan1("%s\n","[(fp2mkfifo) name-string] extension obj-fp2.");
! 212: }
! 213: {
! 214: char *fname;
! 215: fname = KopString(obj1);
! 216: if (mkfifo(fname,0600)) {
! 217: rob = KpoInteger(-1);
! 218: if (errno != EEXIST) {
! 219: perror(fname);
! 220: unlink(fname);
! 221: }
! 222: }else{
! 223: rob = KpoInteger(0);
! 224: }
! 225: }
! 226: }
! 227: else if (strcmp(key,"fp2popen") == 0) {
! 228: if (size != 3) errorKan1("%s\n","[(fp2popen) name mode] extension obj-fp2.");
! 229: if (SecureMode) errorKan1("%s\n","Security violation for fp2popen.");
! 230: obj1= getoa(obj,1);
! 231: if (obj1.tag != Sdollar) {
! 232: errorKan1("%s\n","[(fp2popen) name-string mode] extension obj-fp2.");
! 233: }
! 234: obj2= getoa(obj,2);
! 235: if (obj2.tag != Sdollar) {
! 236: errorKan1("%s\n","[(fp2popen) name-string mode] extension obj-fp2.");
! 237: }
! 238: {
! 239: FILE *fff;
! 240: fff = popen(KopString(obj1),KopString(obj2));
! 241: if (fff == NULL) {
! 242: perror(KopString(obj1));
! 243: rob = NullObject;
! 244: }else{
! 245: rob.tag = Sfile;
! 246: rob.lc.str = MAGIC2 ;
! 247: rob.rc.voidp = (void *) fp2open(fileno(fff));
! 248: fp2setfp((FILE2 *) rob.rc.voidp, fff,1);
! 249: }
! 250: }
! 251: }
1.1 maekawa 252:
253:
254:
255:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>