Example #1
0
void update_last_caller()
{
   int fd, fdb;
   char filename[80], backup[80];
   long stamp;
   struct _lastcall lc;

   stamp = time (NULL);
   memset ((char *)&lastcall, 0, sizeof (struct _lastcall));

   sprintf (backup, "%sLASTCALL.BAK", config.sys_path);
   sprintf (filename, "%sLASTCALL.BBS", config.sys_path);
   unlink (backup);
   rename (filename, backup);

   fdb = shopen (backup, O_RDONLY|O_BINARY);
   if (fdb == -1)
      return;

   fd = cshopen (filename, O_RDONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE);

   while (read(fdo, (char *)&lc, sizeof(struct _lastcall)) == sizeof(struct _lastcall)) {
      if (stamp - lc.timestamp < 86400L)
         write (fd, (char *)&lc, sizeof (struct _lastcall));
   }

   close (fd);
   close (fdo);
}
Example #2
0
int BusyFileOpen(char *name, int wait)
{
  char *bsyname, *dir, *point;
  char temp[PATHLEN];
  int bfile;
  unsigned bs;

  /* Only use if FLAG_BSY is set, and FLAG_FRODO is *not* set. */

  if ((config.flag & FLAG_BSY)==0)
    return 0;

  bsyname=bsy_extension(name);
  
  /* Open the file with O_EXCL, such that the create fails if the file      *
   * already exists.                                                        */

  while ((bfile=cshopen(bsyname, O_EXCL | O_CREAT | O_WRONLY | O_BINARY))==-1)
  {
    if (!wait)
      return -1;

    dir=sstrdup(bsyname);
    
    point=strrchr(dir, PATH_DELIM);
    
    if (point)
      *point='\0';
    
    (void)make_dir(dir);
    free(dir);

    (void)sprintf(temp," (%s busy; wait)", name);
    (void)printf(temp);
    
    while (fexist(bsyname))
    {
      if (khit() && kgetch()==K_ESC)
        break;

      tdelay(200);
    }

    for (bs=strlen(temp); bs--; )
      (void)printf("\b \b");
  }

  if (bfile != -1)
    (void)close(bfile);
  
  free(bsyname);
  return 0;
}