Esempio n. 1
0
int test_yaffs_read_EINVAL(void)
{
	int error_code = 0;
	handle=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
	char text[2000000];
	int output=0;	
	
	if (handle<0){
		print_message("could not open file\n",2);
		return -1;
	}	

	/*there needs a large amout of test in the file in order to trigger EINVAL */
	output=test_yaffs_read_EINVAL_init();
	if (output<0){
		print_message("could not write text to the file\n",2);
		return -1; 
	}

	if (handle>=0){
		output=yaffs_read(handle, text, -1);
		if (output<0){ 
			error_code=yaffs_get_error();
			if (abs(error_code)== EINVAL){
				return 1;
			} else {
				print_message("different error than expected\n",2);
				return -1;
			}
		} else{
			print_message("read a negative number of bytes (which is a bad thing)\n",2);
			return -1;
		}
	} else {
		print_message("error opening file\n",2);
		return -1;
	}
}
Esempio n. 2
0
int
prep2_cb(tse_task_t *task, void *data)
{
	int *verify_cnt = *((int **)data);

	print_message("Prep2 CB: counter = %d\n", *verify_cnt);
	if (*verify_cnt != 1) {
		print_error("Failed verification of prep cb ordering\n");
		return -1;
	}

	*verify_cnt = *verify_cnt + 1;
	return 0;
}
Esempio n. 3
0
void exportData( const char *filename , 
		 const std::vector<double> & v1 ) 
{
  
  int max = v1.size();
  
  std::ofstream os;
  os.open(filename);
  
  if(!os.good()) {
    print_message("could not open output file.");
    print_message(filename);
    exit(1);
  }
  
  print_message("Exporting data:");
  
  os << "//Data values" << '\n';
  
  for (int i = 0; i < max; i++ ) os << v1[i] << '\n'; 
  
  
}
Esempio n. 4
0
int proc_led( int argc, char *argv[], byte first_param )
{
	if (argc < (first_param+1)) {
			printf( "No instance parameter.\n"); 
			return 0;
	}
	byte instance = atoi(argv[first_param+1]);

	printf("SYSTEM LEDS... instance=%d\n", instance );
	if (argc < (first_param+2)) {
			printf( "No LED mode parameter.\n"); 
			return 0;
	}
	if (strcmp(argv[first_param+2], "device") == 0) {
		printf("Device\n");
		pack_system_led( &msg1, instance, SYSTEM_LED_MODE_DEVICE, 0 );
	}
	if (strcmp(argv[first_param+2], "myInstance") == 0) {
		printf("Strobing\n");
		pack_system_led( &msg1, instance, SYSTEM_LED_MODE_MYINSTANCE, 0 );				
	} 
	else if (strcmp(argv[first_param+2], "strobe") == 0)
	{ 
		if (argc < (first_param+3)) {
				printf( "No LED on/off parameter.\n"); 
				return 0;
		}
		byte value;
		if (strcmp(argv[first_param+3], "on") == 0)
			value = 1;
		else if (strcmp(argv[first_param+3], "off") == 0)
			value = 0;
		else 
			value = atoi( argv[first_param+3] );
		pack_system_led( &msg1, instance, SYSTEM_LED_MODE_STROBE, value );
	}
	else if (strcmp(argv[first_param+2], "pattern") == 0)
	{
		if (argc < (first_param+3)) {
				printf( "No LED pattern parameter.\n"); 
				return 0;
		}
		printf("pattern: id=%d", ID_SYSTEM_LED_REQUEST );
		byte pattern = atoi( argv[first_param+3] );
		pack_system_led( &msg1, instance, SYSTEM_LED_MODE_PATTERN, pattern );
		print_message(&msg1);
	}
	AddToSendList( &msg1 );
	return 1;
}
int  test_yaffs_rename_file_over_file(void)
{

    int output=0;
    int error_code =0;

    if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1) {
        print_message("failed to create file\n",1);
        return -1;
    }
    if (yaffs_close(yaffs_open(FILE_PATH2,O_CREAT | O_RDWR, FILE_MODE))==-1) {
        print_message("failed to create file\n",1);
        return -1;
    }
    output = yaffs_rename(FILE_PATH ,FILE_PATH2 );
    if (output<0) {
        print_message("could not rename a file over a file (which is a bad thing)\n",2);
        return -1;
    }

    return 1;

}
Esempio n. 6
0
int test_yaffs_access_NULL(void)
{
	int output=0;
	int error=0;
	if (set_up_ELOOP()<0){
		print_message("failed to setup symlinks\n",2);
		return -1;
	}
	output= yaffs_access(NULL,0);
	if (output<0){
		error=yaffs_get_error();
		if ( abs(error)== EFAULT){
			return 1;
		} else {
			print_message("error does not match expected error\n",2);
			return -1;
		}
	} else{
		print_message("accessed an existing file with bad mode (which is a bad thing\n",2);

		return -1;
	}
}
int test_yaffs_mkdir_ELOOP_dir(void)
{
	int error_code = 0;

	if (set_up_ELOOP()<0){
		print_message("failed to setup symlinks\n",2);
		return -1;
	}

	output = yaffs_mkdir(ELOOP_PATH "/file",O_CREAT | O_RDWR);
	if (output < 0){
		error_code = yaffs_get_error();
		if (abs(error_code) == ELOOP){
			return 1;
		} else {
			print_message("different error than expected\n", 2);
			return -1;
		}
	} else {
		print_message("created a new directory on top of an non-existing directory (which is a bad thing)\n", 2);
		return -1;
	}
}
Esempio n. 8
0
static void torture_path_expand_tilde_win(void **state) {
    char *d;

    (void) state;

    d = ssh_path_expand_tilde("~\\.ssh");
    assert_false(d == NULL);
    print_message("Expanded path: %s\n", d);
    free(d);

    d = ssh_path_expand_tilde("/guru/meditation");
    assert_string_equal(d, "/guru/meditation");
    free(d);
}
Esempio n. 9
0
/******************************
 Routine:
 Description:
 ******************************/
void XferToRam(void)
{
	unsigned int temp;
	void (*entry_point) (void);

	cons_hook();

	print_message("Copying image from Flash to Ram.\n");
	for (temp = 0; temp < (0x100000 - 0x20000); temp = temp + 4) {
		*(volatile unsigned int *) (temp + 0xa0400000) =
		    *(volatile unsigned int *) (temp + srcAddr);
		if (*(volatile unsigned int *) (temp + 0xa0400000) !=
		    *(volatile unsigned int *) (temp + srcAddr)) {
			print_message
			    ("Error!: copy verification failed.\n");
			break;
		}
	}

	print_message("Now jumping to the code just xferred to ram.\n");
	entry_point = (void *) 0x80400000;
	entry_point();
}
Esempio n. 10
0
void play_press()
{
   struct disc_status status;
   
   if(!disc_present)
     return;
   
   cd_poll(cd_fd, &status);
   
   switch(status.status_mode) {
    case CDAUDIO_PLAYING:
      print_message("Paused");
      break;
    case CDAUDIO_PAUSED:
      print_message("Resuming");
      break;
    default:
      if(valid_cddb)
	printf_message("Playing track %d: %s", play_track, data.data_track[play_track - 1].track_name);
      else
	printf_message("Playing track %d", play_track);
   }
}
Esempio n. 11
0
/* Install the service */
int install_service(char *name, char *exe, char *flags) {
  /* Open service manager */
  SC_HANDLE services = open_service_manager();
  if (! services) {
    print_message(stderr, NSSM_MESSAGE_OPEN_SERVICE_MANAGER_FAILED);
    return 2;
  }

  /* Get path of this program */
  char path[MAX_PATH];
  GetModuleFileName(0, path, MAX_PATH);

  /* Construct command */
  char command[CMD_LENGTH];
  size_t pathlen = strlen(path);
  if (pathlen + 1 >= VALUE_LENGTH) {
    print_message(stderr, NSSM_MESSAGE_PATH_TOO_LONG, NSSM);
    return 3;
  }
  if (_snprintf(command, sizeof(command), "\"%s\"", path) < 0) {
    print_message(stderr, NSSM_MESSAGE_OUT_OF_MEMORY_FOR_IMAGEPATH);
    return 4;
  }

  /* Work out directory name */
  size_t len = strlen(exe);
  size_t i;
  for (i = len; i && exe[i] != '\\' && exe[i] != '/'; i--);
  char dir[MAX_PATH];
  memmove(dir, exe, i);
  dir[i] = '\0';

  /* Create the service */
  SC_HANDLE service = CreateService(services, name, name, SC_MANAGER_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, command, 0, 0, 0, 0, 0);
  if (! service) {
    print_message(stderr, NSSM_MESSAGE_CREATESERVICE_FAILED);
    CloseServiceHandle(services);
    return 5;
  }

  /* Now we need to put the parameters into the registry */
  if (create_parameters(name, exe, flags, dir)) {
    print_message(stderr, NSSM_MESSAGE_CREATE_PARAMETERS_FAILED);
    DeleteService(service);
    CloseServiceHandle(services);
    return 6;
  }

  set_service_recovery(service, name);

  /* Cleanup */
  CloseServiceHandle(service);
  CloseServiceHandle(services);

  print_message(stdout, NSSM_MESSAGE_SERVICE_INSTALLED, name);
  return 0;
}
Esempio n. 12
0
File: main.c Progetto: KurSh/crxprof
static waitres_t
do_wait(ptrace_context *ctx, bool blocked)
{
    int status, ret;
    do {
        ret = waitpid(ctx->pid, &status, blocked ? 0 : WNOHANG);

        if (ret == 0)
            return WR_NOTHING;

        if (ret == -1 && errno != EINTR)
            err(2, "waitpid failed");
    } while(ret < 0);

    assert(ret == ctx->pid) ;
    assert(!WIFCONTINUED(status));

    if (WIFEXITED(status)) {
        print_message("Traced process (%d) exited with code %d", ctx->pid, WEXITSTATUS(status));
        return WR_FINISHED;
    }
    if (WIFSIGNALED(status)) {
        print_message("Traced process (%d) terminated by signal %d (%s)", ctx->pid, 
            WTERMSIG(status), strsignal(WTERMSIG(status)));
        return WR_FINISHED;
    }

    assert(WIFSTOPPED(status));
    ctx->stop_signal = WSTOPSIG(status);

    if (ctx->stop_signal == SIGTSTP || 
        ctx->stop_signal == SIGTTIN || ctx->stop_signal == SIGTTOU) {
        return WR_NEED_DETACH;
    }
        
    return WR_STOPPED;
}
Esempio n. 13
0
void readData(const char *source,
	      std::vector<double> &v1,
	      std::vector<double> &v2,
	      std::vector<double> &v3)
{
  
  v1.clear();
  v2.clear();
  v3.clear();
  
  ifstream in;
  in.open(source);
  
  if(!in) {
    print_message("could not open input file.");
    print_message(source);
    exit(1);
  }
  
  print_message("opening files:");
  
  char comment[256];
  in.getline (comment,256);
  print_message(comment);
  
  while (1) {
    double x(0.), y(0.), z(0.);
    in >> x >> y >> z;
    if (!in.good()) break;
    v1.push_back(x);
    v2.push_back(y);
    v3.push_back(z);
  }    
  
  in.close();
  
}
Esempio n. 14
0
void getListOfFiles(const char *source, TList *fileNames, 
		    std::vector<double> &v1, std::vector<double> &v2)
{
  
  gROOT->Reset();
  
  ifstream in;
  in.open(source);
  
  if(!in) {
    print_message("could not open input file.");
    print_message(source);
    exit(1);
  }
  
  print_message("opening files:");
  
  char comment[256];
  in.getline (comment,256);
  print_message(comment);
  
  while (1) {
    char str[60];
    double x1(0.);
    double x2(0.);
    in >> str >> x1 >> x2;
    if (!in.good()) break;
    TString name(str);
    print_message(name.Data());
    fileNames->Add( TFile::Open(name.Data()) );
    v1.push_back(x1);
    v2.push_back(x2);
  }    
  
  in.close();
  
}
Esempio n. 15
0
int test_yaffs_read_EINVAL_init(void)
{
	int output=0;
	int x=0;
	
	int file_name_length=1000000;

	file_name = malloc(file_name_length);
	if(!file_name){
		print_message("unable to create file text\n",2);
		return -1;
	}
	
	strcpy(file_name,YAFFS_MOUNT_POINT);
	for (x=strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
		file_name[x]='a';
	}
	file_name[file_name_length-2]='\0';



	if (handle>=0){
		output= yaffs_write(handle, file_name, file_name_length-1);
		if (output<0){
			print_message("could not write text to file\n",2);
			return -1;
		} else {
			
			return 1;
		}

	} else {
		print_message("error opening file\n",2);
		return -1;
	}
	
}
static void torture_channel_read_error(void **state) {
    ssh_session session = *state;
    char *user = getenv("TORTURE_USER");
    ssh_channel channel;
    int rc;
    int i;

    if (user == NULL) {
        print_message("*** Please set the environment variable TORTURE_USER"
                      " to enable this test!!\n");
        return;
    }

    rc = ssh_options_set(session, SSH_OPTIONS_USER, user);
    assert_true(rc == SSH_OK);

    rc = ssh_connect(session);
    assert_true(rc == SSH_OK);

    rc = ssh_userauth_none(session,NULL);
    /* This request should return a SSH_REQUEST_DENIED error */
    if (rc == SSH_ERROR) {
        assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);
    }
    assert_true(ssh_auth_list(session) & SSH_AUTH_METHOD_PUBLICKEY);

    rc = ssh_userauth_autopubkey(session, NULL);
    assert_true(rc == SSH_AUTH_SUCCESS);

    channel = ssh_channel_new(session);
    assert_true(channel != NULL);

    rc = ssh_channel_open_session(channel);
    assert_true(rc == SSH_OK);

    rc = ssh_channel_request_exec(channel, "hexdump -C /dev/urandom");
    assert_true(rc == SSH_OK);

    /* send crap and for server to send us a disconnect */
    rc = write(ssh_get_fd(session),"AAAA", 4);
    assert_int_equal(rc, 4);

    for (i=0;i<20;++i){
        rc = ssh_channel_read(channel,buffer,sizeof(buffer),0);
        if (rc == SSH_ERROR)
            break;
    }
    assert_true(rc == SSH_ERROR);
}
Esempio n. 17
0
void listener(const orb_id_t &id, unsigned num_msgs, unsigned topic_instance, unsigned topic_interval)
{
	if (orb_exists(id, topic_instance) != 0) {
		printf("never published\n");
		return;
	}

	int sub = orb_subscribe_multi(id, topic_instance);
	orb_set_interval(sub, topic_interval);

	bool updated = false;
	unsigned i = 0;
	hrt_abstime start_time = hrt_absolute_time();

	while (i < num_msgs) {
		orb_check(sub, &updated);

		if (i == 0) {
			updated = true;

		} else {
			usleep(500);
		}

		if (updated) {
			start_time = hrt_absolute_time();
			i++;

			printf("\nTOPIC: %s instance %d #%d\n", id->o_name, topic_instance, i);

			T container;

			if (orb_copy(id, sub, &container) == PX4_OK) {
				print_message(container);

			} else {
				PX4_ERR("orb_copy failed");
			}

		} else {
			if (hrt_elapsed_time(&start_time) > 2 * 1000 * 1000) {
				printf("Waited for 2 seconds without a message. Giving up.\n");
				break;
			}
		}
	}

	orb_unsubscribe(sub);
}
Esempio n. 18
0
void sendData(ENC_ctx *ENC_ctx_sender, const unsigned char *input, const unsigned int input_size, message_ctx *ciphermessage)
{   if (PRINT_inputs_outputs){
        printf("\n-->Encrypt: %s\n", input);
        print_hex_memory(input, input_size);
        printf("\n");
    }

    CCM_encrypt(ciphermessage, ENC_ctx_sender, input, input_size);
    ciphermessage->tag=0xFF;

    if (PRINT_messages){
        print_message(ciphermessage);
        printf("\n");
    }
}
Esempio n. 19
0
int test_yaffs_rename_dir(void)
{
	int output=0;


	if (0 !=  yaffs_access(DIR_PATH,0)) {
		output = yaffs_mkdir(DIR_PATH,S_IREAD|S_IWRITE);
		if (output < 0) {
			print_message("failed to create file\n",2);
			return -1;
		}
	}
	output = yaffs_rename( DIR_PATH , RENAME_DIR_PATH);
	return output;	
}
Esempio n. 20
0
/* Client function
   Randomly chooses a port
   Randomly chooses a server port
   Sends message from that port
   Waits for reply on that port
   Recieves the messae and prints it 
   Then chooses another port
*/
void client(){
     int my_port;
     int server_port = (rand() % 2 == 1) ? SERVER_PORT1 : SERVER_PORT0; 
     struct message *rec_message;
     rec_message = (struct message*)malloc(sizeof(struct message));
     while(1) {
     	my_port = rand() % 98;
        printf("\nClient Port [%d] : Sending Message to %d\n", my_port, server_port);
        send(server_port, my_port);
        rec_message = receive(my_port);
        printf("\nClient Port [%d] : Recieving Message from %d\n", my_port, server_port);
        print_message(rec_message);
        sleep(1);
     } 
}
Esempio n. 21
0
int test_yaffs_fchmod_EROFS(void)
{
	int error = 0;
	int output = 0;
	if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
		print_message("failed to create file\n",1);
		return -1;
	}
	if (EROFS_setup() < 0 ){
		return -1;
	}
	handle = yaffs_open(FILE_PATH,O_CREAT  ,S_IREAD  );
	if (handle<0){
		print_message("failed to open file\n",2);
		return -1;
	}



	output = yaffs_fchmod(handle,S_IREAD|S_IWRITE);

	if (output<0){
		error=yaffs_get_error();
		if (abs(error)==EROFS){
			return 1;
		} else {
			print_message("different error than expected\n",2);
			return -1;
		}
	} else {
		print_message("chmoded with EROFS (which is a bad thing)\n",2);
		return -1;
	}


}
Esempio n. 22
0
int create_userMove_for_gui(char board[BOARD_SIZE][BOARD_SIZE], MovesList* moves){
	/* creates the user's move according to the input given by console
	returns 1 if the move was successfully created, and 0 otherwise */

	int fromRow = moves->start->row;
	int fromCol = moves->start->col;
	int toRow = moves->end->row;
	int toCol = moves->end->col;

	/*first we get the starting position of the move from the user input*/
	if (is_valid_position_on_board(fromCol, fromRow) == 0){ /*check if the position is valid*/
		print_message(WRONG_POSITION);
		return 0;
	}

	/*second we get the ending position of the move from the user input*/

	if (is_valid_position_on_board(toCol, toRow) == 0){ /*check if the position is valid*/
		print_message(WRONG_POSITION);
		return 0;
	}

	return 1; /*move was successfully created*/
}
Esempio n. 23
0
int test_yaffs_link_EROFS(void)
{
	int output=0;	
	int error =0;
	if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
		print_message("failed to create file\n",1);
		return -1;
	}
	EROFS_setup();

	output = yaffs_link(FILE_PATH,HARD_LINK_PATH);
	if (output<0){
		error=yaffs_get_error();
		if (abs(error)==EROFS){
			return 1;
		} else {
			print_message("different error than expected\n",2);
			return -1;
		}
	} else {
		print_message("created a hard link with EROFS set (which is a bad thing)\n",2);
		return -1;	
	}
}
Esempio n. 24
0
int test_yaffs_truncate_ELOOP(void)
{
	int error=0;
	int output=0;

	if (set_up_ELOOP()<0){
		print_message("failed to setup symlinks\n",2);
		return -1;
	}

	output= yaffs_truncate(ELOOP_PATH,FILE_SIZE_TRUNCATED );
	if (output<0){
		error=yaffs_get_error();
		if (abs(error)==ELOOP){
			return 1;
		} else {
			print_message("received a different error than expected\n",2);
			return -1;
		}
	} else{
		print_message("truncated a nonexisting file\n",2);
		return -1;
	}
}
int test_yaffs_unlink_ENOTDIR(void)
{
	int output=0;
	int error_code=0;
	if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
		print_message("failed to create file before remounting\n",1);
		return -1;
	}
	output=yaffs_unlink("/yaffs2/test_dir/foo/file");
	if (output==-1){
		error_code=yaffs_get_error();
		if (abs(error_code)==ENOTDIR){
			return 1;
		} else {
			print_message("different error than expected\n",2);
			return -1;
		}
	} else {
		print_message("non existant directory opened.(which is a bad thing)\n",2);
		return -1;
	}


}
Esempio n. 26
0
int test_yaffs_access_EACCES(void)
{
	int output=0;
	int error=0;
	output=yaffs_chmod(FILE_PATH,S_IREAD);
	if (output<0){
		print_message("failed to chmod file\n",2);
		return -1;
	}
	output= yaffs_access(FILE_PATH,W_OK);
	if (output<0){
		error=yaffs_get_error();
		if ( abs(error)== EACCES){
			return 1;
		} else {
			print_message("error does not match expected error\n",2);
			return -1;
		}
	} else{
		print_message("accessed an existing file with bad mode (which is a bad thing\n",2);

		return -1;
	}
}
Esempio n. 27
0
void ff_release()
{
   struct disc_timeval time;
   
   if(!disc_present || !disc_playing)
     return;
   
   print_message("Advancing 15 seconds");
   
   time.minutes = 0;
   time.seconds = 15;
   time.frames = 0;
   
   cd_advance(cd_fd, time);
}
int test_yaffs_rmdir_ENOTEMPTY(void)
{
	int output=0;
	int error_code =0;
	if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
		print_message("failed to create file\n",1);
		return -1;
	}
	if (0 !=  yaffs_access(DIR_PATH,0)) {
		output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
		if (output < 0) {
			print_message("failed to create directory\n",2);
			return -1;
		}
	}
	if (0 !=  yaffs_access("/yaffs2/test_dir/new_directory/dir",0)) {
		output = yaffs_mkdir("/yaffs2/test_dir/new_directory/dir",S_IWRITE | S_IREAD);
		if (output < 0) {
			print_message("failed to create directory\n",2);
			return -1;
		}
	}
	output = yaffs_rmdir(DIR_PATH);
	if (output<0){ 
		error_code=yaffs_get_error();
		if (abs(error_code)==ENOTEMPTY){
			return 1;
		} else {
			print_message("returned error does not match the the expected error\n",2);
			return -1;
		}
	} else{
		print_message("removed /yaffs2/ directory (which is a bad thing)\n",2);
		return -1;
	}	
}
Esempio n. 29
0
int test_yaffs_open_EACCES_clean(void)
{
	int output= -1;
	int output2=-1;	
	if (handle >=0){
		output2= yaffs_close(handle);
	}
	output=yaffs_chmod(FILE_PATH,S_IREAD|S_IWRITE);
	if (output<0){
		print_message("failed to chmod file\n",2);
		return -1;
	}
	return (output2&&output);
	
}
Esempio n. 30
0
static int setting_set_priority(const TCHAR *service_name, void *param, const TCHAR *name, void *default_value, value_t *value, const TCHAR *additional) {
  HKEY key = (HKEY) param;
  if (! param) return -1;

  TCHAR *priority_string;
  int i;
  long error;

  if (value && value->string) priority_string = value->string;
  else if (default_value) priority_string = (TCHAR *) default_value;
  else {
    error = RegDeleteValue(key, name);
    if (error == ERROR_SUCCESS || error == ERROR_FILE_NOT_FOUND) return 0;
    print_message(stderr, NSSM_MESSAGE_REGDELETEVALUE_FAILED, name, service_name, error_string(error));
    return -1;
  }

  for (i = 0; priority_strings[i]; i++) {
    if (! str_equiv(priority_strings[i], priority_string)) continue;

    if (default_value && str_equiv(priority_string, (TCHAR *) default_value)) {
      error = RegDeleteValue(key, name);
      if (error == ERROR_SUCCESS || error == ERROR_FILE_NOT_FOUND) return 0;
      print_message(stderr, NSSM_MESSAGE_REGDELETEVALUE_FAILED, name, service_name, error_string(error));
      return -1;
    }

    if (set_number(key, (TCHAR *) name, priority_index_to_constant(i))) return -1;
    return 1;
  }

  print_message(stderr, NSSM_MESSAGE_INVALID_PRIORITY, priority_string);
  for (i = 0; priority_strings[i]; i++) _ftprintf(stderr, _T("%s\n"), priority_strings[i]);

  return -1;
}