Beispiel #1
0
/**
 * read a tiff image by name
 * return a pointer to an image struct
 */
image *readTIFF(char* filename) {
//  /*Using Sam Leffler's libtiff library */
//  TIFFRGBAImage img;
//  image *im;
//  uint32 *raster;
//
//  size_t npixels;
//  int imgwidth, imgheight, imgcomponents;
//
//  TIFF *tif;
//  char emsg[1024];
//
//  tif = TIFFOpen(filename, "r");
//  if (tif == NULL){
//    fprintf(stderr, "tif == NULL\n");
//    return NULL;
//  }
//  if (TIFFRGBAImageBegin(&img, tif, 0,emsg)){
//    npixels = img.width*img.height;
//    raster = (uint32 *)_TIFFmalloc(npixels*sizeof(uint32));
//    if (raster != NULL){
//      if (TIFFRGBAImageGet(&img, raster, img.width, img.height) == 0){
//	TIFFError(name, emsg);
//	exit(1);
//      }
//    }
//    TIFFRGBAImageEnd(&img);
//  }
//  else {
//    TIFFError(name, emsg);
//    return NULL;
//  }
//  
//  /* reverse from abgr to rgb */
//  int i;
//  im = createImage(img.width,img.height,3);
//  for (i = 0; i < npixels; i++) {
//    register unsigned char *cp = (unsigned char *) &raster[i];
//
//    im.pixels[i][0] = (unsigned short) cp[0];
//    
//    t = cp[3];
//    cp[3] = cp[0];
//    cp[0] = t;
//    t = cp[2];
//    cp[2] = cp[1];
//    cp[1] = t;
//  }
//
//  return im;
  notSupported();
  return NULL;
}
Beispiel #2
0
common::Error CommandHandler::execute(int argc, char** argv, FastoObject* out) {
  char* input_cmd = argv[0];
  for(size_t i = 0; i < commands_.size(); ++i) {
    commands_t cmd = commands_[i];
    if (cmd.isCommand(input_cmd)) {
      int argc_to_call = argc - 1;
      char** argv_to_call = argv + 1;
      if (argc_to_call > cmd.maxArgumentsCount() || argc_to_call < cmd.minArgumentsCount()) {
        std::string buff = common::MemSPrintf("Invalid input argument for command: %s", input_cmd);
        return common::make_error_value(buff, common::ErrorValue::E_ERROR);
      }

      return cmd.execute(this, argc_to_call, argv_to_call, out);
    }
  }

  return notSupported(input_cmd);
}
/**
 * write a freesurfer curvature file
 */
int writeMGHCurvatureFile(surface *surf, char *filename) {
  return notSupported();
}
/**
 * write a freesurfer label file
 */
int writeMGHLabelFile(surface *surf, char *filename) {
  return notSupported();
}
Beispiel #5
0
/*
 * For each non-const attribute in template t, print the appropriate args
 * in the call to evl_log_write().
 */
static void
printAttArgs(const evltemplate_t *t, const char *prefix)
{
	evl_listnode_t *head = t->tm_attributes, *end, *p;
	const evltemplate_t *st;	/* struct attribute's template */

	for (end=NULL, p=head; p!=end; end=head, p=p->li_next) {
		evlattribute_t *att = (evlattribute_t*) p->li_data;
		int ty;

		if (isConstAtt(att)) {
			continue;
		}
		if (isBitField(att)) {
			notSupported("bit-fields");
			continue;
		}

		ty = evlatt_gettype(att);
		if (isArray(att)) {
			char *dimString;

			dimString = getDimensionString(att, prefix);
			if (ty == TY_STRUCT) {
				/* Array of structs */
				st = att->ta_type->u.st_template;
				if ((st->tm_flags & TMPL_TF_ALIGNED) != 0) {
					/* Array of aligned structs */
					printf(
"\t\"char[]\",\t%s*sizeof(struct %s),\t%s%s,\n",
						dimString, st->tm_name, prefix,
						att->ta_name);
				} else {
					notSupported("arrays of unaligned structs");
				}
			} else {
				/* Array of scalars or strings */
				printf(
"\t\"%s[]\",\t%s,\t%s%s,\n",
					typeName(ty), dimString, prefix,
					att->ta_name);
			}

			free(dimString);
		} else {
			/* Not an array */
			if (ty == TY_STRUCT) {
				st = att->ta_type->u.st_template;
				if ((st->tm_flags & TMPL_TF_ALIGNED) != 0) {
					printf(
"\t\"char[]\",\tsizeof(struct %s),\t%s%s,\n",
						st->tm_name, prefix,
						att->ta_name);
				} else {
					/* Unaligned struct.  Print all its members. */
					size_t newPrefixSize = strlen(prefix)
						+ strlen(att->ta_name) + 1;
					char *newPrefix = (char*)
						malloc(newPrefixSize);
					assert(newPrefix != NULL);
					snprintf(newPrefix, newPrefixSize, "%s%s.", prefix,
						att->ta_name);
					printAttArgs(st, newPrefix);
					free(newPrefix);
				}
			} else {
				/* Not an array or struct */
				printf(
"\t\"%s\",\t%s%s,\n",
					typeName(ty), prefix, att->ta_name);
			}
		}
	}
}
Beispiel #6
0
/**
 * write an image struct to a dicom image file
 * return SUCCESS or FAILURE
 */
int writeDICOM(image *img, char *filename) {
  return notSupported();
}
Beispiel #7
0
/**
 * save a 8 bit per pixel pNm image from an image struct
 * return SUCCESS or FAILURE
 */
image *readPNM(char *filename) {
  notSupported();
  return NULL;
}
common::Error RocksdbRaw::help(int argc, char** argv) {
  return notSupported("HELP");
}
void UserConnection::on(BufferedSocketListener::Line, const string& aLine) throw () {

	if(aLine.length() < 2)
		return;

	if(aLine[0] == 'C' && !isSet(FLAG_NMDC)) {
		dispatch(aLine);
		return;
	} else if(aLine[0] == '$') {
		setFlag(FLAG_NMDC);
	} else {
		// We shouldn't be here?
		dcdebug("Unknown UserConnection command: %.50s\n", aLine.c_str());
		return;
	}
	string cmd;
	string param;

	string::size_type x;

	if( (x = aLine.find(' ')) == string::npos) {
		cmd = aLine;
	} else {
		cmd = aLine.substr(0, x);
		param = aLine.substr(x+1);
	}

	if(cmd == "$MyNick") {
		if(!param.empty())
			fire(UserConnectionListener::MyNick(), this, Text::acpToUtf8(param));
	} else if(cmd == "$Direction") {
		x = param.find(" ");
		if(x != string::npos) {
			fire(UserConnectionListener::Direction(), this, param.substr(0, x), param.substr(x+1));
		}
	} else if(cmd == "$Error") {
		if(Util::stricmp(param.c_str(), FILE_NOT_AVAILABLE) == 0 ||
			param.rfind(/*path/file*/" no more exists") != string::npos) {
			fire(UserConnectionListener::FileNotAvailable(), this);
		} else {
			fire(UserConnectionListener::Failed(), this, param);
		}
	} else if(cmd == "$FileLength") {
		if(!param.empty())
			fire(UserConnectionListener::FileLength(), this, Util::toInt64(param));
	} else if(cmd == "$GetListLen") {
		fire(UserConnectionListener::GetListLength(), this);
	} else if(cmd == "$Get") {
		notSupported();
		disconnect();
		StringMap params;
		params["user"] = getUser()->getNick();
		params["hub"] = getUser()->getClientUrl();
		params["ip"] = getRemoteIp();
		string tmp = Util::formatParams(STRING(OLD_CLIENT), params, false);
		LogManager::getInstance()->message(tmp);
	} else if(cmd == "$GetZBlock" || cmd == "$UGetZBlock" || cmd == "$UGetBlock") {
		notSupported();
		disconnect();
		StringMap params;
		params["user"] = getUser()->getNick();
		params["hub"] = getUser()->getClientUrl();
		params["ip"] = getRemoteIp();
		string tmp = Util::formatParams(STRING(OLD_CLIENT), params, false);
		LogManager::getInstance()->message(tmp);
	} else if(cmd == "$Key") {
		if(!param.empty())
			fire(UserConnectionListener::Key(), this, param);
	} else if(cmd == "$Lock") {
		if(!param.empty()) {
			x = param.find(" Pk=");
			if(x != string::npos) {
				fire(UserConnectionListener::CLock(), this, param.substr(0, x), param.substr(x + 4));
			} else {
				// Workaround for faulty linux clients...
				x = param.find(' ');
				if(x != string::npos) {
					setFlag(FLAG_INVALIDKEY);
					fire(UserConnectionListener::CLock(), this, param.substr(0, x), Util::emptyString);
				} else {
					fire(UserConnectionListener::CLock(), this, param, Util::emptyString);
				}
			}
		}
	} else if(cmd == "$Send") {
		fire(UserConnectionListener::Send(), this);
	} else if(cmd == "$Sending") {
		int64_t bytes = -1;
		if(!param.empty())
			bytes = Util::toInt64(param);
		fire(UserConnectionListener::Sending(), this, bytes);
	} else if(cmd == "$MaxedOut") {
		fire(UserConnectionListener::MaxedOut(), this);
	} else if(cmd == "$Supports") {
		if(!param.empty()) {
			fire(UserConnectionListener::Supports(), this, StringTokenizer<string>(param, ' ').getTokens());
		}
	} else if(cmd.compare(0, 4, "$ADC") == 0) {
		dispatch(aLine, true);
	} else {
		dcdebug("Unknown NMDC command: %.50s\n", aLine.c_str());
	}
}
Beispiel #10
0
/*******************************************************
Function: initialize, set color, hide cursor, get system language, copy icon data
Argument: none
Return  : void
*******************************************************/
void initialize() {
    // console settings
    char con_size[30] = {};
    sprintf(con_size, "mode con cols=%d lines=%d", ABSOLUTE_RIGHT + 1, ABSOLUTE_BOTTOM + 1);
    system (con_size);
    system ("title Tetris Game by Lane at ZDS");
    system ("color 3e"); // set color
    system ("cls");      // clean screen
    HideCursor();       // hide cursor

    // get random seed
    srand((unsigned)time(NULL));        // Random number seed initial

    // initialize global varibals
    memset(g_GRID,     0, sizeof(g_GRID));
    memset(g_GRID_BAK, 0, sizeof(g_GRID_BAK));
    g_SCORE = 0;

    // initialize icons
    getLocalLanguage(); // get local language information

    if(!strcmp(g_Local_Language, "CHS") && !strcmp(g_Local_Language, "JPN")) {
        notSupported(); // if not supported, stop in NotSupport() function
    }

    else if(!strcmp(g_Local_Language, "CHS")) {
        g_const_circ_b = CIRC_CHA_B;
        g_const_rect_b = RECT_CHA_B;
        g_const_rect_w = RECT_CHA_W;
        g_const_star_b = STAR_CHA_B;
        g_const_star_w = STAR_CHA_W;
    }

    else if(!strcmp(g_Local_Language, "JPN")) {
        g_const_circ_b = CIRC_JPN_B;
        g_const_rect_b = RECT_JPN_B;
        g_const_rect_w = RECT_JPN_W;
        g_const_star_b = STAR_JPN_B;
        g_const_star_w = STAR_JPN_W;
    }

    // load shapes
    g_CubeGenerator = new CubeGenerator();
    g_CubeGenerator->loadShape(SHAPE_O);
    g_CubeGenerator->loadShape(SHAPE_I);
    g_CubeGenerator->loadShape(SHAPE_T);
    g_CubeGenerator->loadShape(SHAPE_S);
    g_CubeGenerator->loadShape(SHAPE_2);
    g_CubeGenerator->loadShape(SHAPE_L);
    g_CubeGenerator->loadShape(SHAPE_J);

    // initialize global cubes
    COORD ref_coord = {4, 2};
    Shape *next = createShape();
    Shape *curr = createShape();
    g_NEXT_CUBE = new Cube(ref_coord, next->shape, next->types);
    g_CUR_CUBE =  new Cube(ref_coord, curr->shape, curr->types);
    setShape(g_CUR_CUBE);

    // draw initial game screen
    drawGame();
}
Beispiel #11
0
Options::Status Options::parse(int argc, const char **argv) {
    bool test = false;
    bool recursive = false;
    bool ultra = false;
    bool forceStdout = false;
    // Local copy of input files, which are pointers into argv.
    std::vector<const char *> localInputFiles;
    for (int i = 1; i < argc; ++i) {
        const char *arg = argv[i];
        // Protect against empty arguments
        if (arg[0] == 0) {
            continue;
        }
        // Everything after "--" is an input file
        if (!std::strcmp(arg, "--")) {
            ++i;
            std::copy(argv + i, argv + argc, std::back_inserter(localInputFiles));
            break;
        }
        // Long arguments that don't have a short option
        {
            bool isLongOption = true;
            if (!std::strcmp(arg, "--rm")) {
                keepSource = false;
            } else if (!std::strcmp(arg, "--ultra")) {
                ultra = true;
                maxWindowLog = 0;
            } else if (!std::strcmp(arg, "--no-check")) {
                checksum = false;
            } else if (!std::strcmp(arg, "--sparse")) {
                writeMode = WriteMode::Sparse;
                notSupported("Sparse mode");
                return Status::Failure;
            } else if (!std::strcmp(arg, "--no-sparse")) {
                writeMode = WriteMode::Regular;
                notSupported("Sparse mode");
                return Status::Failure;
            } else if (!std::strcmp(arg, "--dictID")) {
                notSupported(arg);
                return Status::Failure;
            } else if (!std::strcmp(arg, "--no-dictID")) {
                notSupported(arg);
                return Status::Failure;
            } else {
                isLongOption = false;
            }
            if (isLongOption) {
                continue;
            }
        }
        // Arguments with a short option simply set their short option.
        const char *options = nullptr;
        if (!std::strcmp(arg, "--processes")) {
            options = "p";
        } else if (!std::strcmp(arg, "--version")) {
            options = "V";
        } else if (!std::strcmp(arg, "--help")) {
            options = "h";
        } else if (!std::strcmp(arg, "--decompress")) {
            options = "d";
        } else if (!std::strcmp(arg, "--force")) {
            options = "f";
        } else if (!std::strcmp(arg, "--stdout")) {
            options = "c";
        } else if (!std::strcmp(arg, "--keep")) {
            options = "k";
        } else if (!std::strcmp(arg, "--verbose")) {
            options = "v";
        } else if (!std::strcmp(arg, "--quiet")) {
            options = "q";
        } else if (!std::strcmp(arg, "--check")) {
            options = "C";
        } else if (!std::strcmp(arg, "--test")) {
            options = "t";
        } else if (arg[0] == '-' && arg[1] != 0) {
            options = arg + 1;
        } else {
            localInputFiles.emplace_back(arg);
            continue;
        }
        assert(options != nullptr);

        bool finished = false;
        while (!finished && *options != 0) {
            // Parse the compression level
            if (*options >= '0' && *options <= '9') {
                compressionLevel = parseUnsigned(&options);
                continue;
            }

            switch (*options) {
            case 'h':
            case 'H':
                usage();
                return Status::Message;
            case 'V':
                std::fprintf(stderr, "PZSTD version: %s.\n", ZSTD_VERSION_STRING);
                return Status::Message;
            case 'p': {
                finished = true;
                const char *optionArgument = getArgument(options, argv, i, argc);
                if (optionArgument == nullptr) {
                    return Status::Failure;
                }
                if (*optionArgument < '0' || *optionArgument > '9') {
                    std::fprintf(stderr, "Option -p expects a number, but %s provided\n",
                                 optionArgument);
                    return Status::Failure;
                }
                numThreads = parseUnsigned(&optionArgument);
                if (*optionArgument != 0) {
                    std::fprintf(stderr,
                                 "Option -p expects a number, but %u%s provided\n",
                                 numThreads, optionArgument);
                    return Status::Failure;
                }
                break;
            }
            case 'o': {
                finished = true;
                const char *optionArgument = getArgument(options, argv, i, argc);
                if (optionArgument == nullptr) {
                    return Status::Failure;
                }
                outputFile = optionArgument;
                break;
            }
            case 'C':
                checksum = true;
                break;
            case 'k':
                keepSource = true;
                break;
            case 'd':
                decompress = true;
                break;
            case 'f':
                overwrite = true;
                forceStdout = true;
                break;
            case 't':
                test = true;
                decompress = true;
                break;
#ifdef UTIL_HAS_CREATEFILELIST
            case 'r':
                recursive = true;
                break;
#endif
            case 'c':
                outputFile = kStdOut;
                forceStdout = true;
                break;
            case 'v':
                ++verbosity;
                break;
            case 'q':
                --verbosity;
                // Ignore them for now
                break;
            // Unsupported options from Zstd
            case 'D':
            case 's':
                notSupported("Zstd dictionaries.");
                return Status::Failure;
            case 'b':
            case 'e':
            case 'i':
            case 'B':
                notSupported("Zstd benchmarking options.");
                return Status::Failure;
            default:
                std::fprintf(stderr, "Invalid argument: %s\n", arg);
                return Status::Failure;
            }
            if (!finished) {
                ++options;
            }
        } // while (*options != 0);
    }   // for (int i = 1; i < argc; ++i);

    // Input file defaults to standard input if not provided.
    if (localInputFiles.empty()) {
        localInputFiles.emplace_back(kStdIn);
    }

    // Check validity of input files
    if (localInputFiles.size() > 1) {
        const auto it = std::find(localInputFiles.begin(), localInputFiles.end(),
                                  std::string{kStdIn});
        if (it != localInputFiles.end()) {
            std::fprintf(
                stderr,
                "Cannot specify standard input when handling multiple files\n");
            return Status::Failure;
        }
    }
    if (localInputFiles.size() > 1 || recursive) {
        if (!outputFile.empty() && outputFile != nullOutput) {
            std::fprintf(
                stderr,
                "Cannot specify an output file when handling multiple inputs\n");
            return Status::Failure;
        }
    }

    // Translate input files/directories into files to (de)compress
    if (recursive) {
        char *scratchBuffer = nullptr;
        unsigned numFiles = 0;
        const char **files =
            UTIL_createFileList(localInputFiles.data(), localInputFiles.size(),
                                &scratchBuffer, &numFiles);
        if (files == nullptr) {
            std::fprintf(stderr, "Error traversing directories\n");
            return Status::Failure;
        }
        auto guard =
            makeScopeGuard([&] { UTIL_freeFileList(files, scratchBuffer); });
        if (numFiles == 0) {
            std::fprintf(stderr, "No files found\n");
            return Status::Failure;
        }
        inputFiles.resize(numFiles);
        std::copy(files, files + numFiles, inputFiles.begin());
    } else {
        inputFiles.resize(localInputFiles.size());
        std::copy(localInputFiles.begin(), localInputFiles.end(),
                  inputFiles.begin());
    }
    localInputFiles.clear();
    assert(!inputFiles.empty());

    // If reading from standard input, default to standard output
    if (inputFiles[0] == kStdIn && outputFile.empty()) {
        assert(inputFiles.size() == 1);
        outputFile = "-";
    }

    if (inputFiles[0] == kStdIn && IS_CONSOLE(stdin)) {
        assert(inputFiles.size() == 1);
        std::fprintf(stderr, "Cannot read input from interactive console\n");
        return Status::Failure;
    }
    if (outputFile == "-" && IS_CONSOLE(stdout) && !(forceStdout && decompress)) {
        std::fprintf(stderr, "Will not write to console stdout unless -c or -f is "
                     "specified and decompressing\n");
        return Status::Failure;
    }

    // Check compression level
    {
        unsigned maxCLevel =
            ultra ? ZSTD_maxCLevel() : kMaxNonUltraCompressionLevel;
        if (compressionLevel > maxCLevel || compressionLevel == 0) {
            std::fprintf(stderr, "Invalid compression level %u.\n", compressionLevel);
            return Status::Failure;
        }
    }

    // Check that numThreads is set
    if (numThreads == 0) {
        std::fprintf(stderr, "Invalid arguments: # of threads not specified "
                     "and unable to determine hardware concurrency.\n");
        return Status::Failure;
    }

    // Modify verbosity
    // If we are piping input and output, turn off interaction
    if (inputFiles[0] == kStdIn && outputFile == kStdOut && verbosity == 2) {
        verbosity = 1;
    }
    // If we are in multi-file mode, turn off interaction
    if (inputFiles.size() > 1 && verbosity == 2) {
        verbosity = 1;
    }

    // Set options for test mode
    if (test) {
        outputFile = nullOutput;
        keepSource = true;
    }
    return Status::Success;
}
Beispiel #12
0
bool Kleo::KpgpBackendBase::checkForSMIME( QString * reason ) const {
    if ( reason ) *reason = notSupported();
    return false;
}