Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for ep/src/fd.c between version 1.5 and 1.6

version 1.5, 2001/12/20 00:26:52 version 1.6, 2002/02/06 21:44:11
Line 1 
Line 1 
 /*  /*
  * $Log$   * $Id$
  * Revision 1.5  2001/12/20 00:26:52  jombik9  
  * Various Makefile & code improvements.  
  * wait() implementation - no error is reported on ctrl+d now  
  *  
  * Revision 1.4  2001/12/02 23:30:06  jombik9  
  * A lot of new functions added.  
  * Various improvements.  
  *  
  * Revision 1.3  2001/09/21 19:54:45  host8  
  * Cosmetics changes in *.c  
  *  
  * Revision 1.2  2001/09/21 19:44:51  host8  
  * Added $Log$  
  * Added Revision 1.5  2001/12/20 00:26:52  jombik9  
  * Added Various Makefile & code improvements.  
  * Added wait() implementation - no error is reported on ctrl+d now  
  * Added  
  * Added Revision 1.4  2001/12/02 23:30:06  jombik9  
  * Added A lot of new functions added.  
  * Added Various improvements.  
  * Added  
  * Added Revision 1.3  2001/09/21 19:54:45  host8  
  * Added Cosmetics changes in *.c  
  * Added keyword substitution  
  *  
  */   */
 #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
 #  include "config.h"  #  include "config.h"
Line 46 
Line 21 
 #include "message.h"  #include "message.h"
   
 /*  /*
  * TODO   * TODO:
  * - make this static a cut the same parameters,   * - make this static a cut the same parameters,
  * because the comparion will be case insensitive   * because the comparion will be case insensitive
  */   */
Line 64  char *fd_str[N_FD_STR][N_FD] = {
Line 39  char *fd_str[N_FD_STR][N_FD] = {
         {"I", "O", "E"}          {"I", "O", "E"}
 };  };
   
           static int
   my_close(fd)
           int fd;
   {
   #if DEBUG
           msg_debug_print("my_close(%d)\n", fd);
   #endif
           if (fd == 1 || fd == 2)
                   return 0;
   
           return close(fd);
   }
   
 int fd_str_to_fd_id(char *str)  int fd_str_to_fd_id(char *str)
 {  {
         register int i, j;          register int i, j;
Line 85  fd_add_proclink(fd, link)
Line 73  fd_add_proclink(fd, link)
 {  {
 #if DEBUG  #if DEBUG
         msg_debug_print("fd_add_proclink(): link = (%d.%d)\n",          msg_debug_print("fd_add_proclink(): link = (%d.%d)\n",
                                                         link->proc_id, link->fd_id);                          link->proc_id, link->fd_id);
 #endif  #endif
   
         fd->link = (struct proclink *) realloc(fd->link,          fd->link = (struct proclink *) realloc(fd->link,
                                                         (fd->n_link + 1) * sizeof(struct proclink));                          (fd->n_link + 1) * sizeof(struct proclink));
   
         if (fd->link == NULL) {          if (fd->link == NULL) {
                 msg_error_print("fd_add_proclink(): realloc() failure\n");                  msg_error_print("fd_add_proclink(): realloc() failure\n");
Line 109  fd_remove_proclink(fd, link)
Line 97  fd_remove_proclink(fd, link)
         struct fd *fd;          struct fd *fd;
         const struct proclink *link;          const struct proclink *link;
 {  {
         register int index;          register int ord;
   
 #if DEBUG  #if DEBUG
         msg_debug_print("fd_remove_proclink(): link = (%d.%d)\n",          msg_debug_print("fd_remove_proclink(): link = (%d.%d)\n",
                                                         link->proc_id, link->fd_id);                          link->proc_id, link->fd_id);
 #endif  #endif
   
         while ((index = fd_is_proclink(fd, link)) != 0)          while ((ord = fd_is_proclink(fd, link)) != 0) /* ord is index + 1 */
                 if (fd_remove_proclink_by_index(fd, index) != 1)                  if (fd_remove_proclink_by_index(fd, ord - 1) != 1)
                           return 0;
   
           return 1;
   }
   
           int
   fd_remove_proclink2(fd, link_proc_id, link_fd_id)
           struct fd *fd;
           int link_proc_id;
           int link_fd_id;
   {
           register int ord;
   
   #if DEBUG
           msg_debug_print("fd_remove_proclink2(): link = (%d.%d)\n",
                           link_proc_id, link_fd_id);
   #endif
   
           while ((ord = fd_is_proclink2(fd, link_proc_id, link_fd_id)) != 0)
                   if (fd_remove_proclink_by_index(fd, ord - 1) != 1)
                         return 0;                          return 0;
   
         return 1;          return 1;
Line 137  fd_remove_proclink_by_index(fd, index)
Line 145  fd_remove_proclink_by_index(fd, index)
   
         /* Copying proclinks down by 1. */          /* Copying proclinks down by 1. */
         for (i = index + 1; i < fd->n_link; i++)          for (i = index + 1; i < fd->n_link; i++)
                 fd->link[i-1] = fd->link[i];                  fd->link[i - 1] = fd->link[i];
   
         if (fd->n_link > 1) {          if (fd->n_link > 1) {
   
                 /* Reallocating array. */                  /* Reallocating array. */
                 fd->link = (struct proclink *)realloc(fd->link,                  fd->link = (struct proclink *)realloc(fd->link,
                                                                 (fd->n_link - 1) * sizeof(struct proclink));                                  (fd->n_link - 1) * sizeof(struct proclink));
   
                 if (fd->link == NULL) {                  if (fd->link == NULL) {
                         msg_error_print("fd_remove_proclink_by_index(): "                          msg_error_print("fd_remove_proclink_by_index(): "
                                                                         "realloc() failure\n");                                          "realloc() failure\n");
                         return 0;                          return 0;
                 }                  }
   
                 fd->n_link--;                  fd->n_link--;
         }          }
         else {          else {
                   my_close(fd->pipe[0]);
                   my_close(fd->pipe[1]);
                 free(fd->link);                  free(fd->link);
                 fd->link = NULL;                  fd->link = NULL;
                 fd->n_link = 0;                  fd->n_link = 0;
Line 179  fd_is_proclink(fd, link)
Line 189  fd_is_proclink(fd, link)
                  * Does somebody know it?!?                   * Does somebody know it?!?
                  */                   */
                 if (fd->link[i].proc_id == link->proc_id &&                  if (fd->link[i].proc_id == link->proc_id &&
                                                                 fd->link[i].fd_id == link->fd_id)                                  fd->link[i].fd_id == link->fd_id)
                         return i + 1;                          return i + 1;
   
         return 0;          return 0;
 }  }
   
           int
   fd_is_proclink2(fd, link_proc_id, link_fd_id)
           struct fd *fd;
           int link_proc_id;
           int link_fd_id;
   {
           register int i;
   
           for (i = 0; i < fd->n_link; i++)
                   if (fd->link[i].proc_id == link_proc_id &&
                                   fd->link[i].fd_id == link_fd_id)
                           return i + 1;
   
           return 0;
   }
   

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top