// if not executing one of the erlang commands // then process erln8 options etc int erln8(int argc, gchar* argv[]) { // TODO: think about getting erlangs, configs, repos in one go // instead of for each option. meh, maybe I don't care. GError* error = NULL; GOptionContext* context; context = g_option_context_new(""); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_error("erln8 option parsing failed: %s\n", error->message); } g_debug("argv[0] = [%s]\n",argv[0]); g_debug("opt_id = %s\n", opt_id); if(opt_quickstart) { initialize(); opt_clone = "default"; doclone(); opt_repo = "default"; opt_config = "default"; // detect the latest git TAG from the OTP repo // I hope this works... ;-) opt_tag = "`git describe --abbrev=0 --tags`"; opt_id = "quickstart_build"; display_latest_quickstart(); dobuild(); return 0; } if(opt_init_erln8) { initialize(); return 0; } else { if(!check_home()) { g_error("Please initialize erln8 with --init\n"); } } GHashTable* runtime_options = get_erln8(); gchar* use_color = (gchar*)g_hash_table_lookup(runtime_options, "color"); if(g_strcmp0(use_color, "true") == 0) { opt_color = TRUE; } else { opt_color = FALSE; } if(opt_use) { init_here(opt_use); return 0; } if(opt_list) { list_erlangs(); return 0; } if(opt_clone) { doclone(); return 0; } if(opt_repos) { dorepos(); return 0 ; } if(opt_configs) { doconfigs(); return 0; } if(opt_fetch) { if(opt_repo == NULL) { git_fetch("default"); } else { git_fetch(opt_repo); } return 0; } if(opt_build) { dobuild(); return 0; } if(opt_link) { dolink(); return 0; } if(opt_unlink) { dounlink(); return 0; } if(opt_buildable) { git_allbuildable(); return 0; } if(opt_show) { gchar* erl = which_erlang(); if(erl != NULL) { printf("%s\n", erl); g_free(erl); return 0; } } if(opt_prompt) { gchar* erl = which_erlang(); if(erl != NULL) { printf("%s", erl); g_free(erl); } else { printf("erln8 error"); } return 0; } printf("\nerln8: the sneaky Erlang version manager\n"); printf("(c) 2013 Dave Parfitt\n"); printf("Licensed under the Apache License, Version 2.0\n\n"); printf("%s\n", g_option_context_get_help(context, TRUE, NULL)); return 0; }
void rwalk(void) { Xfile *f, *nf; Isofile *oldptr; int oldlen; Qid oldqid; rep->nwqid = 0; nf = nil; f = xfile(req->fid, Asis); if(req->fid != req->newfid) f = nf = doclone(f, req->newfid); /* save old state in case of error */ oldqid = f->qid; oldlen = f->len; oldptr = f->ptr; if(oldlen){ oldptr = ealloc(oldlen); memmove(oldptr, f->ptr, oldlen); } if(waserror()){ if(nf != nil) xfile(req->newfid, Clunk); if(rep->nwqid == req->nwname){ if(oldlen) free(oldptr); }else{ /* restore previous state */ f->qid = oldqid; if(f->len) free(f->ptr); f->ptr = oldptr; f->len = oldlen; } if(rep->nwqid==req->nwname || rep->nwqid > 0){ err_msg[0] = '\0'; return; } nexterror(); } for(rep->nwqid=0; rep->nwqid < req->nwname && rep->nwqid < MAXWELEM; rep->nwqid++){ chat("\twalking %s\n", req->wname[rep->nwqid]); if(!(f->qid.type & QTDIR)){ chat("\tnot dir: type=%#x\n", f->qid.type); error("walk in non-directory"); } if(strcmp(req->wname[rep->nwqid], "..")==0){ if(f->qid.path != f->xf->rootqid.path) (*f->xf->s->walkup)(f); }else (*f->xf->s->walk)(f, req->wname[rep->nwqid]); rep->wqid[rep->nwqid] = f->qid; } poperror(); if(oldlen) free(oldptr); }