|
| |||||||||||||
#include "mit-copyright.h"#include "main.h"#include "new_string.h"#include "port_dictionary.h"#include "port.h"#include "notice.h"#include "variables.h"Go to the source code of this file.
Functions | |
| void | init_ports () |
| string | read_from_port (string name) |
| void | write_on_port (string name, char *text, int length) |
| void | close_port_input (string name) |
| void | close_port_output (string name) |
| void | create_port_from_files (string name, FILE *input, FILE *output) |
| void | create_subprocess_port (string name, char **argv) |
| void | create_file_append_port (string name, string filename) |
| void | create_file_input_port (string name, string filename) |
| void | create_file_output_port (string name, string filename) |
| void | create_port_from_filter (string name, string(*)() filter) |
| void | create_port_from_output_proc (string name, char *(*)() output) |
|
|
Definition at line 285 of file port.c. References port_dictionary_binding, port_dictionary_Delete(), port_dictionary_Lookup(), port::status, and _port_dictionary_binding::value. 00287 {
00288 port_dictionary_binding *binding;
00289
00290 binding = port_dictionary_Lookup(port_dict, name);
00291 if (!binding)
00292 return;
00293
00294 port_close_input(&(binding->value));
00295 if (binding->value.status == PORT_CLOSED)
00296 port_dictionary_Delete(port_dict, binding);
00297 }
|
|
|
Definition at line 312 of file port.c. References port_dictionary_binding, port_dictionary_Delete(), port_dictionary_Lookup(), port::status, and _port_dictionary_binding::value. 00314 {
00315 port_dictionary_binding *binding;
00316
00317 binding = port_dictionary_Lookup(port_dict, name);
00318 if (!binding)
00319 return;
00320
00321 port_close_output(&(binding->value));
00322 if (binding->value.status == PORT_CLOSED)
00323 port_dictionary_Delete(port_dict, binding);
00324 }
|
|
||||||||||||
|
Definition at line 491 of file port.c. References create_port_from_files(), errno, and var_set_variable(). 00494 {
00495 FILE *out;
00496 int oumask;
00497
00498 errno = 0;
00499
00500 oumask = umask(077); /* allow read/write for us only */
00501 out = fopen(filename, "a");
00502 (void) umask(oumask);
00503 if (out == NULL) {
00504 var_set_variable("error", strerror(errno));
00505 return;
00506 }
00507
00508 create_port_from_files(name, 0, out);
00509 }
|
|
||||||||||||
|
Definition at line 512 of file port.c. References create_port_from_files(), errno, and var_set_variable(). 00515 {
00516 FILE *in;
00517
00518 errno = 0;
00519 in = fopen(filename, "r");
00520 if (in == NULL) {
00521 var_set_variable("error", strerror(errno));
00522 return;
00523 }
00524
00525 create_port_from_files(name, in, 0);
00526 }
|
|
||||||||||||
|
Definition at line 529 of file port.c. References create_port_from_files(), errno, and var_set_variable(). 00532 {
00533 FILE *out;
00534 int oumask;
00535
00536 errno = 0;
00537
00538 oumask = umask(077); /* allow read/write for us only */
00539 out = fopen(filename, "w");
00540 (void) umask(oumask);
00541 if (out == NULL) {
00542 var_set_variable("error", strerror(errno));
00543 return;
00544 }
00545
00546 create_port_from_files(name, 0, out);
00547 }
|
|
||||||||||||||||
|
Definition at line 411 of file port.c. References port::close_input, port::close_output, port::data, port__data::file, port::get, port__data::input_connector, port__data::output_connector, port::put, and port::status. 00415 {
00416 port *p = create_named_port(name);
00417
00418 #if !defined(__HIGHC__)
00419 p->get = input ? get_file : NULL;
00420 p->put = output ? put_file : NULL;
00421 #else
00422 /* RT compiler (hc2.1y) bug workaround */
00423 if (input)
00424 p->get = get_file;
00425 else
00426 p->get = NULL;
00427 if (output)
00428 p->put = put_file;
00429 else
00430 p->put = NULL;
00431 #endif
00432 p->close_input = close_file_input;
00433 p->close_output = close_file_output;
00434 p->status = 0;
00435 p->data.file.input_connector = input;
00436 p->data.file.output_connector = output;
00437 }
|
|
||||||||||||
|
Definition at line 610 of file port.c. References port::close_input, port::close_output, port::data, port__data::filter, port::get, port::put, port::status, string_stack_create, and port__data::waiting_packets. 00613 {
00614 port *p = create_named_port(name);
00615
00616 p->get = get_filter;
00617 p->put = put_filter;
00618 p->close_input = close_filter_input;
00619 p->close_output = close_filter_output;
00620 p->status = 0;
00621 p->data.filter.waiting_packets = string_stack_create();
00622 p->data.filter.filter = filter;
00623 }
|
|
||||||||||||
|
Definition at line 655 of file port.c. References port::close_input, port::close_output, port::data, port::get, port__data::output, port::put, and port::status. 00658 {
00659 #ifdef SABER /* Yes, it's another ANSI incompatiblity */
00660 port *p;
00661 #else
00662 port *p = create_named_port(name);
00663 #endif
00664
00665 #ifdef SABER
00666 p = create_named_port(name);
00667 #endif
00668
00669 p->get = NULL;
00670 p->put = put_output;
00671 p->close_input = close_output;
00672 p->close_output = close_output;
00673 p->status = 0;
00674 p->data.output.output = output;
00675 }
|
|
||||||||||||
|
Definition at line 446 of file port.c. References create_port_from_files(), and errno. 00449 {
00450 int pid;
00451 int to_child_descriptors[2];
00452 int to_parent_descriptors[2];
00453 FILE *in = 0;
00454 FILE *out = 0;
00455
00456 /* <<<>>> (file leak) */
00457 if (pipe(to_child_descriptors) != 0 || pipe(to_parent_descriptors) != 0)
00458 return;
00459
00460 pid = fork();
00461 if (pid == -1) {
00462 fprintf(stderr, "jwgc: error while attempting to fork: ");
00463 perror("");
00464 return; /* <<<>>> */
00465 }
00466 else if (pid == 0) { /* in child */
00467 close(0);
00468 close(1);
00469 dup2(to_child_descriptors[0], 0);
00470 dup2(to_parent_descriptors[1], 1);
00471 close(to_child_descriptors[1]);
00472 close(to_parent_descriptors[0]);
00473
00474 execvp(argv[0], argv);
00475 fprintf(stderr, "jwgc: unable to exec %s: ", argv[0]);
00476 perror("");
00477 _exit(errno);
00478 }
00479
00480 fcntl(to_parent_descriptors[0], F_SETFD, 1);
00481 fcntl(to_child_descriptors[1], F_SETFD, 1);
00482 in = fdopen(to_parent_descriptors[0], "r");
00483 out = fdopen(to_child_descriptors[1], "w");
00484 close(to_child_descriptors[0]);
00485 close(to_parent_descriptors[1]);
00486
00487 create_port_from_files(name, in, out);
00488 }
|
|
|
Definition at line 153 of file port.c. References port_dictionary_Create(), port_dictionary_Destroy(), and port_dictionary_Enumerate(). Referenced by main(). 00154 {
00155 if (port_dict) {
00156 port_dictionary_Enumerate(port_dict, close_port_from_binding);
00157 port_dictionary_Destroy(port_dict);
00158 }
00159
00160 port_dict = port_dictionary_Create(31);
00161 }
|
|
|
Definition at line 233 of file port.c. References string_Copy, and var_set_variable(). 00235 {
00236 port *p;
00237
00238 if (!(p = get_named_port(name))) {
00239 var_set_variable("error", "No such port");
00240 return (string_Copy(""));
00241 }
00242
00243 return (port_get(p));
00244 }
|
|
||||||||||||||||
|
Definition at line 257 of file port.c. References var_set_variable(). 00261 {
00262 port *p;
00263
00264 if (!(p = get_named_port(name))) {
00265 var_set_variable("error", "No such port");
00266 return;
00267 }
00268
00269 port_put(p, text, length);
00270 }
|
| Last updated at Tue Dec 18 21:07:42 PST 2007. | This site and project hosted by... |