Skip to content

Commit

Permalink
Merge pull request #365 from zowe/v2.x/staging
Browse files Browse the repository at this point in the history
Merge staging into RC
  • Loading branch information
1000TurquoisePogs authored Mar 13, 2023
2 parents fc86523 + af6a1ad commit dcf61e4
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Zowe Common C Changelog

## `2.8.0`

- Bugfix: `fileCopy` would not work when convert encoding was not requested. The destination file would be created, but without the requested content.

## `2.5.0`

- Added embeddedjs command "xplatform.appendFileUTF8" for appending to files rather than writing whole files.
Expand Down
14 changes: 10 additions & 4 deletions c/httpfileservice.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,12 @@ void copyUnixDirectoryAndRespond(HttpResponse *response, char *oldAbsolutePath,
case RC_HTTP_FILE_SERVICE_NOT_FOUND:
respondWithJsonError(response, "Directory not found", 404, "Not Found");
break;
default:
respondWithJsonError(response, "Failed to copy a directory", 500, "Internal Server Error");
default: {
char error[64];
snprintf(error, 64, "Error copying directory, rc=%d", returnCode);
respondWithJsonError(response, error, 500, "Internal Server Error");
break;
}
}
}
}
Expand Down Expand Up @@ -593,9 +596,12 @@ void copyUnixFileAndRespond(HttpResponse *response, char *oldAbsolutePath, char
case RC_HTTP_FILE_SERVICE_NOT_FOUND:
respondWithJsonError(response, "File not found", 404, "Not Found");
break;
default:
respondWithJsonError(response, "Failed to copy a file", 500, "Internal Server Error");
default: {
char error[64];
snprintf(error, 64, "Error copying file, rc=%d", returnCode);
respondWithJsonError(response, error, 500, "Internal Server Error");
break;
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion c/httpserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -4979,7 +4979,6 @@ void parseURLMask(HttpService *service, char *urlMask){

if (strcmp(urlMask,"/")){
while ((slashPos = indexOf(urlMask,len,'/',prevSlashPos+1)) != -1){
zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG3, "wow\n");
int partLen = slashPos - prevSlashPos;
char *part = (char*) safeMalloc(NORMALIZED_PART_LENGTH, "urlMask part");
zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG3, "parse URL mask loop top len=%d slashPos=%d prevSlashPos=%d partLen=%d\n",
Expand Down
13 changes: 13 additions & 0 deletions c/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,23 @@ jsonPrinter *makeCustomUtf8JsonPrinter(void (*writeMethod)(jsonPrinter *, char *
return p;
}

jsonPrinter *makeCustomNativeJsonPrinter(void (*writeMethod)(jsonPrinter *, char *, int),
void *object, int inputCCSID) {
jsonPrinter *p = makeCustomJsonPrinter(writeMethod, object);

p->mode = JSON_MODE_NATIVE_CHARSET;
p->inputCCSID = inputCCSID;
return p;
}

jsonPrinter *makeBufferJsonPrinter(int inputCCSID, JsonBuffer *buf) {
return makeCustomUtf8JsonPrinter(&writeToBuffer, buf, inputCCSID);
}

jsonPrinter *makeBufferNativeJsonPrinter(int inputCCSID, JsonBuffer *buf) {
return makeCustomNativeJsonPrinter(&writeToBuffer, buf, inputCCSID);
}

void jsonEnablePrettyPrint(jsonPrinter *p) {
p->prettyPrint = TRUE;
}
Expand Down
19 changes: 10 additions & 9 deletions c/zosfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ int fileCopyConverted(const char *existingFileName, const char *newFileName,
char *fileBuffer = safeMalloc(FILE_BUFFER_SIZE,"fileCopyBuffer");
int conversionBufferLength = FILE_BUFFER_SIZE * MAX_CONVERT_FACTOR;
char *conversionBuffer = (shouldConvert ? safeMalloc(conversionBufferLength,"fileCopyConvertBuffer"): NULL);
char *writeBuffer = (shouldConvert ? conversionBuffer : writeBuffer);
char *writeBuffer = (shouldConvert ? conversionBuffer : fileBuffer);
int writeLength;
int returnValue = 0;

Expand All @@ -680,14 +680,15 @@ int fileCopyConverted(const char *existingFileName, const char *newFileName,
} else {
writeLength = bytesRead;
}

status = fileWrite(newFile, writeBuffer, writeLength, &returnCode, &reasonCode);
if (status == -1) {
*retCode = returnCode;
*resCode = reasonCode;
returnValue = -1;
goto cleanup;
}
if (bytesRead > 0) {
status = fileWrite(newFile, writeBuffer, writeLength, &returnCode, &reasonCode);
if (status == -1) {
*retCode = returnCode;
*resCode = reasonCode;
returnValue = -1;
goto cleanup;
}
}
} while (bytesRead != 0);

status = fileClose(existingFile, &returnCode, &reasonCode);
Expand Down
5 changes: 5 additions & 0 deletions h/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ jsonPrinter *makeCustomJsonPrinter(void (*writeMethod)(jsonPrinter *,char *,int)
jsonPrinter *makeCustomUtf8JsonPrinter(
void (*writeMethod)(jsonPrinter *, char *, int), void *object,
int inputCCSID);
jsonPrinter *makeCustomNativeJsonPrinter(
void (*writeMethod)(jsonPrinter *, char *, int), void *object,
int inputCCSID);

/**
* \brief Reset a printer to its starting state.
Expand All @@ -97,6 +100,8 @@ void jsonPrinterReset(jsonPrinter *printer);

jsonPrinter *makeBufferJsonPrinter(int inputCCSID, JsonBuffer *buf);

jsonPrinter *makeBufferNativeJsonPrinter(int inputCCSID, JsonBuffer *buf);

/**
* \brief This will change the JSON printing to generate newlines and indentation to make the output human-friendly.
*
Expand Down

0 comments on commit dcf61e4

Please sign in to comment.