Example #1
0
static char *
filter_quotes(const char *s)
{
  int i, l = strlen(s);
  int quote = 0;
  int backquote = 0;
  int doubquote = 0;
  char *str, *t;

  for (i=0; i < l; i++)
    switch(s[i])
    {
      case '\'': quote++; break;
      case '`' : backquote++; break;
      case '"' : doubquote++;
    }
  str = (char*)pari_malloc(l + quote * (strlen(QUOTE)-1)
                          + doubquote * (strlen(DOUBQUOTE)-1)
                          + backquote * (strlen(BACKQUOTE)-1) + 1);
  t = str;
  for (i=0; i < l; i++)
    switch(s[i])
    {
      case '\'': t = _cat(t, QUOTE); break;
      case '`' : t = _cat(t, BACKQUOTE); break;
      case '"' : t = _cat(t, DOUBQUOTE); break;
      default: *t++ = s[i];
    }
  *t = 0; return str;
}
Example #2
0
int main(int argc, const char *argv[])
{
    udfread *udf;
    UDFFILE *fp;

    if (argc < 3) {
        fprintf(stderr, "usage: udfcat <image> <file>\n"
                "    image   path to UDF filesystem image (raw device or image file)\n"
                "    file    path to file inside UDF filesystem\n");
        return -1;
    }

    udf = udfread_init();
    if (!udf) {
        fprintf(stderr, "udfread_init() failed\n");
        return -1;
    }
    if (udfread_open(udf, argv[1]) < 0) {
        fprintf(stderr, "udfread_open(%s) failed\n", argv[1]);
        udfread_close(udf);
        return -1;
    }

    fp = udfread_file_open(udf, argv[2]);
    if (!fp) {
        fprintf(stderr, "udfread_file_open(%s) failed\n", argv[2]);
        udfread_close(udf);
        return -1;
    }

    _cat(fp);

    udfread_file_close(fp);
    udfread_close(udf);
}
Example #3
0
                      boot_script,
                      ALWAYS_ENABLED, true,
                      CONFIG_BOOL,
                      false
    );
RedBoot_config_option("Boot script",
                      boot_script_data,
                      "boot_script", true,
                      CONFIG_SCRIPT,
                      ""
    );
// Some preprocessor magic for building the [constant] prompt string
#define __cat(s1,c2,s3) s1 #c2 s3
#define _cat(s1,c2,s3) __cat(s1,c2,s3)
RedBoot_config_option(_cat("Boot script timeout (",
                           CYGNUM_REDBOOT_BOOT_SCRIPT_TIMEOUT_RESOLUTION,
                           "ms resolution)"),
                      boot_script_timeout,
                      "boot_script", true,
                      CONFIG_INT,
                      0
    );
#undef __cat
#undef _cat

#ifdef CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
RedBoot_config_option("Console baud rate",
                      console_baud_rate,
                      ALWAYS_ENABLED, true,
                      CONFIG_INT,
                      CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD
Example #4
0
int main(int argc, char * argv[], char * env[])
{
	char line[128], command[128], pathname[128];
	int ID;
	
	// DEVICE SELECT
	get_device();

	// INITIALIZE 
	init();
	
	// MOUNT ROOT
	mount_root();

	// PROCESS LOOP
	while(1)
	{
		strcpy(line, "");
		strcpy(command, "");
		strcpy(pathname, "");
		strcpy(completePath, "");

		printf("\n\ninput a command (type help for more info): ");
		//read a line containting  command [pathname]; // [ ] means optional
		fgets(line, 256, stdin);
		line[strlen(line)-1] = '\0';

		//Find the command string and call the corresponding function;
		parseString(line, arg1, command, pathname);

		compPath(pathname);
		
		
		printf("PATHNAME: %s\n", pathname);
		ID = findCommand(command);
		switch(ID)
		{
			case -1 : printDir(running->cwd->ino);	break;
			case  0 : _menu  (arg1, pathname);	break;
			case  1 : _ls    (arg1, pathname);	break;
			case  2 : _cd    (arg1, pathname);	break;
			case  3 : _mkdir (arg1, pathname);	break;
			case  4 : _rmdir (arg1, pathname);	break;
			case  5 : _pwd   (arg1, pathname);	break;
			case  6 : _creat0(arg1, pathname);	break;
			case  7 : _rm    (arg1, pathname);	break;
			case  8 : _stat  (arg1, pathname);	break;
			case  9 : compPath(arg1); _link(arg1, pathname); break;
			case  10: _unlink(arg1, pathname); break;
			case  11: compPath(arg1); _symlink(arg1, pathname); break;
			case  12: _touch (arg1, pathname);	break;
			case  13: _chmod (arg1, pathname);	break;
			case  14: _chown (arg1, pathname);	break;
			case  15: _chgrp (arg1, pathname);	break;
			case  16: _open  (arg1, pathname);	break;
			case  17: _close (arg1, pathname);	break;
			case  18: _read  (arg1, pathname);	break;
			case  19: _write (arg1, pathname);	break;
			case  20: _pfd   (arg1, pathname);	break;
			case  21: _lseek (arg1, pathname);	break;
			case  22: _cat   (arg1, pathname);	break;
			case  23: _cp    (arg1, pathname);	break;
			case  24: _mv    (arg1, pathname);	break;
			case  25: __exit (arg1, pathname);	break;
		}
	}
	
	quit();
	return 0;
}