feat(landerctl): implement placeholder requests
							parent
							
								
									b833d0ed74
								
							
						
					
					
						commit
						bdbc750f7f
					
				| 
						 | 
					@ -34,6 +34,7 @@ typedef enum landerctl_mode {
 | 
				
			||||||
  landerctl_mode_short,
 | 
					  landerctl_mode_short,
 | 
				
			||||||
  landerctl_mode_paste,
 | 
					  landerctl_mode_paste,
 | 
				
			||||||
  landerctl_mode_file,
 | 
					  landerctl_mode_file,
 | 
				
			||||||
 | 
					  landerctl_mode_placeholder,
 | 
				
			||||||
} landerctl_mode;
 | 
					} landerctl_mode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -64,6 +65,7 @@ int landerctl_parse_args(landerctl_args *out, int argc, char **argv);
 | 
				
			||||||
int landerctl_cmd_short(landerctl_args *args);
 | 
					int landerctl_cmd_short(landerctl_args *args);
 | 
				
			||||||
int landerctl_cmd_paste(landerctl_args *args);
 | 
					int landerctl_cmd_paste(landerctl_args *args);
 | 
				
			||||||
int landerctl_cmd_file(landerctl_args *args);
 | 
					int landerctl_cmd_file(landerctl_args *args);
 | 
				
			||||||
 | 
					int landerctl_cmd_placeholder(landerctl_args *args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Initialize a CURL object
 | 
					 * Initialize a CURL object
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,7 +55,7 @@ int landerctl_parse_args(landerctl_args *args, int argc, char **argv) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const char *cfg_path = NULL;
 | 
					  const char *cfg_path = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  while ((c = getopt(argc, argv, "SPFsvc:")) != -1) {
 | 
					  while ((c = getopt(argc, argv, "SPFHsvc:")) != -1) {
 | 
				
			||||||
    switch (c) {
 | 
					    switch (c) {
 | 
				
			||||||
    case 'S':
 | 
					    case 'S':
 | 
				
			||||||
      args->mode = landerctl_mode_short;
 | 
					      args->mode = landerctl_mode_short;
 | 
				
			||||||
| 
						 | 
					@ -66,6 +66,9 @@ int landerctl_parse_args(landerctl_args *args, int argc, char **argv) {
 | 
				
			||||||
    case 'F':
 | 
					    case 'F':
 | 
				
			||||||
      args->mode = landerctl_mode_file;
 | 
					      args->mode = landerctl_mode_file;
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					    case 'H':
 | 
				
			||||||
 | 
					      args->mode = landerctl_mode_placeholder;
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
    case 's':
 | 
					    case 's':
 | 
				
			||||||
      args->secure = true;
 | 
					      args->secure = true;
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -145,3 +145,30 @@ int landerctl_cmd_file(landerctl_args *args) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return res;
 | 
					  return res;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int landerctl_cmd_placeholder(landerctl_args *args) {
 | 
				
			||||||
 | 
					  // TODO argument count check
 | 
				
			||||||
 | 
					  int res;
 | 
				
			||||||
 | 
					  landerctl_curl curl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if ((res = landerctl_curl_init(&curl))) {
 | 
				
			||||||
 | 
					    return res;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const char *key = args->args.arr[0];
 | 
				
			||||||
 | 
					  if ((res = landerctl_curl_set_common(&curl, args, key))) {
 | 
				
			||||||
 | 
					    return res;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  curl_easy_setopt(curl.curl, CURLOPT_POST, 1L);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  res = landerctl_curl_perform(&curl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (res == 0) {
 | 
				
			||||||
 | 
					    landerctl_curl_inspect(&curl, args);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  landerctl_curl_cleanup(&curl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return res;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,6 +43,9 @@ int landerctl_curl_set_common(landerctl_curl *curl, landerctl_args *args,
 | 
				
			||||||
  case landerctl_mode_file:
 | 
					  case landerctl_mode_file:
 | 
				
			||||||
    mode_char = 'f';
 | 
					    mode_char = 'f';
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
 | 
					  case landerctl_mode_placeholder:
 | 
				
			||||||
 | 
					    mode_char = 'h';
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
  // Shouldn't be able  to happen
 | 
					  // Shouldn't be able  to happen
 | 
				
			||||||
  default:
 | 
					  default:
 | 
				
			||||||
    return 10;
 | 
					    return 10;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,6 +25,9 @@ int main(int argc, char **argv) {
 | 
				
			||||||
  case landerctl_mode_file:
 | 
					  case landerctl_mode_file:
 | 
				
			||||||
    res = landerctl_cmd_file(&args);
 | 
					    res = landerctl_cmd_file(&args);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
 | 
					  case landerctl_mode_placeholder:
 | 
				
			||||||
 | 
					    res = landerctl_cmd_placeholder(&args);
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
  default:
 | 
					  default:
 | 
				
			||||||
    res = 7;
 | 
					    res = 7;
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue