/*prototipo: int (char *srvName,char *dirName,char *idBucket,KEY_T key) *objetivo: Retorna o valor associado a chave key*/ int ss_get_key(char *srvName,char *dirName,char *idBucket,KEY_T key,PAIR_T *pair){ BUCKET_T buff_bucket; int hit; hit = -1; /*solicitar o bucket ao cache ou ao SA buff_bucket e atualizado com o buffer do bucket, hit indica se esta utilizando cache*/ state = ss_get_bucket(srvName,dirName,idBucket,&buff_bucket,&hit); if(state == 0){ //get_bucket retorna 1 para falha e 0 para sucesso //3) extrair o par chave_valor retOper = extract_pair(&buff_bucket,key,pair); //se nao tiver utilizando cache a area alocada deve ser liberada if(hit == 0) free(buff_bucket); } }
static int parse_opt(int argc, char **argv, myargs *args) { int rc = 0; while (1) { int key; key = getopt_long(argc, argv, "clbxs:i:o:?V", long_options, NULL); if (key == -1) break; switch (key) { case 'c': err_msg("%s\n", copyright); ABORT_ARGP; break; case 'l': args->action = ACT_LIST; break; case 'b': args->both = 1; break; case 'x': args->x86 = 1; break; case 's': args->side = get_update_side(optarg); if (args->side < 0) { err_msg("Unsupported seqnum: %d.\n" "Supported seqnums are " "'0' and '1'\n", args->side, optarg); ERR_ARGP; } break; case 'i': args->file_in = optarg; break; case 'o': args->file_out = optarg; break; case '?': /* help */ err_msg("Usage: pddcustomize [OPTION...] " "[key=value] [...]"); err_msg("%s", doc); err_msg("%s", optionsstr); err_msg("\nReport bugs to %s", PACKAGE_BUGREPORT); exit(0); break; case 'V': err_msg("%s", PROGRAM_VERSION); exit(0); break; default: err_msg("%s", usage); exit(-1); } } if (optind < argc) { rc = extract_pair(args->env_in, argv[optind++]); if (rc != 0) ERR_ARGP; } return 0; }