void sp_poll_loop() { ptbl.shutdown = 0; ptbl.looping = 1; while (!ptbl.shutdown) sp_poll_once(); ptbl.looping = 0; }
int spc_rpc(Spcfsys *fs, Spfcall *tc, Spfcall **rc) { char *ename; Spcrpc r; if (fs->fd < 0) return -1; if (rc) *rc = NULL; r.fs = fs; r.tc = tc; r.rc = NULL; r.ename = NULL; r.ecode = 0; spc_rpcnb(fs, tc, spc_rpc_cb, &r); while (!r.ename && !r.rc) sp_poll_once(); if (r.ename) { sp_werror(r.ename, r.ecode); goto error; } if (r.rc && r.rc->type == Rerror) { ename = sp_strdup(&r.rc->ename); if (ename) sp_werror(ename, r.rc->ecode); free(ename); goto error; } free(r.ename); if (rc) *rc = r.rc; else free(r.rc); return 0; error: if (r.ename != Enomem) free(r.ename); free(r.rc); return -1; }
int main(int argc, char **argv) { int ecode; int c; char *addr; char *ename, *path; Spuser *user; Spcfsys *fs; user = sp_unix_users->uid2user(sp_unix_users, geteuid()); while ((c = getopt(argc, argv, "dp:")) != -1) { switch (c) { case 'd': spc_chatty = 1; break; case 'u': user = sp_unix_users->uname2user(sp_unix_users, optarg); break; default: usage(); } } if (!user) { fprintf(stderr, "cannot retrieve user %d\n", geteuid()); exit(1); } if (argc - optind < 2) usage(); addr = argv[optind]; path = argv[optind+1]; fs = spc_netmount(addr, user, 564, NULL, NULL); fid = spc_open(fs, path, Oread); if (!fid) { fprintf(stderr, "cannot open\n"); exit(1); } if (readnb(buf1) < 0) goto error; if (readnb(buf2) < 0) goto error; if (readnb(buf3) < 0) goto error; if (readnb(buf4) < 0) goto error; while (done < 4) sp_poll_once(); spc_close(fid); spc_umount(fs); return 0; error: sp_rerror(&ename, &ecode); fprintf(stderr, "Error: %s\n", ename); return -1; }