ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

cmdStop.c
Go to the documentation of this file.
00001 
00002 /*
00003  * COPYRIGHT:       See COPYING in the top level directory
00004  * PROJECT:         ReactOS net command
00005  * FILE:
00006  * PURPOSE:
00007  *
00008  * PROGRAMMERS:     Magnus Olsen (greatlord@reactos.org)
00009  */
00010 
00011 #include "net.h"
00012 
00013 INT cmdStop(INT argc, CHAR **argv )
00014 {
00015    char *string;
00016    long size = 100*sizeof(char);
00017 
00018    if (argc>4)
00019    {
00020       help();
00021       return 0;
00022    }
00023 
00024    if (argc==2)
00025    {
00026       string = (char *) malloc(size);
00027       if (string != NULL)
00028       {
00029          sprintf(string,"rpcclient -c \"service enum\"");
00030          system(string);
00031          free(string);
00032       }
00033       return 0;
00034    }
00035 
00036    if (argc==3)
00037    {
00038       stop_service(argv[1]);
00039       return 0;
00040    }
00041 
00042    return 0;
00043 }
00044 
00045 
00046 INT stop_service(CHAR *service)
00047 {
00048 
00049   CHAR *srvlst;
00050   LONG pos=0;
00051   LONG old_pos=0;
00052   LONG row_size=0;
00053   LONG size=0;
00054 
00055   CHAR *row; /* we assume display name can max be 20 row and each row is 80 char */
00056 
00057 
00058   /* Get the size for  srvlst */
00059   myCreateProcessStartGetSzie("rpcclient -c \"service enum\"", &size);
00060   if (size==0)
00061   {
00062     return 0;
00063   }
00064 
00065   srvlst = (CHAR *) malloc(size);
00066   if (srvlst == NULL)
00067   {
00068       return 0;
00069   }
00070   /* Get the server list */
00071   myCreateProcessStart("rpcclient -c \"service enum\"", srvlst, size);
00072 
00073 
00074   /* scan after display name */
00075   while (pos<size)
00076   {
00077         old_pos = pos;
00078 
00079         if (1 == row_scanner_service(srvlst, &pos, size, service, NULL))
00080         {
00081           row_size = (pos - old_pos)+32; /* 32 buffer for command */
00082           pos = old_pos;
00083           row = (CHAR *) malloc(row_size*sizeof(CHAR));
00084           if (row == NULL)
00085           {
00086             free(srvlst);
00087             return 0;
00088           }
00089           memset(row,0,row_size*sizeof(CHAR));
00090           if (1 == row_scanner_service(srvlst, &pos, size, service, &row[27]))
00091           {
00092              /*
00093                 display name found
00094                 now we can start the service
00095               */
00096 
00097               memcpy(row,"rpcclient -c \"service stop %s\"\"",27*sizeof(CHAR));
00098               row_size = strlen(row);
00099               row[row_size] = '\"';
00100               system(row);
00101           }
00102           free(row);
00103         }
00104   }
00105 
00106   free(srvlst);
00107   return 0;
00108 }

Generated on Mon May 28 2012 04:17:12 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.