* env the Java environment
* obj the current Java object
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Token_initializeAdminClient(JNIEnv *env, jclass cls)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Token_initializeAdminClient(JNIEnv * env, jclass cls)
{
- afs_status_t ast;
- if ( !afsclient_Init( &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
+ afs_status_t ast;
+ if (!afsclient_Init(&ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
}
* jpassword the password of the user
* returns a token representing the authentication
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Token_getToken
- (JNIEnv *env, jobject obj, jstring jcellName, jstring juserName,
- jstring jpassword)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Token_getToken(JNIEnv * env, jobject obj,
+ jstring jcellName, jstring juserName,
+ jstring jpassword)
{
- afs_status_t ast;
- char *cellName;
- char *userName;
- char *password;
- void *tokenHandle;
- int rc;
-
- // convert java strings
- if ( jcellName != NULL ) {
- cellName = getNativeString(env, jcellName);
- if ( !cellName ) {
- throwAFSException( env, JAFSADMNOMEM );
- return 0;
+ afs_status_t ast;
+ char *cellName;
+ char *userName;
+ char *password;
+ void *tokenHandle;
+ int rc;
+
+ // convert java strings
+ if (jcellName != NULL) {
+ cellName = getNativeString(env, jcellName);
+ if (!cellName) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return 0;
+ }
+ } else {
+ cellName = NULL;
}
- } else {
- cellName = NULL;
- }
-
- if ( juserName != NULL ) {
- userName = getNativeString(env, juserName);
- if ( !userName ) {
- if ( cellName != NULL ) free( cellName );
- throwAFSException( env, JAFSADMNOMEM );
- return 0;
+
+ if (juserName != NULL) {
+ userName = getNativeString(env, juserName);
+ if (!userName) {
+ if (cellName != NULL)
+ free(cellName);
+ throwAFSException(env, JAFSADMNOMEM);
+ return 0;
+ }
+ } else {
+ if (cellName != NULL)
+ free(cellName);
+ throwAFSException(env, JAFSNULLUSER);
+ return 0;
}
- } else {
- if ( cellName != NULL ) free( cellName );
- throwAFSException( env, JAFSNULLUSER );
- return 0;
- }
-
- if ( jpassword != NULL ) {
- password = getNativeString(env, jpassword);
- if ( !password ) {
- if ( cellName != NULL ) free( cellName );
- free( userName );
- throwAFSException( env, JAFSADMNOMEM );
- return 0;
+
+ if (jpassword != NULL) {
+ password = getNativeString(env, jpassword);
+ if (!password) {
+ if (cellName != NULL)
+ free(cellName);
+ free(userName);
+ throwAFSException(env, JAFSADMNOMEM);
+ return 0;
+ }
+ } else {
+ if (cellName != NULL)
+ free(cellName);
+ free(userName);
+ throwAFSException(env, JAFSNULLPASS);
+ return 0;
+ }
+
+ if (!
+ (afsclient_TokenGetNew
+ (cellName, userName, password, &tokenHandle, &ast))) {
+ throwAFSException(env, ast);
}
- } else {
- if ( cellName != NULL ) free( cellName );
- free( userName );
- throwAFSException( env, JAFSNULLPASS );
- return 0;
- }
-
- if ( !(afsclient_TokenGetNew( cellName, userName, password, &tokenHandle,
- &ast) ) ) {
- throwAFSException( env, ast );
- }
-
- if ( cellName != NULL ) free( cellName );
- free( userName );
- free( password );
-
- return (jint) tokenHandle;
+
+ if (cellName != NULL)
+ free(cellName);
+ free(userName);
+ free(password);
+
+ return (jint) tokenHandle;
}
/**
* obj the current Java object
* tokenHandle the token to close
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Token_close
- (JNIEnv *env, jobject obj, jint tokenHandle)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Token_close(JNIEnv * env, jobject obj, jint tokenHandle)
{
- afs_status_t ast;
+ afs_status_t ast;
- if ( !afsclient_TokenClose( (void *) tokenHandle, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
+ if (!afsclient_TokenClose((void *)tokenHandle, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
}
/**
* tokenHandle a token handle previously returned by a call to getToken
* returns a handle to the open cell
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getCellHandle
- (JNIEnv *env, jobject obj, jstring jcellName, jint tokenHandle)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getCellHandle(JNIEnv * env, jobject obj,
+ jstring jcellName, jint tokenHandle)
{
- afs_status_t ast;
- char *cellName;
- void *cellHandle;
-
- if ( jcellName != NULL ) {
- cellName = getNativeString(env, jcellName);
- if ( !cellName ) {
- throwAFSException( env, JAFSADMNOMEM );
+ afs_status_t ast;
+ char *cellName;
+ void *cellHandle;
+
+ if (jcellName != NULL) {
+ cellName = getNativeString(env, jcellName);
+ if (!cellName) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return -1;
+ }
+ } else {
+ throwAFSException(env, JAFSNULLCELL);
return -1;
}
- } else {
- throwAFSException( env, JAFSNULLCELL );
- return -1;
- }
- if ( !afsclient_CellOpen( cellName, (void *) tokenHandle,
- &cellHandle, &ast ) ) {
- throwAFSException( env, ast );
- }
+ if (!afsclient_CellOpen(cellName, (void *)tokenHandle, &cellHandle, &ast)) {
+ throwAFSException(env, ast);
+ }
- free( cellName );
+ free(cellName);
- return (jint) cellHandle;
+ return (jint) cellHandle;
}
/**
* obj the current Java object
* cellHandle the cell handle to close
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Cell_closeCell
- (JNIEnv *env, jobject obj, jint cellHandle)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Cell_closeCell(JNIEnv * env, jobject obj,
+ jint cellHandle)
{
- afs_status_t ast;
+ afs_status_t ast;
- if ( !afsclient_CellClose( (void *) cellHandle, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
+ if (!afsclient_CellClose((void *)cellHandle, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
}
/**
* a vos handle
* returns a vos handle to the server
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Server_getVosServerHandle
- (JNIEnv *env, jobject obj, jint cellHandle, jstring jserverName)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Server_getVosServerHandle(JNIEnv * env, jobject obj,
+ jint cellHandle,
+ jstring jserverName)
{
- afs_status_t ast;
- void *serverHandle;
- char *serverName;
-
- if ( jserverName != NULL ) {
- serverName = getNativeString(env, jserverName);
- if ( !serverName ) {
- throwAFSException( env, JAFSADMNOMEM );
- return -1;
+ afs_status_t ast;
+ void *serverHandle;
+ char *serverName;
+
+ if (jserverName != NULL) {
+ serverName = getNativeString(env, jserverName);
+ if (!serverName) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return -1;
+ }
+ } else {
+ throwAFSException(env, JAFSNULLSERVER);
+ return -1;
}
- } else {
- throwAFSException( env, JAFSNULLSERVER );
- return -1;
- }
-
- if ( !vos_ServerOpen( (void *) cellHandle, serverName,
- (void **) &serverHandle, &ast ) ) {
- throwAFSException( env, ast );
- }
- // release converted string
- free( serverName );
+ if (!vos_ServerOpen
+ ((void *)cellHandle, serverName, (void **)&serverHandle, &ast)) {
+ throwAFSException(env, ast);
+ }
+ // release converted string
+ free(serverName);
- return (jint) serverHandle;
+ return (jint) serverHandle;
}
/**
* obj the current Java object
* vosServerHandle the vos server handle to close
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Server_closeVosServerHandle
- (JNIEnv *env, jobject obj, jint vosServerHandle)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Server_closeVosServerHandle(JNIEnv * env, jobject obj,
+ jint vosServerHandle)
{
- afs_status_t ast;
+ afs_status_t ast;
- if ( !vos_ServerClose( (void *) vosServerHandle, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
+ if (!vos_ServerClose((void *)vosServerHandle, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
}
/**
* a bos handle
* returns a bos handle to the server
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Server_getBosServerHandle
- (JNIEnv *env, jobject obj, jint cellHandle, jstring jserverName)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Server_getBosServerHandle(JNIEnv * env, jobject obj,
+ jint cellHandle,
+ jstring jserverName)
{
- afs_status_t ast;
- void *serverHandle;
- char *serverName;
-
- if ( jserverName != NULL ) {
- serverName = getNativeString(env, jserverName);
- if ( !serverName ) {
- throwAFSException( env, JAFSADMNOMEM );
- return;
+ afs_status_t ast;
+ void *serverHandle;
+ char *serverName;
+
+ if (jserverName != NULL) {
+ serverName = getNativeString(env, jserverName);
+ if (!serverName) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return;
+ }
+ } else {
+ throwAFSException(env, JAFSNULLSERVER);
+ return;
}
- } else {
- throwAFSException( env, JAFSNULLSERVER );
- return;
- }
-
- if ( !bos_ServerOpen( (void *) cellHandle, serverName,
- (void **) &serverHandle, &ast ) ) {
- throwAFSException( env, ast );
- }
- // release converted string
- free( serverName );
+ if (!bos_ServerOpen
+ ((void *)cellHandle, serverName, (void **)&serverHandle, &ast)) {
+ throwAFSException(env, ast);
+ }
+ // release converted string
+ free(serverName);
- return (jint) serverHandle;
+ return (jint) serverHandle;
}
/**
* obj the current Java object
* bosServerHandle the bos server handle to close
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Server_closeBosServerHandle
- (JNIEnv *env, jobject obj, jint bosServerHandle)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Server_closeBosServerHandle(JNIEnv * env, jobject obj,
+ jint bosServerHandle)
{
- afs_status_t ast;
+ afs_status_t ast;
- if ( !bos_ServerClose( (void *) bosServerHandle, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
+ if (!bos_ServerClose((void *)bosServerHandle, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
}
/**
* to getToken
* returns a long representing the UTC time for the token expiration
*/
-JNIEXPORT jlong JNICALL
-Java_org_openafs_jafs_Token_getExpiration
- (JNIEnv *env, jobject obj, jint tokenHandle)
+JNIEXPORT jlong JNICALL
+Java_org_openafs_jafs_Token_getExpiration(JNIEnv * env, jobject obj,
+ jint tokenHandle)
{
- afs_status_t ast;
- unsigned long expTime;
- char *prince = malloc( sizeof(char)*KAS_MAX_NAME_LEN );
- char *inst = malloc( sizeof(char)*KAS_MAX_NAME_LEN );
- char *cell = malloc( sizeof(char)*AFS_MAX_SERVER_NAME_LEN );
- int hkt;
-
- if ( !prince || !inst || !cell ) {
- if ( prince ) {
- free( prince );
- }
- if ( inst ) {
- free( inst );
+ afs_status_t ast;
+ unsigned long expTime;
+ char *prince = malloc(sizeof(char) * KAS_MAX_NAME_LEN);
+ char *inst = malloc(sizeof(char) * KAS_MAX_NAME_LEN);
+ char *cell = malloc(sizeof(char) * AFS_MAX_SERVER_NAME_LEN);
+ int hkt;
+
+ if (!prince || !inst || !cell) {
+ if (prince) {
+ free(prince);
+ }
+ if (inst) {
+ free(inst);
+ }
+ if (cell) {
+ free(cell);
+ }
+ throwAFSException(env, JAFSADMNOMEM);
+ return;
}
- if ( cell ) {
- free( cell );
- }
- throwAFSException( env, JAFSADMNOMEM );
- return;
- }
- if ( !afsclient_TokenQuery( (void *) tokenHandle, &expTime, prince, inst,
- cell, &hkt, &ast ) ) {
- throwAFSException( env, ast );
- }
+ if (!afsclient_TokenQuery
+ ((void *)tokenHandle, &expTime, prince, inst, cell, &hkt, &ast)) {
+ throwAFSException(env, ast);
+ }
- free( prince );
- free( inst );
- free( cell );
+ free(prince);
+ free(inst);
+ free(cell);
- return (jlong) expTime;
+ return (jlong) expTime;
}
// reclaim global memory used by this portion
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Token_reclaimAuthMemory (JNIEnv *env, jclass cls)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Token_reclaimAuthMemory(JNIEnv * env, jclass cls)
{
}
/*-----------------------------------------------------------------------
* Definition in User.c
*/
-extern void getUserInfoChar (JNIEnv *env, int cellHandle, const char *name,
- jobject user);
+extern void getUserInfoChar(JNIEnv * env, int cellHandle, const char *name,
+ jobject user);
/*-----------------------------------------------------------------------
* Definition in Group.c
*/
-extern void getGroupInfoChar (JNIEnv *env, int cellHandle, const char *name,
- jobject group);
+extern void getGroupInfoChar(JNIEnv * env, int cellHandle, const char *name,
+ jobject group);
/*-----------------------------------------------------------------------
* Definition in Server.c
*/
-extern void fillServerInfo (JNIEnv *env, jint cellHandle, jobject server,
- afs_serverEntry_t servEntry);
+extern void fillServerInfo(JNIEnv * env, jint cellHandle, jobject server,
+ afs_serverEntry_t servEntry);
/*-----------------------------------------------------------------------*/
* cellHandle the handle of the cell to which the users belong
* returns total count of KAS users
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getKasUserCount
- (JNIEnv *env, jclass cls, jint cellHandle)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getKasUserCount(JNIEnv * env, jclass cls,
+ jint cellHandle)
{
- afs_status_t ast;
- void *iterationId;
- kas_identity_t who;
- int i = 0;
+ afs_status_t ast;
+ void *iterationId;
+ kas_identity_t who;
+ int i = 0;
- if ( !kas_PrincipalGetBegin( (void *) cellHandle, NULL,
- &iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return -1;
- }
+ if (!kas_PrincipalGetBegin((void *)cellHandle, NULL, &iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return -1;
+ }
- while ( kas_PrincipalGetNext( (void *) iterationId, &who, &ast ) ) i++;
+ while (kas_PrincipalGetNext((void *)iterationId, &who, &ast))
+ i++;
- if ( ast != ADMITERATORDONE ) {
- throwAFSException( env, ast );
- return -1;
- }
+ if (ast != ADMITERATORDONE) {
+ throwAFSException(env, ast);
+ return -1;
+ }
- return i;
+ return i;
}
* cellHandle the handle of the cell to which the users belong
* returns an iteration ID
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getKasUsersBegin
- (JNIEnv *env, jclass cls, jint cellHandle)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getKasUsersBegin(JNIEnv * env, jclass cls,
+ jint cellHandle)
{
- afs_status_t ast;
- void *iterationId;
+ afs_status_t ast;
+ void *iterationId;
- if ( !kas_PrincipalGetBegin( (void *) cellHandle, NULL, &iterationId,
- &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
+ if (!kas_PrincipalGetBegin((void *)cellHandle, NULL, &iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
- return (jint) iterationId;
+ return (jint) iterationId;
}
/**
* startIndex the starting base-zero index
* returns an iteration ID
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getKasUsersBeginAt
- (JNIEnv *env, jclass cls, jint cellHandle, jint startIndex)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getKasUsersBeginAt(JNIEnv * env, jclass cls,
+ jint cellHandle,
+ jint startIndex)
{
- afs_status_t ast;
- void *iterationId;
- kas_identity_t who;
- int i;
-
- if ( !kas_PrincipalGetBegin( (void *) cellHandle, NULL,
- &iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
-
- for ( i = 1; i < startIndex; i++) {
- if ( !kas_PrincipalGetNext( (void *) iterationId, &who, &ast ) ) {
- if ( ast == ADMITERATORDONE ) {
- return 0;
- } else {
- throwAFSException( env, ast );
- return 0;
- }
- }
- }
-
- return (jint) iterationId;
+ afs_status_t ast;
+ void *iterationId;
+ kas_identity_t who;
+ int i;
+
+ if (!kas_PrincipalGetBegin((void *)cellHandle, NULL, &iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
+
+ for (i = 1; i < startIndex; i++) {
+ if (!kas_PrincipalGetNext((void *)iterationId, &who, &ast)) {
+ if (ast == ADMITERATORDONE) {
+ return 0;
+ } else {
+ throwAFSException(env, ast);
+ return 0;
+ }
+ }
+ }
+
+ return (jint) iterationId;
}
/**
* iterationId the iteration ID of this iteration
* returns the name of the next user of the cell
*/
-JNIEXPORT jstring JNICALL
-Java_org_openafs_jafs_Cell_getKasUsersNextString
- (JNIEnv *env, jclass cls, jint iterationId)
+JNIEXPORT jstring JNICALL
+Java_org_openafs_jafs_Cell_getKasUsersNextString(JNIEnv * env, jclass cls,
+ jint iterationId)
{
- afs_status_t ast;
- kas_identity_t who;
- jstring juser;
+ afs_status_t ast;
+ kas_identity_t who;
+ jstring juser;
- if ( !kas_PrincipalGetNext( (void *) iterationId, &who, &ast ) ) {
- if ( ast == ADMITERATORDONE ) {
- return NULL;
- // other
+ if (!kas_PrincipalGetNext((void *)iterationId, &who, &ast)) {
+ if (ast == ADMITERATORDONE) {
+ return NULL;
+ // other
+ } else {
+ throwAFSException(env, ast);
+ return;
+ }
+ }
+
+ if (strcmp(who.instance, "")) {
+ char *fullName = (char *)malloc(sizeof(char) * (strlen(who.principal)
+ + strlen(who.instance)
+ + 2));
+ if (!fullName) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return;
+ }
+ *fullName = '\0';
+ strcat(fullName, who.principal);
+ strcat(fullName, ".");
+ strcat(fullName, who.instance);
+ juser = (*env)->NewStringUTF(env, fullName);
+ free(fullName);
} else {
- throwAFSException( env, ast );
- return;
- }
- }
-
- if ( strcmp( who.instance, "" ) ) {
- char *fullName = (char *) malloc( sizeof(char)*( strlen( who.principal )
- + strlen( who.instance )
- + 2 ) );
- if ( !fullName ) {
- throwAFSException( env, JAFSADMNOMEM );
- return;
- }
- *fullName = '\0';
- strcat( fullName, who.principal );
- strcat( fullName, "." );
- strcat( fullName, who.instance );
- juser = (*env)->NewStringUTF(env, fullName );
- free( fullName );
- } else {
- juser = (*env)->NewStringUTF(env, who.principal);
- }
-
- return juser;
+ juser = (*env)->NewStringUTF(env, who.principal);
+ }
+
+ return juser;
}
* the next kas user
* returns 0 if there are no more users, != 0 otherwise
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getKasUsersNext
- (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId,
- jobject juserObject)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getKasUsersNext(JNIEnv * env, jclass cls,
+ jint cellHandle, jint iterationId,
+ jobject juserObject)
{
- afs_status_t ast;
- kas_identity_t who;
- jstring juser;
- char *fullName = NULL;
+ afs_status_t ast;
+ kas_identity_t who;
+ jstring juser;
+ char *fullName = NULL;
- if ( !kas_PrincipalGetNext( (void *) iterationId, &who, &ast ) ) {
- if ( ast == ADMITERATORDONE ) {
- return 0;
- // other
+ if (!kas_PrincipalGetNext((void *)iterationId, &who, &ast)) {
+ if (ast == ADMITERATORDONE) {
+ return 0;
+ // other
+ } else {
+ throwAFSException(env, ast);
+ return 0;
+ }
+ }
+ // take care of the instance stuff(by concatenating with a period in between)
+ if (strcmp(who.instance, "")) {
+ fullName =
+ (char *)malloc(sizeof(char) *
+ (strlen(who.principal) + strlen(who.instance) +
+ 2));
+ if (!fullName) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return;
+ }
+ *fullName = '\0';
+ strcat(fullName, who.principal);
+ strcat(fullName, ".");
+ strcat(fullName, who.instance);
+ juser = (*env)->NewStringUTF(env, fullName);
} else {
- throwAFSException( env, ast );
- return 0;
- }
- }
-
- // take care of the instance stuff(by concatenating with a period in between)
- if ( strcmp( who.instance, "" ) ) {
- fullName = (char *) malloc( sizeof(char)*( strlen( who.principal ) +
- strlen( who.instance ) + 2 ) );
- if ( !fullName ) {
- throwAFSException( env, JAFSADMNOMEM );
- return;
- }
- *fullName = '\0';
- strcat( fullName, who.principal );
- strcat( fullName, "." );
- strcat( fullName, who.instance );
- juser = (*env)->NewStringUTF(env, fullName );
- } else {
- juser = (*env)->NewStringUTF(env, who.principal);
- }
-
- if ( userCls == 0 ) {
- internal_getUserClass( env, juserObject );
- }
-
- (*env)->SetObjectField(env, juserObject, user_nameField, juser);
-
- if ( fullName != NULL ) {
- getUserInfoChar( env, (int) cellHandle, fullName, juserObject );
- free( fullName );
- } else {
- getUserInfoChar( env, (int) cellHandle, who.principal, juserObject );
- }
- (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE );
-
- return 1;
+ juser = (*env)->NewStringUTF(env, who.principal);
+ }
+
+ if (userCls == 0) {
+ internal_getUserClass(env, juserObject);
+ }
+
+ (*env)->SetObjectField(env, juserObject, user_nameField, juser);
+
+ if (fullName != NULL) {
+ getUserInfoChar(env, (int)cellHandle, fullName, juserObject);
+ free(fullName);
+ } else {
+ getUserInfoChar(env, (int)cellHandle, who.principal, juserObject);
+ }
+ (*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE);
+
+ return 1;
}
* cls the current Java class
* iterationId the iteration ID of this iteration
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Cell_getKasUsersDone
- (JNIEnv *env, jclass cls, jint iterationId)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Cell_getKasUsersDone(JNIEnv * env, jclass cls,
+ jint iterationId)
{
- afs_status_t ast;
+ afs_status_t ast;
- if ( !kas_PrincipalGetDone( (void *) iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
+ if (!kas_PrincipalGetDone((void *)iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
}
* cellHandle the handle of the cell to which the user belongs
* returns the name of the cell
*/
-JNIEXPORT jstring JNICALL
-Java_org_openafs_jafs_Cell_getCellName
- (JNIEnv *env, jclass cls, jint cellHandle)
+JNIEXPORT jstring JNICALL
+Java_org_openafs_jafs_Cell_getCellName(JNIEnv * env, jclass cls,
+ jint cellHandle)
{
- afs_status_t ast;
- char *cellName;
- jstring jcellName;
+ afs_status_t ast;
+ char *cellName;
+ jstring jcellName;
+
+ if (!afsclient_CellNameGet
+ ((void *)cellHandle, (const char **)&cellName, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
- if ( !afsclient_CellNameGet( (void *) cellHandle,
- (const char **) &cellName, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
-
- jcellName = (*env)->NewStringUTF(env, cellName);
+ jcellName = (*env)->NewStringUTF(env, cellName);
- return jcellName;
+ return jcellName;
}
* cellHandle the handle of the cell to which the users belong
* returns total number of PTS users
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getPtsUserCount
- (JNIEnv *env, jclass cls, jint cellHandle)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getPtsUserCount(JNIEnv * env, jclass cls,
+ jint cellHandle)
{
- afs_status_t ast;
- void *iterationId;
- char *userName;
- int i = 0;
+ afs_status_t ast;
+ void *iterationId;
+ char *userName;
+ int i = 0;
- if ( !pts_UserListBegin( (void *) cellHandle, &iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return -1;
- }
+ if (!pts_UserListBegin((void *)cellHandle, &iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return -1;
+ }
- userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
+ userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
- if ( !userName ) {
- throwAFSException( env, JAFSADMNOMEM );
- return -1;
- }
+ if (!userName) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return -1;
+ }
- while ( pts_UserListNext( (void *) iterationId, userName, &ast ) ) i++;
+ while (pts_UserListNext((void *)iterationId, userName, &ast))
+ i++;
- free( userName );
+ free(userName);
- if ( ast != ADMITERATORDONE ) {
- throwAFSException( env, ast );
- return -1;
- }
+ if (ast != ADMITERATORDONE) {
+ throwAFSException(env, ast);
+ return -1;
+ }
- return i;
+ return i;
}
/**
* cellHandle the handle of the cell to which the users belong
* returns total number of users that are in PTS and not KAS
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getPtsOnlyUserCount
- (JNIEnv *env, jclass cls, jint cellHandle)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getPtsOnlyUserCount(JNIEnv * env, jclass cls,
+ jint cellHandle)
{
- afs_status_t ast;
- void *iterationId;
- kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) );
- kas_principalEntry_t kasEntry;
- char *userName;
- int i = 0;
-
- if ( who == NULL ) {
- throwAFSException( env, JAFSADMNOMEM );
- return -1;
- }
-
- if ( !pts_UserListBegin( (void *) cellHandle, &iterationId, &ast ) ) {
- free( who );
- throwAFSException( env, ast );
- return -1;
- }
-
- userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
- if ( !userName ) {
- free( who );
- throwAFSException( env, JAFSADMNOMEM );
- return -1;
- }
-
- while ( pts_UserListNext( (void *) iterationId, userName, &ast ) ) {
- if ( strcmp( userName, "anonymous" ) != 0 ) {
- // make sure the name is within the allowed bounds
- if ( strlen( userName ) > KAS_MAX_NAME_LEN ) {
- free( who );
- free( userName );
- throwAFSException( env, ADMPTSUSERNAMETOOLONG );
- return -1;
- }
-
- // if there is a kas entry, recurse
- internal_makeKasIdentity( userName, who );
- if ( !kas_PrincipalGet( (void *) cellHandle, NULL, who,
- &kasEntry, &ast ) ) i++;
+ afs_status_t ast;
+ void *iterationId;
+ kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t));
+ kas_principalEntry_t kasEntry;
+ char *userName;
+ int i = 0;
+
+ if (who == NULL) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return -1;
+ }
+
+ if (!pts_UserListBegin((void *)cellHandle, &iterationId, &ast)) {
+ free(who);
+ throwAFSException(env, ast);
+ return -1;
+ }
+
+ userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
+ if (!userName) {
+ free(who);
+ throwAFSException(env, JAFSADMNOMEM);
+ return -1;
+ }
+
+ while (pts_UserListNext((void *)iterationId, userName, &ast)) {
+ if (strcmp(userName, "anonymous") != 0) {
+ // make sure the name is within the allowed bounds
+ if (strlen(userName) > KAS_MAX_NAME_LEN) {
+ free(who);
+ free(userName);
+ throwAFSException(env, ADMPTSUSERNAMETOOLONG);
+ return -1;
+ }
+ // if there is a kas entry, recurse
+ internal_makeKasIdentity(userName, who);
+ if (!kas_PrincipalGet
+ ((void *)cellHandle, NULL, who, &kasEntry, &ast))
+ i++;
}
- }
+ }
- free( userName );
- free( who );
+ free(userName);
+ free(who);
- if ( ast != ADMITERATORDONE ) {
- throwAFSException( env, ast );
- return -1;
- }
+ if (ast != ADMITERATORDONE) {
+ throwAFSException(env, ast);
+ return -1;
+ }
- return i;
+ return i;
}
/**
* cellHandle the handle of the cell to which the users belong
* returns an iteration ID
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getPtsUsersBegin
- (JNIEnv *env, jclass cls, jint cellHandle)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getPtsUsersBegin(JNIEnv * env, jclass cls,
+ jint cellHandle)
{
- afs_status_t ast;
- void *iterationId;
+ afs_status_t ast;
+ void *iterationId;
- if ( !pts_UserListBegin( (void *) cellHandle, &iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return -1;
- }
+ if (!pts_UserListBegin((void *)cellHandle, &iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return -1;
+ }
- return (jint) iterationId;
+ return (jint) iterationId;
}
* iterationId the iteration ID of this iteration
* returns the name of the next user of the cell
*/
-JNIEXPORT jstring JNICALL
-Java_org_openafs_jafs_Cell_getPtsUsersNextString
- (JNIEnv *env, jclass cls, jint iterationId)
+JNIEXPORT jstring JNICALL
+Java_org_openafs_jafs_Cell_getPtsUsersNextString(JNIEnv * env, jclass cls,
+ jint iterationId)
{
- afs_status_t ast;
- char *userName;
- jstring juser;
+ afs_status_t ast;
+ char *userName;
+ jstring juser;
- userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
+ userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
- if ( !userName ) {
- throwAFSException( env, JAFSADMNOMEM );
- return NULL;
- }
+ if (!userName) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return NULL;
+ }
- if ( !pts_UserListNext( (void *) iterationId, userName, &ast ) ) {
- free( userName );
- if ( ast == ADMITERATORDONE ) {
- return NULL;
- } else {
- throwAFSException( env, ast );
- return NULL;
+ if (!pts_UserListNext((void *)iterationId, userName, &ast)) {
+ free(userName);
+ if (ast == ADMITERATORDONE) {
+ return NULL;
+ } else {
+ throwAFSException(env, ast);
+ return NULL;
+ }
}
- }
- if ( strcmp( userName, "anonymous" ) == 0 ) {
- free( userName );
- return Java_org_openafs_jafs_Cell_getPtsUsersNextString( env, cls,
- iterationId );
- }
+ if (strcmp(userName, "anonymous") == 0) {
+ free(userName);
+ return Java_org_openafs_jafs_Cell_getPtsUsersNextString(env, cls,
+ iterationId);
+ }
- juser = (*env)->NewStringUTF(env, userName);
- free( userName );
- return juser;
+ juser = (*env)->NewStringUTF(env, userName);
+ free(userName);
+ return juser;
}
* cellHandle the cell handle to which these users will belong
* returns the name of the next pts user (not kas user) of the cell
*/
-JNIEXPORT jstring JNICALL
-Java_org_openafs_jafs_Cell_getPtsOnlyUsersNextString
- (JNIEnv *env, jclass cls, jint iterationId, jint cellHandle)
+JNIEXPORT jstring JNICALL
+Java_org_openafs_jafs_Cell_getPtsOnlyUsersNextString(JNIEnv * env, jclass cls,
+ jint iterationId,
+ jint cellHandle)
{
- kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) );
+ kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t));
kas_principalEntry_t kasEntry;
afs_status_t ast;
char *userName;
jstring juser;
- if ( !who ) {
- throwAFSException( env, JAFSADMNOMEM );
- return NULL;
+ if (!who) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return NULL;
}
- userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
+ userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
- if ( !userName ) {
- free( who );
- throwAFSException( env, JAFSADMNOMEM );
- return NULL;
+ if (!userName) {
+ free(who);
+ throwAFSException(env, JAFSADMNOMEM);
+ return NULL;
}
- while( 1 ) {
+ while (1) {
- if ( !pts_UserListNext( (void *) iterationId, userName, &ast ) ) {
- free( userName );
- free( who );
- if ( ast == ADMITERATORDONE ) {
+ if (!pts_UserListNext((void *)iterationId, userName, &ast)) {
+ free(userName);
+ free(who);
+ if (ast == ADMITERATORDONE) {
return NULL;
} else {
- throwAFSException( env, ast );
+ throwAFSException(env, ast);
return NULL;
}
}
- if ( strcmp( userName, "anonymous" ) == 0 ) {
+ if (strcmp(userName, "anonymous") == 0) {
continue;
}
-
// make sure the name is within the allowed bounds
- if ( strlen( userName ) > KAS_MAX_NAME_LEN ) {
- free( who );
- free( userName );
- throwAFSException( env, ADMPTSUSERNAMETOOLONG );
+ if (strlen(userName) > KAS_MAX_NAME_LEN) {
+ free(who);
+ free(userName);
+ throwAFSException(env, ADMPTSUSERNAMETOOLONG);
return NULL;
}
-
// if there is a kas entry, recurse
- internal_makeKasIdentity( userName, who );
- if ( kas_PrincipalGet( (void *) cellHandle, NULL, who,
- &kasEntry, &ast ) ) {
+ internal_makeKasIdentity(userName, who);
+ if (kas_PrincipalGet((void *)cellHandle, NULL, who, &kasEntry, &ast)) {
continue;
}
-
+
juser = (*env)->NewStringUTF(env, userName);
- free( userName );
- free( who );
+ free(userName);
+ free(who);
return juser;
}
* the next pts user
* returns 0 if there are no more users, != 0 otherwise
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getPtsUsersNext
- (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId,
- jobject juserObject )
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getPtsUsersNext(JNIEnv * env, jclass cls,
+ jint cellHandle, jint iterationId,
+ jobject juserObject)
{
-
- afs_status_t ast;
- char *userName;
- jstring juser;
-
- userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
-
- if ( !userName ) {
- throwAFSException( env, JAFSADMNOMEM );
- return 0;
- }
-
- if ( !pts_UserListNext( (void *) iterationId, userName, &ast ) ) {
- free( userName );
- if ( ast == ADMITERATORDONE ) {
- return 0;
- } else {
- throwAFSException( env, ast );
- return 0;
+
+ afs_status_t ast;
+ char *userName;
+ jstring juser;
+
+ userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
+
+ if (!userName) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return 0;
}
- }
- if ( strcmp( userName, "anonymous" ) == 0 ) {
- free( userName );
- return Java_org_openafs_jafs_Cell_getPtsUsersNext( env, cls,
- cellHandle,
- iterationId,
- juserObject );
- }
-
- juser = (*env)->NewStringUTF(env, userName);
+ if (!pts_UserListNext((void *)iterationId, userName, &ast)) {
+ free(userName);
+ if (ast == ADMITERATORDONE) {
+ return 0;
+ } else {
+ throwAFSException(env, ast);
+ return 0;
+ }
+ }
+
+ if (strcmp(userName, "anonymous") == 0) {
+ free(userName);
+ return Java_org_openafs_jafs_Cell_getPtsUsersNext(env, cls,
+ cellHandle,
+ iterationId,
+ juserObject);
+ }
- if ( userCls == 0 ) {
- internal_getUserClass( env, juserObject );
- }
+ juser = (*env)->NewStringUTF(env, userName);
- (*env)->SetObjectField(env, juserObject, user_nameField, juser);
+ if (userCls == 0) {
+ internal_getUserClass(env, juserObject);
+ }
- getUserInfoChar( env, (int) cellHandle, userName, juserObject );
- (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE );
+ (*env)->SetObjectField(env, juserObject, user_nameField, juser);
- free( userName );
- return 1;
+ getUserInfoChar(env, (int)cellHandle, userName, juserObject);
+ (*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE);
+
+ free(userName);
+ return 1;
}
/**
* the next pts (with no kas) user
* returns 0 if there are no more users, != 0 otherwise
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getPtsOnlyUsersNext
- (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId,
- jobject juserObject )
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getPtsOnlyUsersNext(JNIEnv * env, jclass cls,
+ jint cellHandle,
+ jint iterationId,
+ jobject juserObject)
{
- kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) );
- kas_principalEntry_t kasEntry;
- afs_status_t ast;
- char *userName;
- jstring juser;
-
- if ( !who ) {
- throwAFSException( env, JAFSADMNOMEM );
- return 0;
- }
-
- userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
-
- if ( !userName ) {
- free( who );
- throwAFSException( env, JAFSADMNOMEM );
- return 0;
- }
-
- while( 1 ) {
-
- if ( !pts_UserListNext( (void *) iterationId, userName, &ast ) ) {
- free( userName );
- free( who );
- if ( ast == ADMITERATORDONE ) {
- return 0;
- } else {
- throwAFSException( env, ast );
- return 0;
- }
- }
-
- if ( strcmp( userName, "anonymous" ) == 0 ) {
- continue;
- }
-
- // make sure the name is within the allowed bounds
- if ( strlen( userName ) > KAS_MAX_NAME_LEN ) {
- free( userName );
- free( who );
- throwAFSException( env, ADMPTSUSERNAMETOOLONG );
- return 0;
- }
-
- if ( userCls == 0 ) {
- internal_getUserClass( env, juserObject );
- }
-
-
- // if there is a kas entry, recurse
- internal_makeKasIdentity( userName, who );
- if ( kas_PrincipalGet( (void *) cellHandle, NULL, who,
- &kasEntry, &ast ) ) {
- continue;
- }
-
- juser = (*env)->NewStringUTF(env, userName);
-
- (*env)->SetObjectField(env, juserObject, user_nameField, juser);
- getUserInfoChar( env, (int) cellHandle, userName, juserObject );
- (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE );
-
- free( who );
- free( userName );
- return 1;
-
- }
+ kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t));
+ kas_principalEntry_t kasEntry;
+ afs_status_t ast;
+ char *userName;
+ jstring juser;
+
+ if (!who) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return 0;
+ }
+
+ userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
+
+ if (!userName) {
+ free(who);
+ throwAFSException(env, JAFSADMNOMEM);
+ return 0;
+ }
+
+ while (1) {
+
+ if (!pts_UserListNext((void *)iterationId, userName, &ast)) {
+ free(userName);
+ free(who);
+ if (ast == ADMITERATORDONE) {
+ return 0;
+ } else {
+ throwAFSException(env, ast);
+ return 0;
+ }
+ }
+
+ if (strcmp(userName, "anonymous") == 0) {
+ continue;
+ }
+ // make sure the name is within the allowed bounds
+ if (strlen(userName) > KAS_MAX_NAME_LEN) {
+ free(userName);
+ free(who);
+ throwAFSException(env, ADMPTSUSERNAMETOOLONG);
+ return 0;
+ }
+
+ if (userCls == 0) {
+ internal_getUserClass(env, juserObject);
+ }
+ // if there is a kas entry, recurse
+ internal_makeKasIdentity(userName, who);
+ if (kas_PrincipalGet((void *)cellHandle, NULL, who, &kasEntry, &ast)) {
+ continue;
+ }
+
+ juser = (*env)->NewStringUTF(env, userName);
+
+ (*env)->SetObjectField(env, juserObject, user_nameField, juser);
+ getUserInfoChar(env, (int)cellHandle, userName, juserObject);
+ (*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE);
+
+ free(who);
+ free(userName);
+ return 1;
+
+ }
}
* cls the current Java class
* iterationId the iteration ID of this iteration
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Cell_getPtsUsersDone
- (JNIEnv *env, jclass cls, jint iterationId)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Cell_getPtsUsersDone(JNIEnv * env, jclass cls,
+ jint iterationId)
{
- afs_status_t ast;
+ afs_status_t ast;
+
+ if (!pts_UserListDone((void *)iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
- if ( !pts_UserListDone( (void *) iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
-
}
/**
* cellHandle the handle of the cell to which the groups belong
* returns total number of groups
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getGroupCount
- (JNIEnv *env, jclass cls, jint cellHandle)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getGroupCount(JNIEnv * env, jclass cls,
+ jint cellHandle)
{
- afs_status_t ast;
- void *iterationId;
- char *groupName;
- int i = 0;
+ afs_status_t ast;
+ void *iterationId;
+ char *groupName;
+ int i = 0;
- if ( !pts_GroupListBegin( (void *) cellHandle, &iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return -1;
- }
+ if (!pts_GroupListBegin((void *)cellHandle, &iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return -1;
+ }
- groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
+ groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
- if ( !groupName ) {
- throwAFSException( env, JAFSADMNOMEM );
- return -1;
- }
+ if (!groupName) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return -1;
+ }
- while ( pts_GroupListNext( (void *) iterationId, groupName, &ast ) ) i++;
+ while (pts_GroupListNext((void *)iterationId, groupName, &ast))
+ i++;
- free( groupName );
+ free(groupName);
- if ( ast != ADMITERATORDONE ) {
- throwAFSException( env, ast );
- return -1;
- }
+ if (ast != ADMITERATORDONE) {
+ throwAFSException(env, ast);
+ return -1;
+ }
- return i;
+ return i;
}
/**
* cellHandle the handle of the cell to which the groups belong
* returns an iteration ID
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getGroupsBegin
- (JNIEnv *env, jclass cls, jint cellHandle)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getGroupsBegin(JNIEnv * env, jclass cls,
+ jint cellHandle)
{
- afs_status_t ast;
- void *iterationId;
+ afs_status_t ast;
+ void *iterationId;
- if ( !pts_GroupListBegin( (void *) cellHandle, &iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
+ if (!pts_GroupListBegin((void *)cellHandle, &iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
- return (jint) iterationId;
+ return (jint) iterationId;
}
/**
* startIndex the starting base-zero index
* returns an iteration ID
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getGroupsBeginAt
- (JNIEnv *env, jclass cls, jint cellHandle, jint startIndex)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getGroupsBeginAt(JNIEnv * env, jclass cls,
+ jint cellHandle, jint startIndex)
{
- afs_status_t ast;
- void *iterationId;
- char *groupName;
- int i;
-
- groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
-
- if ( !pts_GroupListBegin( (void *) cellHandle, &iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return 0;
- }
-
- for ( i = 1; i < startIndex; i++) {
- if ( !pts_GroupListNext( (void *) iterationId, groupName, &ast ) ) {
- free( groupName );
- if ( ast == ADMITERATORDONE ) {
- return 0;
- } else {
- throwAFSException( env, ast );
- return 0;
- }
- }
- }
-
- free( groupName );
- return (jint) iterationId;
+ afs_status_t ast;
+ void *iterationId;
+ char *groupName;
+ int i;
+
+ groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
+
+ if (!pts_GroupListBegin((void *)cellHandle, &iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return 0;
+ }
+
+ for (i = 1; i < startIndex; i++) {
+ if (!pts_GroupListNext((void *)iterationId, groupName, &ast)) {
+ free(groupName);
+ if (ast == ADMITERATORDONE) {
+ return 0;
+ } else {
+ throwAFSException(env, ast);
+ return 0;
+ }
+ }
+ }
+
+ free(groupName);
+ return (jint) iterationId;
}
/**
* iterationId the iteration ID of this iteration
* returns the name of the next user of the cell
*/
-JNIEXPORT jstring JNICALL
-Java_org_openafs_jafs_Cell_getGroupsNextString
- (JNIEnv *env, jclass cls, jint iterationId)
+JNIEXPORT jstring JNICALL
+Java_org_openafs_jafs_Cell_getGroupsNextString(JNIEnv * env, jclass cls,
+ jint iterationId)
{
- afs_status_t ast;
- char *groupName;
- jstring jgroup;
+ afs_status_t ast;
+ char *groupName;
+ jstring jgroup;
- groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
+ groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
- if ( !groupName ) {
- throwAFSException( env, JAFSADMNOMEM );
- return NULL;
- }
+ if (!groupName) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return NULL;
+ }
- if ( !pts_GroupListNext( (void *) iterationId, groupName, &ast ) ) {
- free( groupName );
- if ( ast == ADMITERATORDONE ) {
- return NULL;
- } else {
- throwAFSException( env, ast );
- return NULL;
+ if (!pts_GroupListNext((void *)iterationId, groupName, &ast)) {
+ free(groupName);
+ if (ast == ADMITERATORDONE) {
+ return NULL;
+ } else {
+ throwAFSException(env, ast);
+ return NULL;
+ }
}
- }
- jgroup = (*env)->NewStringUTF(env, groupName);
- free( groupName );
- return jgroup;
+ jgroup = (*env)->NewStringUTF(env, groupName);
+ free(groupName);
+ return jgroup;
}
* the next group
* returns 0 if there are no more users, != 0 otherwise
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getGroupsNext
- (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId,
- jobject jgroupObject)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getGroupsNext(JNIEnv * env, jclass cls,
+ jint cellHandle, jint iterationId,
+ jobject jgroupObject)
{
- afs_status_t ast;
- char *groupName;
- jstring jgroup;
-
- groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN );
-
- if ( !groupName ) {
- throwAFSException( env, JAFSADMNOMEM );
- return;
- }
-
- if ( !pts_GroupListNext( (void *) iterationId, groupName, &ast ) ) {
- free( groupName );
- if ( ast == ADMITERATORDONE ) {
- return 0;
- } else {
- throwAFSException( env, ast );
- return 0;
+ afs_status_t ast;
+ char *groupName;
+ jstring jgroup;
+
+ groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
+
+ if (!groupName) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return;
}
- }
- jgroup = (*env)->NewStringUTF(env, groupName);
+ if (!pts_GroupListNext((void *)iterationId, groupName, &ast)) {
+ free(groupName);
+ if (ast == ADMITERATORDONE) {
+ return 0;
+ } else {
+ throwAFSException(env, ast);
+ return 0;
+ }
+ }
- if ( groupCls == 0 ) {
- internal_getGroupClass( env, jgroupObject );
- }
+ jgroup = (*env)->NewStringUTF(env, groupName);
+
+ if (groupCls == 0) {
+ internal_getGroupClass(env, jgroupObject);
+ }
- (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup);
+ (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup);
- getGroupInfoChar( env, (int) cellHandle, groupName, jgroupObject );
- (*env)->SetBooleanField( env, jgroupObject, group_cachedInfoField, TRUE );
+ getGroupInfoChar(env, (int)cellHandle, groupName, jgroupObject);
+ (*env)->SetBooleanField(env, jgroupObject, group_cachedInfoField, TRUE);
- free( groupName );
- return 1;
+ free(groupName);
+ return 1;
}
/**
* cls the current Java class
* iterationId the iteration ID of this iteration
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Cell_getGroupsDone
- (JNIEnv *env, jclass cls, jint iterationId)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Cell_getGroupsDone(JNIEnv * env, jclass cls,
+ jint iterationId)
{
- afs_status_t ast;
+ afs_status_t ast;
+
+ if (!pts_GroupListDone((void *)iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
- if ( !pts_GroupListDone( (void *) iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
-
}
/**
* cellHandle the handle of the cell to which the group belongs
* returns an integer reresenting the max group id in a cell
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getMaxGroupID
- (JNIEnv *env, jclass cls, jint cellHandle)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getMaxGroupID(JNIEnv * env, jclass cls,
+ jint cellHandle)
{
- afs_status_t ast;
- jint maxID;
+ afs_status_t ast;
+ jint maxID;
- if ( !pts_GroupMaxGet( (void *) cellHandle, (int *) &maxID, &ast ) ) {
- throwAFSException( env, ast );
- return 0;
- }
+ if (!pts_GroupMaxGet((void *)cellHandle, (int *)&maxID, &ast)) {
+ throwAFSException(env, ast);
+ return 0;
+ }
- return maxID;
+ return maxID;
}
/**
* cellHandle the handle of the cell to which the group belongs
* maxID an integer reresenting the new max group id in a cell
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Cell_setMaxGroupID
- (JNIEnv *env, jclass cls, jint cellHandle, jint maxID)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Cell_setMaxGroupID(JNIEnv * env, jclass cls,
+ jint cellHandle, jint maxID)
{
- afs_status_t ast;
+ afs_status_t ast;
- if ( !pts_GroupMaxSet( (void *) cellHandle, (int) maxID, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
+ if (!pts_GroupMaxSet((void *)cellHandle, (int)maxID, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
}
/**
* cellHandle the handle of the cell to which the user belongs
* returns an integer reresenting the max user id in a cell
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getMaxUserID
- (JNIEnv *env, jclass cls, jint cellHandle)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getMaxUserID(JNIEnv * env, jclass cls,
+ jint cellHandle)
{
- afs_status_t ast;
- jint maxID;
+ afs_status_t ast;
+ jint maxID;
- if ( !pts_UserMaxGet( (void *) cellHandle, (int *) &maxID, &ast ) ) {
- throwAFSException( env, ast );
- return 0;
- }
+ if (!pts_UserMaxGet((void *)cellHandle, (int *)&maxID, &ast)) {
+ throwAFSException(env, ast);
+ return 0;
+ }
- return maxID;
+ return maxID;
}
/**
* cellHandle the handle of the cell to which the user belongs
* maxID an integer reresenting the new max user id in a cell
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Cell_setMaxUserID
- (JNIEnv *env, jclass cls, jint cellHandle, jint maxID)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Cell_setMaxUserID(JNIEnv * env, jclass cls,
+ jint cellHandle, jint maxID)
{
- afs_status_t ast;
+ afs_status_t ast;
- if ( !pts_UserMaxSet( (void *) cellHandle, (int) maxID, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
+ if (!pts_UserMaxSet((void *)cellHandle, (int)maxID, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
}
/**
* cellHandle the handle of the cell to which the servers belong
* returns total number of servers
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getServerCount
- (JNIEnv *env, jclass cls, jint cellHandle)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getServerCount(JNIEnv * env, jclass cls,
+ jint cellHandle)
{
- afs_status_t ast;
- void *iterationId;
- afs_serverEntry_t servEntry;
- int i = 0;
-
- if ( !afsclient_AFSServerGetBegin( (void *) cellHandle,
- &iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return -1;
- }
-
- while ( afsclient_AFSServerGetNext( (void *) iterationId,
- &servEntry, &ast ) ) i++;
-
- if ( ast != ADMITERATORDONE ) {
- throwAFSException( env, ast );
- return -1;
- }
-
- return i;
+ afs_status_t ast;
+ void *iterationId;
+ afs_serverEntry_t servEntry;
+ int i = 0;
+
+ if (!afsclient_AFSServerGetBegin((void *)cellHandle, &iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return -1;
+ }
+
+ while (afsclient_AFSServerGetNext((void *)iterationId, &servEntry, &ast))
+ i++;
+
+ if (ast != ADMITERATORDONE) {
+ throwAFSException(env, ast);
+ return -1;
+ }
+
+ return i;
}
/**
* cellHandle the handle of the cell to which the servers belong
* returns an iteration ID
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getServersBegin
- (JNIEnv *env, jclass cls, jint cellHandle)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getServersBegin(JNIEnv * env, jclass cls,
+ jint cellHandle)
{
- afs_status_t ast;
- void *iterationId;
+ afs_status_t ast;
+ void *iterationId;
- if ( !afsclient_AFSServerGetBegin( (void *) cellHandle,
- &iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return -1;
- }
+ if (!afsclient_AFSServerGetBegin((void *)cellHandle, &iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return -1;
+ }
- return (jint) iterationId;
+ return (jint) iterationId;
}
/**
* iterationId the iteration ID of this iteration
* returns the name of the next server of the cell
*/
-JNIEXPORT jstring JNICALL
-Java_org_openafs_jafs_Cell_getServersNextString
- (JNIEnv *env, jclass cls, jint iterationId)
+JNIEXPORT jstring JNICALL
+Java_org_openafs_jafs_Cell_getServersNextString(JNIEnv * env, jclass cls,
+ jint iterationId)
{
- afs_status_t ast;
- jstring jserver;
- afs_serverEntry_t servEntry;
+ afs_status_t ast;
+ jstring jserver;
+ afs_serverEntry_t servEntry;
- if ( !afsclient_AFSServerGetNext( (void *) iterationId, &servEntry, &ast ) ) {
- if ( ast == ADMITERATORDONE ) {
- return NULL;
- } else {
- throwAFSException( env, ast );
- return NULL;
+ if (!afsclient_AFSServerGetNext((void *)iterationId, &servEntry, &ast)) {
+ if (ast == ADMITERATORDONE) {
+ return NULL;
+ } else {
+ throwAFSException(env, ast);
+ return NULL;
+ }
}
- }
- return jserver;
+ return jserver;
}
/**
* of the next server
* returns 0 if there are no more servers, != 0 otherwise
*/
-JNIEXPORT jint JNICALL
-Java_org_openafs_jafs_Cell_getServersNext
- (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId,
- jobject jserverObject)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_Cell_getServersNext(JNIEnv * env, jclass cls,
+ jint cellHandle, jint iterationId,
+ jobject jserverObject)
{
- afs_status_t ast;
- jstring jserver;
- afs_serverEntry_t servEntry;
- jintArray jaddress;
-
- if ( !afsclient_AFSServerGetNext( (void *) iterationId, &servEntry, &ast ) ) {
- if ( ast == ADMITERATORDONE ) {
- return 0;
- } else {
- throwAFSException( env, ast );
- return 0;
+ afs_status_t ast;
+ jstring jserver;
+ afs_serverEntry_t servEntry;
+ jintArray jaddress;
+
+ if (!afsclient_AFSServerGetNext((void *)iterationId, &servEntry, &ast)) {
+ if (ast == ADMITERATORDONE) {
+ return 0;
+ } else {
+ throwAFSException(env, ast);
+ return 0;
+ }
+ }
+ // get the class fields if need be
+ if (serverCls == 0) {
+ internal_getServerClass(env, jserverObject);
}
- }
-
- // get the class fields if need be
- if ( serverCls == 0 ) {
- internal_getServerClass( env, jserverObject );
- }
- fillServerInfo( env, (int) cellHandle, jserverObject, servEntry );
+ fillServerInfo(env, (int)cellHandle, jserverObject, servEntry);
- (*env)->SetBooleanField( env, jserverObject, server_cachedInfoField, TRUE );
+ (*env)->SetBooleanField(env, jserverObject, server_cachedInfoField, TRUE);
- return 1;
+ return 1;
}
/**
* cls the current Java class
* iterationId the iteration ID of this iteration
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Cell_getServersDone
- (JNIEnv *env, jclass cls, jint iterationId)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Cell_getServersDone(JNIEnv * env, jclass cls,
+ jint iterationId)
{
- afs_status_t ast;
+ afs_status_t ast;
- if ( !afsclient_AFSServerGetDone( (void *) iterationId, &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
+ if (!afsclient_AFSServerGetDone((void *)iterationId, &ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
}
/**
* readWrite whether or not this is to be a readwrite mount point
* forceCheck whether or not to check if this volume name exists
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Cell_createMountPoint
- (JNIEnv *env, jclass cls, jint cellHandle, jstring jdirectory,
- jstring jvolumeName, jboolean readWrite, jboolean forceCheck)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Cell_createMountPoint(JNIEnv * env, jclass cls,
+ jint cellHandle,
+ jstring jdirectory,
+ jstring jvolumeName,
+ jboolean readWrite,
+ jboolean forceCheck)
{
- afs_status_t ast;
- char *directory;
- char *volumeName;
- vol_type_t type;
- vol_check_t check;
-
- if ( jdirectory != NULL ) {
- directory = getNativeString(env, jdirectory);
- if ( !directory ) {
- throwAFSException( env, JAFSADMNOMEM );
- return;
- }
- } else {
- throwAFSException( env, JAFSNULLPATH );
- return;
- }
- if ( jvolumeName != NULL ) {
- volumeName = getNativeString(env, jvolumeName);
- if ( volumeName == NULL ) {
- free( directory );
- throwAFSException( env, JAFSADMNOMEM );
- return;
- }
- } else {
- free( directory );
- throwAFSException( env, JAFSNULLVOLUME );
- return;
- }
-
- if ( readWrite ) {
- type = READ_WRITE;
- } else {
- type = READ_ONLY;
- }
-
- if ( forceCheck ) {
- check = CHECK_VOLUME;
- } else {
- check = DONT_CHECK_VOLUME;
- }
-
- if ( !afsclient_MountPointCreate( (void *) cellHandle, directory,
- volumeName, type, check, &ast ) ) {
- throwAFSException( env, ast );
- }
-
- free( directory );
- free( volumeName );
+ afs_status_t ast;
+ char *directory;
+ char *volumeName;
+ vol_type_t type;
+ vol_check_t check;
+
+ if (jdirectory != NULL) {
+ directory = getNativeString(env, jdirectory);
+ if (!directory) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return;
+ }
+ } else {
+ throwAFSException(env, JAFSNULLPATH);
+ return;
+ }
+ if (jvolumeName != NULL) {
+ volumeName = getNativeString(env, jvolumeName);
+ if (volumeName == NULL) {
+ free(directory);
+ throwAFSException(env, JAFSADMNOMEM);
+ return;
+ }
+ } else {
+ free(directory);
+ throwAFSException(env, JAFSNULLVOLUME);
+ return;
+ }
+
+ if (readWrite) {
+ type = READ_WRITE;
+ } else {
+ type = READ_ONLY;
+ }
+
+ if (forceCheck) {
+ check = CHECK_VOLUME;
+ } else {
+ check = DONT_CHECK_VOLUME;
+ }
+
+ if (!afsclient_MountPointCreate
+ ((void *)cellHandle, directory, volumeName, type, check, &ast)) {
+ throwAFSException(env, ast);
+ }
+
+ free(directory);
+ free(volumeName);
}
/*
* lock whether or not to allow lock access to this user
* admin whether or not to allow admin access to this user
*/
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Cell_setACL
- (JNIEnv *env, jclass cls, jstring jdirectory, jstring juserName,
- jboolean read, jboolean write, jboolean lookup, jboolean delete,
- jboolean insert, jboolean lock, jboolean admin)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Cell_setACL(JNIEnv * env, jclass cls,
+ jstring jdirectory, jstring juserName,
+ jboolean read, jboolean write,
+ jboolean lookup, jboolean delete,
+ jboolean insert, jboolean lock,
+ jboolean admin)
{
- afs_status_t ast;
- char *directory;
- char *userName;
- acl_t acl;
-
- if ( !afsclient_Init( &ast ) ) {
- throwAFSException( env, ast );
- return;
- }
-
- if ( jdirectory != NULL ) {
- directory = getNativeString(env, jdirectory);
- if ( !directory ) {
- throwAFSException( env, JAFSADMNOMEM );
- return;
- }
- } else {
- throwAFSException( env, JAFSNULLPATH );
- return;
- }
-
- if ( juserName != NULL ) {
- userName = getNativeString(env, juserName);
- if ( !userName ) {
- free( directory );
- throwAFSException( env, JAFSADMNOMEM );
- return;
- }
- } else {
- free( directory );
- throwAFSException( env, JAFSNULLUSER );
- return;
- }
-
- if ( read ) {
- acl.read = READ;
- } else {
- acl.read = NO_READ;
- }
-
- if ( write ) {
- acl.write = WRITE;
- } else {
- acl.write = NO_WRITE;
- }
-
- if ( lookup ) {
- acl.lookup = LOOKUP;
- } else {
- acl.lookup = NO_LOOKUP;
- }
-
- if ( delete ) {
- acl.del = DELETE;
- } else {
- acl.del = NO_DELETE;
- }
-
- if ( insert ) {
- acl.insert = INSERT;
- } else {
- acl.insert = NO_INSERT;
- }
-
- if ( lock ) {
- acl.lock = LOCK;
- } else {
- acl.lock = NO_LOCK;
- }
-
- if ( admin ) {
- acl.admin = ADMIN;
- } else {
- acl.admin = NO_ADMIN;
- }
-
- if ( !afsclient_ACLEntryAdd( directory, userName, &acl, &ast ) ) {
- throwAFSException( env, ast );
- }
-
- free( userName );
- free( directory );
+ afs_status_t ast;
+ char *directory;
+ char *userName;
+ acl_t acl;
+
+ if (!afsclient_Init(&ast)) {
+ throwAFSException(env, ast);
+ return;
+ }
+
+ if (jdirectory != NULL) {
+ directory = getNativeString(env, jdirectory);
+ if (!directory) {
+ throwAFSException(env, JAFSADMNOMEM);
+ return;
+ }
+ } else {
+ throwAFSException(env, JAFSNULLPATH);
+ return;
+ }
+
+ if (juserName != NULL) {
+ userName = getNativeString(env, juserName);
+ if (!userName) {
+ free(directory);
+ throwAFSException(env, JAFSADMNOMEM);
+ return;
+ }
+ } else {
+ free(directory);
+ throwAFSException(env, JAFSNULLUSER);
+ return;
+ }
+
+ if (read) {
+ acl.read = READ;
+ } else {
+ acl.read = NO_READ;
+ }
+
+ if (write) {
+ acl.write = WRITE;
+ } else {
+ acl.write = NO_WRITE;
+ }
+
+ if (lookup) {
+ acl.lookup = LOOKUP;
+ } else {
+ acl.lookup = NO_LOOKUP;
+ }
+
+ if (delete) {
+ acl.del = DELETE;
+ } else {
+ acl.del = NO_DELETE;
+ }
+
+ if (insert) {
+ acl.insert = INSERT;
+ } else {
+ acl.insert = NO_INSERT;
+ }
+
+ if (lock) {
+ acl.lock = LOCK;
+ } else {
+ acl.lock = NO_LOCK;
+ }
+
+ if (admin) {
+ acl.admin = ADMIN;
+ } else {
+ acl.admin = NO_ADMIN;
+ }
+
+ if (!afsclient_ACLEntryAdd(directory, userName, &acl, &ast)) {
+ throwAFSException(env, ast);
+ }
+
+ free(userName);
+ free(directory);
}
// reclaim global memory used by this portion
-JNIEXPORT void JNICALL
-Java_org_openafs_jafs_Cell_reclaimCellMemory (JNIEnv *env, jclass cls)
+JNIEXPORT void JNICALL
+Java_org_openafs_jafs_Cell_reclaimCellMemory(JNIEnv * env, jclass cls)
{
}
#include "dmalloc.h"
#endif
-void setFileNotExistsAttributes(JNIEnv *env, jobject *obj);
+void setFileNotExistsAttributes(JNIEnv * env, jobject * obj);
typedef struct {
char *fileName;
/*static char compile_date[] = COMPILE_DATE;*/
-int sub_time(struct timeval *tv1, struct timeval *tv2)
+int
+sub_time(struct timeval *tv1, struct timeval *tv2)
{
- if (tv2->tv_usec > tv1->tv_usec) {
- tv1->tv_usec += 1000000;
- tv1->tv_usec -= 1;
- }
+ if (tv2->tv_usec > tv1->tv_usec) {
+ tv1->tv_usec += 1000000;
+ tv1->tv_usec -= 1;
+ }
- tv1->tv_usec -= tv2->tv_usec;
- tv1->tv_sec -= tv2->tv_sec;
+ tv1->tv_usec -= tv2->tv_usec;
+ tv1->tv_sec -= tv2->tv_sec;
}
/**
* env the Java environment
* obj the current Java object
*/
-char* getAbsolutePath(JNIEnv *env, jobject *obj, char *dirName)
+char *
+getAbsolutePath(JNIEnv * env, jobject * obj, char *dirName)
{
jclass thisClass;
jstring jDirName;
jfieldID fid;
thisClass = (*env)->GetObjectClass(env, *obj);
- if( thisClass == NULL ) {
- fprintf(stderr, "File::getAbsolutePath(): GetObjectClass failed\n");
- return NULL;
+ if (thisClass == NULL) {
+ fprintf(stderr, "File::getAbsolutePath(): GetObjectClass failed\n");
+ return NULL;
}
fid = (*env)->GetFieldID(env, thisClass, "path", "Ljava/lang/String;");
- if ( fid == NULL ) {
- fprintf(stderr, "File::getAbsolutePath(): GetFieldID (path) failed\n");
- return NULL;
+ if (fid == NULL) {
+ fprintf(stderr,
+ "File::getAbsolutePath(): GetFieldID (path) failed\n");
+ return NULL;
}
jDirName = (*env)->GetObjectField(env, *obj, fid);
- if( jDirName == NULL ) {
- fprintf(stderr, "File::getAbsolutePath(): failed to get file name\n");
- return NULL;
+ if (jDirName == NULL) {
+ fprintf(stderr, "File::getAbsolutePath(): failed to get file name\n");
+ return NULL;
}
auxDirName = getNativeString(env, jDirName);
- if ( auxDirName == NULL ) {
- fprintf(stderr, "File::getAbsolutePath(): failed to get translated file name\n");
- return NULL;
+ if (auxDirName == NULL) {
+ fprintf(stderr,
+ "File::getAbsolutePath(): failed to get translated file name\n");
+ return NULL;
}
strcpy(dirName, auxDirName);
- free( auxDirName );
+ free(auxDirName);
}
/**
*
* throws AFSException
*/
-JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_setAttributes
- (JNIEnv *env, jobject obj)
+JNIEXPORT jboolean JNICALL
+Java_org_openafs_jafs_File_setAttributes(JNIEnv * env, jobject obj)
{
- char target[FILENAME_MAX+1];
+ char target[FILENAME_MAX + 1];
char dirName[FILENAME_MAX];
jclass thisClass;
jfieldID fid;
struct timeval tv0, tv1;
struct timezone tz;
- /*memset(target, 0, FILENAME_MAX);*/
+ /*memset(target, 0, FILENAME_MAX); */
*dirName = '\0';
getAbsolutePath(env, &obj, dirName);
- /*fprintf(stderr, "dirName=%s\n", dirName);*/
+ /*fprintf(stderr, "dirName=%s\n", dirName); */
- if(*dirName == '\0') {
- fprintf(stderr, "File::setAttributes(): failed to get dirName\n");
- return JNI_FALSE;
+ if (*dirName == '\0') {
+ fprintf(stderr, "File::setAttributes(): failed to get dirName\n");
+ return JNI_FALSE;
}
- thisClass = (*env) -> GetObjectClass(env, obj);
- if(thisClass == NULL) {
- fprintf(stderr, "File::setAttributes(): GetObjectClass failed\n");
- return JNI_FALSE;
+ thisClass = (*env)->GetObjectClass(env, obj);
+ if (thisClass == NULL) {
+ fprintf(stderr, "File::setAttributes(): GetObjectClass failed\n");
+ return JNI_FALSE;
}
gettimeofday(&tv0, &tz);
if ((strcmp(dirName, "/afs") == 0) || (strcmp(dirName, "/afs/") == 0)) {
- rc = 1; /* special case for /afs since statmountpoint fails on it */
+ rc = 1; /* special case for /afs since statmountpoint fails on it */
} else {
- rc = uafs_statmountpoint(dirName);
- gettimeofday(&tv1, &tz);
- sub_time(&tv1, &tv0);
- /*printf("%s: statmountpoint %d.%06d\n", dirName, tv1.tv_sec, tv1.tv_usec);*/
- }
-
- if(rc < 0) {
- setError(env, &obj, errno);
- if(errno == ENOENT) {
- setFileNotExistsAttributes(env, &obj);
- return JNI_TRUE; /* not really an error */
- } else {
- fprintf(stderr, "File::setAttributes(): uafs_statmountpoint failed "
- "for %s (%s)\n", dirName, error_message(errno));
- return JNI_FALSE;
- }
+ rc = uafs_statmountpoint(dirName);
+ gettimeofday(&tv1, &tz);
+ sub_time(&tv1, &tv0);
+ /*printf("%s: statmountpoint %d.%06d\n", dirName, tv1.tv_sec, tv1.tv_usec); */
+ }
+
+ if (rc < 0) {
+ setError(env, &obj, errno);
+ if (errno == ENOENT) {
+ setFileNotExistsAttributes(env, &obj);
+ return JNI_TRUE; /* not really an error */
+ } else {
+ fprintf(stderr,
+ "File::setAttributes(): uafs_statmountpoint failed "
+ "for %s (%s)\n", dirName, error_message(errno));
+ return JNI_FALSE;
+ }
}
if (rc == 1) {
- /* this is an AFS mount point; we don't want to stat it */
- /* fake up a stat entry instead */
- mtpoint = 1;
- st.st_mtime = 0;
- st.st_size = 2048;
- st.st_mode = 0; /* don't match anything */
+ /* this is an AFS mount point; we don't want to stat it */
+ /* fake up a stat entry instead */
+ mtpoint = 1;
+ st.st_mtime = 0;
+ st.st_size = 2048;
+ st.st_mode = 0; /* don't match anything */
} else {
- mtpoint = 0;
- fid = (*env)->GetFieldID(env, thisClass, "isLink", "Z");
- if (fid == 0) {
- fprintf(stderr, "File::setAttributes(): GetFieldID (isLink) failed\n");
- setError(env, &obj, -1);
- return JNI_FALSE;
- }
- islink = (*env)->GetBooleanField(env, obj, fid);
- if (islink != JNI_TRUE) {
- rc = uafs_lstat(dirName, &st);
- } else {
- /* Here we are being called on a link object for the second time,
- so we want info on the object pointed to by the link. */
- fprintf(stderr, "islink = TRUE on file %s\n", dirName);
- rc = uafs_stat(dirName, &st);
- }
-
- if(rc < 0) {
- setError(env, &obj, errno);
- fprintf(stderr, "uafs_lstat failed for dir %s: error %d\n",
- dirName, errno);
- if(errno == ENOENT) {
- setFileNotExistsAttributes(env, &obj);
- return JNI_TRUE;
- }
- fprintf(stderr,
- "File::setAttributes(): uafs_stat failed for %s (%s)\n",
- dirName, error_message(errno));
- return JNI_FALSE;
- }
+ mtpoint = 0;
+ fid = (*env)->GetFieldID(env, thisClass, "isLink", "Z");
+ if (fid == 0) {
+ fprintf(stderr,
+ "File::setAttributes(): GetFieldID (isLink) failed\n");
+ setError(env, &obj, -1);
+ return JNI_FALSE;
+ }
+ islink = (*env)->GetBooleanField(env, obj, fid);
+ if (islink != JNI_TRUE) {
+ rc = uafs_lstat(dirName, &st);
+ } else {
+ /* Here we are being called on a link object for the second time,
+ * so we want info on the object pointed to by the link. */
+ fprintf(stderr, "islink = TRUE on file %s\n", dirName);
+ rc = uafs_stat(dirName, &st);
+ }
+
+ if (rc < 0) {
+ setError(env, &obj, errno);
+ fprintf(stderr, "uafs_lstat failed for dir %s: error %d\n",
+ dirName, errno);
+ if (errno == ENOENT) {
+ setFileNotExistsAttributes(env, &obj);
+ return JNI_TRUE;
+ }
+ fprintf(stderr,
+ "File::setAttributes(): uafs_stat failed for %s (%s)\n",
+ dirName, error_message(errno));
+ return JNI_FALSE;
+ }
}
fid = (*env)->GetFieldID(env, thisClass, "exists", "Z");
if (fid == 0) {
- fprintf(stderr,
- "File::setAttributes(): GetFieldID (exists) failed\n");
- setError(env, &obj, -1);
- return JNI_FALSE;
+ fprintf(stderr,
+ "File::setAttributes(): GetFieldID (exists) failed\n");
+ setError(env, &obj, -1);
+ return JNI_FALSE;
}
(*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
fid = (*env)->GetFieldID(env, thisClass, "isDirectory", "Z");
if (fid == 0) {
- fprintf(stderr,
- "File::setAttributes(): GetFieldID (isDirectory) failed\n");
- setError(env, &obj, -1);
- return JNI_FALSE;
+ fprintf(stderr,
+ "File::setAttributes(): GetFieldID (isDirectory) failed\n");
+ setError(env, &obj, -1);
+ return JNI_FALSE;
}
if ((st.st_mode & S_IFMT) == S_IFDIR && !mtpoint) {
- (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
+ (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
} else {
- (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
+ (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
}
fid = (*env)->GetFieldID(env, thisClass, "isFile", "Z");
if (fid == 0) {
- fprintf(stderr,
- "File::setAttributes(): GetFieldID (isFile) failed\n");
- setError(env, &obj, -1);
- return JNI_FALSE;
+ fprintf(stderr,
+ "File::setAttributes(): GetFieldID (isFile) failed\n");
+ setError(env, &obj, -1);
+ return JNI_FALSE;
}
if ((st.st_mode & S_IFMT) == S_IFREG) {
- (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
+ (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
} else {
- (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
+ (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
}
fid = (*env)->GetFieldID(env, thisClass, "isLink", "Z");
if (fid == 0) {
- fprintf(stderr,
- "File::setAttributes(): GetFieldID (isLink) failed\n");
- setError(env, &obj, -1);
- return JNI_FALSE;
- }
-
- if (islink != JNI_TRUE) { /* don't re-process link */
- if ((st.st_mode & S_IFMT) == S_IFLNK) {
- (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
-
- /* Find the target of the link */
- rc = uafs_readlink(dirName, target, FILENAME_MAX);
- if (rc < 0) {
- fprintf(stderr, "File::setAttributes(): uafs_readlink failed\n");
- setError(env, &obj, errno);
- return JNI_FALSE;
- } else {
- target[rc] = 0; /* weird that we have to do this */
- /*fprintf(stderr, "readlink %s succeeded, target=%s, rc=%d\n", dirName,
- target, rc);*/
- }
-
- rc = setString(env, &obj, "target", target);
- if (rc < 0) {
- fprintf(stderr, "setString dirName=%s target=%s failed\n",
- dirName, target);
- }
- } else {
- (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
- }
+ fprintf(stderr,
+ "File::setAttributes(): GetFieldID (isLink) failed\n");
+ setError(env, &obj, -1);
+ return JNI_FALSE;
+ }
+
+ if (islink != JNI_TRUE) { /* don't re-process link */
+ if ((st.st_mode & S_IFMT) == S_IFLNK) {
+ (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
+
+ /* Find the target of the link */
+ rc = uafs_readlink(dirName, target, FILENAME_MAX);
+ if (rc < 0) {
+ fprintf(stderr,
+ "File::setAttributes(): uafs_readlink failed\n");
+ setError(env, &obj, errno);
+ return JNI_FALSE;
+ } else {
+ target[rc] = 0; /* weird that we have to do this */
+ /*fprintf(stderr, "readlink %s succeeded, target=%s, rc=%d\n", dirName,
+ * target, rc); */
+ }
+
+ rc = setString(env, &obj, "target", target);
+ if (rc < 0) {
+ fprintf(stderr, "setString dirName=%s target=%s failed\n",
+ dirName, target);
+ }
+ } else {
+ (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
+ }
}
fid = (*env)->GetFieldID(env, thisClass, "isMountPoint", "Z");
if (fid == 0) {
- fprintf(stderr,
- "File::setAttributes(): GetFieldID (isMountPoint) failed\n");
- setError(env, &obj, -1);
- return JNI_FALSE;
+ fprintf(stderr,
+ "File::setAttributes(): GetFieldID (isMountPoint) failed\n");
+ setError(env, &obj, -1);
+ return JNI_FALSE;
}
if (mtpoint) {
- (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
+ (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
} else {
- (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
+ (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
}
fid = (*env)->GetFieldID(env, thisClass, "lastModified", "J");
if (fid == 0) {
- fprintf(stderr,
- "File::setAttributes(): GetFieldID (lastModified) failed\n");
- setError(env, &obj, -1);
- return JNI_FALSE;
+ fprintf(stderr,
+ "File::setAttributes(): GetFieldID (lastModified) failed\n");
+ setError(env, &obj, -1);
+ return JNI_FALSE;
}
- (*env)->SetLongField(env, obj, fid, ((jlong) st.st_mtime)*1000);
+ (*env)->SetLongField(env, obj, fid, ((jlong) st.st_mtime) * 1000);
fid = (*env)->GetFieldID(env, thisClass, "length", "J");
if (fid == 0) {
- fprintf(stderr,
- "File::setAttributes(): GetFieldID (length) failed\n");
- setError(env, &obj, -1);
- return JNI_FALSE;
+ fprintf(stderr,
+ "File::setAttributes(): GetFieldID (length) failed\n");
+ setError(env, &obj, -1);
+ return JNI_FALSE;
}
(*env)->SetLongField(env, obj, fid, st.st_size);
*
* return permission/ACL mask
*/
-JNIEXPORT jint JNICALL Java_org_openafs_jafs_File_getRights
- (JNIEnv *env, jobject obj)
+JNIEXPORT jint JNICALL
+Java_org_openafs_jafs_File_getRights(JNIEnv * env, jobject obj)
{
char dirName[FILENAME_MAX];
jclass thisClass;
*dirName = '\0';
getAbsolutePath(env, &obj, dirName);
- if(*dirName == '\0') {
- fprintf(stderr, "File::getRights(): failed to get dirName\n");
- setError(env, &obj, -1);
- return JNI_FALSE;
+ if (*dirName == '\0') {
+ fprintf(stderr, "File::getRights(): failed to get dirName\n");
+ setError(env, &obj, -1);
+ return JNI_FALSE;
}
/*-Access Rights-
rights = 0;
afs_rights = uafs_getRights(dirName);
if (afs_rights < 0) {
- setError(env, &obj, errno);
- return -1;
+ setError(env, &obj, errno);
+ return -1;
}
-
+
if (afs_rights & PRSFS_READ)
- rights |= UAFS_READ;
+ rights |= UAFS_READ;
if (afs_rights & PRSFS_WRITE)
- rights |= UAFS_WRITE;
+ rights |= UAFS_WRITE;
if (afs_rights & PRSFS_INSERT)
- rights |= UAFS_INSERT;
+ rights |= UAFS_INSERT;
if (afs_rights & PRSFS_LOOKUP)
- rights |= UAFS_LOOKUP;
+ rights |= UAFS_LOOKUP;
if (afs_rights & PRSFS_DELETE)
- rights |= UAFS_DELETE;
+ rights |= UAFS_DELETE;
if (afs_rights & PRSFS_LOCK)
- rights |= UAFS_LOCK;
+ rights |= UAFS_LOCK;
if (afs_rights & PRSFS_ADMINISTER)
- rights |= UAFS_ADMIN;
-
+ rights |= UAFS_ADMIN;
+
return rights;
}
*
* return the directory handle
*/
-JNIEXPORT jlong JNICALL Java_org_openafs_jafs_File_listNative
- (JNIEnv *env, jobject obj, jobject buffer)
+JNIEXPORT jlong JNICALL
+Java_org_openafs_jafs_File_listNative(JNIEnv * env, jobject obj,
+ jobject buffer)
{
char dirName[FILENAME_MAX];
jclass arrayListClass;
struct usr_dirent *enp;
int i, dirSize;
- *dirName='\0';
+ *dirName = '\0';
getAbsolutePath(env, &obj, dirName);
- if(*dirName == '\0') {
- fprintf(stderr, "File::listNative(): failed to get dirName\n");
- setError(env, &obj, -1);
- return 0;
+ if (*dirName == '\0') {
+ fprintf(stderr, "File::listNative(): failed to get dirName\n");
+ setError(env, &obj, -1);
+ return 0;
}
arrayListClass = (*env)->GetObjectClass(env, buffer);
- if(arrayListClass == NULL) {
- fprintf(stderr, "File::listNative(): GetObjectClass failed\n");
- setError(env, &obj, -1);
- return 0;
- }
- addID = (*env) -> GetMethodID(env, arrayListClass, "add",
- "(Ljava/lang/Object;)Z");
- if(addID == 0) {
- fprintf(stderr,
- "File::listNative(): failed to get addID\n");
- setError(env, &obj, -1);
- return 0;
+ if (arrayListClass == NULL) {
+ fprintf(stderr, "File::listNative(): GetObjectClass failed\n");
+ setError(env, &obj, -1);
+ return 0;
+ }
+ addID =
+ (*env)->GetMethodID(env, arrayListClass, "add",
+ "(Ljava/lang/Object;)Z");
+ if (addID == 0) {
+ fprintf(stderr, "File::listNative(): failed to get addID\n");
+ setError(env, &obj, -1);
+ return 0;
}
dirp = uafs_opendir(dirName);
- if(dirp == NULL) {
- fprintf(stderr, "File::listNative(): uafs_opendir(%s) failed(%s)\n",
- dirName, error_message(errno));
- setError(env, &obj, errno);
- //throwAFSSecurityException( env, errno );
- return 0;
- }
- while((enp = uafs_readdir(dirp)) != NULL) {
- if(strcmp(enp->d_name, ".") == 0 || strcmp(enp->d_name, "..") == 0) {
- continue;
+ if (dirp == NULL) {
+ fprintf(stderr, "File::listNative(): uafs_opendir(%s) failed(%s)\n",
+ dirName, error_message(errno));
+ setError(env, &obj, errno);
+ //throwAFSSecurityException( env, errno );
+ return 0;
+ }
+ while ((enp = uafs_readdir(dirp)) != NULL) {
+ if (strcmp(enp->d_name, ".") == 0 || strcmp(enp->d_name, "..") == 0) {
+ continue;
}
- entryJString = (*env) -> NewStringUTF(env, enp->d_name);
- if(entryJString == NULL) {
- fprintf(stderr, "File::listNative(): NewStringUTF failed\n");
- setError(env, &obj, -1);
- return 0;
- }
- (*env) -> CallBooleanMethod(env, buffer, addID, entryJString);
+ entryJString = (*env)->NewStringUTF(env, enp->d_name);
+ if (entryJString == NULL) {
+ fprintf(stderr, "File::listNative(): NewStringUTF failed\n");
+ setError(env, &obj, -1);
+ return 0;
+ }
+ (*env)->CallBooleanMethod(env, buffer, addID, entryJString);
}
- /*uafs_closedir(dirp);*/
+ /*uafs_closedir(dirp); */
setError(env, &obj, 0);
*
* return true if the directory closes without error
*/
-JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_closeDir
- (JNIEnv *env, jobject obj, jlong dp)
+JNIEXPORT jboolean JNICALL
+Java_org_openafs_jafs_File_closeDir(JNIEnv * env, jobject obj, jlong dp)
{
- usr_DIR *dirp = (usr_DIR *) dp;
- int rc;
-
- rc = uafs_closedir(dirp);
- if (rc < 0) {
- setError(env, &obj, errno);
- return JNI_FALSE;
- } else {
- return JNI_TRUE;
- }
+ usr_DIR *dirp = (usr_DIR *) dp;
+ int rc;
+
+ rc = uafs_closedir(dirp);
+ if (rc < 0) {
+ setError(env, &obj, errno);
+ return JNI_FALSE;
+ } else {
+ return JNI_TRUE;
+ }
}
*
* return true if the file is removed without error
*/
-JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_rmfile
- (JNIEnv *env, jobject obj)
+JNIEXPORT jboolean JNICALL
+Java_org_openafs_jafs_File_rmfile(JNIEnv * env, jobject obj)
{
char dirName[FILENAME_MAX];
int rc;
- *dirName='\0';
+ *dirName = '\0';
getAbsolutePath(env, &obj, dirName);
- if(*dirName == '\0') {
- setError(env, &obj, EINVAL);
- fprintf(stderr, "File::rmfile(): failed to get dirName\n");
- return JNI_FALSE;
+ if (*dirName == '\0') {
+ setError(env, &obj, EINVAL);
+ fprintf(stderr, "File::rmfile(): failed to get dirName\n");
+ return JNI_FALSE;
}
rc = uafs_unlink(dirName);
- if(rc < 0) {
- setError(env, &obj, errno);
- fprintf(stderr, "File::rmfile(): uafs_unlink failed\n");
- return JNI_FALSE;
+ if (rc < 0) {
+ setError(env, &obj, errno);
+ fprintf(stderr, "File::rmfile(): uafs_unlink failed\n");
+ return JNI_FALSE;
}
setError(env, &obj, 0);
return JNI_TRUE;
*
* return true if the directory is removed without error
*/
-JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_rmdir
- (JNIEnv *env, jobject obj)
+JNIEXPORT jboolean JNICALL
+Java_org_openafs_jafs_File_rmdir(JNIEnv * env, jobject obj)
{
char dirName[FILENAME_MAX];
int rc;
- *dirName='\0';
+ *dirName = '\0';
getAbsolutePath(env, &obj, dirName);
- if(*dirName == '\0') {
- setError(env, &obj, -1);
- fprintf(stderr, "File::rmdir(): failed to get dirName\n");
- return JNI_FALSE;
+ if (*dirName == '\0') {
+ setError(env, &obj, -1);
+ fprintf(stderr, "File::rmdir(): failed to get dirName\n");
+ return JNI_FALSE;
}
rc = uafs_rmdir(dirName);
- if(rc < 0) {
- setError(env, &obj, errno);
- fprintf(stderr, "File::rmdir(): uafs_unlink failed\n");
- return JNI_FALSE;
+ if (rc < 0) {
+ setError(env, &obj, errno);
+ fprintf(stderr, "File::rmdir(): uafs_unlink failed\n");
+ return JNI_FALSE;
}
setError(env, &obj, 0);
return JNI_TRUE;
* return true if and only if the directory was
* created; false otherwise
*/
-JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_mkdir
- (JNIEnv *env, jobject obj)
+JNIEXPORT jboolean JNICALL
+Java_org_openafs_jafs_File_mkdir(JNIEnv * env, j