PyObject * Repository_listall_references(Repository *self, PyObject *args) { unsigned list_flags=GIT_REF_LISTALL; git_strarray c_result; PyObject *py_result, *py_string; unsigned index; int err; /* 1- Get list_flags */ if (!PyArg_ParseTuple(args, "|I", &list_flags)) return NULL; /* 2- Get the C result */ err = git_reference_list(&c_result, self->repo, list_flags); if (err < 0) return Error_set(err); /* 3- Create a new PyTuple */ py_result = PyTuple_New(c_result.count); if (py_result == NULL) goto out; /* 4- Fill it */ for (index=0; index < c_result.count; index++) { py_string = to_path((c_result.strings)[index]); if (py_string == NULL) { Py_CLEAR(py_result); goto out; } PyTuple_SET_ITEM(py_result, index, py_string); } out: git_strarray_free(&c_result); return py_result; }
PyObject * Reference_name__get__(Reference *self) { CHECK_REFERENCE(self); return to_path(git_reference_name(self->reference)); }
PyObject * Repository_path__get__(Repository *self, void *closure) { return to_path(git_repository_path(self->repo)); }
PyObject * TreeEntry_name__get__(TreeEntry *self) { return to_path(git_tree_entry_name(self->entry)); }
// ----------------------------------------------------------------------------- // Given a "base" directory, yield the relative path of this file in the package // layout. // // Parameters: // base - The base directory to look for the relative path of this entry // str - If the method returns true, contains the file path for this deps // entry relative to the "base" directory // // Returns: // If the file exists in the path relative to the "base" directory. // bool deps_entry_t::to_rel_path(const pal::string_t& base, pal::string_t* str) const { return to_path(base, false, str); }
/* Create a temp (binary) file from a CSV so we don't have to waste time * parsing it in between sending samples. * * Preconditions: Assumes CLI state's TX cfg data has a valid file descriptor * * Postconditions: TX cfg's file descriptor, filename, and format will be * changed. * * return 0 on success, CMD_RET_* on failure */ static int tx_csv_to_c16(struct cli_state *s) { const char delim[] = " \r\n\t,.:"; const size_t buff_size = 81; char buff[buff_size]; enum rxtx_fmt fmt = RXTX_FMT_BINHOST_C16; struct tx_cfg *tx = &s->rxtx_data->tx; char *token, *saveptr; int tmp_int; int16_t tmp_iq[2]; bool ok; int ret; FILE *bin; int bin_fd; char *bin_path; char bin_name[] = TMP_FILE_NAME; ret = 0; bin_fd = mkstemp(bin_name); if (!bin_fd) { return CMD_RET_FILEOP; } bin = fdopen(bin_fd, "wb"); if (!bin) { return CMD_RET_FILEOP; } bin_path = to_path(bin); if (!bin_path) { return CMD_RET_FILEOP; } while (fgets(buff, buff_size, tx->common.file)) { /* I */ token = strtok_r(buff, delim, &saveptr); if (token) { tmp_int = str2int(token, INT16_MIN, INT16_MAX, &ok); if (ok) { tmp_iq[0] = tmp_int; } else { cli_err(s, "tx", "Invalid I value encountered in CSV file"); ret = CMD_RET_INVPARAM; break; } /* Q */ token = strtok_r(NULL, delim, &saveptr); if (token) { tmp_int = str2int(token, INT16_MIN, INT16_MAX, &ok); if (ok) { tmp_iq[1] = tmp_int; } else { cli_err(s, "tx", "Invalid Q value encountered in CSV file"); ret = CMD_RET_INVPARAM; break; } } else { cli_err(s, "tx", "Missing Q value in CSV file"); ret = CMD_RET_INVPARAM; break; } /* Check for extraneous tokens */ token = strtok_r(NULL, delim, &saveptr); if (!token) { if (fwrite(tmp_iq, sizeof(tmp_iq[0]), 2, bin) != 2) { ret = CMD_RET_FILEOP; break; } } else { cli_err(s, "tx", "Encountered extra token after Q value in CSV file"); ret = CMD_RET_INVPARAM; break; } } } if (ret >= 0 && feof(tx->common.file)) { fclose(tx->common.file); tx->common.file = bin; tx->common.file_fmt = fmt; free(tx->common.file_path); tx->common.file_path = bin_path; } else { ret = -1; fclose(bin); free(bin_path); } return ret; }
PyObject * Reference_shorthand__get__(Reference *self) { CHECK_REFERENCE(self); return to_path(git_reference_shorthand(self->reference)); }
PyObject * IndexEntry_path__get__(IndexEntry *self) { return to_path(self->entry.path); }
PyObject * TreeEntry_type__get__(TreeEntry *self) { return to_path(git_object_type2string(git_tree_entry_type(self->entry))); }
PyObject * IndexEntry_get_path(IndexEntry *self) { return to_path(self->entry->path); }
// ----------------------------------------------------------------------------- // Given a "base" directory, yield the local path of this file // // Parameters: // base - The base directory to look for the relative path of this entry // str - If the method returns true, contains the file path for this deps // entry relative to the "base" directory // // Returns: // If the file exists in the path relative to the "base" directory. // bool deps_entry_t::to_dir_path(const pal::string_t& base, pal::string_t* str) const { return to_path(base, true, str); }