mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 08:26:01 +01:00
Remove obsolete print completion
This commit is contained in:
parent
196c6d2fd6
commit
032af18f36
2 changed files with 0 additions and 66 deletions
57
completion.c
57
completion.c
|
@ -8,63 +8,6 @@
|
||||||
#include "completion.h"
|
#include "completion.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
girara_completion_t*
|
|
||||||
cc_print(girara_session_t* session, char* input)
|
|
||||||
{
|
|
||||||
girara_completion_t* completion = girara_completion_init();
|
|
||||||
girara_completion_group_t* group = girara_completion_group_create(session, NULL);
|
|
||||||
|
|
||||||
if (!session || !input || !completion || !group)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
girara_completion_add_group(completion, group);
|
|
||||||
|
|
||||||
char* const list_printers[] = {
|
|
||||||
"lpstat", "-v", NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
char* output;
|
|
||||||
if (!execute_command(list_printers, &output)) {
|
|
||||||
girara_completion_free(completion);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* parse single lines */
|
|
||||||
unsigned int prefix_length = strlen("device for ");
|
|
||||||
char* p = strtok(output, "\n");
|
|
||||||
char* q;
|
|
||||||
|
|
||||||
while (p) {
|
|
||||||
if (!(p = strstr(p, "device for ")) || !(q = strchr(p, ':'))) {
|
|
||||||
p = strtok(NULL, "\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int printer_length = q - p - prefix_length;
|
|
||||||
char* printer_name = malloc(sizeof(char) * printer_length);
|
|
||||||
|
|
||||||
if (!printer_name) {
|
|
||||||
p = strtok(NULL, "\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(printer_name, p + prefix_length, printer_length - 1);
|
|
||||||
printer_name[printer_length - 1] = '\0';
|
|
||||||
|
|
||||||
/* add printer */
|
|
||||||
girara_completion_group_add_element(group, printer_name, NULL);
|
|
||||||
|
|
||||||
free(printer_name);
|
|
||||||
|
|
||||||
/* next line */
|
|
||||||
p = strtok(NULL, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
free(output);
|
|
||||||
|
|
||||||
return completion;
|
|
||||||
}
|
|
||||||
|
|
||||||
girara_completion_t*
|
girara_completion_t*
|
||||||
cc_open(girara_session_t* session, char* input)
|
cc_open(girara_session_t* session, char* input)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,15 +5,6 @@
|
||||||
|
|
||||||
#include <girara.h>
|
#include <girara.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* Completion for the print command. Creates a list of available printers
|
|
||||||
*
|
|
||||||
* @param session The used girara session
|
|
||||||
* @param input The current input
|
|
||||||
* @return The completion object or NULL if an error occured
|
|
||||||
*/
|
|
||||||
girara_completion_t* cc_print(girara_session_t* session, char* input);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Completion for the open command - Creates a list of accesible directories or
|
* Completion for the open command - Creates a list of accesible directories or
|
||||||
* files
|
* files
|
||||||
|
|
Loading…
Reference in a new issue