main.c
author Kristian H?gsberg <krh@redhat.com>
Sun Apr 06 23:36:45 2008 -0400 (2008-04-06)
changeset 193 2d0d5e7dd439
parent 192 55b177b689c0
child 194 6d25d2fa0935
permissions -rw-r--r--
Fix segfault on ./razor list.
     1 #include <stdlib.h>
     2 #include <stddef.h>
     3 #include <stdio.h>
     4 #include <stdint.h>
     5 #include <string.h>
     6 #include <sys/stat.h>
     7 #include <unistd.h>
     8 #include <dirent.h>
     9 #include <curl/curl.h>
    10 #include <fnmatch.h>
    11 #include "razor.h"
    12 #include "razor-internal.h"
    13 
    14 static const char system_repo_filename[] = "system.repo";
    15 static const char next_repo_filename[] = "system-next.repo";
    16 static const char rawhide_repo_filename[] = "rawhide.repo";
    17 static const char updated_repo_filename[] = "system-updated.repo";
    18 static const char razor_root_path[] = "/var/lib/razor";
    19 static const char root[] = "install";
    20 static const char *repo_filename = system_repo_filename;
    21 
    22 static int
    23 command_list(int argc, const char *argv[])
    24 {
    25 	struct razor_set *set;
    26 	struct razor_package_iterator *pi;
    27 	struct razor_package *package;
    28 	const char *pattern, *name, *version, *arch;
    29 	int only_names = 0, i = 0;
    30 
    31 	if (i < argc && strcmp(argv[i], "--only-names") == 0) {
    32 		only_names = 1;
    33 		i++;
    34 	}
    35 
    36 	pattern = argv[i];
    37 	set = razor_set_open(repo_filename);
    38 	pi = razor_package_iterator_create(set);
    39 	while (razor_package_iterator_next(pi, &package,
    40 					   &name, &version, &arch)) {
    41 		if (pattern && fnmatch(pattern, name, 0) != 0)
    42 			continue;
    43 
    44 		if (only_names)
    45 			printf("%s\n", name);
    46 		else
    47 			printf("%s-%s.%s\n", name, version, arch);
    48 	}
    49 	razor_package_iterator_destroy(pi);
    50 	razor_set_destroy(set);
    51 
    52 	return 0;
    53 }
    54 
    55 static int
    56 list_properties(const char *package_name,
    57 		enum razor_property_type required_type)
    58 {
    59 	struct razor_set *set;
    60 	struct razor_property *property;
    61 	struct razor_package *package;
    62 	struct razor_property_iterator *pi;
    63 	const char *name, *version;
    64 	enum razor_property_type type;
    65 	enum razor_version_relation relation;
    66 
    67 	set = razor_set_open(repo_filename);
    68 	if (package_name)
    69 		package = razor_set_get_package(set, package_name);
    70 	else
    71 		package = NULL;
    72 
    73 	pi = razor_property_iterator_create(set, package);
    74 	while (razor_property_iterator_next(pi, &property,
    75 					    &name, &relation, &version,
    76 					    &type)) {
    77 		if (type != required_type)
    78 			continue;
    79 		if (version[0] == '\0')
    80 			printf("%s\n", name);
    81 		else
    82 			printf("%s %s %s\n", name,
    83 			       razor_version_relations[relation], version);
    84 	}
    85 	razor_property_iterator_destroy(pi);
    86 
    87 	razor_set_destroy(set);
    88 
    89 	return 0;
    90 }
    91 
    92 static int
    93 command_list_requires(int argc, const char *argv[])
    94 {
    95 	return list_properties(argv[0], RAZOR_PROPERTY_REQUIRES);
    96 }
    97 
    98 static int
    99 command_list_provides(int argc, const char *argv[])
   100 {
   101 	return list_properties(argv[0], RAZOR_PROPERTY_PROVIDES);
   102 }
   103 
   104 static int
   105 command_list_obsoletes(int argc, const char *argv[])
   106 {
   107 	return list_properties(argv[0], RAZOR_PROPERTY_OBSOLETES);
   108 }
   109 
   110 static int
   111 command_list_conflicts(int argc, const char *argv[])
   112 {
   113 	return list_properties(argv[0], RAZOR_PROPERTY_CONFLICTS);
   114 }
   115 
   116 static int
   117 command_list_files(int argc, const char *argv[])
   118 {
   119 	struct razor_set *set;
   120 
   121 	set = razor_set_open(repo_filename);
   122 	if (set == NULL)
   123 		return 1;
   124 	razor_set_list_files(set, argv[0]);
   125 	razor_set_destroy(set);
   126 
   127 	return 0;
   128 }
   129 
   130 static int
   131 command_list_file_packages(int argc, const char *argv[])
   132 {
   133 	struct razor_set *set;
   134 	struct razor_package_iterator *pi;
   135 	struct razor_package *package;
   136 	const char *name, *version, *arch;
   137 
   138 	set = razor_set_open(repo_filename);
   139 	if (set == NULL)
   140 		return 1;
   141 
   142 	pi = razor_package_iterator_create_for_file(set, argv[0]);
   143 	while (razor_package_iterator_next(pi, &package,
   144 					   &name, &version, &arch))
   145 		printf("%s-%s\n", name, version);
   146 	razor_package_iterator_destroy(pi);
   147 
   148 	razor_set_destroy(set);
   149 
   150 	return 0;
   151 }
   152 
   153 static int
   154 command_list_package_files(int argc, const char *argv[])
   155 {
   156 	struct razor_set *set;
   157 
   158 	set = razor_set_open(repo_filename);
   159 	if (set == NULL)
   160 		return 1;
   161 	razor_set_list_package_files(set, argv[0]);
   162 	razor_set_destroy(set);
   163 
   164 	return 0;
   165 }
   166 
   167 static void
   168 list_packages_for_property(struct razor_set *set,
   169 			   struct razor_property *property)
   170 {
   171 	struct razor_package_iterator *pi;
   172 	struct razor_package *package;
   173 	const char *name, *version, *arch;
   174 
   175 	pi = razor_package_iterator_create_for_property(set, property);
   176 	while (razor_package_iterator_next(pi, &package,
   177 					   &name, &version, &arch))
   178 		printf("%s-%s.%s\n", name, version, arch);
   179 	razor_package_iterator_destroy(pi);
   180 }
   181 
   182 static int
   183 list_property_packages(const char *ref_name,
   184 		       const char *ref_version,
   185 		       enum razor_property_type ref_type)
   186 {
   187 	struct razor_set *set;
   188 	struct razor_property *property;
   189 	struct razor_property_iterator *pi;
   190 	const char *name, *version;
   191 	enum razor_property_type type;
   192 	enum razor_version_relation relation;
   193 
   194 	if (ref_name == NULL)
   195 		return 0;
   196 
   197 	set = razor_set_open(repo_filename);
   198 	if (set == NULL)
   199 		return 1;
   200 
   201 	pi = razor_property_iterator_create(set, NULL);
   202 	while (razor_property_iterator_next(pi, &property,
   203 					    &name, &relation, &version,
   204 					    &type)) {
   205 		if (strcmp(ref_name, name) != 0)
   206 			continue;
   207 		if (ref_version && relation == RAZOR_VERSION_EQUAL &&
   208 		    strcmp(ref_version, version) != 0)
   209 			continue;
   210 		if (ref_type != type)
   211 			continue;
   212 
   213 		list_packages_for_property(set, property);
   214 	}
   215 	razor_property_iterator_destroy(pi);
   216 
   217 	return 0;
   218 }
   219 
   220 static int
   221 command_what_requires(int argc, const char *argv[])
   222 {
   223 	return list_property_packages(argv[0], argv[1],
   224 				      RAZOR_PROPERTY_REQUIRES);
   225 }
   226 
   227 static int
   228 command_what_provides(int argc, const char *argv[])
   229 {
   230 	return list_property_packages(argv[0], argv[1],
   231 				      RAZOR_PROPERTY_PROVIDES);
   232 }
   233 
   234 static int
   235 show_progress(void *clientp,
   236 	      double dltotal, double dlnow, double ultotal, double ulnow)
   237 {
   238 	const char *file = clientp;
   239 
   240 	if (!dlnow < dltotal)
   241 		fprintf(stderr, "\rdownloading %s, %dkB/%dkB",
   242 			file, (int) dlnow / 1024, (int) dltotal / 1024);
   243 
   244 	return 0;
   245 }
   246 
   247 static int
   248 download_if_missing(CURL *curl, const char *url, const char *file)
   249 {
   250 	struct stat buf;
   251 	char error[256];
   252 	FILE *fp;
   253 	CURLcode res;
   254 
   255 	curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error);
   256 	curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
   257 	curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, show_progress);
   258 	curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, file);
   259 
   260 	if (stat(file, &buf) < 0) {
   261 		fp = fopen(file, "w");
   262 		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
   263 		curl_easy_setopt(curl, CURLOPT_URL, url);
   264 		res = curl_easy_perform(curl);
   265 		fclose(fp);
   266 		if (res != CURLE_OK) {
   267 			fprintf(stderr, "curl error: %s\n", error);
   268 			unlink(file);
   269 			return -1;
   270 		}
   271 		fprintf(stderr, "\n");
   272 	}
   273 
   274 	return 0;
   275 }
   276 
   277 #define REPO_URL "http://download.fedora.redhat.com" \
   278 	"/pub/fedora/linux/development/i386/os"
   279 
   280 static int
   281 command_import_yum(int argc, const char *argv[])
   282 {
   283 	struct razor_set *set;
   284 	CURL *curl;
   285 
   286 	curl = curl_easy_init();
   287 	if (curl == NULL)
   288 		return 1;
   289 
   290 	if (download_if_missing(curl,
   291 				REPO_URL "/repodata/primary.xml.gz",
   292 				"primary.xml.gz") < 0)
   293 		return -1;
   294 	if (download_if_missing(curl,
   295 				REPO_URL "/repodata/filelists.xml.gz",
   296 				"filelists.xml.gz") < 0)
   297 		return -1;
   298 	curl_easy_cleanup(curl);
   299 
   300 	set = razor_set_create_from_yum();
   301 	if (set == NULL)
   302 		return 1;
   303 	razor_set_write(set, rawhide_repo_filename);
   304 	razor_set_destroy(set);
   305 	printf("wrote %s\n", rawhide_repo_filename);
   306 
   307 	return 0;
   308 }
   309 
   310 static int
   311 command_import_rpmdb(int argc, const char *argv[])
   312 {
   313 	struct razor_set *set;
   314 
   315 	set = razor_set_create_from_rpmdb();
   316 	if (set == NULL)
   317 		return 1;
   318 	razor_set_write(set, repo_filename);
   319 	razor_set_destroy(set);
   320 	printf("wrote %s\n", repo_filename);
   321 
   322 	return 0;
   323 }
   324 
   325 static int
   326 command_validate(int argc, const char *argv[])
   327 {
   328 	struct razor_set *set;
   329 
   330 	set = razor_set_open(repo_filename);
   331 	if (set == NULL)
   332 		return 1;
   333 	razor_set_list_unsatisfied(set);
   334 	razor_set_destroy(set);
   335 
   336 	return 0;
   337 }
   338 
   339 static int
   340 command_update(int argc, const char *argv[])
   341 {
   342 	struct razor_set *set, *upstream;
   343 	struct razor_transaction *trans;
   344 	int errors;
   345 
   346 	set = razor_set_open(repo_filename);
   347 	upstream = razor_set_open(rawhide_repo_filename);
   348 	if (set == NULL || upstream == NULL)
   349 		return 1;
   350 	trans = razor_transaction_create(set, upstream, argc, argv, 0, NULL);
   351 	errors = razor_transaction_describe(trans);
   352 	if (errors)
   353 		return 1;
   354 
   355 	set = razor_transaction_run(trans);
   356 	razor_transaction_destroy(trans);
   357 	razor_set_write(set, updated_repo_filename);
   358 	razor_set_destroy(set);
   359 	razor_set_destroy(upstream);
   360 	printf("wrote system-updated.repo\n");
   361 
   362 	return 0;
   363 }
   364 
   365 static int
   366 command_remove(int argc, const char *argv[])
   367 {
   368 	struct razor_set *set;
   369 	struct razor_transaction *trans;
   370 	int errors;
   371 
   372 	set = razor_set_open(repo_filename);
   373 	if (set == NULL)
   374 		return 1;
   375 	trans = razor_transaction_create(set, NULL, 0, NULL, argc, argv);
   376 	errors = razor_transaction_describe(trans);
   377 	if (errors)
   378 		return 1;
   379 
   380 	set = razor_transaction_run(trans);
   381 	razor_transaction_destroy(trans);
   382 	razor_set_write(set, updated_repo_filename);
   383 	razor_set_destroy(set);
   384 	printf("wrote system-updated.repo\n");
   385 
   386 	return 0;
   387 }
   388 
   389 static void
   390 print_diff(const char *name,
   391 	   const char *old_version, const char *new_version, const char *arch,
   392 	   void *data)
   393 {
   394 	if (old_version)
   395 		printf("removing %s %s\n", name, old_version);
   396 	else
   397 		printf("install %s %s\n", name, new_version);
   398 }
   399 
   400 static int
   401 command_diff(int argc, const char *argv[])
   402 {
   403 	struct razor_set *set, *updated;
   404 
   405 	set = razor_set_open(repo_filename);
   406 	updated = razor_set_open(updated_repo_filename);
   407 	if (set == NULL || updated == NULL)
   408 		return 1;
   409 
   410 	razor_set_diff(set, updated, print_diff, NULL);	
   411 
   412 	razor_set_destroy(set);
   413 	razor_set_destroy(updated);
   414 
   415 	return 0;
   416 }
   417 
   418 static int
   419 command_import_rpms(int argc, const char *argv[])
   420 {
   421 	DIR *dir;
   422 	struct dirent *de;
   423 	struct razor_importer *importer;
   424 	struct razor_set *set;
   425 	struct razor_rpm *rpm;
   426 	int len;
   427 	char filename[256];
   428 	const char *dirname = argv[0];
   429 
   430 	if (dirname == NULL) {
   431 		fprintf(stderr, "usage: razor import-rpms DIR\n");
   432 		return -1;
   433 	}
   434 
   435 	dir = opendir(dirname);
   436 	if (dir == NULL) {
   437 		fprintf(stderr, "couldn't read dir %s\n", dirname);
   438 		return -1;
   439 	}
   440 
   441 	importer = razor_importer_new();
   442 
   443 	while (de = readdir(dir), de != NULL) {
   444 		len = strlen(de->d_name);
   445 		if (len < 5 || strcmp(de->d_name + len - 4, ".rpm") != 0)
   446 		    continue;
   447 		snprintf(filename, sizeof filename,
   448 			 "%s/%s", dirname, de->d_name);
   449 		rpm = razor_rpm_open(filename);
   450 		if (rpm == NULL) {
   451 			fprintf(stderr,
   452 				"failed to open rpm \"%s\"\n", filename);
   453 			continue;
   454 		}
   455 		if (razor_importer_add_rpm(importer, rpm)) {
   456 			fprintf(stderr, "couldn't import %s\n", filename);
   457 			break;
   458 		}
   459 		razor_rpm_close(rpm);
   460 	}
   461 
   462 	if (de != NULL) {
   463 		razor_importer_destroy(importer);
   464 		return -1;
   465 	}
   466 
   467 	set = razor_importer_finish(importer);
   468 
   469 	razor_set_write(set, repo_filename);
   470 	razor_set_destroy(set);
   471 	printf("wrote %s\n", repo_filename);
   472 
   473 	return 0;
   474 }
   475 
   476 static struct razor_set *
   477 create_set_from_rpms(int argc, const char *argv[])
   478 {
   479 	struct razor_importer *importer;
   480 	struct razor_rpm *rpm;
   481 	int i;
   482 
   483 	importer = razor_importer_new();
   484 	for (i = 0; i < argc; i++) {
   485 		rpm = razor_rpm_open(argv[i]);
   486 		if (rpm == NULL) {
   487 			fprintf(stderr,
   488 				"failed to open rpm \"%s\"\n", argv[i]);
   489 			continue;
   490 		}
   491 		if (razor_importer_add_rpm(importer, rpm)) {
   492 			fprintf(stderr, "couldn't import %s\n", argv[i]);
   493 			break;
   494 		}
   495 		razor_rpm_close(rpm);
   496 	}
   497 
   498 	return razor_importer_finish(importer);
   499 }
   500 
   501 static char **
   502 list_packages(int count, struct razor_set *set)
   503 {
   504 	struct razor_package_iterator *pi;
   505 	struct razor_package *package;
   506 	const char *name, *version, *arch;
   507 	char **packages;
   508 	int i;
   509 
   510 	packages = malloc(count * sizeof *packages);
   511 	pi = razor_package_iterator_create(set);
   512 	i = 0;
   513 	while (razor_package_iterator_next(pi, &package,
   514 					   &name, &version, &arch))
   515 		packages[i++] = strdup(name);
   516 	razor_package_iterator_destroy(pi);
   517 
   518 	return packages;
   519 }
   520 
   521 static int
   522 command_install(int argc, const char *argv[])
   523 {
   524 	struct razor_set *system, *upstream, *next;
   525 	struct razor_transaction *trans;
   526 	struct razor_rpm *rpm;
   527 	const char *filename;
   528 	char path[PATH_MAX], new_path[PATH_MAX], **packages;
   529 	int errors, i;
   530 
   531 	upstream = create_set_from_rpms(argc, argv);
   532 	snprintf(path, sizeof path,
   533 		 "%s%s/%s", root, razor_root_path, system_repo_filename);
   534 	system = razor_set_open(path);
   535 	if (system == NULL) {
   536 		fprintf(stderr, "couldn't open system package database\n");
   537 		return -1;
   538 	}
   539 
   540 	packages = list_packages(argc, upstream);
   541 	trans = razor_transaction_create(system, upstream,
   542 					 argc, (const char **)packages,
   543 					 0, NULL);
   544 	free(packages);
   545 	errors = razor_transaction_describe(trans);
   546 	if (errors)
   547 		return 1;
   548 
   549 	/* FIXME: Use _finish() convention here?  That is, a function
   550 	 * that starts the computation and returns the result while
   551 	 * destroying the transaction.  Nice for transient objects
   552 	 * such as the merger and the importer.  Should we do that for
   553 	 * transactions too, that is, razor_transaction_finish()? */
   554 	next = razor_transaction_run(trans);
   555 	razor_transaction_destroy(trans);
   556 
   557 	/* FIXME: Need razor_set_write_to_fd() so we can open it excl
   558 	 * up front here or fail if it already exists. */
   559 	snprintf(new_path, sizeof new_path,
   560 		 "%s%s/%s", root, razor_root_path, next_repo_filename);
   561 	razor_set_write(next, path);
   562 
   563 	razor_set_destroy(next);
   564 	razor_set_destroy(system);
   565 	razor_set_destroy(upstream);
   566 
   567 	printf("wrote %s\n", new_path);
   568 
   569 	for (i = 0; i < argc; i++) {
   570 		filename = argv[i];
   571 		rpm = razor_rpm_open(argv[i]);
   572 		if (rpm == NULL) {
   573 			fprintf(stderr, "failed to open rpm %s\n", filename);
   574 			return -1;
   575 		}
   576 		if (razor_rpm_install(rpm, root) < 0) {
   577 			fprintf(stderr,
   578 				"failed to install rpm %s\n", filename);
   579 			return -1;
   580 		}
   581 		razor_rpm_close(rpm);
   582 	}	
   583 
   584 	/* Make it so. */
   585 	rename(new_path, path);
   586 	printf("renamed %s to %s\n", new_path, path);
   587 
   588 	return 0;
   589 }
   590 
   591 static int
   592 command_init(int argc, const char *argv[])
   593 {
   594 	struct stat buf;
   595 	struct razor_set *set;
   596 	char path[PATH_MAX];
   597 
   598 	if (stat(root, &buf) < 0) {
   599 		if (mkdir(root, 0777) < 0) {
   600 			fprintf(stderr,
   601 				"could not create install root \"%s\"\n",
   602 				root);
   603 			return -1;
   604 		}
   605 		fprintf(stderr, "created install root \"%s\"\n", root);
   606 	} else if (!S_ISDIR(buf.st_mode)) {
   607 		fprintf(stderr,
   608 			"install root \"%s\" exists, but is not a directory\n",
   609 			root);
   610 		return -1;
   611 	}
   612 
   613 	if (razor_create_dir(root, razor_root_path) < 0) {
   614 		fprintf(stderr, "could not create %s%s\n",
   615 			root, razor_root_path);
   616 		return -1;
   617 	}
   618 
   619 	set = razor_set_create();
   620 	snprintf(path, sizeof path, "%s%s/%s",
   621 		 root, razor_root_path, system_repo_filename);
   622 	if (razor_set_write(set, path) < 0) {
   623 		fprintf(stderr, "could not write initial package set\n");
   624 		return -1;
   625 	}
   626 	razor_set_destroy(set);
   627 
   628 	return 0;
   629 }
   630 
   631 static int
   632 command_download(int argc, const char *argv[])
   633 {
   634 	struct razor_set *set;
   635 	struct razor_package_iterator *pi;
   636 	struct razor_package *package;
   637 	const char *pattern = argv[0], *name, *version, *arch;
   638 	char url[256], file[256];
   639 	CURL *curl;
   640 
   641 	curl = curl_easy_init();
   642 	if (curl == NULL)
   643 		return 1;
   644 
   645 	set = razor_set_open(rawhide_repo_filename);
   646 	pi = razor_package_iterator_create(set);
   647 	while (razor_package_iterator_next(pi, &package,
   648 					   &name, &version, &arch)) {
   649 		if (pattern && fnmatch(pattern, name, 0) != 0)
   650 			continue;
   651 
   652 		snprintf(url, sizeof url,
   653 			 REPO_URL "/Packages/%s-%s.i386.rpm", name, version);
   654 		snprintf(file, sizeof file,
   655 			 "rpms/%s-%s.i386.rpm", name, version);
   656 		if (download_if_missing(curl, url, file) < 0)
   657 			fprintf(stderr, "failed to download %s\n", name);
   658 	}
   659 	razor_package_iterator_destroy(pi);
   660 	razor_set_destroy(set);
   661 	curl_easy_cleanup(curl);
   662 
   663 	return 0;
   664 }
   665 
   666 static struct {
   667 	const char *name;
   668 	const char *description;
   669 	int (*func)(int argc, const char *argv[]);
   670 } razor_commands[] = {
   671 	{ "list", "list all packages", command_list },
   672 	{ "list-requires", "list all requires for the given package", command_list_requires },
   673 	{ "list-provides", "list all provides for the given package", command_list_provides },
   674 	{ "list-obsoletes", "list all obsoletes for the given package", command_list_obsoletes },
   675 	{ "list-conflicts", "list all conflicts for the given package", command_list_conflicts },
   676 	{ "list-files", "list files for package set", command_list_files },
   677 	{ "list-file-packages", "list packages owning file", command_list_file_packages },
   678 	{ "list-package-files", "list files in package", command_list_package_files },
   679 	{ "what-requires", "list the packages that have the given requires", command_what_requires },
   680 	{ "what-provides", "list the packages that have the given provides", command_what_provides },
   681 	{ "import-yum", "import yum metadata files", command_import_yum },
   682 	{ "import-rpmdb", "import the system rpm database", command_import_rpmdb },
   683 	{ "import-rpms", "import rpms from the given directory", command_import_rpms },
   684 	{ "validate", "validate a package set", command_validate },
   685 	{ "update", "update all or specified packages", command_update },
   686 	{ "remove", "remove specified packages", command_remove },
   687 	{ "diff", "show diff between two package sets", command_diff },
   688 	{ "install", "install rpm", command_install },
   689 	{ "init", "init razor root", command_init },
   690 	{ "download", "download packages", command_download }
   691 };
   692 
   693 static int
   694 usage(void)
   695 {
   696 	int i;
   697 
   698 	printf("usage:\n");
   699 	for (i = 0; i < ARRAY_SIZE(razor_commands); i++)
   700 		printf("  %-20s%s\n",
   701 		       razor_commands[i].name, razor_commands[i].description);
   702 
   703 	return 1;
   704 }
   705 
   706 int
   707 main(int argc, const char *argv[])
   708 {
   709 	char *repo;
   710 	int i;
   711 
   712 	repo = getenv("RAZOR_REPO");
   713 	if (repo != NULL)
   714 		repo_filename = repo;
   715 
   716 	if (argc < 2)
   717 		return usage();
   718 
   719 	for (i = 0; i < ARRAY_SIZE(razor_commands); i++)
   720 		if (strcmp(razor_commands[i].name, argv[1]) == 0)
   721 			return razor_commands[i].func(argc - 2, argv + 2);
   722 
   723 	return usage();
   724 }