tab replaced with spaces

This commit is contained in:
vysheng 2013-10-03 20:10:53 +04:00
parent 9c70da9ed7
commit f773c0cf18
3 changed files with 34 additions and 34 deletions

View File

@ -115,11 +115,11 @@ char *command_generator (const char *text, int state) {
index = -1; index = -1;
rl_line_buffer[rl_point] = '\0'; /* the effect should be such rl_line_buffer[rl_point] = '\0'; /* the effect should be such
* that the cursor position * that the cursor position
* is at the end of line for * is at the end of line for
* the auto completion regex * the auto completion regex
* above (note the $ at end) * above (note the $ at end)
*/ */
mode = get_complete_mode (); mode = get_complete_mode ();
} else { } else {

30
loop.c
View File

@ -26,25 +26,25 @@ int main_loop (void) {
FD_SET (0, &inp); FD_SET (0, &inp);
tv.tv_sec = 1; tv.tv_sec = 1;
tv.tv_usec = 0; tv.tv_usec = 0;
int lfd = 0; int lfd = 0;
if (select (lfd + 1, &inp, &outp, NULL, &tv) < 0) { if (select (lfd + 1, &inp, &outp, NULL, &tv) < 0) {
if (errno == EINTR) { if (errno == EINTR) {
/* resuming from interrupt, so not an error situation, /* resuming from interrupt, so not an error situation,
this generally happens when you suspend your this generally happens when you suspend your
messenger with "C-z" and then "fg". This is allowed " messenger with "C-z" and then "fg". This is allowed "
*/ */
rl_reset_line_state (); rl_reset_line_state ();
rl_forced_update_display (); rl_forced_update_display ();
continue; continue;
} }
perror ("select()"); perror ("select()");
break; break;
} }
if (FD_ISSET (0, &inp)) { if (FD_ISSET (0, &inp)) {
rl_callback_read_char (); rl_callback_read_char ();
} }
} }
return 0; return 0;
@ -57,9 +57,9 @@ int loop (void) {
if (!user && !auth_token) { if (!user && !auth_token) {
printf ("Telephone number (with '+' sign): "); printf ("Telephone number (with '+' sign): ");
if (getline (&user, &size, stdin) == -1) { if (getline (&user, &size, stdin) == -1) {
perror ("getline()"); perror ("getline()");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
user[strlen (user) - 1] = '\0'; user[strlen (user) - 1] = '\0';
set_default_username (user); set_default_username (user);
} }

28
main.c
View File

@ -93,7 +93,7 @@ char *get_config_directory (void) {
config_directory = (char *) calloc (length, sizeof (char)); config_directory = (char *) calloc (length, sizeof (char));
sprintf (config_directory, "%s/" CONFIG_DIRECTORY, sprintf (config_directory, "%s/" CONFIG_DIRECTORY,
get_home_directory ()); get_home_directory ());
return config_directory; return config_directory;
} }
@ -136,26 +136,26 @@ void running_for_first_time (void) {
if (stat (config_filename, config_file_stat) != 0) { if (stat (config_filename, config_file_stat) != 0) {
// config file missing, so touch it // config file missing, so touch it
config_file_fd = open (config_filename, O_CREAT | O_RDWR, S_IRWXU); config_file_fd = open (config_filename, O_CREAT | O_RDWR, S_IRWXU);
if (config_file_fd == -1) { if (config_file_fd == -1) {
perror ("open[config_file]"); perror ("open[config_file]");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
if (fchmod (config_file_fd, CONFIG_DIRECTORY_MODE) != 0) { if (fchmod (config_file_fd, CONFIG_DIRECTORY_MODE) != 0) {
perror ("fchmod[" CONFIG_FILE "]"); perror ("fchmod[" CONFIG_FILE "]");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
if (write (config_file_fd, DEFAULT_CONFIG_CONTENTS, strlen (DEFAULT_CONFIG_CONTENTS)) <= 0) { if (write (config_file_fd, DEFAULT_CONFIG_CONTENTS, strlen (DEFAULT_CONFIG_CONTENTS)) <= 0) {
perror ("write[config_file]"); perror ("write[config_file]");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
close (config_file_fd); close (config_file_fd);
printf ("[%s] created\n", config_filename); printf ("[%s] created\n", config_filename);
/* create downloads directory */ /* create downloads directory */
if (mkdir (downloads_directory, 0755) !=0) { if (mkdir (downloads_directory, 0755) !=0) {
perror ("creating download directory"); perror ("creating download directory");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
} }
set_setup_mode (); set_setup_mode ();