Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Aug 28, 2021
1 parent 053b19c commit f1e651e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 65 deletions.
12 changes: 5 additions & 7 deletions gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ int returnMessage(unsigned int code)
return 0;
}



static void writeflag(GtkWidget *widget, gpointer data)
{
logclear();
Expand Down Expand Up @@ -205,11 +203,11 @@ static void oneclick(GtkWidget *widget, gpointer data)
switch (installer_start()) {
case NO_AVAILABLE_FIRMWARE:
logprint("Your camera model has a working build,\n"
"but not for your firmware version.");
"but not for your firmware version.");
break;
case CAMERA_UNSUPPORTED:
logprint("Your camera model is not supported.\n"
"Come back in 5 years and check again.");
"Come back in 5 years and check again.");
break;
}
}
Expand All @@ -220,7 +218,7 @@ static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
return FALSE;
}

#define MENU_ADD_BUTTON(text, function, tip) \
#define MENU_ADD_BUTTON(text, function, tip) \
button = gtk_button_new_with_label(text); \
g_signal_connect(button, "clicked", G_CALLBACK(function), NULL); \
gtk_grid_attach(GTK_GRID(grid), button, 0, order++, 1, 1); \
Expand Down Expand Up @@ -360,7 +358,7 @@ int main(int argc, char *argv[])
label = gtk_label_new("Advanced");
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), grid, label);

#ifdef DEV
#ifdef DEV

grid = gtk_grid_new();
gtk_container_set_border_width(GTK_CONTAINER(grid), 10);
Expand All @@ -372,7 +370,7 @@ int main(int argc, char *argv[])
label = gtk_label_new("Quick Install");
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), grid, label);

#endif
#endif

logw = gtk_label_new(logbuf);
gtk_grid_attach(GTK_GRID(mainGrid), logw, 0, 2, 1, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/evproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int evproc_run(char string[])
} else {
r = ptp_runeventproc(&params, string, iparam);
}

close_camera(&ptp_usb, &params, dev);
return r;
}
110 changes: 55 additions & 55 deletions src/installer.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ struct Release {
char version[1024];
char description[1024];
char download_url[1024];
char forum_url[1024];
char forum_url[1024];
};

int find(struct Release *release, char name[], char version[]) {
int find(struct Release *release, char name[], char version[])
{
char buffer[1024];
FILE *f = fopen("ML_TEMP", "r");
if (f == NULL) {
Expand All @@ -44,21 +45,21 @@ int find(struct Release *release, char name[], char version[]) {
}

switch (order) {
case 0:
strcpy(release->name, buffer);
break;
case 1:
strcpy(release->version, buffer);
break;
case 2:
strcpy(release->description, buffer);
break;
case 3:
strcpy(release->download_url, buffer);
break;
case 4:
strcpy(release->forum_url, buffer);
break;
case 0:
strcpy(release->name, buffer);
break;
case 1:
strcpy(release->version, buffer);
break;
case 2:
strcpy(release->description, buffer);
break;
case 3:
strcpy(release->download_url, buffer);
break;
case 4:
strcpy(release->forum_url, buffer);
break;
}

order++;
Expand All @@ -78,23 +79,23 @@ int find(struct Release *release, char name[], char version[]) {
return CAMERA_UNSUPPORTED;
}

int download(char in[], char out[]) {
int download(char in[], char out[])
{
char command[512];

#ifdef WIN32
snprintf(command, 512,
"certutil -urlcache -split -f \"%s\" %s", in, out);
#endif

#ifdef __unix__
snprintf(command, 512,
"curl -L -4 %s --output %s", in, out);
#endif
#ifdef WIN32
snprintf(command, 512, "certutil -urlcache -split -f \"%s\" %s", in, out);
#endif

#ifdef __unix__
snprintf(command, 512, "curl -L -4 %s --output %s", in, out);
#endif

return system(command);
}

int installer_start() {
int installer_start()
{
download("https://petabyt.dev/mlinstall_repo", "ML_TEMP");

struct Release release;
Expand All @@ -103,8 +104,7 @@ int installer_start() {
return r;
}

printf("Found a match for model/firmware version. Downloading\n%s\n",
release.download_url);
printf("Found a match for model/firmware version. Downloading\n%s\n", release.download_url);

printf("%s\n", release.download_url);
download(release.download_url, "ML_RELEASE.ZIP");
Expand All @@ -122,21 +122,22 @@ int installer_start() {
flag_usable_drive(file);

char command[512];
#ifdef __unix__
snprintf(command, 512, "unzip -o ML_RELEASE.ZIP -d %s", file);
#ifdef __unix__
snprintf(command, 512, "unzip -o ML_RELEASE.ZIP -d %s", file);
system(command);
#endif

#ifdef WIN32
FILE *test = fopen("C:\\Program Files\\7-Zip\\7z.exe", "r");
if (test == NULL) {
puts("!!!! 7z not found, unzip ML_RELEASE.ZIP onto card manually.");
} else {
fclose(test);
snprintf(command, 512, "C:\\Program Files\\7-Zip\\7z.exe x ML_RELEASE.ZIP -o %s",
file);
system(command);
#endif

#ifdef WIN32
FILE *test = fopen("C:\\Program Files\\7-Zip\\7z.exe", "r");
if (test == NULL) {
puts("!!!! 7z not found, unzip ML_RELEASE.ZIP onto card manually.");
} else {
fclose(test);
snprintf(command, 512, "C:\\Program Files\\7-Zip\\7z.exe x ML_RELEASE.ZIP -o %s", file);
system(command);
}
#endif
}
#endif

puts("Writing card flags...");
if (flag_write_flag(FLAG_BOOT)) {
Expand All @@ -155,7 +156,7 @@ int installer_start() {
PTPParams params;
PTP_USB ptp_usb;
struct usb_device *dev;

if (open_camera(busn, devn, force, &ptp_usb, &params, &dev) < 0) {
puts("Can't open PTP camera!");
return 1;
Expand All @@ -171,7 +172,8 @@ int installer_start() {
return 0;
}

int installer_remove() {
int installer_remove()
{
char command[512];

char input[5];
Expand All @@ -182,17 +184,15 @@ int installer_remove() {
}

char file[128];
flag_usable_drive(file);
flag_usable_drive(file);

#ifdef __unix__
snprintf(command, 512,
"rm -rf %s/autoexec.bin %s/ML", file, file);
#endif
#ifdef __unix__
snprintf(command, 512, "rm -rf %s/autoexec.bin %s/ML", file, file);
#endif

#ifdef WIN32
snprintf(command, 512,
"del %s/autoexec.bin %s/ML", file, file);
#endif
#ifdef WIN32
snprintf(command, 512, "del %s/autoexec.bin %s/ML", file, file);
#endif

printf("Will execute '%s'\n", command);
system(command);
Expand Down
4 changes: 2 additions & 2 deletions src/ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2267,8 +2267,8 @@ uint16_t ptp_runeventproc(PTPParams *params, char string[], unsigned int *iparam
ptp.Param5 = iparam[5];
}

printf("Length: %u: %u %u %u %u %u\n", ptp.Nparam, ptp.Param1,
ptp.Param2, ptp.Param3, ptp.Param4, ptp.Param5);
printf("Length: %u: %u %u %u %u %u\n", ptp.Nparam, ptp.Param1, ptp.Param2, ptp.Param3,
ptp.Param4, ptp.Param5);

ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, sizeof(command), &_command);

Expand Down

0 comments on commit f1e651e

Please sign in to comment.