Exemplo n.º 1
0
Arquivo: spki.c Projeto: macssh/macssh
struct verifier *
spki_make_verifier(struct alist *algorithms,
		   struct sexp *e)
{
  /* Syntax: (<algorithm> <s-expr>*) */
  struct signature_algorithm *algorithm;
  struct verifier *v;
  int algorithm_name;
  struct sexp_iterator *i;

  algorithm_name = spki_get_type(e, &i);

  {
    CAST_SUBTYPE(signature_algorithm, a, 
		 ALIST_GET(algorithms, algorithm_name));
    algorithm = a;
  }
  
  if (!algorithm)
    {
      werror("spki_make_verifier: Unsupported algorithm %a.\n", algorithm_name);
      return NULL;
    }

  v = MAKE_VERIFIER(algorithm, i);
  KILL(i);
  
  if (!v)
    {
      werror("spki_make_verifier: Invalid public-key data.\n");
      return NULL;
    }
  
  return v;
}
Exemplo n.º 2
0
int wcopy_file(const char *dir, const char *src_file, const char *dest_file)
{
	FILE *src, *dst;
	size_t nread, nwritten;
	char *dstpath;
	struct stat st;
	char buf[4096];

	/* only to a directory */
	if (stat(dir, &st) != 0 || !S_ISDIR(st.st_mode))
		return -1;
	/* only copy files */
	if (stat(src_file, &st) != 0 || !S_ISREG(st.st_mode))
		return -1;

	do {
		src = fopen(src_file, "rb");
	} while ((src == NULL) && (errno == EINTR));
	if (src == NULL) {
		werror(_("Could not open input file \"%s\""), src_file);
		return -1;
	}

	dstpath = wstrconcat(dir, dest_file);
	do {
		dst = fopen(dstpath, "wb");
	} while ((dst == NULL) && (errno == EINTR));
	if (dst == NULL) {
		werror(_("Could not create target file \"%s\""), dstpath);
		wfree(dstpath);
		fclose(src);
		return -1;
	}

	do {
		nread = fread(buf, 1, sizeof(buf), src);
		if (ferror(src))
			break;

		nwritten = fwrite(buf, 1, nread, dst);
		if (ferror(dst) || feof(src) || nread != nwritten)
			break;

	} while (1);

	if (ferror(src) || ferror(dst))
		unlink(dstpath);

	fclose(src);
	fchmod(fileno(dst), st.st_mode);
	fsync(fileno(dst));
	if (fclose(dst))
		wwarning("error occured during fclose(\"%s\")", dstpath);
	wfree(dstpath);

	return 0;
}
Exemplo n.º 3
0
static int
process_file(struct rsa_session *ctx,
	     FILE *in, FILE *out)
{
  uint8_t buffer[BLOCK_SIZE + SHA1_DIGEST_SIZE];

  for (;;)
    {
      size_t size = fread(buffer, 1, BLOCK_SIZE, in);
      hmac_sha1_update(&ctx->hmac, size, buffer);

      if (size < BLOCK_SIZE)
	{
	  unsigned leftover;
	  unsigned padding;

	  if (ferror(in))
	    {
	      werror("Reading input failed: %s\n", strerror(errno));
	      return 0;
	    }
	  
	  leftover = size % AES_BLOCK_SIZE;
	  padding = AES_BLOCK_SIZE - leftover;

	  assert (size + padding <= BLOCK_SIZE);
	  
	  if (padding > 1)
	    yarrow256_random(&ctx->yarrow, padding - 1, buffer + size);

	  size += padding;

	  buffer[size - 1] = padding;
	  CBC_ENCRYPT(&ctx->aes, aes_encrypt, size, buffer, buffer);

	  assert (size + SHA1_DIGEST_SIZE <= sizeof(buffer));

	  hmac_sha1_digest(&ctx->hmac, SHA1_DIGEST_SIZE, buffer + size);
	  size += SHA1_DIGEST_SIZE;

	  if (!write_string(out, size, buffer))
	    {
	      werror("Writing output failed: %s\n", strerror(errno));
	      return 0;
	    }
	  return 1;
	}

      CBC_ENCRYPT(&ctx->aes, aes_encrypt, size, buffer, buffer);
      if (!write_string(out, size, buffer))
	{
	  werror("Writing output failed: %s\n", strerror(errno));
	  return 0;
	}
    }
}
int
main(int argc, char **argv)
{
  struct rsa_private_key key;
  struct rsa_session ctx;
  struct rsa_session_info session;

  unsigned length;
  mpz_t x;

  mpz_init(x);
  
  if (argc != 2)
    {
      werror("Usage: rsa-decrypt PRIVATE-KEY < ciphertext\n");
      return EXIT_FAILURE;
    }

  rsa_private_key_init(&key);
  
  if (!read_rsa_key(argv[1], NULL, &key))
    {
      werror("Invalid key\n");
      return EXIT_FAILURE;
    }

  if (!read_version(stdin))
    {
      werror("Bad version number in input file.\n");
      return EXIT_FAILURE;
    }

  if (!read_bignum(stdin, x))
    {
      werror("Bad rsa header in input file.\n");
      return EXIT_FAILURE;
    }

  length = sizeof(session.key);
  if (!rsa_decrypt(&key, &length, session.key, x) || length != sizeof(session.key))
    {
      werror("Failed to decrypt rsa header in input file.\n");
      return EXIT_FAILURE;      
    }
  mpz_clear(x);
  
  rsa_session_set_decrypt_key(&ctx, &session);

  if (!process_file(&ctx,
		    stdin, stdout))
    return EXIT_FAILURE;
  
  rsa_private_key_clear(&key);

  return EXIT_SUCCESS;
}
Exemplo n.º 5
0
int
main(int argc, char **argv)
{
  struct rsa_public_key key;
  struct sha1_ctx hash;
  mpz_t s;
  
  if (argc != 3)
    {
      werror("Usage: rsa-verify PUBLIC-KEY SIGNATURE-FILE < FILE\n");
      return EXIT_FAILURE;
    }

  rsa_public_key_init(&key);
  
  if (!read_rsa_key(argv[1], &key, NULL))
    {
      werror("Invalid key\n");
      return EXIT_FAILURE;
    }

  mpz_init(s);

  if (!read_signature(argv[2], s))
    {
      werror("Failed to read signature file `%s'\n",
	      argv[2]);
      return EXIT_FAILURE;
    }
  
  sha1_init(&hash);
  if (!hash_file(&nettle_sha1, &hash, stdin))
    {
      werror("Failed reading stdin: %s\n",
	      strerror(errno));
      return 0;
    }

  if (!rsa_sha1_verify(&key, &hash, s))
    {
      werror("Invalid signature!\n");
      return EXIT_FAILURE;
    }
    
  mpz_clear(s);
  rsa_public_key_clear(&key);

  return EXIT_SUCCESS;
}
Exemplo n.º 6
0
/*
 * Run kermit. Used to do this in the main window, but newer
 * versions of kermit are too intelligent and just want a tty
 * for themselves or they won't function ok. Shame.
 */
void kermit(void)
{
  int status, pid, n;
  char * translated_cmdline;
  char *kermit_path = P_KERMIT;

  if (!kermit_path || !*kermit_path) {
    werror("No kermit path defined!");
    return;
  }

  /* Clear screen, set keyboard modes etc. */
  mc_wleave();

  switch (pid = fork()) {
    case -1:
      mc_wreturn();
      werror(_("Out of memory: could not fork()"));
      return;
    case 0: /* Child */
      close(portfd);

      /* Remove lockfile */
      lockfile_remove();

      for (n = 0; n < _NSIG; n++)
        signal(n, SIG_DFL);

      translated_cmdline = translate(P_KERMIT);
      if (translated_cmdline != NULL) {
        fastexec(translated_cmdline);
        free(translated_cmdline);
      }
      exit(1);
    default: /* Parent */
      break;
  }

  m_wait(&status);

  /* Restore screen and keyboard modes */
  mc_wreturn();

  /* Re-create lockfile */
  lockfile_create();

  m_flush(portfd);
  port_init();
}
Exemplo n.º 7
0
/* FIXME: !!! failed requests show up as an exception. /Bazsi
 *
 * I think that is normal. It's up to the caller to do something reasonable
 * about the exception. /nisse
 */
static void
do_pty_continuation(struct command_continuation *s,
		    struct lsh_object *x)
{
  CAST(pty_request_continuation, self, s);
  CAST_SUBTYPE(ssh_channel, channel, x);
  struct terminal_attributes *raw;
  
  assert(x);
  verbose("pty request succeeded\n");
  
  raw = TERM_MAKE_RAW(self->req->attr);
  if (!INTERACT_SET_ATTRIBUTES(self->req->tty, raw))
    {
      werror("do_pty_continuation: "
	     "Setting the attributes of the local terminal failed.\n");
    }

  REMEMBER_RESOURCE(channel->resources,
		    make_client_tty_resource(self->req->tty,
					     self->req->attr));
  
  REMEMBER_RESOURCE(channel->resources,
		    INTERACT_WINDOW_SUBSCRIBE
		    (self->req->tty,
		     make_client_winch_handler(channel)));
  
  COMMAND_RETURN(self->super.up, x);
}
Exemplo n.º 8
0
/*
 * Change to a directory.
 */
static int mcd(char *dir)
{
  char buf[256];
  char err[50];
  static char odir[256];
  static int init = 0;

  if (!init) {
    if (*dir == 0)
      return 0;
    init = 1;
    getcwd(odir, 255);
  }
  if (*dir == 0) {
    chdir(odir);
    return 0;
  }

  if (*dir != '/') {
    snprintf(buf, sizeof(buf), "%s/%s", homedir, dir);
    dir = buf;
  }
  if (chdir(dir) < 0) {
    /* This may look safe but you might I8N change the string! so
       snprintf it */
    snprintf(err, sizeof(err),  _("Cannot chdir to %.30s"), dir);
    err[sizeof(err) - 1] = 0;
    werror("%s", err);
    return -1;
  }
  return 0;
}
Exemplo n.º 9
0
int PatchINIMerge( const char* mergeini
	, const char* baseini
	, const char* resultini
	, int flags
	, char* errorBuffer
	, int errorBufferCharLen )
{
	// Convert to wide strings
	wstring wmergeini = PatchINIToWideString(mergeini);
	wstring wbaseini = PatchINIToWideString(baseini);
	wstring wresultini = PatchINIToWideString(resultini);
	wstring werror(errorBufferCharLen+1, '\0');
	
	// Main app
	int result = PatchINIMergeW(wmergeini.c_str(), wbaseini.c_str(), wresultini.c_str(), flags, &werror.at(0), errorBufferCharLen);

	// Error handling
	if(result != EXIT_SUCCESS) {
		if(errorBuffer) {
			string error = PatchINIToNarrowString(werror.c_str());
			size_t errorBufferBytes = errorBufferCharLen;
			memset(errorBuffer, '\0', errorBufferBytes);
			if(!error.empty()) {
				memcpy(errorBuffer, error.c_str(), std::max<int>(error.length(), errorBufferBytes-1));
			}
		}
	}

	return result;
}
Exemplo n.º 10
0
/*-----------------------------------------------------------------*/
void
deallocLocal (symbol * csym)
{
  symbol *sym;

  for (sym = csym; sym; sym = sym->next)
    {
      if (sym->_isparm)
        continue;

      /* if it is on the stack */
      if (sym->onStack)
        {
          if (options.useXstack)
            xstackPtr -= getSize (sym->type);
          else
            stackPtr -= getSize (sym->type);
        }
      /* if not used give a warning */
      if (!sym->isref && !IS_STATIC (sym->etype))
        werror (W_NO_REFERENCE,
                currFunc ? currFunc->name : "(unknown)",
                "local variable", sym->name);
      /* now delete it from the symbol table */
      deleteSym (SymbolTab, sym, sym->name);
    }
}
Exemplo n.º 11
0
char *wgethomedir()
{
	static char *home = NULL;
	char *tmp;
	struct passwd *user;

	if (home)
		return home;

#ifdef HAVE_SECURE_GETENV
	tmp = secure_getenv("HOME");
#else
	tmp = getenv("HOME");
#endif
	if (tmp) {
		home = wstrdup(tmp);
		return home;
	}

	user = getpwuid(getuid());
	if (!user) {
		werror(_("could not get password entry for UID %i"), getuid());
		home = "/";
		return home;
	}

	if (!user->pw_dir)
		home = "/";
	else
		home = wstrdup(user->pw_dir);

	return home;
}
Exemplo n.º 12
0
/* Show signals when debug is on. */
static void signore(int sig)
{
  if (stdwin)
    werror(_("Got signal %d"), sig);
  else
    printf("%s\r\n", _("Got signal %d"), sig);
}
Exemplo n.º 13
0
static const char *
get_model (void)
{
  int index;

  switch (options.model)
    {
    case MODEL_SMALL:
      index = 0;
      break;
    case MODEL_MEDIUM:
      index = 4;
      break;
    case MODEL_LARGE:
      index = 8;
      break;
    case MODEL_HUGE:
      index = 12;
      break;
    default:
      werror (W_UNKNOWN_MODEL, __FILE__, __LINE__);
      return "unknown";
    }
  if (options.stackAuto)
    index += 2;
  if (options.useXstack)
    index += 1;
  return models[index];
}
Exemplo n.º 14
0
/* Open wav file, check sample rate. Return WAVE* on success, NULL on error, and print the error messages to stderr. */
WAVE* open_wav(const char* infile, int verbose) {
	WAVE* wave = wopen(infile, "r");
	if (wave == NULL) {
		fprintf(stderr, "Error while opening wave file \"%s\".\n", infile);
		return NULL;
	}

	wgetheader(wave);
	if (werror(wave) != WAVE_OK) {
		fprintf(stderr, "Error while reading wave header from file \"%s\", error code: %d.\n", infile, werror(wave));
		return NULL;
	}

	if (verbose == 1) {
		printf("File info ============\n");
		printf("Wave file:   \"%s\"\n", infile);
		printf("Sample rate: %d Hz\n", wave->header.SampleRate);
		printf("Length:      %f s\n",
		((float)wave->header.Subchunk2Size / (wave->header.NumChannels * wave->header.BitsPerSample/8)) / (float)wave->header.SampleRate);
		printf("Sample bits: %d bits\n", wave->header.BitsPerSample);
		printf("Channels:    %d\n", wave->header.NumChannels);
	}

	if (wave->header.SampleRate != OPUS_SUPPORTED_FS) {
		fprintf(stderr, "Sample rate %d Hz is not supported. Only files with sample rate %d Hz are accepted.\n",
		        wave->header.SampleRate, OPUS_SUPPORTED_FS);
		wave = wclose(wave);
		return NULL;
	}

	return wave;
}
static int
convert_dsa_private_key(struct nettle_buffer *buffer, unsigned length, const uint8_t *data)
{
  struct dsa_public_key pub;
  struct dsa_private_key priv;
  int res;
  
  dsa_public_key_init(&pub);
  dsa_private_key_init(&priv);

  if (dsa_openssl_private_key_from_der(&pub, &priv, 0,
				       length, data))
    {
      /* Reuses the buffer */
      nettle_buffer_reset(buffer);
      res = dsa_keypair_to_sexp(buffer, NULL, &pub, &priv);
    }
  else
    {
      werror("Invalid OpenSSL private key.\n");
      res = 0;
    }
  dsa_public_key_clear(&pub);
  dsa_private_key_clear(&priv);

  return res;
}
Exemplo n.º 16
0
Arquivo: code.c Projeto: Sciumo/pcc
NODE *
builtin_return_address(const struct bitable *bt, NODE *a)
{
	NODE *f;

	if (a->n_op != ICON)
		goto bad;

	if (a->n_lval != 0)
		werror("unsupported argument");

	tfree(a);

	f = block(REG, NIL, NIL, INCREF(PTR+CHAR), 0, 0);
	regno(f) = FPREG;
	f = block(UMUL,
		block(PLUS, f,
		    bcon(16), INCREF(PTR+CHAR), 0, 0), NIL, PTR+CHAR, 0, 0);
	f = makety(f, PTR+VOID, 0, 0, 0);

	return f;
bad:
	uerror("bad argument to __builtin_return_address");
	return bcon(0);
}
Exemplo n.º 17
0
static void
do_sighup_close_callback(struct lsh_callback *s)
{
  CAST(sighup_close_callback, self, s);
  
  werror("SIGHUP received.\n");
  KILL_RESOURCE(self->resource);
}
Exemplo n.º 18
0
/*
 * fmg 8/20/97
 * Move scope to next hit of pattern in the buffer.
 * Returns line-number of next "hit_line" or -1 if none found
 * (we beep elsewhere ;-)
 */
int find_next(WIN *w, WIN *w_hist,
              int hit_line,     /* 'current' Match line */
              wchar_t *look,    /* pattern */
              int case_matters) /* guess... */
{
  int next_line;
  ELM *tmp_e;
  wchar_t tmp_line[MAXCOLS];
  int all_lines;

  if (!look)
    return(++hit_line); /* next line */

  tmp_line[0] = '\0';	/* Personal phobia, I need to do this.. */

  hit_line++;           /* we NEED this so we don't search only same line! */
  all_lines = w->histlines + w_hist->ys;

  if (hit_line >= all_lines) {	/* Make sure we've got a valid line! */
    werror(_("Search Wrapping Around to Start!"));
    hit_line = 0;
  }

  for (next_line = hit_line; next_line <= all_lines; next_line++) {
    /* we do 'something' here... :-) */
    tmp_e = mc_getline(w_hist, next_line);

    /*
     * First we "accumulate" the line into a variable.
     * To see 'why', see what an 'ELM' structure looks like!
     */
    mc_wdrawelm_var(w, tmp_e, tmp_line);

    /* Does it have what we want? */
    if (wcslen(tmp_line) > 1 && wcslen(look) > 1)
      if (StrStr(tmp_line, look, case_matters))
        return next_line;
  }

  if (hit_line >= all_lines) {	/* Make sure we've got a valid line! */
    werror(_("Search Wrapping Around to Start!"));
    hit_line = 0;
  }

  return -1; /* nothing found! */
}
Exemplo n.º 19
0
void
suspend_handle_tty(int fd)
{
  tty_fd = fd;

  if (!tty_getattr(fd, &original_mode))
    werror("install_suspend_handler: tty_getattr failed (errno = %i): %z\n",
	   errno, STRERROR(errno));
}
Exemplo n.º 20
0
static void
do_channel_forward_eof(struct ssh_channel *s)
{
  CAST(channel_forward, self, s);

  if (shutdown (self->socket->fd, SHUT_WR) < 0)
    werror("do_channel_forward_eof, shutdown failed, (errno = %i): %z\n",
	   errno, STRERROR(errno));
}
Exemplo n.º 21
0
void
channel_forward_shutdown(struct channel_forward *self)
{
  if (shutdown (self->write.fd, SHUT_WR) < 0)
    werror("close_fd_write, shutdown failed: %e.\n", errno);

  assert(self->super.sinks);
  self->super.sinks--;
  channel_maybe_close(&self->super);  
}
Exemplo n.º 22
0
static void
do_adns_free(adns_state s)
{
  adns_forallqueries_begin(s);

  if (adns_forallqueries_next(s, NULL))
    werror("Dropping queries on the floor.\n");

  adns_finish(s);
}
Exemplo n.º 23
0
Arquivo: spki.c Projeto: macssh/macssh
/* Returns the algorithm type, or zero on error. */
struct signer *
spki_make_signer(struct alist *algorithms,
		 struct sexp *e,
		 int *type)
{
  /* Syntax: (<algorithm> <s-expr>*) */
  struct signature_algorithm *algorithm;
  struct signer *s;
  int algorithm_name;
  struct sexp_iterator *i;

  algorithm_name = spki_get_type(e, &i);

  if (!algorithm_name)
    return NULL;
  
  {
    CAST_SUBTYPE(signature_algorithm, a, 
		 ALIST_GET(algorithms, algorithm_name));
    algorithm = a;
  }

  if (!algorithm)
    {
      werror("spki_make_signer: Unsupported algorithm %a.\n", algorithm_name);
      return NULL;
    }

  s = MAKE_SIGNER(algorithm, i);
  KILL(i);
  
  if (!s)
    {
      werror("spki_make_signer: Invalid public-key data.\n");
      return NULL;
    }

  if (type)
    *type = algorithm_name;

  return s;
}
Exemplo n.º 24
0
NODE *
mips_builtin_va_arg(NODE *f, NODE *a, TWORD t)
{
	NODE *p, *q, *r;
	int sz, tmpnr;

	/* check num args and type */
	if (a == NULL || a->n_op != CM || a->n_left->n_op == CM ||
	    !ISPTR(a->n_left->n_type) || a->n_right->n_op != TYPE)
		goto bad;

	r = a->n_right;

	/* get type size */
	sz = tsize(r->n_type, r->n_df, r->n_ap) / SZCHAR;
	if (sz < SZINT/SZCHAR) {
		werror("%s%s promoted to int when passed through ...",
			r->n_type & 1 ? "unsigned " : "",
			DEUNSIGN(r->n_type) == SHORT ? "short" : "char");
		sz = SZINT/SZCHAR;
	}

	/* alignment */
	p = tcopy(a->n_left);
	if (sz > SZINT/SZCHAR && r->n_type != UNIONTY && r->n_type != STRTY) {
		p = buildtree(PLUS, p, bcon(7));
		p = block(AND, p, bcon(-8), p->n_type, p->n_df, p->n_ap);
	}

	/* create a copy to a temp node */
	q = tempnode(0, p->n_type, p->n_df, p->n_ap);
	tmpnr = regno(q);
	p = buildtree(ASSIGN, q, p);

	q = tempnode(tmpnr, p->n_type, p->n_df,p->n_ap);
	q = buildtree(PLUS, q, bcon(sz));
	q = buildtree(ASSIGN, a->n_left, q);

	q = buildtree(COMOP, p, q);

	nfree(a->n_right);
	nfree(a);
	nfree(f); 

	p = tempnode(tmpnr, INCREF(r->n_type), r->n_df, r->n_ap);
	p = buildtree(UMUL, p, NIL);
	p = buildtree(COMOP, q, p);

	return p;

bad:
	uerror("bad argument to __builtin_va_arg");
	return bcon(0);
}
Exemplo n.º 25
0
/* Look up a port using getaddrinfo, and bind one or more sockets. */
static unsigned
open_port (struct lshd_context *ctx, struct resource_list *resources,
	   const struct lsh_string *interface, const struct lsh_string *port)
{
#if HAVE_GETADDRINFO
  struct addrinfo hints;
  struct addrinfo *list;
  struct addrinfo *p;
  int err;

  const char *node;
  unsigned done = 0;

  memset(&hints, 0, sizeof(hints));
  hints.ai_family = PF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;

  node = interface ? lsh_get_cstring(interface) : NULL;

  if (node && !node[0])
    node = NULL;

  debug("open_port: node = %z, port = %S\n",
	node ? node : "ANY", port);

  /* FIXME: Also use AI_ADDRCONFIG? */
  hints.ai_flags = AI_PASSIVE;

  err = getaddrinfo(node, lsh_get_cstring(port), &hints, &list);
  if (err)
    werror ("getaddrinfo failed for interface %z, port %S: %z\n",
	    node ? node : "ANY", port, gai_strerror(err));
  else
    {
      for (p = list; p; p = p->ai_next)
	{
	  if (p->ai_family == AF_INET || p->ai_family == AF_INET6)
	    {
	      struct resource *port = 
		make_lshd_port (ctx, p->ai_addrlen, p->ai_addr);
	      if (port)
		{
		  remember_resource(resources, port);
		  done++;
		}
	    }
	}
      freeaddrinfo(list);
    }
  return done;
#else /* !HAVE_GETADDRINFO */
#error getaddrinfo currently required */
#endif /* !HAVE_GETADDRINFO */
}
Exemplo n.º 26
0
static void
do_kill_pid_file(struct resource *s)
{
  CAST(pid_file_resource, self, s);
  if (self->super.alive)
    {
      self->super.alive = 0;
      if (unlink(lsh_get_cstring(self->file)) < 0)
	werror("Unlinking pidfile `%S' failed: %e.\n", self->file, errno);
    }
}
static int
write_file(struct nettle_buffer *buffer, FILE *f)
{
  size_t res = fwrite(buffer->contents, 1, buffer->size, f);
  if (res < buffer->size)
    {
      werror("Write failed: %s.\n", strerror(errno));
      return 0;
    }
  else
    return 1;
}
Exemplo n.º 28
0
/*-----------------------------------------------------------------*/
static void 
printCyclomatic (eBBlock ** ebbs, int count)
{
  int nEdges = elementsInSet (graphEdges);
  int i, nNodes = 0;

  for (i = 0; i < count; i++)
    nNodes += (!ebbs[i]->noPath);

  /* print the information */
  werror (I_CYCLOMATIC, currFunc->name, nEdges, nNodes, nEdges - nNodes + 2);
}
Exemplo n.º 29
0
/*
 * We've got the hangup or term signal.
 */
static void hangsig(int sig)
{
  if (stdwin)
    werror(_("Killed by signal %d !\n"), sig);
  if (capfp)
    fclose(capfp);

  keyboard(KUNINSTALL, 0);
  hangup();
  modemreset();
  leave("\n");
}
Exemplo n.º 30
0
/*-----------------------------------------------------------------*/
void
deallocParms (value * val)
{
  value *lval;

  for (lval = val; lval; lval = lval->next)
    {
      /* unmark is myparm */
      lval->sym->ismyparm = 0;

      /* delete it from the symbol table  */
      deleteSym (SymbolTab, lval->sym, lval->sym->name);

      if (!lval->sym->isref)
        {
          lval->sym->allocreq = 0;
            werror (W_NO_REFERENCE,
                    currFunc ? currFunc->name : "(unknown)",
                    "function argument", lval->sym->name);
        }

      /* move the rname if any to the name for both val & sym */
      /* and leave a copy of it in the symbol table           */
      if (lval->sym->rname[0])
        {
          char buffer[SDCC_NAME_MAX];
          symbol * argsym = lval->sym;

          strncpyz (buffer, lval->sym->rname, sizeof(buffer));
          lval->sym = copySymbol (lval->sym);
          strncpyz (lval->sym->rname, buffer, sizeof(lval->sym->rname));

          strncpyz (lval->sym->name, buffer, sizeof(lval->sym->name));
          /* need to keep the original name for inlining to work */
          /*strncpyz (lval->name, buffer, sizeof(lval->name)); */

          addSym (SymbolTab, lval->sym, lval->sym->name,
                  lval->sym->level, lval->sym->block, 1);
          lval->sym->_isparm = 1;
          if (!isinSet (operKeyReset, lval->sym))
            {
              addSet(&operKeyReset, lval->sym);
            }

          /* restore the original symbol */
          lval->sym = argsym;
        }
    }
  return;
}