コード例 #1
0
BranchDialog::BranchDialog(QWidget *parent) :
    QDialog(parent),
    m_ui(new Ui::BranchDialog),
    m_model(new BranchModel(GitPlugin::instance()->gitClient(), this))
{
    setModal(false);
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
    setAttribute(Qt::WA_DeleteOnClose, true); // Do not update unnecessarily

    m_ui->setupUi(this);

    connect(m_ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
    connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(add()));
    connect(m_ui->checkoutButton, SIGNAL(clicked()), this, SLOT(checkout()));
    connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(remove()));
    connect(m_ui->diffButton, SIGNAL(clicked()), this, SLOT(diff()));
    connect(m_ui->logButton, SIGNAL(clicked()), this, SLOT(log()));

    m_ui->branchView->setModel(m_model);

    connect(m_ui->branchView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
            this, SLOT(enableButtons()));

    enableButtons();
}
コード例 #2
0
ファイル: ft_env.c プロジェクト: Morefaya/minishell
int			ft_env(t_list *cmd_l, t_list *env_l)
{
	t_list	*env_c;
	char	**arg;
	t_list	*unset;
	int		i;
	int		illegal;

	i = 1;
	illegal = 0;
	if (!(start_env(env_l, &env_c, &arg, cmd_l)))
		return (1);
	if (!(no_arg_env(arg, &env_c, i)))
		return (help_env(&env_c));
	unset = checkout(arg, &i, env_c, &illegal);
	if (!(unset_it(unset, &env_c)))
		return (help_env(&env_c));
	get_set(arg, &i, &env_c);
	if (arg[i])
		execute(arg + i, &env_c);
	else if (!illegal)
		print_lst(env_c);
	ft_lstdel(&unset, (void(*)(void*, size_t))del_content);
	free_tab2d(arg);
	ft_lstdel(&env_c, (void(*)(void*, size_t))del_content);
	return (1);
}
コード例 #3
0
ファイル: functions.c プロジェクト: jmarinelli/TPE-2-SO
int update(char* dest, char* file, int client_id){
	string container;
	fstree_t client_tree;
	client_tree = repository_tree; 
	fstree_node_t current = client_tree->root;
	char * child_file, * position, *command, *server_folder, *client_folder;
	
	if (!strcmp(file,".")){
		container = remove_last_appended(dest);
		run_command(COMMAND_RM, dest, NULL);
		return checkout(container, client_id);
	}
	
	child_file = (char *)calloc(MAX_PATH_LENGTH, sizeof(char));
	server_folder = (char *)calloc(MAX_PATH_LENGTH, sizeof(char));
	client_folder = (char *)calloc(MAX_PATH_LENGTH, sizeof(char));
	command = (char *)calloc(MAX_PATH_LENGTH, sizeof(char));
	strcpy(child_file, file);
	strcpy(server_folder, REPOSITORY_PATH);
	strcpy(client_folder, dest);
	
	while (position = strchr(child_file, '/')) {
		*position = 0;
		current =  find_child_by_path(current,child_file);
		if (current == NULL)
			return -1;
		if (check_existing_file(client_folder, child_file) == NON_EXISTING_FILE) {
			strcpy(command,"mkdir ");
			strcat(command,client_folder);
			strcat(command,"/");
			strcat(command,child_file);
	
			system(command);
		}
		strcat(client_folder,"/");
		strcat(client_folder,child_file);
		strcat(server_folder,"/");
		strcat(server_folder,child_file);
		child_file = position+1;
	}
	current =  find_child_by_path(current,child_file);
	
	if (current != NULL){
		strcpy(command,"cp -rf ");
		strcat(command,server_folder);
		strcat(command,"/");
		strcat(command,child_file);
		strcat(command," ");
		strcat(command,client_folder);
		system(command);
	}
	else {
		client_send("File not found in server", client_id);
		client_send(END_OF_TRANSMISSION, client_id);
		return -1;
	}
	client_send("Updated", client_id);
	client_send(END_OF_TRANSMISSION, client_id);	
	return SUCCESS; 
}
コード例 #4
0
ファイル: NPS.CPP プロジェクト: chemikadze/oldschool
char* TSolver::convert()  //converts function names to symbols
{if ((S==NULL || !strlen(S)) || !checkin() || !checkbr())
  {seterr(E_VOID);if(S!=NULL)free(S);return NULL;}
 char* p;
 int i,j;
 int sl;
 int SL=strlen(S);
 Err=E_NO;
 for (i=0;i<=SL;i++)
   if (S[i]==' ')
    {for (j=i;j<=SL+1;j++)
       S[j]=S[j+1];
     SL--;
    }
 for (i=NFUNC-1;i>=0;i--)
   while ((p=strstr(S,SLex[i]))!=NULL)
     {S[p-S]=cpi+i;
      sl=strlen(SLex[i])-1;
      SL-=sl;
      for (j=p-S+1;j<=SL;j++)
	S[j]=S[j+sl];
     }
 for (i=0;i<SL;i++)
   if (S[i]=='-' && (minusF))
     S[i]='_';
#ifdef debug
 printf("%s\n",S);
#endif
 if (!checkout() || !checkexpr()) {converted=good=0;return NULL;}
 converted=good=1;
 return S;
}
コード例 #5
0
ファイル: branchdialog.cpp プロジェクト: CNOT/julia-studio
void BranchDialog::add()
{
    QString trackedBranch = m_model->branchName(selectedIndex());
    bool isLocal = m_model->isLocal(selectedIndex());
    if (trackedBranch.isEmpty()) {
        trackedBranch = m_model->branchName(m_model->currentBranch());
        isLocal = true;
    }

    QStringList localNames = m_model->localBranchNames();

    QString suggestedNameBase = trackedBranch.mid(trackedBranch.lastIndexOf(QLatin1Char('/')) + 1);
    QString suggestedName = suggestedNameBase;
    int i = 2;
    while (localNames.contains(suggestedName)) {
        suggestedName = suggestedNameBase + QString::number(i);
        ++i;
    }

    BranchAddDialog branchAddDialog;
    branchAddDialog.setBranchName(suggestedName);
    branchAddDialog.setTrackedBranchName(trackedBranch, !isLocal);

    if (branchAddDialog.exec() == QDialog::Accepted && m_model) {
        QModelIndex idx = m_model->addBranch(branchAddDialog.branchName(), branchAddDialog.track(), trackedBranch);
        m_ui->branchView->selectionModel()->select(idx, QItemSelectionModel::Clear
                                                        | QItemSelectionModel::Select
                                                        | QItemSelectionModel::Current);
        m_ui->branchView->scrollTo(idx);
        if (QMessageBox::question(this, tr("Checkout"), tr("Checkout branch?"),
                                  QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
            checkout();
    }
}
コード例 #6
0
ファイル: GitRepo.cpp プロジェクト: 02JanDal/ralph
Future<void> GitRepo::pull(const QString &id) const
{
	return async([this, id](Notifier notifier)
	{
		notifier.await(fetch());
		notifier.await(checkout(id));
	});
}
コード例 #7
0
ファイル: inout.c プロジェクト: DJHartley/iphone-dev
int
main(
int argc,
char **argv,
char **envp)
{
    unsigned long i;
    char *input, *output;
    struct arch *archs;
    unsigned long narchs;

	progname = argv[0];
	input = NULL;
	output = NULL;
	archs = NULL;
	narchs = 0;
	for(i = 1; i < argc; i++){
	    if(strcmp(argv[i], "-o") == 0){
		if(i + 1 == argc){
		    error("missing argument(s) to: %s option", argv[i]);
		    usage();
		}
		if(output != NULL){
		    error("more than one: %s option specified", argv[i]);
		    usage();
		}
		output = argv[i+1];
		i++;
	    }
	    else{
		if(input != NULL){
		    error("more than one input file specified (%s and %s)",
			  argv[i], input);
		    usage();
		}
		input = argv[i];
	    }
	}
	if(input == NULL || output == NULL)
	    usage();

	breakout(input, &archs, &narchs, FALSE);
	if(errors)
	    exit(EXIT_FAILURE);

	checkout(archs, narchs);

	process(archs, narchs);

	writeout(archs, narchs, output, 0777, TRUE, FALSE, FALSE);

	if(errors)
	    return(EXIT_FAILURE);
	else
	    return(EXIT_SUCCESS);
}
コード例 #8
0
ファイル: checkout_dialog.cpp プロジェクト: caivega/tao-3D
CheckoutDialog::CheckoutDialog(Repository *repo, QWidget *parent)
// ----------------------------------------------------------------------------
//    Create a history dialog with a checkout button
// ----------------------------------------------------------------------------
    : HistoryDialog(repo, parent)
{
    setWindowTitle(tr("Checkout"));
    historyFrame->setMessage(tr("Please select a version of the document and "
                    "click Checkout to bring a copy into a temporary branch"));
    QPushButton *checkoutButton;
    checkoutButton = new QPushButton(tr("&Checkout"));
    buttonBox->addButton(checkoutButton, QDialogButtonBox::ApplyRole);
    connect(checkoutButton, SIGNAL(clicked()), this, SLOT(checkout()));
}
コード例 #9
0
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
int CPCFFixApp::Main()
{
	g_pDataModel->SetUndoEnabled( false );
	g_pDataModel->OnlyCreateUntypedElements( true );
	g_pDataModel->SetDefaultElementFactory( NULL );

	// This bit of hackery allows us to access files on the harddrive
	g_pFullFileSystem->AddSearchPath( "", "LOCAL", PATH_ADD_TO_HEAD ); 

	if ( CommandLine()->CheckParm( "-h" ) || CommandLine()->CheckParm( "-help" ) )
	{
		PrintHelp();
		return 0;
	}

	// Do Perforce Stuff
	if ( CommandLine()->FindParm( "-nop4" ) )
	{
		g_p4factory->SetDummyMode( true );
	}

	g_p4factory->SetOpenFileChangeList( "Fixed PCF files" );

	const char *pPCFFile = CommandLine()->ParmValue( "-i" );
	if ( !pPCFFile )
	{
		PrintHelp();
		return 0;
	}

	CDmElement *pRoot;
	if ( g_pDataModel->RestoreFromFile( pPCFFile, NULL, "pcf", &pRoot, CR_DELETE_NEW ) == DMFILEID_INVALID )
	{
		Error( "Encountered an error reading file \"%s\"!\n", pPCFFile );
		return -1;
	}

	FixupPCFFile( pRoot );

	CP4AutoEditFile checkout( pPCFFile );
	const char *pOutEncoding = g_pDataModel->GetDefaultEncoding( "pcf" );
	if ( !g_pDataModel->SaveToFile( pPCFFile, NULL, pOutEncoding, "pcf", pRoot ) )
	{
		Error( "Encountered an error writing file \"%s\"!\n", pPCFFile );
		return -1;
	}

	g_pDataModel->RemoveFileId( pRoot->GetFileId() );
	return -1;
}
コード例 #10
0
//-----------------------------------------------------------------------------
// Saves an SFM file
//-----------------------------------------------------------------------------
void CSFMGenApp::SaveSFMFile( CDmElement *pRoot, const char *pOutputDir, const char *pFileName )
{
	// Construct actual file name from the model name + dmx file name
	char pFullPathBuf[MAX_PATH];
	Q_snprintf( pFullPathBuf, sizeof(pFullPathBuf), "%s/%s.dmx", pOutputDir, pFileName );
	const char *pFullPath = pFullPathBuf;

	CP4AutoEditAddFile checkout( pFullPath );

	if ( !g_pDataModel->SaveToFile( pFullPath, NULL, g_pDataModel->GetDefaultEncoding( "sfm_session" ), "sfm_session", pRoot ) )
	{
		Warning( "sfmgen: Unable to write file %s\n", pFullPath );
		return;
	}

	Msg( "sfmgen: Wrote file %s\n", pFullPath );
}
コード例 #11
0
ファイル: message_data.hpp プロジェクト: vdeepak13/sill
 /**
  * Checks the message.  If its a write request, a buffer will be
  * taken from the object_allocator.  If the object is currently
  * allocated for writing then this function will return NULL
  */
 F *trycheckout(object_allocator_tls<F> &pool, 
             const ReadWrite rw) {
   if (rw == Reading) {
     return checkout(pool,rw);
   }
   else {
     lock.lock();
     if (writebuffer != NULL) {
       lock.unlock();
       return NULL;
     }
     writebuffer = pool.checkout();
     lock.unlock();
     (*writebuffer) = message;
     return writebuffer;
   }
 }
コード例 #12
0
ファイル: packrec.cpp プロジェクト: wenzong/lab
void
check(int *a){
	rect r[4];

	for( int i = 0 ; i <= 15 ; i++ ){
		for(int j = 0 ; j <= 3 ; j++)
			r[j] = RECT[a[j]];
		if((i%2)== 1)
			rotate(r,0);
		if(((i%4)>>1) == 1)
			rotate(r,1);
		if(((i%8)>>2) == 1)
			rotate(r,2);
		if(((i%16)>>3) == 1)
			rotate(r,3);
		checkout(r);
	}
}
コード例 #13
0
IResultPtr PerforceDepotView::move(const char* srcFile, const char* dstFile, ChangeListId changeListId)
{
	std::stringstream command;
	PathList paths;
	paths.emplace_back(srcFile);
	paths.emplace_back(dstFile);
	getLatest(paths);
	checkout(paths, changeListId);
	if (changeListId != kDefaultChangelist)
	{
		command << "move -c " << changeListId << " -f " << EscapePaths(paths);
	}
	else
	{
		command << "move -f " << EscapePaths(paths);
	}
	return RunCommand(command.str());
}
コード例 #14
0
int main() {
	int n;
	char cn[20];
	list l;
	customer c;
	date d1, d2;
	printf("Welcome to hotel GRAND :\n");
	printf("Total rooms in hotel are: 500\n");
	printf("Single rooms are: 300\nDouble rooms are: 200");
	printf("Cost for one day:\nSingle room stay is:'350'\nDouble room stay is:'600'\n");
	while(1) {
		n = options();
		switch(n) {
			case 1:
				cs_info(&c);
				printf("Entry Date:\n");
				date_info(&d1);
				printf("Exit Date:\n");
				date_info(&d2);
				checkin(&l, &c, &d1, &d2);
				traverse(&l);
				break;
			case 2:
				printf("Enter the name of Customer who want to Checkout\n");
				scanf("%s", cn);
				checkout(&l, &c, &d1, &d2, cn);
				traverse(&l);
				break;
			case 3:
				total_bill(&c, &d1, &d2);
				printf("Your total bill is:%d\n",c.total_bill);
				break;
			case 4:
				rooms();
				break;
			default:
				printf("SORRY we don't get you\nPlease enter the valid option\n");
		}
	}
	return 0;
}
コード例 #15
0
ファイル: branchestree.cpp プロジェクト: scalm/QGit-mod
BranchesTree::BranchesTree(QWidget *parent) : QTreeWidget(parent),
    branchIcon(QString::fromUtf8(":/icons/resources/branch.png")),
    masterBranchIcon(QString::fromUtf8(":/icons/resources/branch_master.png")),
    tagIcon(QString::fromUtf8(":/icons/resources/tag.png"))
{
    setContextMenuPolicy(Qt::CustomContextMenu);

    QObject::connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
                     this, SLOT(changeBranch(QTreeWidgetItem*, int)));

    QObject::connect(this, SIGNAL(customContextMenuRequested(QPoint)),
                     this, SLOT(contextMenu(QPoint)));

    collapseAllAction = new QAction(tr("Collapse all"), this);
    QObject::connect(collapseAllAction, SIGNAL(triggered()),
                     this, SLOT(collapseAll()));

    expandAllAction = new QAction(tr("Expand all"), this);
    QObject::connect(expandAllAction, SIGNAL(triggered()),
                     this, SLOT(expandAll()));

    checkoutAction = new QAction(tr("Checkout"), this);
    QObject::connect(checkoutAction, SIGNAL(triggered()),
                     this, SLOT(checkout()));

    removeTagAction = new QAction(tr("Remove"), this);
    QObject::connect(removeTagAction, SIGNAL(triggered()),
                     this, SLOT(removeTag()));

    this->setRootIsDecorated(false);
    this->setIndentation(10);

    QPalette p = this->palette();
    p.setColor(QPalette::Base, p.color(QPalette::Window));
    this->setPalette(p);
}
コード例 #16
0
ファイル: clone.c プロジェクト: IAmAnubhavSaini/git
int cmd_clone(int argc, const char **argv, const char *prefix)
{
	int is_bundle = 0, is_local;
	struct stat buf;
	const char *repo_name, *repo, *work_tree, *git_dir;
	char *path, *dir;
	int dest_exists;
	const struct ref *refs, *remote_head;
	const struct ref *remote_head_points_at;
	const struct ref *our_head_points_at;
	struct ref *mapped_refs;
	const struct ref *ref;
	struct strbuf key = STRBUF_INIT, value = STRBUF_INIT;
	struct strbuf branch_top = STRBUF_INIT, reflog_msg = STRBUF_INIT;
	struct transport *transport = NULL;
	const char *src_ref_prefix = "refs/heads/";
	struct remote *remote;
	int err = 0, complete_refs_before_fetch = 1;

	struct refspec *refspec;
	const char *fetch_pattern;

	packet_trace_identity("clone");
	argc = parse_options(argc, argv, prefix, builtin_clone_options,
			     builtin_clone_usage, 0);

	if (argc > 2)
		usage_msg_opt(_("Too many arguments."),
			builtin_clone_usage, builtin_clone_options);

	if (argc == 0)
		usage_msg_opt(_("You must specify a repository to clone."),
			builtin_clone_usage, builtin_clone_options);

	if (option_single_branch == -1)
		option_single_branch = option_depth ? 1 : 0;

	if (option_mirror)
		option_bare = 1;

	if (option_bare) {
		if (option_origin)
			die(_("--bare and --origin %s options are incompatible."),
			    option_origin);
		if (real_git_dir)
			die(_("--bare and --separate-git-dir are incompatible."));
		option_no_checkout = 1;
	}

	if (!option_origin)
		option_origin = "origin";

	repo_name = argv[0];

	path = get_repo_path(repo_name, &is_bundle);
	if (path)
		repo = xstrdup(absolute_path(repo_name));
	else if (!strchr(repo_name, ':'))
		die(_("repository '%s' does not exist"), repo_name);
	else
		repo = repo_name;

	/* no need to be strict, transport_set_option() will validate it again */
	if (option_depth && atoi(option_depth) < 1)
		die(_("depth %s is not a positive number"), option_depth);

	if (argc == 2)
		dir = xstrdup(argv[1]);
	else
		dir = guess_dir_name(repo_name, is_bundle, option_bare);
	strip_trailing_slashes(dir);

	dest_exists = !stat(dir, &buf);
	if (dest_exists && !is_empty_dir(dir))
		die(_("destination path '%s' already exists and is not "
			"an empty directory."), dir);

	strbuf_addf(&reflog_msg, "clone: from %s", repo);

	if (option_bare)
		work_tree = NULL;
	else {
		work_tree = getenv("GIT_WORK_TREE");
		if (work_tree && !stat(work_tree, &buf))
			die(_("working tree '%s' already exists."), work_tree);
	}

	if (option_bare || work_tree)
		git_dir = xstrdup(dir);
	else {
		work_tree = dir;
		git_dir = mkpathdup("%s/.git", dir);
	}

	if (!option_bare) {
		junk_work_tree = work_tree;
		if (safe_create_leading_directories_const(work_tree) < 0)
			die_errno(_("could not create leading directories of '%s'"),
				  work_tree);
		if (!dest_exists && mkdir(work_tree, 0777))
			die_errno(_("could not create work tree dir '%s'."),
				  work_tree);
		set_git_work_tree(work_tree);
	}
	junk_git_dir = git_dir;
	atexit(remove_junk);
	sigchain_push_common(remove_junk_on_signal);

	if (safe_create_leading_directories_const(git_dir) < 0)
		die(_("could not create leading directories of '%s'"), git_dir);

	set_git_dir_init(git_dir, real_git_dir, 0);
	if (real_git_dir) {
		git_dir = real_git_dir;
		junk_git_dir = real_git_dir;
	}

	if (0 <= option_verbosity) {
		if (option_bare)
			fprintf(stderr, _("Cloning into bare repository '%s'...\n"), dir);
		else
			fprintf(stderr, _("Cloning into '%s'...\n"), dir);
	}
	init_db(option_template, INIT_DB_QUIET);
	write_config(&option_config);

	git_config(git_default_config, NULL);

	if (option_bare) {
		if (option_mirror)
			src_ref_prefix = "refs/";
		strbuf_addstr(&branch_top, src_ref_prefix);

		git_config_set("core.bare", "true");
	} else {
		strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
	}

	strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
	strbuf_addf(&key, "remote.%s.url", option_origin);
	git_config_set(key.buf, repo);
	strbuf_reset(&key);

	if (option_reference.nr)
		setup_reference();
	else if (option_dissociate) {
		warning(_("--dissociate given, but there is no --reference"));
		option_dissociate = 0;
	}

	fetch_pattern = value.buf;
	refspec = parse_fetch_refspec(1, &fetch_pattern);

	strbuf_reset(&value);

	remote = remote_get(option_origin);
	transport = transport_get(remote, remote->url[0]);
	path = get_repo_path(remote->url[0], &is_bundle);
	is_local = option_local != 0 && path && !is_bundle;
	if (is_local) {
		if (option_depth)
			warning(_("--depth is ignored in local clones; use file:// instead."));
		if (!access(mkpath("%s/shallow", path), F_OK)) {
			if (option_local > 0)
				warning(_("source repository is shallow, ignoring --local"));
			is_local = 0;
		}
	}
	if (option_local > 0 && !is_local)
		warning(_("--local is ignored"));
	transport->cloning = 1;

	if (!transport->get_refs_list || (!is_local && !transport->fetch))
		die(_("Don't know how to clone %s"), transport->url);

	transport_set_option(transport, TRANS_OPT_KEEP, "yes");

	if (option_depth)
		transport_set_option(transport, TRANS_OPT_DEPTH,
				     option_depth);
	if (option_single_branch)
		transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");

	transport_set_verbosity(transport, option_verbosity, option_progress);

	if (option_upload_pack)
		transport_set_option(transport, TRANS_OPT_UPLOADPACK,
				     option_upload_pack);

	if (transport->smart_options && !option_depth)
		transport->smart_options->check_self_contained_and_connected = 1;

	refs = transport_get_remote_refs(transport);

	if (refs) {
		mapped_refs = wanted_peer_refs(refs, refspec);
		/*
		 * transport_get_remote_refs() may return refs with null sha-1
		 * in mapped_refs (see struct transport->get_refs_list
		 * comment). In that case we need fetch it early because
		 * remote_head code below relies on it.
		 *
		 * for normal clones, transport_get_remote_refs() should
		 * return reliable ref set, we can delay cloning until after
		 * remote HEAD check.
		 */
		for (ref = refs; ref; ref = ref->next)
			if (is_null_sha1(ref->old_sha1)) {
				complete_refs_before_fetch = 0;
				break;
			}

		if (!is_local && !complete_refs_before_fetch)
			transport_fetch_refs(transport, mapped_refs);

		remote_head = find_ref_by_name(refs, "HEAD");
		remote_head_points_at =
			guess_remote_head(remote_head, mapped_refs, 0);

		if (option_branch) {
			our_head_points_at =
				find_remote_branch(mapped_refs, option_branch);

			if (!our_head_points_at)
				die(_("Remote branch %s not found in upstream %s"),
				    option_branch, option_origin);
		}
		else
			our_head_points_at = remote_head_points_at;
	}
	else {
		if (option_branch)
			die(_("Remote branch %s not found in upstream %s"),
					option_branch, option_origin);

		warning(_("You appear to have cloned an empty repository."));
		mapped_refs = NULL;
		our_head_points_at = NULL;
		remote_head_points_at = NULL;
		remote_head = NULL;
		option_no_checkout = 1;
		if (!option_bare)
			install_branch_config(0, "master", option_origin,
					      "refs/heads/master");
	}

	write_refspec_config(src_ref_prefix, our_head_points_at,
			remote_head_points_at, &branch_top);

	if (is_local)
		clone_local(path, git_dir);
	else if (refs && complete_refs_before_fetch)
		transport_fetch_refs(transport, mapped_refs);

	update_remote_refs(refs, mapped_refs, remote_head_points_at,
			   branch_top.buf, reflog_msg.buf, transport, !is_local);

	update_head(our_head_points_at, remote_head, reflog_msg.buf);

	transport_unlock_pack(transport);
	transport_disconnect(transport);

	if (option_dissociate)
		dissociate_from_references();

	junk_mode = JUNK_LEAVE_REPO;
	err = checkout();

	strbuf_release(&reflog_msg);
	strbuf_release(&branch_top);
	strbuf_release(&key);
	strbuf_release(&value);
	junk_mode = JUNK_LEAVE_ALL;

	free(refspec);
	return err;
}
コード例 #17
0
ファイル: PDMBuilder.cpp プロジェクト: songcser/ALM
PDMBUILDER_API bool checkSourceCode()
{
	SourceCode *sourceCode = getSourceCode();

	//string url = sourceCode->GetUrl();
	
	string fullpath(workspace+"\\"+sourceCode->GetLocalPath());
	//string fullpath = sourceCode->GetLocalPath();
	string log ;
	fullpath = changeSeparator(fullpath);
	string svnPath(fullpath+"\\.svn");
	if (!PathFileExists(svnPath.c_str()))
	{
		//printf("to checkout");
		log += checkout(workspace);
		
		//printf("svn checkout\n");
		int accessInt = log.find("Access to");
		if (accessInt!=string::npos)
		{
			if (log.find("forbidden")!=string::npos)
			{
				string nextNumFile(fullpath+"\\nextBuildNumber");
				if (!PathFileExists(nextNumFile.c_str()))
				{
					writeLog(log,workspace+"\\log");
					delete sourceCode;
					return true;
				}
				if (forceFlag!="false")
				{
					writeLog(log,workspace+"\\log");
				}
				delete sourceCode;
				return false;
			}
		}
		int errorint = log.find("error");
		if (errorint!=string::npos&&errorint==log.length()-5)
		{
			writeLog(log,workspace+"\\log");
			delete sourceCode;
			return false;
		}
		writeLog(log,workspace+"\\log");
		//writeLog(log,workspace+"\\log");
		delete sourceCode;
		return true;
	}

	char updateCmd[500];
	memset(updateCmd,0,sizeof(updateCmd));

	sprintf(updateCmd,"svn update --force --non-interactive --username %s --password %s --accept tf \"%s\"",buildName.c_str(),buildPassword.c_str(),sourceCode->GetLocalPath().c_str());
	//printf("to update");
	int exitCode = 0;
	log.assign("<---------------------------checkout--------------------------->\n ");
	log += ExeCommand(updateCmd,exitCode,(char *)workspace.c_str());
	//printf("svn update\n");
	if (exitCode>0&&exitCode!=STILL_ACTIVE)
	{
		log += "update source code error";
		if (forceFlag!="false")
		{
			writeLog(log,workspace+"\\log");
		}
		delete sourceCode;
		return false;
	}else if (log.find("svn cleanup")!=string::npos)
	{
		char cleanupCmd[100];
		memset(cleanupCmd,0,sizeof(cleanupCmd));
		sprintf(cleanupCmd,"svn cleanup");
		ExeCommand(cleanupCmd,exitCode,(char *)workspace.c_str());

		log = ExeCommand(updateCmd,exitCode,(char *)workspace.c_str());
		if (exitCode>0&&exitCode!=STILL_ACTIVE)
		{
			log += "update source code error";
			if (forceFlag!="false")
			{
				writeLog(log,workspace+"\\log");
			}
			delete sourceCode;
			return false;
		}
	}
	int index = log.find("Updated to revision");
	
	if (index>0)
	{
		index += 20;
		int in = log.find_last_of(".");
		sourceVersion = log.substr(index,in-index);
		
		writeLog(log,workspace+"\\log");
		delete sourceCode;
		return true;
	}else
	{
		int rindex = log.rfind("At revision");
		if (rindex!=string::npos)
		{
			int lindex = log.rfind(".");
			rindex += 12;
			sourceVersion = log.substr(rindex,lindex-rindex);
		}
		if (forceFlag!="false")
		{
			writeLog(log,workspace+"\\log");
		}
		
		delete sourceCode;
		return false;
	}
}
コード例 #18
0
ファイル: environment.hpp プロジェクト: brycelelbach/prana
 utree invoke (phxpr::shared_ptr<F> const& f) const {
   utree ut(spirit::any_ptr(checkout().get()));
   return f->eval(ut);
 }
コード例 #19
0
ファイル: message_data.hpp プロジェクト: vdeepak13/sill
 F *trycheckout(multi_object_allocator_tls<F> &pool, const ReadWrite rw) {
   return checkout(rw);
 }
コード例 #20
0
ファイル: test_halftoning.cpp プロジェクト: B9907012/pixkit
int main(int argc,char* argv[]){


	if(argc<2){
		return help();
	}
	short	delay	=	-1;	// default
	if(argc>1){
		delay	=	atoi(argv[1]);
	}
	srand(time(NULL));


	//////////////////////////////////////////////////////////////////////////
	///// initial
	construct();
	cv::Mat	src,dst;
	int	nCount	=	0;	// calc the counts of errors


	//////////////////////////////////////////////////////////////////////////
	///// ** (test) empty input, [output] should be false
	std::cout	<<	"(test) empty input, [output] should be false"	<<	std::endl;
	for(int k=0;k<function_vec.size();k++){
		nCount+=checkout(function_vec[k](src,dst),false);
	}
	std::cout	<<	std::endl	<<	std::endl;


	//////////////////////////////////////////////////////////////////////////
	///// ** (test) dst type, [output] should be CV_8UC1
	std::cout	<<	"(test) dst type, [output] should be CV_8UC1"	<<	std::endl;
	src.create(cv::Size(256,256),CV_8UC1);
	src.setTo(rand()%256);
	for(int k=0;k<function_vec.size();k++){
		nCount+=checkout(function_vec[k](src,dst),dst.type()==CV_8UC1?true:false);
		if(delay>0){
			cv::imshow("output",dst);
			cv::waitKey(delay);
		}
	}
	std::cout	<<	std::endl	<<	std::endl;

	
	//////////////////////////////////////////////////////////////////////////
	///// ** (test) check channel types
	std::cout	<<	"(test) check channel types"	<<	std::endl;
	int	chennel_types[]={CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F};	// 10 types
	for(int k=0;k<function_vec.size();k++){
		for(int i=0;i<10;i++){
			src.create(cv::Size(256,256),chennel_types[i]);
			src.setTo(rand()%256);
			std::cout << chennel_types[i];
			nCount+=checkout(function_vec[k](src,dst),chennel_types[i]==CV_8UC1?true:false);
		}
	}
	std::cout	<<	std::endl	<<	std::endl;


	//////////////////////////////////////////////////////////////////////////
	///// ** (test) various input sizes
	std::cout	<<	"(test) various input sizes"	<<	std::endl;
	std::vector<cv::Size>	input_sizes;
	input_sizes.push_back(cv::Size(0,0));		// false
	input_sizes.push_back(cv::Size(0,1));		// false
	input_sizes.push_back(cv::Size(1,0));		// false
	input_sizes.push_back(cv::Size(1,1));		// true
	input_sizes.push_back(cv::Size(100,200));	// true
	input_sizes.push_back(cv::Size(200,100));	// true
	input_sizes.push_back(cv::Size(1001,99));	// true
	input_sizes.push_back(cv::Size(501,277));	// true
	for(int k=0;k<function_vec.size();k++){
		for(int i=0;i<input_sizes.size();i++){
			src.create(input_sizes[i],CV_8UC1);
			src.setTo(rand()%256);
			std::cout << input_sizes[i];
			nCount+=checkout(function_vec[k](src,dst),i<3?false:true);
			if(delay>0){
				cv::imshow("output",dst);
				cv::waitKey(delay);
			}
		}
	}
	std::cout	<<	std::endl	<<	std::endl;


	//////////////////////////////////////////////////////////////////////////
	///// ** (test) check output should be black/white
	std::cout	<<	"(test) check output should be black/white"	<<	std::endl;
	int	error_pixel;
	for(int k=0;k<function_vec.size();k++){

		for(int i=0;i<10;i++){
			src.create(cv::Size(256,256),CV_8UC1);
			int	randv	=	rand()%256;
			src.setTo(randv);
			std::cout << randv;

			// do test
			function_vec[k](src,dst);
			error_pixel=0;
			for(int m=0;m<dst.rows;m++){
				for(int n=0;n<dst.cols;n++){
					if(dst.data[m*dst.cols+n]!=0&&dst.data[m*dst.cols+n]!=255){
						error_pixel++;
					}
				}
			}
			nCount+=checkout(true,error_pixel==0?true:false);
			if(delay>0){
				cv::imshow("output",dst);
				cv::waitKey(delay);
			}
		}
	}
	std::cout	<<	std::endl	<<	std::endl;


	//////////////////////////////////////////////////////////////////////////
	std::cout	<<	nCount	<<	" errors."	<<	std::endl;
	return nCount;
}
コード例 #21
0
ファイル: environment.hpp プロジェクト: brycelelbach/prana
 utree invoke (F const& f) const {
   utree ut(spirit::any_ptr(checkout().get()));
   return f.eval(ut);
 }
コード例 #22
0
ファイル: main.c プロジェクト: cemeyer/git-isvn
static int cmd_isvn_clone(int argc, const char **cargv, const char *prefix)
{
	svn_revnum_t latest_rev = SVN_INVALID_REVNUM;
	struct isvn_client_ctx *first_client;
	char *dir, *key, **argv;
	const char *repo_name;
	svn_error_t *err;

	git_repository_init_options initopts;
	git_config *config;
	int rc;

	argv = __DECONST(cargv, char **);
	argc = isvn_parse_opts(argc, argv, isvn_clone_options,
	    isvn_clone_usage);

	if (argc < 1)
		isvn_usage(isvn_clone_usage, isvn_clone_options,
		    "You must specify a repository to clone.");
	else if (argc < 2)
		isvn_usage(isvn_clone_usage, isvn_clone_options,
		    "You must specify a destination directory.");
	else if (argc > 2)
		isvn_usage(isvn_clone_usage, isvn_clone_options,
		    "Too many arguments.");

	if (!option_origin)
		option_origin = "origin";
	option_cloning = true;
	if (option_maxrev < 0)
		isvn_usage(isvn_clone_usage, isvn_clone_options,
		    "Maxrev cannot be negative");

	repo_name = argv[0];
	if (argc == 2)
		dir = xstrdup(argv[1]);
	else
		dir = guess_dir_name(repo_name);

	initopts = (git_repository_init_options) GIT_REPOSITORY_INIT_OPTIONS_INIT;
	initopts.flags = GIT_REPOSITORY_INIT_MKDIR |
	    GIT_REPOSITORY_INIT_NO_REINIT |
	    GIT_REPOSITORY_INIT_MKPATH;

	rc = git_repository_init_ext(&g_git_repo, dir, &initopts);
	if (rc < 0)
		die("Error creating git repository: %d", rc);

	rc = git_repository_config(&config, g_git_repo);
	if (rc)
		die("git_repository_config: %d", rc);

	xasprintf(&key, "remote.%s.url", option_origin);
	rc = git_config_set_string(config, key, repo_name);
	if (rc)
		die("git_config_set_string: %d", rc);
	g_svn_url = xstrdup(repo_name);
	free(key);

	/* Initialize APR / libsvn */
	if (svn_cmdline_init("git-isvn", stderr) != EXIT_SUCCESS)
		die("svn_cmdline_init");

	first_client = get_svn_ctx();
	if (first_client == NULL)
		die("Could not connect to SVN server.");

	err = svn_ra_get_latest_revnum(first_client->svn_session, &latest_rev,
		first_client->svn_pool);
	assert_noerr(err, "svn_ra_get_latest_revnum");

	if (option_verbosity >= 2)
		printf("Maximum SVN repository revision: %ju\n",
		    (uintmax_t)latest_rev);

	if (option_maxrev == 0 || option_maxrev > latest_rev)
		option_maxrev = latest_rev;

	isvn_fetch(first_client);

	/* Branch 'master' from remote trunk and checkout. */
	checkout(g_git_repo);

	git_config_free(config);
	git_repository_free(g_git_repo);
	g_git_repo = NULL;

	free(dir);
	return 0;
}
コード例 #23
0
int main(void) {

	char line[MAX_LINE];
	entry *entryHead;       //head of entry list
	snapshot *snapHead;		//head of snapshot list
	entryHead = NULL;  
	snapHead = NULL;
	
	while (true) {
		printf("> ");

		if (fgets(line, MAX_LINE, stdin) == NULL) {
			printf("\n");
			command_bye(entryHead, snapHead);
			return 0;
		}
		
		//get command from the input line as well as a second parameter if it exists
		char *ptr = strtok(line, " ");
		char firstToken[MAX_COMMAND];    //stores a command
		strcpy(firstToken, ptr);
		ptr = strtok(NULL, " ");
		char secondToken[MAX_KEY];  	 //stores either a key or a second part of the command
		secondToken[0] = '\0';
		
		//get rid of a new line character if it exists in the last valid token entered
		char *newLine;
		if (ptr != NULL) {		
			strcpy(secondToken, ptr);
			newLine = strchr(secondToken, '\n');
		}
		else {
			newLine = strchr(firstToken, '\n');
		}
		if (newLine) {
			*newLine = 0;	
		}
		
		//identify the command and call the right function to execute the command entered
		if (strcasecmp(firstToken, "BYE") == 0) {
			command_bye(entryHead, snapHead);
			return 0;
		}
		else if (strcasecmp(firstToken, "HELP") == 0) {
			command_help();
		}
		else if (strcasecmp(firstToken, "LIST") == 0) {
			if (strcasecmp(secondToken, "ENTRIES") == 0) {
				list_entries(entryHead);	
			}
			else if (strcasecmp(secondToken, "KEYS") == 0) {
				list_keys(entryHead);
			}
			else if(strcasecmp(secondToken, "SNAPSHOTS") == 0) {
				list_snapshots(snapHead);
			}
			else {
				printf("unknown\n");	
			}
		}
		else if (strcasecmp(firstToken, "GET") == 0) {
			get(secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "DEL") == 0) {
			entryHead = del(entryHead, secondToken);
		}
		else if (strcasecmp(firstToken, "PURGE") == 0) {
			entryHead = purge(secondToken, entryHead, snapHead);
		}
		else if (strcasecmp(firstToken, "SET") == 0) {
			if (ptr != NULL && secondToken[0] != '\0') {
				entryHead = set(ptr, secondToken, entryHead);
			}
			else {
				printf("invalid input\n");	
			}
		}
		else if (strcasecmp(firstToken, "PUSH") == 0 || strcasecmp(firstToken, "APPEND") == 0) {
			push_append(ptr, secondToken, entryHead, firstToken);
		}
		else if (strcasecmp(firstToken, "PICK") == 0) {
			ptr = strtok(NULL, " ");
			int index = atoi(ptr);
			pick(index, secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "PLUCK") == 0) {
			ptr = strtok(NULL, " ");
			int index = atoi(ptr);
			pluck(index, secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "POP") == 0) {
			pluck(1, secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "DROP") == 0) {
			snapHead = drop(snapHead, atoi(secondToken));
		}
		else if (strcasecmp(firstToken, "ROLLBACK") == 0) {
			entryHead = checkout(atoi(secondToken), entryHead, snapHead);
			snapHead = remove_snapshots(atoi(secondToken), snapHead);
		}
		else if (strcasecmp(firstToken, "CHECKOUT") == 0) {
			entryHead = checkout(atoi(secondToken), entryHead, snapHead);
		}
		else if (strcasecmp(firstToken, "SNAPSHOT") == 0) {
			snapHead = take_snapshot(entryHead, snapHead);
		}
		else if (strcasecmp(firstToken, "MIN") == 0) {
			min(secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "MAX") == 0) {
			max(secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "SUM") == 0) {
			sum(secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "LEN") == 0) {
			len(secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "REV") == 0) {
			reverse(secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "UNIQ") == 0) {
			unique(secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "SORT") == 0) {
			sort(secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "DIFF") == 0) {
			diff(ptr, secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "INTER") == 0) {
			inter(ptr, secondToken, entryHead);
		}
		else if (strcasecmp(firstToken, "UNION") == 0) {
			union_oper(ptr, secondToken, entryHead);
		}
		else {
			printf("unknown\n");	
		}
		
		printf("\n");
  	}

	return 0;
}
コード例 #24
0
ファイル: InterpConvert.cpp プロジェクト: cjang/chai
void InterpConvert::sub_eval(stack< vector< FrontMem* > >& outStack)
{
    const size_t PREC   = prec(0);
    const size_t WIDTH  = W(0);
    const size_t HEIGHT = H(0);
    const size_t LEN    = WIDTH * HEIGHT;
    const size_t SLOTS  = slots(0);

    // precision matches, no conversion
    if (_prec == PREC)
    {
        checkout(0);
        outStack.push(_argStack[0]);
        return;
    }

    // must change precision

    swizzle(0);

    // first allocate backing memory
    BackMem* backMem = allocBackMem(_prec, WIDTH, HEIGHT, SLOTS);

    // array memory boxes
    vector< FrontMem* > frontMem;

    // calculate and create fronts
    for (size_t i = 0; i < SLOTS; i++)
    {
        FrontMem* m = allocFrontMem(_prec, WIDTH, HEIGHT, backMem, i);

        frontMem.push_back(m);

        for (size_t j = 0; j < LEN; j++)
        {
            double value;
            switch (PREC)
            {
                case (PrecType::UInt32) :
                    value = uintPtr(0, i)[j];
                    break;

                case (PrecType::Int32) :
                    value = intPtr(0, i)[j];
                    break;

                case (PrecType::Float) :
                    value = floatPtr(0, i)[j];
                    break;

                case (PrecType::Double) :
                    value = doublePtr(0, i)[j];
                    break;
            }

            switch (_prec)
            {
                case (PrecType::UInt32) :
                    m->uintPtr()[j] = value;
                    break;

                case (PrecType::Int32) :
                    m->intPtr()[j] = value;
                    break;

                case (PrecType::Float) :
                    m->floatPtr()[j] = value;
                    break;

                case (PrecType::Double) :
                    m->doublePtr()[j] = value;
                    break;
            }
        }
    }

    // push result on stack
    outStack.push(frontMem);
}
コード例 #25
0
ファイル: fp_CSDPoS.cpp プロジェクト: jrvmbust/ite-001
void sales()
{	
	system("cls");
	fclose(fsal);
	fclose(fsaldel);	
	fclose(fi1);
	FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); 
	printBorders(95,31);
	system("color 8f");
	gtc(40,2); printf("S  A  L  E  S"); 			
	printBox(3,4,35,25);
	printsales();
	printBox(42,11,50,8);
	printBox(42,22,50,7);
	printBox(42,4,50,4); gtc(47,6); printf("Add Items"); gtc(60,6); printf("Void Items"); gtc(73,6); printf("Checkout"); gtc(86,6); printf("Exit");
	gtc(53,14);printf("Choose from the options above.");
	gtc(45,6); printf("\xb10");
	int a,b=45;
	while(getch()!=13) //THIS PART OMG.
	{		
		a=getch();

		if (a==0 || a==0xE0) a=getch();
		
		if (a==27) 
			{
			break;
			}
		else if (a==75)
		{
			if(b!=45)
			{
				gtc(b,6);
				printf(" ");
				b-=13;
				gtc(b,6);
				printf("\xb10");
			}
		}
		else if (a==77)
			{
				if(b!=84)
				{
					gtc(b,6);
					printf(" ");
					b+=13;
					gtc(b,6);
					printf("\xb10");
				}

			}		
	}
	switch(b)
	{
		case 45:
			gtc(53,14);printf("                                  ");
			additem();
			break;
		case 58:
			gtc(53,14);printf("                                  ");
			voiditem();
			break;
		case 71:
			gtc(53,14);printf("                                  ");
			checkout();
			break;
		case 84:
			menu();
			exit(0);
			break;
	}
	getch();
	
	
}
コード例 #26
0
int main (int argc, char **argv)
{
Q330 q330;
Q330_ADDR addr;

    init(argc, argv, &q330);

    switch (q330.cmd.code) {

      case Q330_CMD_REBOOT:
        boot(&q330);
        break;

      case Q330_CMD_SAVE:
        save(&q330);
        break;

      case Q330_CMD_SAVEBOOT:
        save(&q330);
        sleep(5);
        boot(&q330);
        break;

      case Q330_CMD_RESYNC:
        resync(&q330);
        break;

      case Q330_CMD_GPS_ON:
        gpsON(&q330);
        break;

      case Q330_CMD_GPS_OFF:
        gpsOFF(&q330);
        break;

      case Q330_CMD_GPS_COLD:
        gpsColdStart(&q330);
        break;

      case Q330_CMD_GPS_CNF:
        gpsCnf(&q330);
        break;

      case Q330_CMD_GPS_ID:
        gpsId(&q330);
        break;

      case Q330_CMD_CAL_START:
        calStart(&q330);
        break;

      case Q330_CMD_CAL_STOP:
        calStop(&q330);
        break;

      case Q330_CMD_IFCONFIG:
        ifconfig(&q330);
        break;

      case Q330_CMD_STATUS:
        status(&q330);
        break;

      case Q330_CMD_FIX:
        fix(&q330);
        break;

      case Q330_CMD_GLOB:
        glob(&q330);
        break;

      case Q330_CMD_SC:
        sc(&q330);
        break;

      case Q330_CMD_PULSE:
        pulse(&q330);
        break;

      case Q330_CMD_AMASS:
        amass(&q330);
        break;

      case Q330_CMD_DCP:
        dcp(&q330);
        break;

      case Q330_CMD_SPP:
        spp(&q330);
        break;

      case Q330_CMD_MAN:
        man(&q330);
        break;

      case Q330_CMD_CO:
        checkout(&q330);
        break;

      default:
        fprintf(stderr, "ERROR: command '%s' is unsupported\n", q330.cmd.name);
        break;

    }

    if (q330.qdp != NULL) qdpDeregister(q330.qdp, TRUE);
}
コード例 #27
0
ファイル: ctf_insert.c プロジェクト: coolstar/cctools-port
/*
 * The ctf_insert(1) tool has the following usage:
 *
 *	ctf_insert input -arch arch ctf_file ...  -o output
 * 
 * Where the input is a Mach-O file that is the ctf_file(s) are to be inserted
 * into and output is the file to be created.
 */
int
main(
int argc,
char **argv,
char **envp)
{
    uint32_t i;
    char *input, *output, *contents;
    struct arch *archs;
    uint32_t narchs;
    struct stat stat_buf;
    int fd;

	progname = argv[0];
	input = NULL;
	output = NULL;
	archs = NULL;
	narchs = 0;
	for(i = 1; i < argc; i++){
	    if(strcmp(argv[i], "-o") == 0){
		if(i + 1 == argc){
		    error("missing argument to: %s option", argv[i]);
		    usage();
		}
		if(output != NULL){
		    error("more than one: %s option specified", argv[i]);
		    usage();
		}
		output = argv[i+1];
		i++;
	    }
	    else if(strcmp(argv[i], "-arch") == 0){
		if(i + 2 == argc){
		    error("missing argument(s) to: %s option", argv[i]);
		    usage();
		}
		else{
		    arch_ctfs = reallocate(arch_ctfs,
			    (narch_ctfs + 1) * sizeof(struct arch_ctf));
		    if(get_arch_from_flag(argv[i+1],
				  &(arch_ctfs[narch_ctfs].arch_flag)) == 0){
			error("unknown architecture specification flag: "
			      "%s %s %s", argv[i], argv[i+1], argv[i+2]);
			arch_usage();
			usage();
		    }
		    if((fd = open(argv[i+2], O_RDONLY, 0)) == -1)
			system_fatal("can't open file: %s", argv[i+2]);
		    if(fstat(fd, &stat_buf) == -1)
			system_fatal("can't stat file: %s", argv[i+2]);
		    /*
		     * For some reason mapping files with zero size fails
		     * so it has to be handled specially.
		     */
		    contents = NULL;
		    if(stat_buf.st_size != 0){
			contents = mmap(0, stat_buf.st_size,
					PROT_READ|PROT_WRITE,
				        MAP_FILE|MAP_PRIVATE, fd, 0);
			if((intptr_t)contents == -1)
			    system_error("can't map file : %s", argv[i+2]);
		    }
		    arch_ctfs[narch_ctfs].filename = argv[i+2];
		    arch_ctfs[narch_ctfs].contents = contents;
		    arch_ctfs[narch_ctfs].size = stat_buf.st_size;
		    arch_ctfs[narch_ctfs].arch_found = FALSE;
		    narch_ctfs++;
		    i += 2;
		}
	    }
	    else{
		if(input != NULL){
		    error("more than one input file file: %s specified",
			  input);
		    usage();
		}
		input = argv[i];
	    }
	}
	if(input == NULL || output == NULL || narch_ctfs == 0)
	    usage();

	breakout(input, &archs, &narchs, FALSE);
	if(errors)
	    exit(EXIT_FAILURE);

	checkout(archs, narchs);

	process(archs, narchs);

	for(i = 0; i < narch_ctfs; i++){
	    if(arch_ctfs[i].arch_found == FALSE)
		fatal("input file: %s does not contain a matching architecture "
		      "for specified '-arch %s %s' option", input,
		      arch_ctfs[i].arch_flag.name, arch_ctfs[i].filename);
	}

	writeout(archs, narchs, output, 0777, TRUE, FALSE, FALSE, FALSE, NULL);

	if(errors)
	    return(EXIT_FAILURE);
	else
	    return(EXIT_SUCCESS);
}
コード例 #28
0
/*
 * The codesign_allocate(1) tool has the following usage:
 *
 *	codesign_allocate -i oldfile -a arch size ...  -o newfile
 *
 * Where the oldfile is a Mach-O file that is input for the dynamic linker
 * and it creates or adds an
 */
int
main(
    int argc,
    char **argv,
    char **envp)
{
    uint32_t i;
    char *input, *output, *endp;
    struct arch *archs;
    uint32_t narchs;

    progname = argv[0];
    input = NULL;
    output = NULL;
    archs = NULL;
    narchs = 0;
    for(i = 1; i < argc; i++) {
        if(strcmp(argv[i], "-i") == 0) {
            if(i + 1 == argc) {
                error("missing argument to: %s option", argv[i]);
                usage();
            }
            if(input != NULL) {
                error("more than one: %s option specified", argv[i]);
                usage();
            }
            input = argv[i+1];
            i++;
        }
        else if(strcmp(argv[i], "-o") == 0) {
            if(i + 1 == argc) {
                error("missing argument to: %s option", argv[i]);
                usage();
            }
            if(output != NULL) {
                error("more than one: %s option specified", argv[i]);
                usage();
            }
            output = argv[i+1];
            i++;
        }
        else if(strcmp(argv[i], "-a") == 0) {
            if(i + 2 == argc) {
                error("missing argument(s) to: %s option", argv[i]);
                usage();
            }
            else {
                arch_signs = reallocate(arch_signs,
                                        (narch_signs + 1) * sizeof(struct arch_sign));
                if(get_arch_from_flag(argv[i+1],
                                      &(arch_signs[narch_signs].arch_flag)) == 0) {
                    error("unknown architecture specification flag: "
                          "%s %s %s", argv[i], argv[i+1], argv[i+2]);
                    arch_usage();
                    usage();
                }
                arch_signs[narch_signs].datasize =
                    strtoul(argv[i+2], &endp, 0);
                if(*endp != '\0')
                    fatal("size for '-a %s %s' not a proper number",
                          argv[i+1], argv[i+2]);
                if((arch_signs[narch_signs].datasize % 16) != 0)
                    fatal("size for '-a %s %s' not a multiple of 16",
                          argv[i+1], argv[i+2]);
                arch_signs[narch_signs].found = FALSE;
                narch_signs++;
                i += 2;
            }
        }
        else if(strcmp(argv[i], "-A") == 0) {
            if(i + 3 == argc) {
                error("missing argument(s) to: %s option", argv[i]);
                usage();
            }
            else {
                arch_signs = reallocate(arch_signs,
                                        (narch_signs + 1) * sizeof(struct arch_sign));

                arch_signs[narch_signs].arch_flag.cputype =
                    strtoul(argv[i+1], &endp, 0);
                if(*endp != '\0')
                    fatal("cputype for '-A %s %s %s' not a proper number",
                          argv[i+1], argv[i+2], argv[i+3]);

                arch_signs[narch_signs].arch_flag.cpusubtype =
                    strtoul(argv[i+2], &endp, 0);
                if(*endp != '\0')
                    fatal("cpusubtype for '-A %s %s %s' not a proper "
                          "number", argv[i+1], argv[i+2], argv[i+3]);

                arch_signs[narch_signs].arch_flag.name = (char *)
                        get_arch_name_from_types(
                            arch_signs[narch_signs].arch_flag.cputype,
                            arch_signs[narch_signs].arch_flag.cpusubtype);

                arch_signs[narch_signs].datasize =
                    strtoul(argv[i+3], &endp, 0);
                if(*endp != '\0')
                    fatal("size for '-A %s %s %s' not a proper number",
                          argv[i+1], argv[i+2], argv[i+3]);
                if((arch_signs[narch_signs].datasize % 16) != 0)
                    fatal("size for '-A %s %s %s' not a multiple of 16",
                          argv[i+1], argv[i+2], argv[i+3]);

                arch_signs[narch_signs].found = FALSE;
                narch_signs++;
                i += 3;
            }
        }
        else {
            error("unknown flag: %s", argv[i]);
            usage();
        }
    }
    if(input == NULL || output == NULL || narch_signs == 0)
        usage();

    breakout(input, &archs, &narchs, FALSE);
    if(errors)
        exit(EXIT_FAILURE);

    checkout(archs, narchs);

    process(archs, narchs);

    for(i = 0; i < narch_signs; i++) {
        if(arch_signs[i].found == FALSE)
            fatal("input file: %s does not contain a matching architecture "
                  "for specified '-a %s %u' option", input,
                  arch_signs[i].arch_flag.name, arch_signs[i].datasize);
    }

    writeout(archs, narchs, output, 0777, TRUE, FALSE, FALSE, NULL);

    if(errors)
        return(EXIT_FAILURE);
    else
        return(EXIT_SUCCESS);
}
コード例 #29
0
ファイル: MS4.c プロジェクト: ManaliAmin/C-Programming
int main(){
	struct Player player[8];
	struct Player winner;
	int  playerCount = 0, score, highScore = 500, game = 0;
	char userInput, highName = NULL;
	printf("\nWelcome to CHECKOUT\n");
Menu:
	printf("\n\nMain Menu\n\n");
	printf("p - (p)lay q - (q)uit r - inst(r)uctions s - HI(s)core: ");
	userInput = getValidCharacter('p', 's');
	if (userInput == 'p'){
		int i = 0, boardSize;
		printf("Enter Number of Players:");
		playerCount = getValidItenger(1, 8);
		for (i = 0; i < playerCount; i++){													 //plares[i].id
			if (player[i].id != NULL){
				initPlayer(&player[i]);
			}
		}
        printf("Enter board size: ");
		boardSize = getValidItenger(5, 15);
		playGame(boardSize, player, playerCount);

		score = checkout(player);
		
		int p;
		for (i = 0; i<playerCount; ++i)                                                 /* Loop to store largest number to arr[0] */
		{
			if (score == player[i].playerScore){                                        /* Change < to > if you want to find smallest element*/
				p = i;
			}


		}
		winner.id = player[p].id;
		strcpy(winner.playerName, player[p].playerName);
		winner.playerScore = player[p].playerScore;
		printf("Congratulations %s (%c)!You win!", winner.playerName, winner.id);
		addToLeaderboard(game, &winner);
		goto Menu;


	}
	else if (userInput == 's'){
		displayHighestScore();
		goto Menu;
	}
	else if (userInput == 'r'){
		displayInstructions();

		main();
	}
	//Quit

	else if (userInput == 'q'){
		printf("This game is much more fun than bash...");
	}
	else{
		printf("INVALID!");
	}
	return 0;
}
コード例 #30
0
ファイル: client.c プロジェクト: khjabir/shopping_cart_C
int main()
{
	int condition;
	printf("Enter 'help' to view available options: ");
	
	int ch=0,reply,status,checkout_flag=0;
	char command[COMMAND_LENGTH],buf[BUF_LENGTH],choice[1];

	while(1)
	{
		printf("\n>");
		scanf("%s",command);
		ch=choiceValue(command);
		switch(ch)
		{
			case 1:
					help();
					break;

			case 2:
					if(login_session==1)
						printf("Already logged in..!!");
					else
						signup();
					break;

			case 3:
					if(login_session==1)
						printf("Already logged in..!!");
					else
						login_session = login();
					break;

			case 4:
					if(login_session==0)
						printf("Not yet logged in..!!");
					else
					{
						if(checkout_flag==0)
						{
							printf("\nYour cart file will be deleted..Do you want to logout(y/n)??");
							scanf("%s",choice);
							if((choice[0]=='y')||(choice[0]=='Y'))
							{
								status = remove(CART_FILE);
								
								login_session=0;
								strcpy(buf,"logout");
								reply = sendtoserver(buf);
 
 								if( status == 0 )
 									printf("Cart file deleted.\n");
 								else
 								{
 									printf("Cart file is already deleted.\n");
 								}
 							}
 							else 
								continue;
						}
						else
						{
							login_session=0;
							strcpy(buf,"logout");
							reply = sendtoserver(buf);

						}
						
					}
					break;

			case 5:
					if(login_session==0)
						printf("Please login to view catalog..!!");
					else
						viewcatalog();
					break;

			case 6:
					if(login_session==0)
						printf("Please login to search an item..!!");
					else
						search();
					break;

			case 7:
					if(login_session==0)
						printf("Please login to add an item..!!");
					else
						addtocart();
					break;

			case 8:
					if(login_session==0)
						printf("Please login to view your cart..!!");
					else
						viewcart();
					break;

			case 9:
					if(login_session==0)
						printf("Please login to remove an item from your cart..!!");
					else
						removefromcart();
					break;

			case 10:
					if(login_session==0)
						printf("Please login to checkout your cart..!!");
					else
					{
						checkout();
						checkout_flag = 1;
					}
					break;

			case 11:
					return 0;

			default:
					printf("Invalid Command\n");
		}
	}
}