Commit ef59d47d authored by Tim Schwartz's avatar Tim Schwartz Committed by Alexandre Julliard

net.exe: Converted strings to resources.

parent 40fb7ca1
......@@ -781,6 +781,7 @@ programs/msiexec/msiexec
programs/msiexec/msiexec.ico
programs/msiexec/rsrc.res
programs/net/net
programs/net/rsrc.res
programs/notepad/notepad
programs/notepad/rsrc.res
programs/oleview/oleview
......
/*
* NET.EXE - Wine-compatible net program
* English language support
*
* Copyright (C) 2007 Tim Schwartz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
STRINGTABLE
{
STRING_USAGE, "The syntax of this command is:\n\nNET [ HELP | START | STOP ]\n"
STRING_START_USAGE, "Specify service name to start.\n"
STRING_STOP_USAGE, "Specify service name to stop.\n"
STRING_STOP_DEP, "Stopping dependent service: %s\n"
STRING_CANT_STOP, "Could not stop service %s\n"
STRING_NO_SCM, "Could not get handle to service control manager.\n"
STRING_NO_SVCHANDLE, "Could not get handle to service.\n"
STRING_START_SVC, "The %s service is starting.\n"
STRING_START_SVC_SUCCESS, "The %s service was started successfully.\n"
STRING_START_SVC_FAIL, "The %s service failed to start.\n"
STRING_STOP_SVC, "The %s service is stopping.\n"
STRING_STOP_SVC_SUCCESS, "The %s service was stopped successfully.\n"
STRING_STOP_SVC_FAIL, "The %s service failed to stop.\n"
STRING_HELP_USAGE, "The syntax of this command is:\n\nNET HELP command\n -or-\nNET command /HELP\n\n Commands available are:\n NET HELP NET START NET STOP\n"
}
......@@ -4,10 +4,12 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = net.exe
APPMODE = -mconsole
IMPORTS = advapi32 kernel32
IMPORTS = user32 advapi32 kernel32
C_SRCS = net.c
RC_SRCS = rsrc.rc
@MAKE_PROG_RULES@
@DEPENDENCIES@ # everything below this line is overwritten by make depend
......@@ -19,10 +19,23 @@
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include "resources.h"
#define NET_START 0001
#define NET_STOP 0002
int output_string(int msg, ...)
{
char msg_buffer[8192];
va_list arguments;
LoadString(GetModuleHandle(NULL), msg, msg_buffer, sizeof(msg_buffer));
va_start(arguments, msg);
vprintf(msg_buffer, arguments);
va_end(arguments);
return 0;
}
static BOOL StopService(SC_HANDLE SCManager, SC_HANDLE serviceHandle)
{
LPENUM_SERVICE_STATUS dependencies = NULL;
......@@ -41,11 +54,11 @@ static BOOL StopService(SC_HANDLE SCManager, SC_HANDLE serviceHandle)
{
for(counter = 0; counter < count; counter++)
{
printf("Stopping dependent service: %s\n", dependencies[counter].lpDisplayName);
output_string(STRING_STOP_DEP, dependencies[counter].lpDisplayName);
dependent_serviceHandle = OpenService(SCManager, dependencies[counter].lpServiceName, SC_MANAGER_ALL_ACCESS);
if(dependent_serviceHandle) result = StopService(SCManager, dependent_serviceHandle);
CloseServiceHandle(dependent_serviceHandle);
if(!result) printf("Could not stop service %s\n", dependencies[counter].lpDisplayName);
if(!result) output_string(STRING_CANT_STOP, dependencies[counter].lpDisplayName);
}
}
}
......@@ -65,13 +78,13 @@ static BOOL net_service(int operation, char *service_name)
SCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(!SCManager)
{
printf("Couldn't get handle to SCManager.\n");
output_string(STRING_NO_SCM);
return FALSE;
}
serviceHandle = OpenService(SCManager, service_name, SC_MANAGER_ALL_ACCESS);
if(!serviceHandle)
{
printf("Couldn't get handle to service.\n");
output_string(STRING_NO_SVCHANDLE);
CloseServiceHandle(SCManager);
return FALSE;
}
......@@ -83,20 +96,18 @@ static BOOL net_service(int operation, char *service_name)
switch(operation)
{
case NET_START:
printf("The %s service is starting.\n", service_display_name);
output_string(STRING_START_SVC, service_display_name);
result = StartService(serviceHandle, 0, NULL);
printf("The %s service ", service_display_name);
if(!result) printf("failed to start.\n");
else printf("was started successfully.\n");
if(result) output_string(STRING_START_SVC_SUCCESS);
else output_string(STRING_START_SVC_FAIL);
break;
case NET_STOP:
printf("The %s service is stopping.\n", service_display_name);
output_string(STRING_STOP_SVC, service_display_name);
result = StopService(SCManager, serviceHandle);
printf("The %s service ", service_display_name);
if(!result) printf("failed to stop.\n");
else printf("was stopped successfully.\n");
if(result) output_string(STRING_STOP_SVC_SUCCESS, service_display_name);
else output_string(STRING_STOP_SVC_FAIL, service_display_name);
break;
}
......@@ -107,27 +118,22 @@ static BOOL net_service(int operation, char *service_name)
int main(int argc, char *argv[])
{
if (argc < 2)
{
printf("The syntax of this command is:\n\n");
printf("NET [ HELP | START | STOP ]\n");
output_string(STRING_USAGE);
return 1;
}
if(!strcasecmp(argv[1], "help"))
{
printf("The syntax of this command is:\n\n");
printf("NET HELP command\n -or-\nNET command /HELP\n\n");
printf(" Commands available are:\n");
printf(" NET HELP NET START NET STOP\n");
output_string(STRING_HELP_USAGE);
}
if(!strcasecmp(argv[1], "start"))
{
if(argc < 3)
{
printf("Specify service name to start.\n");
output_string(STRING_START_USAGE);
return 1;
}
......@@ -142,7 +148,7 @@ int main(int argc, char *argv[])
{
if(argc < 3)
{
printf("Specify service name to stop.\n");
output_string(STRING_STOP_USAGE);
return 1;
}
......
/*
* Copyright 2007 Tim Schwartz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define STRING_USAGE 101
#define STRING_START_USAGE 102
#define STRING_STOP_USAGE 103
#define STRING_STOP_DEP 104
#define STRING_CANT_STOP 105
#define STRING_NO_SCM 106
#define STRING_NO_SVCHANDLE 107
#define STRING_START_SVC 108
#define STRING_START_SVC_SUCCESS 109
#define STRING_START_SVC_FAIL 110
#define STRING_STOP_SVC 111
#define STRING_STOP_SVC_SUCCESS 112
#define STRING_STOP_SVC_FAIL 113
#define STRING_HELP_USAGE 114
/*
* Copyright 2007 Tim Schwartz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <windows.h>
#include "resources.h"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#include "En.rc"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment