update ColumnLimit to match STYLE.md

This commit is contained in:
2026-03-07 16:49:21 -06:00
parent 5ca28bf334
commit 54ba2d8067
4 changed files with 19 additions and 30 deletions

View File

@@ -3,6 +3,7 @@
"UseTab": "Always", "UseTab": "Always",
"IndentWidth": 8, "IndentWidth": 8,
"TabWidth": 8, "TabWidth": 8,
"ColumnLimit": 120,
"LineEnding": "LF", "LineEnding": "LF",
"RemoveBracesLLVM": true, "RemoveBracesLLVM": true,
"AlwaysBreakAfterReturnType": "AllDefinitions", "AlwaysBreakAfterReturnType": "AllDefinitions",

View File

@@ -3,6 +3,7 @@
"UseTab": "Always", "UseTab": "Always",
"IndentWidth": 8, "IndentWidth": 8,
"TabWidth": 8, "TabWidth": 8,
"ColumnLimit": 120,
"LineEnding": "LF", "LineEnding": "LF",
"RemoveBracesLLVM": true, "RemoveBracesLLVM": true,
"AlwaysBreakAfterReturnType": "AllDefinitions", "AlwaysBreakAfterReturnType": "AllDefinitions",

View File

@@ -4,6 +4,7 @@ BasedOnStyle: LLVM # defaults
UseTab: Always UseTab: Always
IndentWidth: 8 IndentWidth: 8
TabWidth: 8 TabWidth: 8
ColumnLimit: 120
LineEnding: LF # unix LineEnding: LF # unix
RemoveBracesLLVM: true # single-statement blocks RemoveBracesLLVM: true # single-statement blocks

View File

@@ -30,7 +30,7 @@ const int DEFAULT_CUR_X = 2; // the x position of the preferred default cursor
const int DEFAULT_CUR_Y = 12; // the x position of the preferred default cursor const int DEFAULT_CUR_Y = 12; // the x position of the preferred default cursor
// position for message entry // position for message entry
int mode = 0; // what mode is this program in. 0 = nothing. 1 = server. 2 = client int mode = 0; // what mode is this program in. 0 = nothing. 1 = server. 2 = client
int serverSocketDescriptor; // a global variable for storing the server socket int serverSocketDescriptor; // a global variable for storing the server socket
// descriptor. // descriptor.
int clientSocketDescriptor; int clientSocketDescriptor;
@@ -44,7 +44,7 @@ struct timeval start1, end1;
int bytesRead, bytesWritten = 0; int bytesRead, bytesWritten = 0;
const int LOG_LENGTH = 10; // number of text log file lines to display const int LOG_LENGTH = 10; // number of text log file lines to display
int linePos = 0; // counter for what current position to use in the file int linePos = 0; // counter for what current position to use in the file
string logFileName; // the name of the log file string logFileName; // the name of the log file
@@ -86,10 +86,8 @@ displayFile(string path, int startLineNum = 0, int numLines = 10)
// print each line directly to the screen // print each line directly to the screen
int num = 0; int num = 0;
while (getline(file, line) && while (getline(file, line) && num <= numLines + startLineNum + 1) // while there is file content and the
num <= numLines + startLineNum + // line number isn't too high
1) // while there is file content and the line
// number isn't too high
{ {
if (num >= startLineNum) { if (num >= startLineNum) {
move(lineNum, 0); move(lineNum, 0);
@@ -134,9 +132,7 @@ void *
waitForClient(void *argss) waitForClient(void *argss)
{ {
waitClientArgs *args = static_cast<waitClientArgs *>(argss); waitClientArgs *args = static_cast<waitClientArgs *>(argss);
clientSocketDescriptor = clientSocketDescriptor = accept(serverSocketDescriptor, (sockaddr *)&args->newSockAddr, &args->newSockAddrSize);
accept(serverSocketDescriptor, (sockaddr *)&args->newSockAddr,
&args->newSockAddrSize);
if (clientSocketDescriptor >= 0) { if (clientSocketDescriptor >= 0) {
writeToFile(logFileName, "client connected"); writeToFile(logFileName, "client connected");
if (linesInFile(logFileName) > LOG_LENGTH) if (linesInFile(logFileName) > LOG_LENGTH)
@@ -155,8 +151,7 @@ pollForClient()
while (1) { while (1) {
// receive a message from the client (listen) // receive a message from the client (listen)
memset(&msg, 0, sizeof(msg)); // clear the buffer memset(&msg, 0, sizeof(msg)); // clear the buffer
bytesRead += bytesRead += recv(clientSocketDescriptor, (char *)&msg, sizeof(msg), 0);
recv(clientSocketDescriptor, (char *)&msg, sizeof(msg), 0);
writeToFile(logFileName, writeToFile(logFileName,
msg); // write the client's message to file msg); // write the client's message to file
if (linesInFile(logFileName) > LOG_LENGTH) if (linesInFile(logFileName) > LOG_LENGTH)
@@ -189,8 +184,7 @@ setupServer(int port)
exit(0); exit(0);
} }
// bind the socket to its local address // bind the socket to its local address
int bindStatus = bind(serverSocketDescriptor, int bindStatus = bind(serverSocketDescriptor, (struct sockaddr *)&servAddr, sizeof(servAddr));
(struct sockaddr *)&servAddr, sizeof(servAddr));
if (bindStatus < 0) { if (bindStatus < 0) {
// keeps from bricking the terminal if this happens // keeps from bricking the terminal if this happens
endwin(); endwin();
@@ -210,8 +204,7 @@ setupServer(int port)
auto *aaa = new waitClientArgs{}; // it looks stupid but it works auto *aaa = new waitClientArgs{}; // it looks stupid but it works
aaa->newSockAddr = newSockAddr; aaa->newSockAddr = newSockAddr;
aaa->newSockAddrSize = newSockAddrSize; aaa->newSockAddrSize = newSockAddrSize;
int rc = int rc = pthread_create(&client_wait_thread, nullptr, waitForClient, aaa);
pthread_create(&client_wait_thread, nullptr, waitForClient, aaa);
pthread_detach(client_wait_thread); pthread_detach(client_wait_thread);
writeToFile(logFileName, "Server started sucessfully"); writeToFile(logFileName, "Server started sucessfully");
gettimeofday(&start1, NULL); gettimeofday(&start1, NULL);
@@ -258,8 +251,7 @@ pollForSever(void *args)
char msg[1024]; char msg[1024];
while (1) { while (1) {
memset(&msg, 0, sizeof(msg)); // clear the buffer memset(&msg, 0, sizeof(msg)); // clear the buffer
bytesRead += bytesRead += recv(socketDescriptor, (char *)&msg, sizeof(msg), 0);
recv(socketDescriptor, (char *)&msg, sizeof(msg), 0);
// not needed for proofs of concept testing // not needed for proofs of concept testing
/*if(!strcmp(msg, "exit")) /*if(!strcmp(msg, "exit"))
@@ -292,13 +284,11 @@ setupClient()
sockaddr_in sendSockAddr; sockaddr_in sendSockAddr;
bzero((char *)&sendSockAddr, sizeof(sendSockAddr)); bzero((char *)&sendSockAddr, sizeof(sendSockAddr));
sendSockAddr.sin_family = AF_INET; sendSockAddr.sin_family = AF_INET;
sendSockAddr.sin_addr.s_addr = sendSockAddr.sin_addr.s_addr = inet_addr(inet_ntoa(*(struct in_addr *)*host->h_addr_list));
inet_addr(inet_ntoa(*(struct in_addr *)*host->h_addr_list));
sendSockAddr.sin_port = htons(PORT_NUM); sendSockAddr.sin_port = htons(PORT_NUM);
clientSocketDescriptor = socket(AF_INET, SOCK_STREAM, 0); clientSocketDescriptor = socket(AF_INET, SOCK_STREAM, 0);
// try to connect... // try to connect...
int status = connect(clientSocketDescriptor, (sockaddr *)&sendSockAddr, int status = connect(clientSocketDescriptor, (sockaddr *)&sendSockAddr, sizeof(sendSockAddr));
sizeof(sendSockAddr));
if (status < 0) if (status < 0)
writeToFile(logFileName, "Error connecting to socket!"); writeToFile(logFileName, "Error connecting to socket!");
writeToFile(logFileName, "Connected to the server!"); writeToFile(logFileName, "Connected to the server!");
@@ -307,8 +297,7 @@ setupClient()
gettimeofday(&start1, NULL); gettimeofday(&start1, NULL);
auto *aaa = new waitClientArgs{}; // it looks stupid but it works auto *aaa = new waitClientArgs{}; // it looks stupid but it works
aaa->auxInt = clientSocketDescriptor; aaa->auxInt = clientSocketDescriptor;
int rc = int rc = pthread_create(&client_wait_thread, nullptr, pollForSever, aaa);
pthread_create(&client_wait_thread, nullptr, pollForSever, aaa);
pthread_detach(client_wait_thread); pthread_detach(client_wait_thread);
} }
@@ -384,13 +373,10 @@ main(int argc, char *argv[])
printw("> "); printw("> ");
getstr(userInput); getstr(userInput);
writeToFile(logFileName, userInput); writeToFile(logFileName, userInput);
if (mode == 1) { if (mode == 1)
send(clientSocketDescriptor, (char *)userInput, send(clientSocketDescriptor, (char *)userInput, strlen(userInput), 0);
strlen(userInput), 0); else
} else { send(clientSocketDescriptor, (char *)userInput, strlen(userInput), 0);
send(clientSocketDescriptor, (char *)userInput,
strlen(userInput), 0);
}
} }
endwin(); endwin();